Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ cache
dist
_site
!.vitepress

# Examples are executable integration specs; they can generate full Drupal codebases under examples/*/*
# which include their own ESLint config/deps that we do not install in this repo.
examples/**
examples/*/*/**
1 change: 1 addition & 0 deletions .github/workflows/pr-drupal-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
leia-test:
- examples/drupal-custom
- examples/drupal-defaults
- examples/drupal-drush-uri
- examples/drupal-export
- examples/drupal-import
- examples/drupal-mariadb
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Added `drush_uri` configuration option to set `DRUSH_OPTIONS_URI` environment variable in the appserver service.
* Updated to [@lando/mariadb@1.8.0](https://github.com/lando/mariadb/releases/tag/v1.8.0)
* Updated to [@lando/postgres@1.6.0](https://github.com/lando/postgres/releases/tag/v1.6.0)

Expand Down
18 changes: 18 additions & 0 deletions builders/_drupaly.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ module.exports = {
webroot: '.',
xdebug: false,
proxy: {},
drush_uri: null,
},
builder: (parent, config) => class LandoDrupal extends parent {
constructor(id, options = {}) {
Expand Down Expand Up @@ -290,6 +291,23 @@ module.exports = {
options.services = _.merge({}, getServices(options), options.services);
options.tooling = _.merge({}, getTooling(options), options.tooling);

// Set DRUSH_OPTIONS_URI based on drush_uri config or proxy settings
let drushUri = options.drush_uri;
if (!drushUri) {
const proxyUrl = options.proxy[options.proxyService]?.[0];
if (proxyUrl) {
// Check SSL setting for the proxy service
const proxyServiceSsl = options.services[options.proxyService]?.ssl;
const ssl = proxyServiceSsl !== undefined ? proxyServiceSsl : options.services.appserver?.ssl;
drushUri = ssl ? `https://${proxyUrl}` : `http://${proxyUrl}`;
}
}

if (drushUri) {
options.services.appserver.environment = options.services.appserver.environment || {};
options.services.appserver.environment.DRUSH_OPTIONS_URI = drushUri;
}

// Send downstream
super(id, _.merge({}, config, options));
}
Expand Down
18 changes: 14 additions & 4 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Here are the configuration options, set to the default values, for this recipe's
recipe: drupal11
config:
php: '8.3'
composer_version: 2-latest
composer_version: '2-latest'
via: apache:2.4
webroot: .
database: mysql:8.0
drush: false
webroot: public
database: mysql:8.4
drush: ^13
drush_uri: SEE BELOW
xdebug: false
config:
database: SEE BELOW
Expand Down Expand Up @@ -139,6 +140,15 @@ port: 3306

You can get also get the above information, and more, by using the [`lando info`](https://docs.lando.dev/cli/info.html) command.

## Configuring Drush URI

The `drush_uri` option allows you to set a custom URL for Drush to use when connecting to your Drupal site. This overrides the `DRUSH_OPTIONS_URI` environment variable in the `appserver` service which, by default, is automatically set to the proxy URL for the webserver you are using. You will need to run `lando rebuild` to apply changes to this setting.

```yaml
recipe: drupal11
config:
drush_uri: 'https://custom-uri.lndo.site'
```

## Using custom config files

Expand Down
2 changes: 1 addition & 1 deletion docs/legacy/drupal-7.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ config:

While Lando will globally install Drush for you it is increasingly common and in some cases a straight-up best practice to [install a site-local Drush](https://www.drush.org/latest/install/) by requiring it in your projects `composer.json` file.

Because of how Lando's [php service](https://docs.lando.dev/plugins/php) sets up its [`PATH`](https://docs.lando.dev/plugins/php/caveats.html) this means that if you have indeed installed Drush on your own via `composer` Lando will use yours over its own.
Because of how Lando's [php service](https://docs.lando.dev/plugins/php/index.html) sets up its [`PATH`](https://docs.lando.dev/plugins/php/caveats.html) this means that if you have indeed installed Drush on your own via `composer` Lando will use yours over its own.

Said more explicitly: **if you've required `drush` via `composer` in your application then this recipe will use your `drush` and not the one you've specified in this recipes config.**

Expand Down
89 changes: 89 additions & 0 deletions examples/drupal-drush-uri/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Drupal Drush URI Example

This example exists primarily to test the following documentation:

* [Drupal Recipe Configuration](https://docs.lando.dev/config/drupal.html#configuring-drush-uri)

## Start up tests

Run the following commands to get up and running with this example.

```bash
# Should poweroff
lando poweroff

# Should initialize the latest Drupal 10 codebase
rm -rf drupal-drush-uri && mkdir -p drupal-drush-uri && cd drupal-drush-uri
lando init --source remote --remote-url https://ftp.drupal.org/files/projects/drupal-10.0.x-dev.tar.gz --remote-options="--strip-components 1" --recipe drupal10 --webroot . --name lando-drupal-drush-uri

# Should start up successfully
cd drupal-drush-uri
cp -f ../../.lando.upstream.yml .lando.upstream.yml && cat .lando.upstream.yml
lando start
```

## Verification commands

Run the following commands to validate things are rolling as they should.

```bash
# Should use default drush_uri based on proxy settings
cd drupal-drush-uri
lando exec appserver -- env | grep DRUSH_OPTIONS_URI | grep "https://lando-drupal-drush-uri.lndo.site"

# Should use site-local drush if installed
cd drupal-drush-uri
lando composer require drush/drush
lando exec appserver -- which drush | grep "/app/vendor/bin/drush"

# Should be able to install drupal
cd drupal-drush-uri
lando drush si --db-url=mysql://drupal10:drupal10@database/drupal10 -y

# Should be able to use drush with default uri
cd drupal-drush-uri
lando drush status | grep "Site URI" | grep "https://lando-drupal-drush-uri.lndo.site"
```

## Custom drush_uri test

Now let's test with a custom drush_uri configuration.

```bash
# Should update the .lando.yml file
cd drupal-drush-uri
cat > .lando.yml << EOF
name: lando-drupal-drush-uri
recipe: drupal10
config:
drush_uri: 'https://custom-uri.lndo.site'
EOF

# Should rebuild with new configuration
cd drupal-drush-uri
lando rebuild -y

# Should use custom drush_uri
cd drupal-drush-uri
lando exec appserver -- env | grep DRUSH_OPTIONS_URI | grep "https://custom-uri.lndo.site"

# Should use site-local drush if installed
cd drupal-drush-uri
lando composer require drush/drush
lando exec appserver -- which drush | grep "/app/vendor/bin/drush"

# Should be able to use drush with custom uri
cd drupal-drush-uri
lando drush status | grep "Site URI" | grep "https://custom-uri.lndo.site"
```

## Destroy tests

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
cd drupal-drush-uri
lando destroy -y
lando poweroff
```
4 changes: 4 additions & 0 deletions examples/drupal10/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ lando exec appserver -- which drush | grep "/app/vendor/bin/drush"
cd drupal10
lando drush si --db-url=mysql://drupal10:drupal10@database/drupal10 -y

# Should use default drush_uri based on proxy settings
cd drupal10
lando drush uli --no-browser | tee >(cat 1>&2) | grep "lando-drupal10.lndo.site"

# Should be able to enable and access jsonapi
cd drupal10
lando drush en jsonapi -y
Expand Down
4 changes: 2 additions & 2 deletions examples/drupal11-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ lando exec appserver -- curl -IL appserver_nginx | grep Server | grep nginx
cd nginx
lando mysql -V | grep 8.0

# Should be running sqlite 3.45 by default
# Should be running sqlite 3.46 by default
cd nginx
lando php -r "print_r(SQLite3::version());" | grep versionString | tee >(cat 1>&2) | grep 3.45
lando php -r "print_r(SQLite3::version());" | grep versionString | tee >(cat 1>&2) | grep 3.46.

# Should not enable xdebug by default
cd nginx
Expand Down
8 changes: 6 additions & 2 deletions examples/drupal11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ lando exec appserver -- curl -IL localhost | grep Server | grep 2.4
cd drupal11
lando mysql -V | grep 8.0

# Should be running sqlite 3.45 by default
# Should be running sqlite 3.46 by default
cd drupal11
lando php -r "print_r(SQLite3::version());" | grep versionString | tee >(cat 1>&2) | grep 3.45
lando php -r "print_r(SQLite3::version());" | grep versionString | tee >(cat 1>&2) | grep 3.46.

# Should not enable xdebug by default
cd drupal11
Expand All @@ -75,6 +75,10 @@ lando exec appserver -- which drush | grep "/app/vendor/bin/drush"
cd drupal11
lando drush si --db-url=mysql://drupal11:drupal11@database/drupal11 -y

# Should use default drush_uri based on proxy settings
cd drupal11
lando drush uli --no-browser | tee >(cat 1>&2) | grep "lando-drupal11.lndo.site"

# Should be able to enable and access jsonapi
cd drupal11
lando drush en jsonapi -y
Expand Down
14 changes: 7 additions & 7 deletions examples/drupal7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lando poweroff

# Should initialize the latest Drupal 7 codebase
rm -rf drupal7 && mkdir -p drupal7 && cd drupal7
lando init --source remote --remote-url https://ftp.drupal.org/files/projects/drupal-7.71.tar.gz --remote-options="--strip-components 1" --recipe drupal7 --webroot . --name lando-drupal7 --option drush="^8"
lando init --source remote --remote-url https://ftp.drupal.org/files/projects/drupal-7.103.tar.gz --remote-options="--strip-components 1" --recipe drupal7 --webroot . --name lando-drupal7

# Should start up successfully
cd drupal7
Expand All @@ -34,16 +34,16 @@ lando exec appserver -- curl -L localhost | grep "Drupal 7"

# Should use 7.4 as the default php version
cd drupal7
lando php -v | grep "PHP 7.4"
lando php -v | tee >(cat 1>&2) | grep "PHP 7.4"

# Should be running apache 2.4 by default
cd drupal7
lando exec appserver -- apachectl -V | grep 2.4
lando exec appserver -- curl -IL localhost | grep Server | grep 2.4
lando exec appserver -- apachectl -V | tee >(cat 1>&2) | grep 2.4
lando exec appserver -- curl -IL localhost | grep Server | tee >(cat 1>&2) | grep 2.4

# Should be running mysql 5.7 by default
cd drupal7
lando mysql -V | grep 5.7
lando mysql -V | tee >(cat 1>&2) | grep 5.7

# Should be using the mysql_native_password authentication plugin by default
cd drupal7
Expand All @@ -59,15 +59,15 @@ lando mysql -udrupal7 -pdrupal7 drupal7 -e quit

# Should use drush 8.5.x by default
cd drupal7
lando drush version | grep 8.5
lando drush version | tee >(cat 1>&2) | grep 8.5

# Should be able to install drupal
cd drupal7
lando drush si --db-url=mysql://drupal7:drupal7@database/drupal7 -y

# Should have infinite memory for drush
cd drupal7
lando drush eval "phpinfo();" | grep memory_limit | grep -e "-1"
lando drush eval "phpinfo();" | grep memory_limit | tee >(cat 1>&2) | grep -e "-1"

# Should have SIMPLETEST envvars set correctly
cd drupal7
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"CHANGELOG.html",
"x.com",
"twitter.com",
"https://www.drupal.org",
"drupal.org",
"/v/"
]
skipPatterns = [ ".rss", ".gif", ".jpg" ]
Expand Down
Loading