#!/usr/bin/env bash

## Install dependencies, sync database and build FE.
##
## Usage: fin setup

. ${PROJECT_ROOT}/.docksal/scripts/common


# Install the packages.
fin composer install

# Copy docksal settings.
cp "$ASSETS_DIR/settings/default.settings.docksal.php" "$SETTINGS_DIR/settings.docksal.php"
cp "$ASSETS_DIR/settings/default.including.docksal.settings.php" "$SETTINGS_DIR/settings.php"

# Copy Lobbyist repo modules/theme.
cd "${PROJECT_ROOT}/html/sites/default"
rm -rf .git
git init
git remote add origin git@app-cms-git01.gov.yk.ca:services/lobbyist-registry.git
git fetch
git checkout -f prod
cd "${PROJECT_ROOT}"

# Import DB.
fin import/db

# Build FE stuff.
fin yarn

# Clear cache.
fin drush cr

# Here update the URLS with the backend environment url.
fin drush cset biz_lobbyist_registration.settings base_url 'http://yukon-base-backend.docksal/' --input-format=string -y
fin drush cset biz_lobbyist_registration.settings registration_url_api 'http://yukon-base-backend.docksal/entity/user?_format=json' --input-format=string -y




