@wordpress/env 10.15.0 → 10.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -479,17 +479,19 @@ You can customize the WordPress installation, plugins and themes that the develo
479
479
 
480
480
  `.wp-env.json` supports fields for options applicable to both the tests and development instances.
481
481
 
482
- | Field | Type | Default | Description |
483
- |----------------|----------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
484
- | `"core"` | `string\|null` | `null` | The WordPress installation to use. If `null` is specified, `wp-env` will use the latest production release of WordPress. |
485
- | `"phpVersion"` | `string\|null` | `null` | The PHP version to use. If `null` is specified, `wp-env` will use the default version used with production release of WordPress. |
486
- | `"plugins"` | `string[]` | `[]` | A list of plugins to install and activate in the environment. |
487
- | `"themes"` | `string[]` | `[]` | A list of themes to install in the environment. |
488
- | `"port"` | `integer` | `8888` (`8889` for the tests instance) | The primary port number to use for the installation. You'll access the instance through the port: 'http://localhost:8888'. |
489
- | `"testsPort"` | `integer` | `8889` | The port number for the test site. You'll access the instance through the port: 'http://localhost:8889'. |
490
- | `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. |
491
- | `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. |
492
- | `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. |
482
+ | Field | Type | Default | Description |
483
+ |--------------------|----------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
484
+ | `"core"` | `string\|null` | `null` | The WordPress installation to use. If `null` is specified, `wp-env` will use the latest production release of WordPress. |
485
+ | `"phpVersion"` | `string\|null` | `null` | The PHP version to use. If `null` is specified, `wp-env` will use the default version used with production release of WordPress. |
486
+ | `"plugins"` | `string[]` | `[]` | A list of plugins to install and activate in the environment. |
487
+ | `"themes"` | `string[]` | `[]` | A list of themes to install in the environment. |
488
+ | `"port"` | `integer` | `8888` (`8889` for the tests instance) | The primary port number to use for the installation. You'll access the instance through the port: 'http://localhost:8888'. |
489
+ | `"testsPort"` | `integer` | `8889` | The port number for the test site. You'll access the instance through the port: 'http://localhost:8889'. |
490
+ | `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. |
491
+ | `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. |
492
+ | `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. |
493
+ | `"phpmyadminPort"` | `integer` | `null` | The port number for phpMyAdmin. If provided, you'll access phpMyAdmin through: http://localhost:<port> |
494
+ | `"multisite"` | `boolean` | `false` | Whether to set up a multisite installation. |
493
495
 
494
496
  _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PORT`) take precedent over the .wp-env.json values._
495
497
 
@@ -523,7 +525,8 @@ Additionally, the key `env` is available to override any of the above options on
523
525
  "KEY_1": false
524
526
  },
525
527
  "port": 3000,
526
- "mysqlPort": 13306
528
+ "mysqlPort": 13306,
529
+ "phpmyadminPort": 9001
527
530
  }
528
531
  }
529
532
  }
@@ -688,7 +691,12 @@ You can tell `wp-env` to use a custom port number so that your instance does not
688
691
  }
689
692
  ```
690
693
 
691
- These can also be set via the environment variables `WP_ENV_PORT`, `WP_ENV_TESTS_PORT`, `WP_ENV_MYSQL_PORT` and `WP_ENV_TESTS_MYSQL_PORT`.
694
+ These can also be set via environment variables:
695
+
696
+ - `WP_ENV_PORT` to override the development environment's web server's port.
697
+ - `WP_ENV_TESTS_PORT` to override the testing environment's web server's port.
698
+ - phpMyAdmin is not enabled by default, but its port can also be overridden for the development and testing environments via `WP_ENV_PHPMYADMIN_PORT` and `WP_ENV_TESTS_PHPMYADMIN_PORT`, respectively.
699
+ - By default, MySQL aren't exposed to the host, which means no chance of port conflicts. But these can also be overridden for the development and testing environments via `WP_ENV_MYSQL_PORT` and `WP_ENV_TESTS_MYSQL_PORT`, respectively.
692
700
 
693
701
  ### Specific PHP Version
694
702
 
@@ -701,6 +709,17 @@ You can tell `wp-env` to use a specific PHP version for compatibility and testin
701
709
  }
