Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Last active October 12, 2022 20:36
Show Gist options
  • Save jazzsequence/d382e94607186f160eef7a88d95f9a4d to your computer and use it in GitHub Desktop.
Save jazzsequence/d382e94607186f160eef7a88d95f9a4d to your computer and use it in GitHub Desktop.

Revisions

  1. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 0 additions and 33 deletions.
    33 changes: 0 additions & 33 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -1,38 +1,5 @@
    #!/bin/bash

    echo "
    ____ __ __ _____ __
    / __ \____ _____ / /_/ /_ ___ ____ ____ / ___/__ _______/ /____ ____ ___ _____
    / /_/ / __ `/ __ \/ __/ __ \/ _ \/ __ \/ __ \ \__ \/ / / / ___/ __/ _ \/ __ `__ \/ ___/
    / ____/ /_/ / / / / /_/ / / / __/ /_/ / / / / ___/ / /_/ (__ ) /_/ __/ / / / / (__ )
    /_/ \__,_/_/ /_/\__/_/ /_/\___/\____/_/ /_/ /____/\__, /____/\__/\___/_/ /_/ /_/____/
    /____/
    ____ ________ ________ ____ / /______
    / __ \/ ___/ _ \/ ___/ _ \/ __ \/ __/ ___/
    / /_/ / / / __(__ ) __/ / / / /_(__ )
    / .___/_/ \___/____/\___/_/ /_/\__/____/
    /_/
    ____ __ ______
    /\ _`\ /\ \__ / /\ _`\
    \ \ \L\ \ ___ ___\ \ ,_\ ____ / /\ \,\L\_\ __ __ __
    \ \ , / / __`\ / __`\ \ \/ /',__\ / / \/_\__ \ /'__`\ /'_ `\ /'__`\
    \ \ \\ \ /\ \L\ \/\ \L\ \ \ \_/\__, `\/ / /\ \L\ \/\ \L\.\_/\ \L\ \/\ __/
    \ \_\ \_\ \____/\ \____/\ \__\/\____/_/ \ `\____\ \__/.\_\ \____ \ \____\
    \/_/\/ /\/___/ \/___/ \/__/\/___/_/ \/_____/\/__/\/_/\/___L\ \/____/
    /\____/
    \_/__/
    ______ __ ___ ___
    /\__ _\ /\ \__ /\_ \ /\_ \
    \/_/\ \/ ___ ___\ \ ,_\ __ \//\ \ \//\ \ __ _ __
    \ \ \ /' _ `\ /',__\ \ \/ /'__`\ \ \ \ \ \ \ /'__`\/\`'__\
    \_\ \__/\ \/\ \/\__, `\ \ \_/\ \L\.\_ \_\ \_ \_\ \_/\ __/\ \ \/
    /\_____\ \_\ \_\/\____/\ \__\ \__/.\_\/\____\/\____\ \____\\ \_\
    \/_____/\/_/\/_/\/___/ \/__/\/__/\/_/\/____/\/____/\/____/ \/_/
    "
    themedir="web/app/themes/"

    echo "Enter the site name. \n
  2. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 32 additions and 29 deletions.
    61 changes: 32 additions & 29 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,37 @@
    #!/bin/bash

    echo " ____ __ __ _____ __ ";
    echo " / __ \____ _____ / /_/ /_ ___ ____ ____ / ___/__ _______/ /____ ____ ___ _____";
    echo " / /_/ / __ \`/ __ \/ __/ __ \/ _ \/ __ \/ __ \ \__ \/ / / / ___/ __/ _ \/ __ \`__ \/ ___/";
    echo " / ____/ /_/ / / / / /_/ / / / __/ /_/ / / / / ___/ / /_/ (__ ) /_/ __/ / / / / (__ ) ";
    echo "/_/ \__,_/_/ /_/\__/_/ /_/\___/\____/_/ /_/ /____/\__, /____/\__/\___/_/ /_/ /_/____/ ";
    echo " /____/ ";
    echo " ____ ________ ________ ____ / /______ ";
    echo " / __ \/ ___/ _ \/ ___/ _ \/ __ \/ __/ ___/ ";
    echo " / /_/ / / / __(__ ) __/ / / / /_(__ ) ";
    echo " / .___/_/ \___/____/\___/_/ /_/\__/____/ ";
    echo " /_/ ";
    echo " __ __ __ __ ___ ___ ";
    echo "/\ \ /\ \__/\ \ __ /\ \__ /\_ \ /\_ \ ";
    echo "\ \ \ __\ \ ,_\ \/ ____ /\_\ ___ ___\ \ ,_\ __ \//\ \ \//\ \ ";
    echo " \ \ \ __ /'__\`\ \ \/\/ /',__\ \/\ \ /' _ \`\ /',__\ \ \/ /'__\`\ \ \ \ \ \ \ ";
    echo " \ \ \L\ \/\ __/\ \ \_ /\__, \`\ \ \ \/\ \/\ \/\__, \`\ \ \_/\ \L\.\_ \_\ \_ \_\ \_ ";
    echo " \ \____/\ \____\\ \__\ \/\____/ \ \_\ \_\ \_\/\____/\ \__\ \__/.\_\/\____\/\____\";
    echo " \/___/ \/____/ \/__/ \/___/ \/_/\/_/\/_/\/___/ \/__/\/__/\/_/\/____/\/____/";
    echo " ";
    echo " ";
    echo " ____ __ ______ __ ";
    echo "/\ _\`\ /\ \__ / /\ _\`\ /\ \ ";
    echo "\ \ \L\ \ ___ ___\ \ ,_\ ____ / /\ \,\L\_\ __ __ __\ \ \ ";
    echo " \ \ , / / __\`\ / __\`\ \ \/ /',__\ / / \/_\__ \ /'__\`\ /'_ \`\ /'__\`\ \ \ ";
    echo " \ \ \\ \ /\ \L\ \/\ \L\ \ \ \_/\__, \`\/ / /\ \L\ \/\ \L\.\_/\ \L\ \/\ __/\ \_\ ";
    echo " \ \_\ \_\ \____/\ \____/\ \__\/\____/_/ \ \`\____\ \__/.\_\ \____ \ \____\\/\_\ ";
    echo " \/_/\/ /\/___/ \/___/ \/__/\/___/_/ \/_____/\/__/\/_/\/___L\ \/____/ \/_/ ";
    echo " /\____/ ";
    echo " \_/__/ ";
    echo "
    ____ __ __ _____ __
    / __ \____ _____ / /_/ /_ ___ ____ ____ / ___/__ _______/ /____ ____ ___ _____
    / /_/ / __ `/ __ \/ __/ __ \/ _ \/ __ \/ __ \ \__ \/ / / / ___/ __/ _ \/ __ `__ \/ ___/
    / ____/ /_/ / / / / /_/ / / / __/ /_/ / / / / ___/ / /_/ (__ ) /_/ __/ / / / / (__ )
    /_/ \__,_/_/ /_/\__/_/ /_/\___/\____/_/ /_/ /____/\__, /____/\__/\___/_/ /_/ /_/____/
    /____/
    ____ ________ ________ ____ / /______
    / __ \/ ___/ _ \/ ___/ _ \/ __ \/ __/ ___/
    / /_/ / / / __(__ ) __/ / / / /_(__ )
    / .___/_/ \___/____/\___/_/ /_/\__/____/
    /_/
    ____ __ ______
    /\ _`\ /\ \__ / /\ _`\
    \ \ \L\ \ ___ ___\ \ ,_\ ____ / /\ \,\L\_\ __ __ __
    \ \ , / / __`\ / __`\ \ \/ /',__\ / / \/_\__ \ /'__`\ /'_ `\ /'__`\
    \ \ \\ \ /\ \L\ \/\ \L\ \ \ \_/\__, `\/ / /\ \L\ \/\ \L\.\_/\ \L\ \/\ __/
    \ \_\ \_\ \____/\ \____/\ \__\/\____/_/ \ `\____\ \__/.\_\ \____ \ \____\
    \/_/\/ /\/___/ \/___/ \/__/\/___/_/ \/_____/\/__/\/_/\/___L\ \/____/
    /\____/
    \_/__/
    ______ __ ___ ___
    /\__ _\ /\ \__ /\_ \ /\_ \
    \/_/\ \/ ___ ___\ \ ,_\ __ \//\ \ \//\ \ __ _ __
    \ \ \ /' _ `\ /',__\ \ \/ /'__`\ \ \ \ \ \ \ /'__`\/\`'__\
    \_\ \__/\ \/\ \/\__, `\ \ \_/\ \L\.\_ \_\ \_ \_\ \_/\ __/\ \ \/
    /\_____\ \_\ \_\/\____/\ \__\ \__/.\_\/\____\/\____\ \____\\ \_\
    \/_____/\/_/\/_/\/___/ \/__/\/__/\/_/\/____/\/____/\/____/ \/_/
    "
    themedir="web/app/themes/"
  3. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,35 @@
    #!/bin/bash

    echo " ____ __ __ _____ __ ";
    echo " / __ \____ _____ / /_/ /_ ___ ____ ____ / ___/__ _______/ /____ ____ ___ _____";
    echo " / /_/ / __ \`/ __ \/ __/ __ \/ _ \/ __ \/ __ \ \__ \/ / / / ___/ __/ _ \/ __ \`__ \/ ___/";
    echo " / ____/ /_/ / / / / /_/ / / / __/ /_/ / / / / ___/ / /_/ (__ ) /_/ __/ / / / / (__ ) ";
    echo "/_/ \__,_/_/ /_/\__/_/ /_/\___/\____/_/ /_/ /____/\__, /____/\__/\___/_/ /_/ /_/____/ ";
    echo " /____/ ";
    echo " ____ ________ ________ ____ / /______ ";
    echo " / __ \/ ___/ _ \/ ___/ _ \/ __ \/ __/ ___/ ";
    echo " / /_/ / / / __(__ ) __/ / / / /_(__ ) ";
    echo " / .___/_/ \___/____/\___/_/ /_/\__/____/ ";
    echo " /_/ ";
    echo " __ __ __ __ ___ ___ ";
    echo "/\ \ /\ \__/\ \ __ /\ \__ /\_ \ /\_ \ ";
    echo "\ \ \ __\ \ ,_\ \/ ____ /\_\ ___ ___\ \ ,_\ __ \//\ \ \//\ \ ";
    echo " \ \ \ __ /'__\`\ \ \/\/ /',__\ \/\ \ /' _ \`\ /',__\ \ \/ /'__\`\ \ \ \ \ \ \ ";
    echo " \ \ \L\ \/\ __/\ \ \_ /\__, \`\ \ \ \/\ \/\ \/\__, \`\ \ \_/\ \L\.\_ \_\ \_ \_\ \_ ";
    echo " \ \____/\ \____\\ \__\ \/\____/ \ \_\ \_\ \_\/\____/\ \__\ \__/.\_\/\____\/\____\";
    echo " \/___/ \/____/ \/__/ \/___/ \/_/\/_/\/_/\/___/ \/__/\/__/\/_/\/____/\/____/";
    echo " ";
    echo " ";
    echo " ____ __ ______ __ ";
    echo "/\ _\`\ /\ \__ / /\ _\`\ /\ \ ";
    echo "\ \ \L\ \ ___ ___\ \ ,_\ ____ / /\ \,\L\_\ __ __ __\ \ \ ";
    echo " \ \ , / / __\`\ / __\`\ \ \/ /',__\ / / \/_\__ \ /'__\`\ /'_ \`\ /'__\`\ \ \ ";
    echo " \ \ \\ \ /\ \L\ \/\ \L\ \ \ \_/\__, \`\/ / /\ \L\ \/\ \L\.\_/\ \L\ \/\ __/\ \_\ ";
    echo " \ \_\ \_\ \____/\ \____/\ \__\/\____/_/ \ \`\____\ \__/.\_\ \____ \ \____\\/\_\ ";
    echo " \/_/\/ /\/___/ \/___/ \/__/\/___/_/ \/_____/\/__/\/_/\/___L\ \/____/ \/_/ ";
    echo " /\____/ ";
    echo " \_/__/ ";
    themedir="web/app/themes/"
    echo "Enter the site name. \n
  4. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -81,11 +81,11 @@ cd ../..
    # Check of jq is installed
    if [ ! command -v jq &> /dev/null ]; then
    if [ ! command -v brew & /dev/null ]; then
    echo 'Brew was not found. Exiting here. You\'ll need to add the following lines to your `composer.json`:
    "scripts": {
    "post-install-cmd": [
    "@composer install --working-dir=web/app/themes/$sagename"
    ],'
    echo 'Brew was not found. Exiting here. You\'ll need to add the following lines to your `composer.json`:'
    echo ' "scripts": {'
    echo ' "post-install-cmd": ['
    echo ' "@composer install --working-dir=web/app/themes/$sagename"'
    echo ' ],'
    exit
    fi
    brew install jq
  5. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ if [ ! command -v jq &> /dev/null ]; then
    echo 'Brew was not found. Exiting here. You\'ll need to add the following lines to your `composer.json`:
    "scripts": {
    "post-install-cmd": [
    "@composer install --working-dir=web/app/themes/sagey"
    "@composer install --working-dir=web/app/themes/$sagename"
    ],'
    exit
    fi
  6. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -106,3 +106,16 @@ git push origin HEAD:master
    # Activate the new theme
    terminus wp -- $sitename.dev theme activate $sagename
    # Switch back to SFTP so files can be written.
    terminus connection:set $sitename.dev sftp
    # Open the site. This should generate requisite files on page load.
    open https://dev-$sitename.pantheonsite.io
    # Commit any additions found in SFTP mode.
    terminus env:commit $sitename.dev --message="[Sage Install] Add any leftover files found in SFTP mode."
    # Switch back to Git.
    terminus connection:set $sitename.env git
    git pull --ff --commit
  7. jazzsequence revised this gist Oct 12, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -103,3 +103,6 @@ git commit -m "[Sage Install] Add post-install-cmd hook to also run install on S
    git pull --ff --commit
    git push origin HEAD:master
    # Activate the new theme
    terminus wp -- $sitename.dev theme activate $sagename
  8. jazzsequence revised this gist Oct 11, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -102,4 +102,4 @@ git add composer.json
    git commit -m "[Sage Install] Add post-install-cmd hook to also run install on Sage theme"
    git pull --ff --commit
    git push origin master
    git push origin HEAD:master
  9. jazzsequence revised this gist Oct 11, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -102,4 +102,4 @@ git add composer.json
    git commit -m "[Sage Install] Add post-install-cmd hook to also run install on Sage theme"
    git pull --ff --commit
    git push
    git push origin master
  10. jazzsequence created this gist Oct 11, 2022.
    105 changes: 105 additions & 0 deletions install-sage.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,105 @@
    #!/bin/bash

    themedir="web/app/themes/"

    echo "Enter the site name. \n
    This will be used to clone your site locally to /{User}/pantheon-local-copies/{site_name) and to interact with your site."

    read $sitename

    echo "Enter your theme name. \n
    This is used to create the theme directory. As such, it should ideally be all lowercase with no spaces (hyphens or underscores recommended)."

    read $sagename

    echo "Enter your SFTP username. \n
    This will only be stored in this terminal session. This can be found in your site dashboard."

    read $sftpuser

    echo "Enter your SFTP hostname. \n
    This will only be stored in this terminal session. This can be found in your site dashboard."

    read $sftphost

    sagedir=$themedir/$sagename

    # Clone the site
    terminus local:clone $sitename

    if [ $? -ne 0 ]; then
    echo "Site could not be cloned. Did you enter the correct site name?"
    exit;
    fi

    # Move to the new site directory.
    cd ~/pantheon-local-copies/$sitename

    # Set the main branch to track master from Pantheon.
    git branch -u origin/master

    # Update to PHP 8.0
    sed -i '' "s/php_version: 7.4/php_version: 8.0" pantheon.upstream.yml
    git commit -am "[Sage Install] Update PHP version to 8.0"

    # Create the new Sage theme
    composer create-project roots/sage $sagedir

    # Require Roots/acorn
    composer require roots/acorn --working-dir=$sagedir

    # Install all the Sage dependencies
    composer install --no-dev --prefer-dist --working-dir=$sagedir

    # NPM the things
    npm install --prefix $sagedir
    npm run build --prefix $sagedir

    # Remove /public from .gitignore
    sed -i '' "s/\/public//" $sagedir/.gitignore

    # Commit the theme
    git add $sagedir
    git commit -m "[Sage Install] Add the Sage theme"

    # Switch to SFTP mode
    terminus connection:set $sitename.dev sftp

    # Create a files/cache directory on the host.
    sftp -P 2222 $sftpuser@$sftphost:/files <<< $'mkdir cache'
    # Switch back to Git mode.
    terminus connection:set $sitename.dev git
    # Create the symlink to /files/cache.
    cd web/app
    ln -sfn uploads/cache
    git add .
    git commit -m "[Sage Install] Add a symlink for /files/cache to /uploads/cache"
    cd ../..
    # Check of jq is installed
    if [ ! command -v jq &> /dev/null ]; then
    if [ ! command -v brew & /dev/null ]; then
    echo 'Brew was not found. Exiting here. You\'ll need to add the following lines to your `composer.json`:
    "scripts": {
    "post-install-cmd": [
    "@composer install --working-dir=web/app/themes/sagey"
    ],'
    exit
    fi
    brew install jq
    fi
    # Add a post-install hook to the composer.json.
    jq -r '.scripts += { "post-install-cmd": [ "@composer install --working-dir=%sagedir%" ] }' composer.json > composer.new.json
    sed -i '' "s,%sagedir%,$sagedir," composer.new.json
    rm composer.json
    mv composer.new.json composer.json
    # Commit the change to composer.json
    git add composer.json
    git commit -m "[Sage Install] Add post-install-cmd hook to also run install on Sage theme"
    git pull --ff --commit
    git push