From eba2d71676e808750946630fe14ba198e09d7d87 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Wed, 22 Jan 2025 09:15:20 -0500 Subject: [PATCH] Add WP_ENV_MULTISITE envoriment variable. (#68792) * 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 * 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 --- packages/env/CHANGELOG.md | 4 ++++ packages/env/README.md | 11 +++++++++++ .../lib/config/get-config-from-environment-vars.js | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/packages/env/CHANGELOG.md b/packages/env/CHANGELOG.md index f972ba1355755..396e0167f1e92 100644 --- a/packages/env/CHANGELOG.md +++ b/packages/env/CHANGELOG.md @@ -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) diff --git a/packages/env/README.md b/packages/env/README.md index 467e8d44e7135..16bba5cba20c0 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -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. diff --git a/packages/env/lib/config/get-config-from-environment-vars.js b/packages/env/lib/config/get-config-from-environment-vars.js index 618b5fff25792..30c7b3e58eece 100644 --- a/packages/env/lib/config/get-config-from-environment-vars.js +++ b/packages/env/lib/config/get-config-from-environment-vars.js @@ -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.} lifecycleScripts An override for various lifecycle scripts. */ @@ -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; };