drainpipe
drainpipe copied to clipboard
Add a dependency on drupal:composer on all commands that use drush
If someone runs a drupal command, and composer's install is out of date, we should run composer automatically. We can do this by adding a dependency on the composer task in all drupal tasks.
This is most helpful on locals that have persistent checkouts, and not CI or other environments.
Here's an example of a composer install task that automatically skips if composer is up to date:
override:drupal:composer:
desc: Install composer dependencies
summary: |
This command is typically used when a developer updates their local after
pulling new changes from source control. Generally when bootstrapping a
fresh clone of the site from git, you'll need to run `composer install`
anyway to get task and drainpipe.
cmds:
- |
# We use the COMPOSER_NO_DEV environment variable to control production
# builds.
# https://getcomposer.org/doc/03-cli.md#composer-no-dev
# We set it in case task is using the "alternate" syntax, including
# when we call task via `ddev task`.
export COMPOSER_NO_DEV={{.COMPOSER_NO_DEV}}
composer install --optimize-autoloader
sources:
- composer.json
- composer.lock
generates:
- ./vendor/composer/installed.json
- ./vendor/autoload.php
status:
- >
{{if eq .COMPOSER_NO_DEV "1"}}
test -f ./vendor/composer/installed.json && grep -q '"dev": false' ./vendor/composer/installed.json
{{else}}
test -f ./vendor/composer/installed.json && grep -q '"dev": true' ./vendor/composer/installed.json
{{end}}
as #169 we can't do this because these tasks also run in remote environments
I think you still need to run composer to get drush in the first place, even when running in remote environments.