@wordpress/env 4.1.3 → 4.2.1-next.f435e9e01b.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/CHANGELOG.md CHANGED
@@ -2,11 +2,20 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.2.0 (2022-01-27)
6
+
7
+ ### Enhancement
8
+ - Added command `wp-env install-path` to list the directory used for the environment.
9
+ - The help entry is now shown when no subcommand is passed to `wp-env`.
10
+
11
+ ### Bug Fix
12
+ - Updated `yargs` to fix [CVE-2021-3807](https://nvd.nist.gov/vuln/detail/CVE-2021-3807).
13
+
5
14
  ## 4.1.3 (2021-11-07)
6
15
 
7
16
  ### Bug Fix
8
17
 
9
- - Fix Xdebug installation code to ensure it would fail gracefully
18
+ - Fix Xdebug installation code to ensure it would fail gracefully
10
19
 
11
20
  ## 4.0.3 (2021-04-29)
12
21
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2021 by the contributors
3
+ Copyright 2016-2022 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/README.md CHANGED
@@ -400,6 +400,18 @@ Options:
400
400
  --watch Watch for logs as they happen. [boolean] [default: true]
401
401
  ```
402
402
 
403
+ ### `wp-env install-path`
404
+
405
+ Outputs the absolute path to the WordPress environment files.
406
+
407
+ Example:
408
+
409
+ ```sh
410
+ $ wp-env install-path
411
+
412
+ /home/user/.wp-env/63263e6506becb7b8613b02d42280a49
413
+ ```
414
+
403
415
  ## .wp-env.json
404
416
 
405
417
  You can customize the WordPress installation, plugins and themes that the development environment will use by specifying a `.wp-env.json` file in the directory that you run `wp-env` from.
@@ -609,4 +621,10 @@ You can tell `wp-env` to use a specific PHP version for compatibility and testin
609
621
  }
610
622
  ```
611
623
 
612
- <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
624
+ ## Contributing to this package
625
+
626
+ This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
627
+
628
+ To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
629
+
630
+ <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
package/bin/wp-env CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- require( '../lib/cli' )().parse( process.argv.slice( 2 ) );
3
+ const command = process.argv.slice( 2 );
4
+ require( '../lib/cli' )().parse( command.length ? command : [ '--help' ] );
package/lib/cli.js CHANGED
@@ -197,6 +197,12 @@ module.exports = function cli() {
197
197
  () => {},
198
198
  withSpinner( env.destroy )
199
199
  );
200
+ yargs.command(
201
+ 'install-path',
202
+ 'Get the path where environment files are located.',
203
+ () => {},
204
+ withSpinner( env.installPath )
205
+ );
200
206
 
201
207
  return yargs;
202
208
  };
@@ -7,6 +7,7 @@ const clean = require( './clean' );
7
7
  const run = require( './run' );
8
8
  const destroy = require( './destroy' );
9
9
  const logs = require( './logs' );
10
+ const installPath = require( './install-path' );
10
11
 
