Skip to content

Commit

Permalink
Add WP_ENV_MULTISITE envoriment variable. (WordPress#68792)
Browse files Browse the repository at this point in the history
* Add WP_ENV_MULTISITE envoriment variable.

Introduce a new `multisite` option in `wp-env` to enable multisite setups. This can be specified via the `WP_ENV_MULTISITE` environment variable or in the configuration file. Updated documentation to include usage instructions.

* Apply suggestions from code review

* Apply suggestions from code review

* Update packages/env/README.md

Co-authored-by: Pascal Birchler <[email protected]>

* Add `WP_ENV_MULTISITE` environment variable to override multisite

This enhancement allows overriding the `multisite` option using the `WP_ENV_MULTISITE` variable. It provides greater flexibility for customizing environment configurations.

* Fix type annotation and format multisite environment logic

Corrected the JSDoc type annotation for the multisite property from `bool` to `boolean` for consistency. Added a minor formatting adjustment to the multisite environment variable processing logic.

---------

Co-authored-by: Pascal Birchler <[email protected]>
  • Loading branch information
spacedmonkey and swissspidy authored Jan 22, 2025
1 parent 06ee5e1 commit eba2d71
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/env/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Add a `WP_ENV_MULTISITE` environment variable to override the `multisite` option ([#68792](https://github.com/WordPress/gutenberg/pull/68792)).

## 10.16.0 (2025-01-15)

## 10.15.0 (2025-01-02)
Expand Down
11 changes: 11 additions & 0 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,17 @@ You can tell `wp-env` to use a specific PHP version for compatibility and testin
}
```

### Multisite support

You can tell `wp-env` if the site should be multisite enabled. This can also be set via the environment variable `WP_ENV_MULTISITE`.

```json
{
"multisite": true,
"plugins": [ "." ]
}
```

### Node Lifecycle Script

This is useful for performing some actions after setting up the environment, such as bootstrapping an E2E test environment.
Expand Down
5 changes: 5 additions & 0 deletions packages/env/lib/config/get-config-from-environment-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const { checkPort, checkVersion, checkString } = require( './validate-config' );
* @property {?number} phpmyadminPort An override for the development environment's phpMyAdmin port.
* @property {?WPSource} coreSource An override for all environment's coreSource.
* @property {?string} phpVersion An override for all environment's PHP version.
* @property {?boolean} multisite An override for if environmen should be multisite.
* @property {?Object.<string, string>} lifecycleScripts An override for various lifecycle scripts.
*/

Expand Down Expand Up @@ -68,6 +69,10 @@ module.exports = function getConfigFromEnvironmentVars( cacheDirectoryPath ) {
environmentConfig.phpVersion = process.env.WP_ENV_PHP_VERSION;
}

if ( process.env.WP_ENV_MULTISITE ) {
environmentConfig.multisite = !! process.env.WP_ENV_MULTISITE;
}

return environmentConfig;
};

Expand Down

0 comments on commit eba2d71

Please sign in to comment.