From 789a8f8ccfafdb1262199af26097e276c253d0a3 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 15 Aug 2023 09:03:41 +0100 Subject: [PATCH] Allow the update command to overriden in Tugboat --- .tugboat/steps/3-build.sh | 2 +- README.md | 11 ++++++----- scaffold/Taskfile.yml | 20 +++++++++++++------- scaffold/tugboat/steps/3-build.sh.twig | 2 +- src/ScaffoldInstallerPlugin.php | 10 +++++++--- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.tugboat/steps/3-build.sh b/.tugboat/steps/3-build.sh index 7af39d6a..fed78af8 100755 --- a/.tugboat/steps/3-build.sh +++ b/.tugboat/steps/3-build.sh @@ -7,4 +7,4 @@ set -eux echo "Building..." ./vendor/bin/task build -./vendor/bin/task drupal:update +./vendor/bin/task update diff --git a/README.md b/README.md index 6f5a2bbe..7413d4b6 100644 --- a/README.md +++ b/README.md @@ -507,13 +507,14 @@ Additionally, Pantheon Terminus can be added: ``` It is assumed the following tasks exist: -- `build` - `sync` +- `build` +- `update` -The `build` and `sync` tasks can be overridden with a `build:tugboat` and -`sync:tugboat` task if required (you will need to re-run `composer install` to -regenerate the Tugboat scripts if you are adding this task to your -`Taskfile.yml` for the first time). +The `build`, `sync`, and `update` tasks can be overridden with `sync:tugboat`, +`build:tugboat`, and `update:tugboat` tasks if required (you will need to re-run +`composer install` to regenerate the Tugboat scripts if you are adding this +task to your `Taskfile.yml` for the first time). ``` sync: diff --git a/scaffold/Taskfile.yml b/scaffold/Taskfile.yml index a37a3929..9fbb534f 100644 --- a/scaffold/Taskfile.yml +++ b/scaffold/Taskfile.yml @@ -21,11 +21,24 @@ silent: true # web/themes/custom/mytheme/script.js:web/themes/custom/mytheme/script.min.js tasks: + sync: + desc: "Sync a database from production and import it" + cmds: + # Replace this with a command to fetch your database. + - ./vendor/bin/drush site:install -y + - echo "🧹 Sanitising database" + - ./vendor/bin/drush sql:sanitize --yes + build: desc: "Builds the project for production" deps: [drupal:composer:production] cmds: - echo "Nothing to do" + + update: + desc: "Runs the Drupal update process" + cmds: + - task: drupal:update # assets: # desc: "Builds assets such as CSS & JS" # cmds: @@ -35,11 +48,4 @@ tasks: # assets:watch: # desc: "Builds assets such as CSS & JS, and watches them for changes" # deps: [sass:watch, javascript:watch] - sync: - desc: "Sync a database from production and import it" - cmds: - # Replace this with a command to fetch your database. - - ./vendor/bin/drush site:install -y - - echo "🧹 Sanitising database" - - ./vendor/bin/drush sql:sanitize --yes diff --git a/scaffold/tugboat/steps/3-build.sh.twig b/scaffold/tugboat/steps/3-build.sh.twig index 51396c0d..ad88cb45 100644 --- a/scaffold/tugboat/steps/3-build.sh.twig +++ b/scaffold/tugboat/steps/3-build.sh.twig @@ -7,4 +7,4 @@ set -eux echo "Building..." ./vendor/bin/task {{ build_command }} -./vendor/bin/task drupal:update +./vendor/bin/task {{ update_command }} diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 6e2279ee..6ece21d1 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -287,8 +287,9 @@ private function installCICommands(): void 'database_type' => 'mariadb', 'database_version' => '10.6', 'php_version' => '8.1', - 'build_command' => 'build', 'sync_command' => 'sync', + 'build_command' => 'build', + 'update_command' => 'update', 'init' => [], 'task_version' => $binaryInstallerPlugin->getBinaryVersion('task'), 'pantheon' => isset($this->extra['drainpipe']['tugboat']['pantheon']), @@ -318,11 +319,14 @@ private function installCICommands(): void if (file_exists('Taskfile.yml')) { // Get steps out of the Taskfile. $taskfile = Yaml::parseFile('./Taskfile.yml'); + if (isset($taskfile['tasks']['sync:tugboat'])) { + $tugboatConfig['sync_command'] = 'sync:tugboat'; + } if (isset($taskfile['tasks']['build:tugboat'])) { $tugboatConfig['build_command'] = 'build:tugboat'; } - if (isset($taskfile['tasks']['sync:tugboat'])) { - $tugboatConfig['sync_command'] = 'sync:tugboat'; + if (isset($taskfile['tasks']['update:tugboat'])) { + $tugboatConfig['update_command'] = 'update:tugboat'; } if (isset($taskfile['tasks']['tugboat:php:init'])) { $tugboatConfig['init']['php'] = true;