11
12
  module.exports = {
12
13
  start,
@@ -15,4 +16,5 @@ module.exports = {
15
16
  run,
16
17
  destroy,
17
18
  logs,
19
+ installPath,
18
20
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ const initConfig = require( '../init-config' );
5
+
6
+ /**
7
+ * Logs the path to where wp-env files are installed.
8
+ *
9
+ * @param {Object} options
10
+ * @param {Object} options.spinner
11
+ * @param {boolean} options.debug
12
+ */
13
+ module.exports = async function installPath( { spinner, debug } ) {
14
+ // Stop the spinner so that stdout is not polluted.
15
+ spinner.stop();
16
+ // initConfig will fail if wp-env start has not yet been called, so that
17
+ // edge case is handled.
18
+ const { workDirectoryPath } = await initConfig( { spinner, debug } );
19
+ console.log( workDirectoryPath );
20
+ };
@@ -174,6 +174,7 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) {
174
174
 
175
175
  const siteUrl = config.env.development.config.WP_SITEURL;
176
176
  const e2eSiteUrl = config.env.tests.config.WP_TESTS_DOMAIN;
177
+
177
178
  const { out: mySQLAddress } = await dockerCompose.port(
178
179
  'mysql',
179
180
  3306,
@@ -181,6 +182,13 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) {
181
182
  );
182
183
  const mySQLPort = mySQLAddress.split( ':' ).pop();
183
184
 
185
+ const { out: testsMySQLAddress } = await dockerCompose.port(
186
+ 'tests-mysql',
187
+ 3306,
188
+ dockerComposeConfig
189
+ );
190
+ const testsMySQLPort = testsMySQLAddress.split( ':' ).pop();
191
+
184
192
  spinner.prefixText = 'WordPress development site started'
185
193
  .concat( siteUrl ? ` at ${ siteUrl }` : '.' )
186
194
  .concat( '\n' )
@@ -188,6 +196,9 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) {
188
196
  .concat( e2eSiteUrl ? ` at ${ e2eSiteUrl }` : '.' )
189
197
  .concat( '\n' )
190
198
  .concat( `MySQL is listening on port ${ mySQLPort }` )
199
+ .concat(
200
+ `MySQL for automated testing is listening on port ${ testsMySQLPort }`
201
+ )
191
202
  .concat( '\n' );
192
203
 
193
204
  spinner.text = 'Done!';
@@ -1,4 +1,4 @@
1
- /* eslint-disable jest/no-try-expect, jest/no-conditional-expect */
1
+ /* eslint-disable jest/no-conditional-expect */
2
2
  /**
3
3
  * External dependencies
4
4
  */
@@ -1128,4 +1128,4 @@ async function testPortNumberValidation( portName, value, envText = '' ) {
1128
1128
  }
1129
1129
  jest.clearAllMocks();
1130
1130
  }
1131
- /* eslint-enable jest/no-try-expect, jest/no-conditional-expect */
1131
+ /* eslint-enable jest/no-conditional-expect */
@@ -4,28 +4,29 @@ const XDEBUG_MODES = [
4
4
  'coverage',
5
5
  'debug',
6
6
  'gcstats',
7
+ 'off',
7
8
  'profile',
8
9
  'trace',
9
10
  ];
10
11
 
11
12
  /**
12
- * Custom parsing for the Xdebug mode set via yargs. This function ensures two things:
13
- * 1. If the --xdebug flag was set by itself, default to 'debug'.
14
- * 2. If the --xdebug flag includes modes, make sure they are accepted by Xdebug.
13
+ * Custom parsing for the Xdebug mode set via yargs. This function ensures three things:
14
+ * 1. If the --xdebug flag was not set, set it to 'off'.
15
+ * 2. If the --xdebug flag was set by itself, default to 'debug'.
16
+ * 3. If the --xdebug flag includes modes, make sure they are accepted by Xdebug.
15
17
  *
16
- * Note: ideally, we would also have this handle the case where no xdebug flag
17
- * is set (and then turn Xdebug off). However, yargs does not pass 'undefined'
18
- * to the coerce callback, so we cannot handle that case here.
19
- *
20
- * @param {string} value The user-set mode of Xdebug
18
+ * @param {string|undefined} value The user-set mode of Xdebug; undefined if there is no --xdebug flag.
21
19
  * @return {string} The Xdebug mode to use with defaults applied.
22
20
  */
23
21
  module.exports = function parseXdebugMode( value ) {
22
+ if ( value === undefined ) {
23
+ return 'off';
24
+ }
24
25
  if ( typeof value !== 'string' ) {
25
26
  throwXdebugModeError( value );
26
27
  }
27
28
 
28
- if ( value.length === 0 ) {
29
+ if ( value.length === 0 || value === 'undefined' ) {
29
30
  return 'debug';
30
31
  }
31
32
 
package/lib/wordpress.js CHANGED
@@ -42,7 +42,20 @@ async function checkDatabaseConnection( { dockerComposeConfigPath, debug } ) {
42
42
  * @param {Object} spinner A CLI spinner which indicates progress.
43
43
  */
44
44
  async function configureWordPress( environment, config, spinner ) {
45
- const installCommand = `wp core install --url="localhost:${ config.env[ environment ].port }" --title="${ config.name }" --admin_user=admin --admin_password=password --admin_email=wordpress@example.com --skip-email`;
45
+ const url = ( () => {
46
+ const port = config.env[ environment ].port;
47
+ const domain =
48
+ environment === 'tests'
49
+ ? config.env.tests.config.WP_TESTS_DOMAIN
50
+ : config.env.development.config.WP_SITEURL;
51
+ if ( port === 80 ) {
52
+ return domain;
53
+ }
54
+
55
+ return `${ domain }:${ port }`;
56
+ } )();
57
+
58
+ const installCommand = `wp core install --url="${ url }" --title="${ config.name }" --admin_user=admin --admin_password=password --admin_email=wordpress@example.com --skip-email`;
46
59
 
47
60
  // -eo pipefail exits the command as soon as anything fails in bash.
48
61
  const setupCommands = [ 'set -eo pipefail', installCommand ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/env",
3
- "version": "4.1.3",
3
+ "version": "4.2.1-next.f435e9e01b.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",
@@ -43,7 +43,7 @@
43
43
  "rimraf": "^3.0.2",
44
44
  "simple-git": "^2.35.0",
45
45
  "terminal-link": "^2.0.0",
46
- "yargs": "^14.0.0"
46
+ "yargs": "^17.3.0"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -51,5 +51,5 @@
51
51
  "scripts": {
52
52
  "test": "echo \"Error: run tests from root\" && exit 1"
53
53
  },
54
- "gitHead": "393c2b5533837fd637e998d23f0124c081a10df0"
54
+ "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
55
55
  }