702
710
  ```
703
711
 
712
+ ### Multisite support
713
+
714
+ You can tell `wp-env` if the site should be multisite enabled. This can also be set via the environment variable `WP_ENV_MULTISITE`.
715
+
716
+ ```json
717
+ {
718
+ "multisite": true,
719
+ "plugins": [ "." ]
720
+ }
721
+ ```
722
+
704
723
  ### Node Lifecycle Script
705
724
 
706
725
  This is useful for performing some actions after setting up the environment, such as bootstrapping an E2E test environment.
@@ -23,6 +23,7 @@ const { checkPort, checkVersion, checkString } = require( './validate-config' );
23
23
  * @property {?number} phpmyadminPort An override for the development environment's phpMyAdmin port.
24
24
  * @property {?WPSource} coreSource An override for all environment's coreSource.
25
25
  * @property {?string} phpVersion An override for all environment's PHP version.
26
+ * @property {?boolean} multisite An override for if environmen should be multisite.
26
27
  * @property {?Object.<string, string>} lifecycleScripts An override for various lifecycle scripts.
27
28
  */
28
29
 
@@ -68,6 +69,10 @@ module.exports = function getConfigFromEnvironmentVars( cacheDirectoryPath ) {
68
69
  environmentConfig.phpVersion = process.env.WP_ENV_PHP_VERSION;
69
70
  }
70
71
 
72
+ if ( process.env.WP_ENV_MULTISITE ) {
73
+ environmentConfig.multisite = !! process.env.WP_ENV_MULTISITE;
74
+ }
75
+
71
76
  return environmentConfig;
72
77
  };
73
78
 
@@ -144,7 +144,7 @@ async function parseConfig( configDirectoryPath, cacheDirectoryPath ) {
144
144
  } );
145
145
 
146
146
  // Users can provide overrides in environment
147
- // variables that supercede all other options.
147
+ // variables that supersede all other options.
148
148
  const environmentVarOverrides =
149
149
  getEnvironmentVarOverrides( cacheDirectoryPath );
150
150
 
@@ -129,7 +129,7 @@ function appendPortToWPConfigs( config ) {
129
129
  */
130
130
  function validatePortUniqueness( config ) {
131
131
  // We're going to build a map of the environments and their port
132
- // so we can accomodate root-level config options more easily.
132
+ // so we can accommodate root-level config options more easily.
133
133
  const environmentPorts = {};
134
134
 
135
135
  // Add all of the environments to the map. This will
@@ -179,7 +179,7 @@ function validate( config ) {
179
179
  * @return {WPRootConfig} A deep copy of the root config object.
180
180
  */
181
181
  function deepCopyRootOptions( config ) {
182
- // Create a shallow clone of the object first so we can operate on it safetly.
182
+ // Create a shallow clone of the object first so we can operate on it safely.
183
183
  const rootConfig = Object.assign( {}, config );
184
184
 
185
185
  // Since we're only dealing with the root options we don't want the environments.
@@ -306,7 +306,7 @@ describe( 'validate-config', () => {
306
306
  } );
307
307
 
308
308
  describe( 'checkValidURL', () => {
309
- it( 'throws for invaid URLs', () => {
309
+ it( 'throws for invalid URLs', () => {
310
310
  expect( () =>
311
311
  checkValidURL( 'test.json', 'test', 'localhost' )
312
312
  ).toThrow(
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /**
8
- * Error subtype which indicates that an expected validation erorr occurred
8
+ * Error subtype which indicates that an expected validation error occurred
9
9
  * while reading wp-env configuration.
10
10
  */
11
11
  class ValidationError extends Error {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/env",
3
- "version": "10.15.0",
3
+ "version": "10.17.0",
4
4
  "description": "A zero-config, self contained local WordPress environment for development and testing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -55,5 +55,5 @@
55
55
  "scripts": {
56
56
  "test": "echo \"Error: run tests from root\" && exit 1"
57
57
  },
58
- "gitHead": "75a65eb8ffc168a92042544052f46d080a71ea45"
58
+ "gitHead": "68a831c3178197fe87db284d4b94e5743bfb6b6c"
59
59
  }