#!/bin/sh

## Description: Create a new quickstart project and use the installation profile as a non-packagist repository using the matching scaffolding branch if available.
## Usage: install
## Example: "ddev install"

rm -rf /var/www/html/*
BRANCH_NAME=$(git -C /usr/local/quickstart-install-profile rev-parse --abbrev-ref HEAD); if [ $(git ls-remote --heads https://github.com/az-digital/az-quickstart-scaffolding.git $BRANCH_NAME | wc -l) = 1 ]; then SCAFFOLD_BRANCH="$BRANCH_NAME"; else SCAFFOLD_BRANCH="main"; fi; git clone --branch $SCAFFOLD_BRANCH https://github.com/az-digital/az-quickstart-scaffolding.git /var/www/html
composer config repositories.localdev path /usr/local/quickstart-install-profile && composer require --no-update drupal/core-recommended:* zaporylie/composer-drupal-optimizations:* az-digital/az_quickstart:\*@dev
composer install
drush --root=/var/www/html/web site:install --account-mail=noreply@email.arizona.edu --account-name=azadmin --account-pass=azadmin --db-url=mysql://db:db@db:3306/db -y --verbose
yarn --cwd /usr/local/quickstart-install-profile install
npm install --no-progress --global eslint-config-drupal-bundle
