From 2b6c488fb1d2d3acd30a016c068d751cf3deb9d1 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 26 Sep 2023 11:35:14 -0600 Subject: [PATCH] Run automated test of Sage Install Script (#113) * adds a sage-test workflow * temporarily allow the test to run on any branch so we can see if it works * add to on push to test the test * pull terminus.phar from latest * authenticate with terminus * this is a github secret, not an environment variable * create a multidev for the build in a separate step need to add a no-input parameter for the install script * add a step to generate a name for our multidev based on the os, pr, and php version * use github.event.number * run a cleanup step that deletes the multidev * add an echo so we can save the output of the pr number * get the pr number a different way? * remove core const if already declared * echo the PR number? * echo all the things * use gh cli? * get the pr number the right way * explicitly set the shell to bash everywhere * set the default shell to bash and remove the definitions * if we're in a windows environment, how we install terminus differs add the current directory to the PATH variable so we can run terminus from where we downloaded it * Sage (and Bedrock) doesn't actually work on PHP 7.4 * remove windows tests terminus isn't technically supported on windows so this is kind of moot * install terminus from homebrew if macos * add a test that terminus works * add latest version back * shorten the test name * support values to be globally set * globally set values we might not actually need this if we're in the site directory... * clone down the site can't believe I went this long without realizing we're going to need to run this in an actual site directory * sync the latest changes to the test multidev * wrap sitename in quotes * install ssh key so we can clone * clone site before multidev creation if it's going to fail, let's fail before we wait for the multidev to be created * deal with pantheon ssh host keys * remove the ssh-keyscan step * need to set a git config before we can git things * make sure we're in the right directory * add a check for CI so we don't loop through the script * export our globals so they are read by the script * don't prompt for confirmation if ci * wait longer for CI since there are concurrent builds * move these to be global variables and add a siteenv variable * use siteenv anywhere we'd manually set .dev * define the SITEENV to the multidev name * lower the waittime to 300 i think 600 might be too much * wait for long running scripts but wait shorter but still vary it based on whether we're on ci or local * add colors * output that we're checking for jq * allow sed handing between linux and macos and bail if it fails * fix sed condition for shellcheck * print current working directory * sed conditional needs to go inside the ostype condition * add closing fi * add a check for the sage theme directory * move the git pull to after we push the post install cmd i think this isn't actually getting pushed * remove random + that must've been a typo * sitename.siteenv * halve the waittime yet again * push to the right branch * only try opening the site if we're not in ci * wrap $branch in quotes * remove composer install step we do this again later inside the multidev that we clone down, so there's no reason to do this before we create the multidev * break terminus stuff up into multiple steps * delete sage theme if it exists * composer install after copying updates from source * git diff before create multidev * git status instead of git diff bail if dirty * temporarily gitignore sage test to create multidev * delete all tags from the CI site * delete the build artifact tag * remove the gitignore steps we don't need them or we shouldn't, anyway * fetch the tags before deleting the multidev artifact * remove extra git pushes so we have less sync code failures * underscore in the build artifact tag name * the other underscore, too * allow other versions of PHP * change output from listing to checking we don't output the themes dir, so we shouldn't sey we're listing it * add 8.3 * allow the build artifact tag deletion to fail if it doesn't exist, that's okay * actually bump the PHP version to the version declared * add a note when checking for unfinished/long-running workflows * allow both tag deletes to fail * remove pwd * set phpversion to 8.0 if 8 is passed * do a git status to see the change * bump version of ssh-agent * set output will be deprecated so use env variables instead https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * get and set in the same step * remove the run of this workflow on every push just need it on merges and when we make changes to the scripts or this workflow * run the workflow whenever updates are pushed the test itself * add documentation for running the script headless * update path to script * update docs about CI env variable * remove extra line * update changelog * remove preceding slash for path to scripts * fix spacing * use latest terminus rather than figuring out a version * Don't worry about checking the exit code Co-authored-by: Phil Tyler * add a newline before php_version Co-authored-by: Phil Tyler * default to 0 * fix missing info prompt * git diff, not status * fix typo Co-authored-by: Phil Tyler * use $siteenv * use env varibales * move the path filter for the scripts folder to push instead of PR, which doesn't seem to be triggering * wrap multidev_name in quotes * export SITEENV inside the script $multidev_name is not carrying over * use multidev_name from env * all caps env variables * don't switch to sftp mode since we're not opening the window, we don't need to switch to sftp and then switch back * actually we can still commit leftover files just don't open the browser --------- Co-authored-by: Phil Tyler --- .github/workflows/sage-test.yml | 139 ++++++++++++++++++++++++++++++ CHANGELOG.md | 3 + docs/Installing-Sage.md | 37 +++++++- private/scripts/helpers.sh | 144 +++++++++++++++++++++++--------- 4 files changed, 284 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/sage-test.yml diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml new file mode 100644 index 00000000..d4e25b36 --- /dev/null +++ b/.github/workflows/sage-test.yml @@ -0,0 +1,139 @@ +name: Sage Install Tests +on: + push: + paths: + - '.github/workflows/sage-test.yml' + - 'private/scripts/**' +jobs: + test: + name: Sage Install Tests + env: + TERM: xterm-256color + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + php-version: [8.0, 8.1, 8.2, 8.3] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install SSH keys + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Get and Set PR number + id: pr + run: | + pr_num=$(gh pr view --json number -q .number || echo "") + echo "PR_NUM=$pr_num" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: Generate multidev name + id: generate_name + run: | + os_short="" + case "${{ matrix.os }}" in + ubuntu-latest) + os_short="nix" + ;; + macos-latest) + os_short="mac" + ;; + windows-latest) + os_short="win" + ;; + esac + + php_short=$(echo "${{ matrix.php-version }}" | tr -d '.') + echo "PR number: $PR_NUM" + echo "OS: $os_short" + echo "PHP: $php_short" + multidev_name="${os_short}-${php_short}-${PR_NUM}" + echo "Generated multidev name: $multidev_name" + echo "multidev_name=$multidev_name" >> $GITHUB_ENV + - name: Get latest Terminus release + run: | + if [[ "${{ matrix.os }}" == "macos-latest" ]]; then + echo "☕ Installing Terminus on macOS from Homebrew..." + brew install pantheon-systems/external/terminus + else + echo "💻 Installing Terminus from phar on Linux..." + curl -L "https://github.com/pantheon-systems/terminus/releases/latest/download/terminus.phar" -o terminus + chmod +x terminus + sudo mv terminus /usr/local/bin/ + fi + # Test that terminus works... + terminus --version + - name: Validate Pantheon Host Key + run: | + echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config + echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config + echo "StrictHostKeyChecking no" >> ~/.ssh/config + - name: Log into Terminus and Check for updates + run: | + terminus auth:login --machine-token=${{ secrets.TERMINUS_TOKEN }} + terminus upstream:updates:apply wpcm-sage-install-tests.dev --accept-upstream + - name: Clone site and create multidev + run: | + echo "Cloning site..." + terminus local:clone wpcm-sage-install-tests + cd ~/pantheon-local-copies/wpcm-sage-install-tests + if [[ -n $(git status --porcelain) ]]; then + echo "❌ Local clone is dirty. Exiting..." + exit 1 + fi + # If sage-test exists, delete it. + if [[ -d "web/app/themes/sage-test" ]]; then + echo "Deleting existing sage-test..." + rm -rf web/app/themes/sage-test + fi + terminus multidev:create wpcm-sage-install-tests.dev $multidev_name + echo "Checking out multidev..." + git fetch --all + git checkout $multidev_name + - name: Copy latest repository changes + run: | + # Sync the files from checked-out repo to pantheon-local-copies, excluding the .git folder + rsync -av --exclude='.git/' ${{ github.workspace }}/ ~/pantheon-local-copies/wpcm-sage-install-tests/ + # Navigate to Pantheon local copies directory + cd ~/pantheon-local-copies/wpcm-sage-install-tests/ + git config --global user.email "bot@getpantheon.com" + git config --global user.name "Pantheon TestBot" + # Add, commit and push + git add . + git commit -m "Sync latest changes to test environment" + git push origin $multidev_name + - name: Install Composer Dependencies + run: | + cd ~/pantheon-local-copies/wpcm-sage-install-tests + composer install + - name: Run Sage Install Script + env: + SAGENAME: sage-test + SITENAME: wpcm-sage-install-tests + CI: 1 + PHPVERSION: ${{ matrix.php-version }} + SITEENV: ${{ env.multidev_name }} + run: | + export SITEENV=$multidev_name + cd ~/pantheon-local-copies/$SITENAME + composer install-sage + echo "✅ Sage Install Script passed!" + - name: Delete multidev + if: always() + run: terminus multidev:delete --delete-branch --yes wpcm-sage-install-tests.$multidev_name + - name: Delete the multidev build artifact + if: always() + run: | + cd ~/pantheon-local-copies/wpcm-sage-install-tests + git fetch --tags origin + # Allow these to fail. + git tag -d pantheon_build_artifacts_$multidev_name || true + git push origin --delete pantheon_build_artifacts_$multidev_name || true diff --git a/CHANGELOG.md b/CHANGELOG.md index fb20c4a9..80a7166a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 2023-09-25 +* Updates to the [Sage install script](docs/Installing-Sage.md) to support running the script without prompting for input. Also adds automated test runs of the script on `ubuntu-latest` and `macos-latest` environments. ([#113](https://github.com/pantheon-systems/wordpress-composer-managed/pull/113)) + ### 2023-06-27 * Fixed a bug that failed to prevent a `composer.lock` file from being committed to the repository. ([#103](https://github.com/pantheon-systems/wordpress-composer-managed/pull/103)) * Removed the `upstream-require` script ([#105](https://github.com/pantheon-systems/wordpress-composer-managed/pull/105)). This is now available as a standalone Composer plugin: [`pantheon-systems/upstream-management`](https://packagist.org/packages/pantheon-systems/upstream-management) diff --git a/docs/Installing-Sage.md b/docs/Installing-Sage.md index 46f7d8fd..975b477b 100644 --- a/docs/Installing-Sage.md +++ b/docs/Installing-Sage.md @@ -27,8 +27,43 @@ If you have all the above requirements, including a copy of the site locally, `c composer install-sage ``` +### Running the Script in Headless Mode + +The script can also be run with no user interaction at all. Instead of answering the prompts in the script itself, you can pass information via environment variables before running the script. The following environment variables are available: + +* **`SITENAME`** - The name of the site on Pantheon. This is the name that you would use to run Terminus commands like `terminus site:info` or `terminus wp`. This is not required if the script is being run from inside a site repo. +* **`SFTPUSER`** - The SFTP username for the site. This is not required if the script is being run from inside a site repo. This is the SFTP username that you can get from the Pantheon dashboard. +* **`SFTPHOST`** - The SFTP hostname for the site. This is not required if the script is being run from inside a site repo. This is the SFTP hostname that you can get from the Pantheon dashboard. +* **`SAGENAME`** - The name of the theme that you want to create. This is _required_. +* **`PHPVERSION`** - The PHP version that you want to use. This is optional and defaults to `8.0`. `8.3` is a valid option but will be updated to 8.2 until PHP 8.3 is available on Pantheon. +* **`SITEENV`** - The Pantheon environment that you want to use. This is optional and defaults to `dev`. This is the environment that you want to install the theme on. This can be `dev` or any valid multidev. +* **`CI`** - Whether the script is being run from a Continuous Integration (CI) environment. When this exists, additional time is given to allow simultaneous workflows to run and the script will not attempt to open the site in a browser. This is optional and defaults to `0` (`false`). If you want to enable CI-mode, set this to `1`. Setting the `CI` variable to `1` will also remove the confirmation prompts and prevent the script from restarting if no input is entered. _Only use this if you are sure you have the correct information_ as the script will run autonomously with whatever data it is able to fetch from Terminus based on the current site repository. + +### Using environment variables + +You can use any environment variables you want by simply `export`ing them in your shell or bash script before running the script. For example: + +```bash +export SAGENAME="sage-theme" +export PHPVERSION="8.2" +export SITEENV="sage-1" +export SITENAME="my-site" +terminus multidev:create "$SITENAME".dev "$SITEENV" +git fetch --all +git checkout "$SITEENV" +composer install-sage +``` + +The above code will: + +* Set the Sage theme name to `sage-theme` +* Set the PHP version to `8.2` in `pantheon.yml` +* Create a multidev environment named `sage-1` +* Check out the `sage-1` branch +* Run the Sage installation script on the `sage-1` multidev environment + ## How it Works -The script does a lot of things and each step builds onto the last. You can look at the script in [`private/scripts/sage-theme-install.sh`](../private/scripts/sage-theme-install.sh) if you're interested in the precise commands that are being run. This overview will walk through each step. +The script does a lot of things and each step builds onto the last. You can look at the script in [`private/scripts/helpers.sh`](../private/scripts/helpers.sh) if you're interested in the precise commands that are being run. This overview will walk through each step. ### Check Login The first thing the script will do is check to see if you are logged into Terminus with a `terminus whoami` command. If you are not logged in, the script will end and you will be prompted to log in first. diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 7208fe8f..745f3c20 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -14,6 +14,20 @@ yellow=$(tput setaf 3) #magenta=$(tput setaf 5) #cyan=$(tput setaf 6) +# Use environment variables if set, otherwise prompt for input +sitename="${SITENAME:-}" +sftpuser="${SFTPUSER:-}" +sftphost="${SFTPHOST:-}" +sagename="${SAGENAME:-}" +phpversion="${PHPVERSION:-8.0}" +is_ci="${CI:-0}" +siteenv="${SITEENV:-dev}" +if [ "$siteenv" == "dev" ]; then + branch="master" +else + branch="$siteenv" +fi + # Main function that runs the script. function main() { help_msg="Usage: bash ./private/scripts/helpers.sh @@ -54,6 +68,10 @@ function get_info() { # Unset the variables if we're doing this a second time. if [ "$is_restarted" -eq 1 ]; then + if [ "$is_ci" -eq 1 ]; then + echo "${yellow}CI detected. We're not going to restart. Bailing here.${normal}" + exit 1; + fi unset sitename unset sagename unset sftpuser @@ -138,19 +156,20 @@ function get_info() { Theme name: ${sagename} SFTP username: ${sftpuser} SFTP hostname: ${sftphost}" - read -p "Is this correct? (y/n) " -n 1 -r - # If the user enters n, redo the prompts. - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Restarting..." - - # Toggle the restarted state. - is_restarted=1 - - get_info + if [ "$is_ci" != 1 ]; then + read -p "Is this correct? (y/n) " -n 1 -r + # If the user enters n, redo the prompts. + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Restarting..." + + # Toggle the restarted state. + is_restarted=1 + get_info + fi fi if [ -z "$sitename" ] || [ -z "$sagename" ] || [ -z "$sftpuser" ] || [ -z "$sftphost" ]; then - echo "${red}Missing information!${normal} Make sure you've everything for all the prompts." + echo "${red}Missing information!${normal} Make sure you input everything for all the prompts." get_info fi @@ -211,8 +230,23 @@ get_field() { # Update to PHP 8.0 function update_php() { + if [ "$phpversion" == "8" ]; then + phpversion="8.0" + fi + if [ "$phpversion" != "8.0" ]; then + echo "${yellow}You've specified PHP version ${phpversion}. The default is 8.0, but we'll use the version you asked for.${normal}" + if [ "$phpversion" == "8.3" ]; then + echo "${yellow}PHP 8.3 is not yet supported. Using 8.2 instead.${normal}" + phpversion="8.2" + fi + # Check if $phpversion is < 8.0. + if [ "$(echo "$phpversion < 8.0" | bc)" -eq 1 ]; then + echo "${red}PHP version must be 8.0 or greater. Exiting here.${normal}" + exit 1; + fi + fi echo "" - echo "${yellow}Updating PHP version to 8.0.${normal}" + echo "${yellow}Updating PHP version to ${phpversion}.${normal}" # Check for pantheon.yml file. if [ ! -f "pantheon.yml" ]; then @@ -230,13 +264,15 @@ function update_php() { # Test for PHP version declartion already in pantheon.yml. if [ ! "$phpDeclaredInFile" -eq 0 ]; then # Update version to 8.x. - sed -i '' "s/7.4/8.0/" pantheon.yml + sed -i '' "s/7.4/${phpversion}/" pantheon.yml else # Add full PHP version declaration to pantheon.yml. - echo "php_version: 8.0" >> pantheon.yml + echo "" >> pantheon.yml + echo "php_version: ${phpversion}" >> pantheon.yml fi - git commit -am "[Sage Install] Update PHP version to 8.0" - git push origin master + git diff HEAD~1 HEAD -- pantheon.yml + git commit -am "[Sage Install] Update PHP version to ${phpversion}" + git push origin "$branch" else echo "${green}PHP version is already 8.x.${normal}" fi @@ -273,14 +309,13 @@ function install_sage_theme() { # Commit the theme git add "$sagedir" git commit -m "[Sage Install] Add the Sage theme ${sagename}." - git push origin master echo "${green}Sage installed!${normal}" } # Create the symlink to the cache directory. function add_symlink() { # Switch to SFTP mode - terminus connection:set "$sitename".dev sftp + terminus connection:set "$sitename"."$siteenv" sftp if [ ! -d "web/app/uploads" ]; then echo "${yellow}Creating the uploads directory.${normal}" @@ -299,7 +334,7 @@ function add_symlink() { EOF # Switch back to Git mode. - terminus connection:set "$sitename".dev git + terminus connection:set "$sitename"."$siteenv" git # Create the symlink to /files/cache. cd web/app || return @@ -307,13 +342,12 @@ EOF ln -sfn uploads/cache . git add . git commit -m "[Sage Install] Add a symlink for /files/cache to /uploads/cache" - git push origin master cd ../.. } -# Check if jq is installed. If it's not, try a couple ways of installing it. # Check if jq is installed. If it's not, try a couple ways of installing it. function check_jq() { + echo "${yellow}Checking if jq is installed.${normal}" # Check if jq is already installed. if command -v jq &> /dev/null; then return # jq is already installed @@ -348,7 +382,6 @@ function update_composer() { echo "${yellow}Updating composer.lock.${normal}" git add composer.lock git commit -m "[Sage Install] Update composer.lock" - git push origin master fi echo "${yellow}Attempting to add a post-install hook to composer.json.${normal}" @@ -359,7 +392,21 @@ function update_composer() { # Add a post-install hook to the composer.json. echo "${yellow}Adding a post-install hook to composer.json.${normal}" jq -r '.scripts += { "post-install-cmd": [ "@composer install --no-dev --prefer-dist --ignore-platform-reqs --working-dir=%sagedir%" ] }' composer.json > composer.new.json - sed -i '' "s,%sagedir%,$sagedir," composer.new.json + + if [[ "$OSTYPE" == "darwin"* ]]; then + # Mac OS + if ! sed -i '' "s,%sagedir%,$sagedir," composer.new.json; then + echo "${red}Failed to add post-install hook to composer.json. Exiting here.${normal}" + exit 1; + fi + else + # Linux + if ! sed -i "s,%sagedir%,$sagedir," composer.new.json; then + echo "${red}Failed to add post-install hook to composer.json. Exiting here.${normal}" + exit 1; + fi + fi + rm composer.json mv composer.new.json composer.json @@ -367,8 +414,7 @@ function update_composer() { git add composer.json git commit -m "[Sage Install] Add post-install-cmd hook to also run install on ${sagename}" - git pull --ff --commit - if ! git push origin master; then + if ! git push origin "$branch"; then echo "${red}Push failed. Stopping here.${normal}" echo "Next steps are to push the changes to the repo and then set the connection mode back to Git." exit 1; @@ -376,7 +422,13 @@ function update_composer() { # Wait for the build to finish. echo "${yellow}Waiting for the deploy to finish.${normal}" - if ! terminus workflow:wait --max=90 "$sitename".dev; then + if [ "$is_ci" -eq 1 ]; then + echo "${yellow}CI detected. We'll need to wait longer.${normal}" + waittime=180 + else + waittime=90 + fi + if ! terminus workflow:wait --max="$waittime" "$sitename"."$siteenv"; then echo "${red}terminus workflow:wait command not found. Stopping here.${normal}" echo "You will need to install the terminus-build-tools-plugin." echo "terminus self:plugin:install terminus-build-tools-plugin" @@ -384,22 +436,34 @@ function update_composer() { fi # Check for long-running workflows. - if [[ "$(terminus workflow:wait --max=1 "${sitename}".dev)" == *"running"* ]]; then - echo "${yellow}Workflow still running, waiting another 30 seconds.${normal}" - terminus workflow:wait --max=30 "$sitename".dev + echo "${yellow}Checking for long-running workflows.${normal}" + if [[ "$(terminus workflow:wait --max=1 "${sitename}"."$siteenv")" == *"running"* ]]; then + waittime=$(( waittime / 3 )) + echo "${yellow}Workflow still running, waiting another ${waittime} seconds.${normal}" + terminus workflow:wait --max="$waittime" "$sitename"."$siteenv" fi + + git pull --ff --commit } # Finish up the Sage install process. function clean_up() { + # List the app/themes directory. + echo "${yellow}Checking the themes directory for ${sagename}.${normal}" + # If the previous output did not include $sagename, bail. + if [[ ! "$(ls -la web/app/themes)" == *"$sagename"* ]]; then + echo "${red}Theme not found. Exiting here.${normal}" + exit 1; + fi + # If the site is multisite, we'll need to enable the theme so we can activate it. - terminus wp -- "$sitename".dev theme enable "$sagename" + terminus wp -- "$sitename"."$siteenv" theme enable "$sagename" # List the themes. - terminus wp -- "$sitename".dev theme list + terminus wp -- "$sitename"."$siteenv" theme list # Activate the new theme echo "${yellow}Activating the ${sagename} theme.${normal}" - if ! terminus wp -- "$sitename".dev theme activate "$sagename"; then + if ! terminus wp -- "$sitename"."$siteenv" theme activate "$sagename"; then echo "${red}Theme activation failed. Exiting here.${normal}" echo "Check the theme list above. If the theme you created is not listed, it's possible that the deploy has not completed. You can try again in a few minutes using the following command:" echo "terminus wp -- $sitename.dev theme activate $sagename" @@ -408,28 +472,32 @@ function clean_up() { fi # Switch back to SFTP so files can be written. - terminus connection:set "$sitename".dev sftp + terminus connection:set "$sitename"."$siteenv" sftp - # Open the site. This should generate requisite files on page load. - echo "${yellow}Opening the dev-${sitename}.pantheonsite.io to generate requisite files.${normal}" - open https://dev-"$sitename".pantheonsite.io + if [ "$is_ci" -ne 1 ]; then + # Open the site. This should generate requisite files on page load. + echo "${yellow}Opening the ${siteenv}-${sitename}.pantheonsite.io to generate requisite files.${normal}" + open https://"$siteenv"-"$sitename".pantheonsite.io + fi # Commit any additions found in SFTP mode. echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}" - terminus env:commit "$sitename".dev --message="[Sage Install] Add any leftover files found in SFTP mode." + terminus env:commit "$sitename"."$siteenv" --message="[Sage Install] Add any leftover files found in SFTP mode." # Switch back to Git. - terminus connection:set "$sitename".dev git + terminus connection:set "$sitename"."$siteenv" git git pull --ff --commit } # Install Sage theme. function install_sage() { + sitename="${SITENAME:-}" + # Check if the user is logged into Terminus before trying to run other Terminus commands. check_login themedir="web/app/themes" - siteinfo=$(terminus site:info) + siteinfo=$(terminus site:info "$sitename") id=$(get_field "ID" "$siteinfo") name=$(get_field "Name" "$siteinfo")