New Composer plugin "Remote Bin Scripts" makes it easy to install 3rd party tools.

Configure remote scripts.

Recently we finished a project that was being moved to Pantheon.

We created a couple custom scripts for pushing data into the pantheon environment, and for pulling data down for continuous integration runs.

The scripts require the Terminus CLI tool created by Pantheon to interact with it's service.

Terminus is a composer project, but it's dependencies don't align with the latest Drupal sites. It's best to install it as a phar file and run it that way.

Since we implemented automated jobs that need terminus, we decided to use composer to download and install it for us using the instructions provided in the documentation: https://docs.pantheon.io/terminus/install#standalone-terminus-phar 

At first we did this using composer's "post-install-cmd" hook to curl the phar to the bin directory.

Then we realized how nice it would be to have a plugin to do this for us.

Introducing Remote Bin Scripts

If you have a script accessible by URL and want to install into your composer bin dir, this plugin is for you.

$ composer require operations/remote-bin-scripts

Then, add the scripts you want to your composer.json file:

{
  "extra": {
    "remote-scripts": {
      "vendor/bin/hello-world": "https://raw.githubusercontent.com/operations-platform/composer-remote-bin-scripts/2.x/hello-world.sh",

      "vendor/bin/terminus": "https://github.com/pantheon-systems/terminus/releases/download/3.3.0/terminus.phar"
    }
  }
}

 

When `composer install` is run, the file is downloaded to the specified location, and marked executable.

See https://github.com/operations-platform/composer-remote-bin-scripts for more information.

Parity

This method ensures that your site is entirely self contained and doesn't rely on any external scripts. It makes life easier for your developers who don't have to go and install something else before the site will work. It keeps things more stable because your codebase decides what version of the script to install.

Enjoy!

Submitted by admin on

Like what you have read? Want to speak about your project?

Contact Jon Now