Skip to content

Tooling: Allow Chaining of Custom Tooling Commands #31

@AaronFeledy

Description

@AaronFeledy

As a Lando user who frequently builds custom tooling to execute common tasks, I find that some of those tasks get repeated within more than one command.
For example:

tooling:
  install-deps:
    description: Install project dependencies
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
  install-db:
    description: Download and install project database
    cmd:
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login
  install-everything:
    description: Download and install project dependencies and database
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

services:
  appserver:
    run:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

So much repetition there.

Lando can help solve this problem by allowing the chaining of tooling commands from within the command definition. More simply, this means allowing one Lando command to call another. In a perfect world, this would work, not only for custom tooling commands, but built-in tooling and build steps as well. This would allow reduced duplication of commands and the above functionality could be defined more like this:

services:
  appserver:
    run: -install-everything

tooling:
  install-deps:
    description: Install project dependencies
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
  install-db:
    description: Download and install project database
    cmd:
    - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
    - lando: db-import /app/drupal/db_dump.sql.gz
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

  install-everything:
    description: Download and install project dependencies and database
    cmd:
      - lando: install-deps
      - lando: install-db

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions