diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6f5ec94..d1ea18609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed bug causing service script loading collisions + ## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22) * Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245) diff --git a/builders/_lando.js b/builders/_lando.js index 8556de70e..e1f21cdf4 100644 --- a/builders/_lando.js +++ b/builders/_lando.js @@ -41,6 +41,7 @@ module.exports = { refreshCerts = false, remoteFiles = {}, scripts = [], + scriptsDir = '', sport = '443', ssl = false, sslExpose = true, @@ -66,16 +67,23 @@ module.exports = { console.error(color.yellow(`${type} version ${version} is a legacy version! We recommend upgrading.`)); } + // normalize scripts dir if needed + if (!path.isAbsolute(scriptsDir)) scriptsDir = path.resolve(root, scriptsDir); + + // Get some basic locations + const globalScriptsDir = path.join(userConfRoot, 'scripts'); + const serviceScriptsDir = path.join(userConfRoot, 'helpers', project, type, name); + const entrypointScript = path.join(globalScriptsDir, 'lando-entrypoint.sh'); + const addCertsScript = path.join(globalScriptsDir, 'add-cert.sh'); + const refreshCertsScript = path.join(globalScriptsDir, 'refresh-certs.sh'); + // Move our config into the userconfroot if we have some // NOTE: we need to do this because on macOS and Windows not all host files // are shared into the docker vm if (fs.existsSync(confSrc)) require('../utils/move-config')(confSrc, confDest); - // Get some basic locations - const scriptsDir = path.join(userConfRoot, 'scripts'); - const entrypointScript = path.join(scriptsDir, 'lando-entrypoint.sh'); - const addCertsScript = path.join(scriptsDir, 'add-cert.sh'); - const refreshCertsScript = path.join(scriptsDir, 'refresh-certs.sh'); + // ditto for service helpers + if (fs.existsSync(scriptsDir)) require('../utils/move-config')(scriptsDir, serviceScriptsDir); // Handle Environment const environment = { @@ -94,11 +102,14 @@ module.exports = { // Handle volumes const volumes = [ `${userConfRoot}:/lando:cached`, - `${scriptsDir}:/helpers`, + `${globalScriptsDir}:/helpers`, `${entrypointScript}:/lando-entrypoint.sh`, `${dataHome}:/var/www`, ]; + // add in service helpers if we have them + if (fs.existsSync(serviceScriptsDir)) volumes.push(`${serviceScriptsDir}:/etc/lando/service/helpers`); + // Handle ssl if (ssl) { // also expose the sport diff --git a/examples/tooling/.lando.yml b/examples/tooling/.lando.yml index 66d5d8c74..399f16275 100644 --- a/examples/tooling/.lando.yml +++ b/examples/tooling/.lando.yml @@ -10,6 +10,7 @@ services: api: 3 type: lando meUser: node + scriptsDir: scripts services: image: node:16 command: docker-entrypoint.sh tail -f /dev/null @@ -261,6 +262,19 @@ tooling: arg2: describe: Uses arg2 type: string + sdargs: + cmd: /etc/lando/service/helpers/args.sh + service: node + positionals: + arg1: + describe: Uses arg1 + type: string + choices: + - thing + - stuff + arg2: + describe: Uses arg2 + type: string plugins: "@lando/core": "../.." diff --git a/examples/tooling/README.md b/examples/tooling/README.md index e8991e604..44de5792c 100644 --- a/examples/tooling/README.md +++ b/examples/tooling/README.md @@ -159,6 +159,10 @@ lando everything --help | grep "lando everything \[arg1\] \[arg2\] MORETHINGS" # Should allow for example pasthru in task definition lando everything --help | grep "lando this is just for testing" +# Should be able to access scriptsDir from the landofile +lando exec node -- stat /etc/lando/service/helpers/args.sh +lando sdargs hello there | grep "hello there" + # Should be able to run even if options are empty lando emptyopter diff --git a/examples/tooling/scripts/args.sh b/examples/tooling/scripts/args.sh new file mode 100755 index 000000000..b00e31206 --- /dev/null +++ b/examples/tooling/scripts/args.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "$1 $2" diff --git a/netlify.toml b/netlify.toml index 554d1debf..1c79b4c45 100644 --- a/netlify.toml +++ b/netlify.toml @@ -20,6 +20,7 @@ "https://docs.google.com/document", "https://docs.google.com/forms", "https://github.com", + "https://www.drupal.org/community/events", "/v/" ] skipPatterns = [