@wordpress/env 11.0.1-next.v.202602200903.0 → 11.0.2-next.v.202602241322.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/lib/cli.js +24 -36
- package/lib/test/cli.js +5 -5
- package/package.json +2 -3
package/lib/cli.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
const chalk = require( 'chalk' );
|
|
6
6
|
const ora = require( 'ora' );
|
|
7
7
|
const yargs = require( 'yargs' );
|
|
8
|
-
const terminalLink = require( 'terminal-link' );
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
@@ -21,28 +20,27 @@ const {
|
|
|
21
20
|
EnvironmentNotInitializedError,
|
|
22
21
|
} = require( './runtime' );
|
|
23
22
|
|
|
24
|
-
// Colors.
|
|
25
|
-
const boldWhite = chalk.bold.white;
|
|
26
|
-
const wpPrimary = boldWhite.bgHex( '#00669b' );
|
|
27
|
-
const wpGreen = boldWhite.bgHex( '#4ab866' );
|
|
28
|
-
const wpRed = boldWhite.bgHex( '#d94f4f' );
|
|
29
|
-
const wpYellow = boldWhite.bgHex( '#f0b849' );
|
|
30
|
-
|
|
31
23
|
// Spinner.
|
|
32
24
|
const withSpinner =
|
|
33
25
|
( command ) =>
|
|
34
26
|
( ...args ) => {
|
|
35
|
-
const
|
|
27
|
+
const isJSON = args[ 0 ].json;
|
|
28
|
+
const spinner = ora();
|
|
29
|
+
if ( ! isJSON ) {
|
|
30
|
+
spinner.start();
|
|
31
|
+
}
|
|
36
32
|
args[ 0 ].spinner = spinner;
|
|
37
33
|
let time = process.hrtime();
|
|
38
34
|
return command( ...args ).then(
|
|
39
35
|
( message ) => {
|
|
40
36
|
time = process.hrtime( time );
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
time[
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
if ( ! isJSON ) {
|
|
38
|
+
spinner.succeed(
|
|
39
|
+
`${ message || spinner.text } (in ${ time[ 0 ] }s ${ (
|
|
40
|
+
time[ 1 ] / 1e6
|
|
41
|
+
).toFixed( 0 ) }ms)`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
46
44
|
process.exit( 0 );
|
|
47
45
|
},
|
|
48
46
|
( error ) => {
|
|
@@ -95,7 +93,8 @@ const withSpinner =
|
|
|
95
93
|
};
|
|
96
94
|
|
|
97
95
|
module.exports = function cli() {
|
|
98
|
-
yargs.usage(
|
|
96
|
+
yargs.usage( '$0 <command>' );
|
|
97
|
+
yargs.usage( '$0 <command> -- --help' );
|
|
99
98
|
yargs.option( 'debug', {
|
|
100
99
|
type: 'boolean',
|
|
101
100
|
describe: 'Enable debug output.',
|
|
@@ -120,15 +119,7 @@ module.exports = function cli() {
|
|
|
120
119
|
|
|
121
120
|
yargs.command(
|
|
122
121
|
'start',
|
|
123
|
-
|
|
124
|
-
chalk`Starts WordPress for development on port {bold.underline ${ terminalLink(
|
|
125
|
-
'8888',
|
|
126
|
-
'http://localhost:8888'
|
|
127
|
-
) }} (override with WP_ENV_PORT) and tests on port {bold.underline ${ terminalLink(
|
|
128
|
-
'8889',
|
|
129
|
-
'http://localhost:8889'
|
|
130
|
-
) }} (override with WP_ENV_TESTS_PORT). The current working directory must be a WordPress installation, a plugin, a theme, or contain a .wp-env.json file. After first install, use the '--update' flag to download updates to mapped sources and to re-apply WordPress configuration options.`
|
|
131
|
-
),
|
|
122
|
+
chalk`Starts WordPress, listening locally. The current working directory must be a WordPress installation, a plugin, a theme, or contain a {bold .wp-env.json} file. The config's port can be overridden via {bold WP_ENV_PORT}.`,
|
|
132
123
|
( args ) => {
|
|
133
124
|
args.option( 'update', {
|
|
134
125
|
type: 'boolean',
|
|
@@ -165,15 +156,13 @@ module.exports = function cli() {
|
|
|
165
156
|
);
|
|
166
157
|
yargs.command(
|
|
167
158
|
'stop',
|
|
168
|
-
|
|
169
|
-
'Stops running WordPress for development and tests and frees the ports.'
|
|
170
|
-
),
|
|
159
|
+
'Stops running WordPress and frees the ports.',
|
|
171
160
|
() => {},
|
|
172
161
|
withSpinner( env.stop )
|
|
173
162
|
);
|
|
174
163
|
yargs.command(
|
|
175
164
|
'reset [environment]',
|
|
176
|
-
|
|
165
|
+
chalk`{bold.red Resets} the WordPress databases.`,
|
|
177
166
|
( args ) => {
|
|
178
167
|
args.positional( 'environment', {
|
|
179
168
|
type: 'string',
|
|
@@ -191,7 +180,7 @@ module.exports = function cli() {
|
|
|
191
180
|
);
|
|
192
181
|
yargs.command(
|
|
193
182
|
'clean [environment]',
|
|
194
|
-
|
|
183
|
+
false,
|
|
195
184
|
( args ) => {
|
|
196
185
|
args.positional( 'environment', {
|
|
197
186
|
type: 'string',
|
|
@@ -235,7 +224,7 @@ module.exports = function cli() {
|
|
|
235
224
|
|
|
236
225
|
yargs.command(
|
|
237
226
|
'run <container> [command...]',
|
|
238
|
-
|
|
227
|
+
chalk`Runs an arbitrary command in one of the underlying Docker containers. Use a double dash to pass arguments to it. You can use {bold bash} to open a shell session. {bold composer} and {bold phpunit} are available in all WordPress and CLI containers. {bold wp} is also available in the CLI containers.`,
|
|
239
228
|
( args ) => {
|
|
240
229
|
args.option( 'env-cwd', {
|
|
241
230
|
type: 'string',
|
|
@@ -272,9 +261,7 @@ module.exports = function cli() {
|
|
|
272
261
|
|
|
273
262
|
yargs.command(
|
|
274
263
|
'destroy',
|
|
275
|
-
|
|
276
|
-
'Destroy the WordPress environment. Deletes docker containers, volumes, networks, and images associated with the WordPress environment and removes local files.'
|
|
277
|
-
),
|
|
264
|
+
chalk`{bold.red Destroys} the WordPress environment. Deletes docker containers, volumes, networks, and images associated with the WordPress environment and removes local files.`,
|
|
278
265
|
( args ) => {
|
|
279
266
|
args.option( 'scripts', {
|
|
280
267
|
type: 'boolean',
|
|
@@ -291,9 +278,7 @@ module.exports = function cli() {
|
|
|
291
278
|
);
|
|
292
279
|
yargs.command(
|
|
293
280
|
'cleanup',
|
|
294
|
-
|
|
295
|
-
'Cleanup the WordPress environment. Removes docker containers, volumes, networks, and local files, but preserves docker images for faster re-starts.'
|
|
296
|
-
),
|
|
281
|
+
chalk`{bold.red Cleans up} the WordPress environment. Removes docker containers, volumes, networks, and local files, but preserves docker images for faster re-starts.`,
|
|
297
282
|
( args ) => {
|
|
298
283
|
args.option( 'scripts', {
|
|
299
284
|
type: 'boolean',
|
|
@@ -320,6 +305,9 @@ module.exports = function cli() {
|
|
|
320
305
|
},
|
|
321
306
|
withSpinner( env.status )
|
|
322
307
|
);
|
|
308
|
+
// Wrap at 100 chars unless the terminal is narrower than that, but ensure
|
|
309
|
+
// formatting is applied even when stdout is not a terminal.
|
|
310
|
+
yargs.wrap( Math.min( 100, yargs.terminalWidth() ?? 100 ) );
|
|
323
311
|
|
|
324
312
|
return yargs;
|
|
325
313
|
};
|
package/lib/test/cli.js
CHANGED
|
@@ -9,11 +9,11 @@ const env = require( '../env' );
|
|
|
9
9
|
* Mocked dependencies
|
|
10
10
|
*/
|
|
11
11
|
jest.spyOn( process, 'exit' ).mockImplementation( () => {} );
|
|
12
|
-
jest.mock( 'ora', () => () =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} )
|
|
12
|
+
jest.mock( 'ora', () => () => {
|
|
13
|
+
const spinner = { text: '', succeed: jest.fn(), fail: jest.fn() };
|
|
14
|
+
spinner.start = () => spinner;
|
|
15
|
+
return spinner;
|
|
16
|
+
} );
|
|
17
17
|
jest.mock( '../env', () => {
|
|
18
18
|
const actual = jest.requireActual( '../env' );
|
|
19
19
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/env",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.2-next.v.202602241322.0+bce7cff88",
|
|
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,7 +55,6 @@
|
|
|
55
55
|
"ora": "^4.0.2",
|
|
56
56
|
"rimraf": "^5.0.10",
|
|
57
57
|
"simple-git": "^3.5.0",
|
|
58
|
-
"terminal-link": "^2.0.0",
|
|
59
58
|
"yargs": "^17.3.0"
|
|
60
59
|
},
|
|
61
60
|
"publishConfig": {
|
|
@@ -64,5 +63,5 @@
|
|
|
64
63
|
"scripts": {
|
|
65
64
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
66
65
|
},
|
|
67
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "943dde7f0b600ce238726c36284bc9f70ce0ffa4"
|
|
68
67
|
}
|