@wordpress/env 4.2.1-next.f435e9e01b.0 → 4.2.3-next.a55ed9455a.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 +89 -61
- package/lib/cli.js +2 -2
- package/lib/config/db-env.js +3 -3
- package/lib/init-config.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Then modify your package.json and add an extra command to npm `scripts` (https:/
|
|
|
51
51
|
When installing `wp-env` in this way, all `wp-env` commands detailed in these docs must be prefixed with `npm run`, for example:
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
|
-
# You must add another dash to pass the "update" flag to wp-env
|
|
54
|
+
# You must add another double dash to pass the "update" flag to wp-env
|
|
55
55
|
$ npm run wp-env start -- --update
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -203,6 +203,14 @@ wp-env start
|
|
|
203
203
|
wp-env start --xdebug=profile,trace,debug
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
+
When you're running `wp-env` using `npm run`, like when working in the Gutenberg repo or when having `wp-env` as a local project dependency, don't forget to add an extra double dash before the `--xdebug` command:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
npm run wp-env start -- --xdebug
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
If you forget about that, the `--xdebug` parameter will be passed to NPM instead of the `wp-env start` command and it will be ignored.
|
|
213
|
+
|
|
206
214
|
You can see a reference on each of the Xdebug modes and what they do in the [Xdebug documentation](https://xdebug.org/docs/all_settings#mode).
|
|
207
215
|
|
|
208
216
|
_Since we are only installing Xdebug 3, Xdebug is only supported for PHP versions greater than or equal to 7.2 (the default). Xdebug won't be installed if `phpVersion` is set to a legacy version._
|
|
@@ -215,16 +223,18 @@ You should only have to translate `port` and `pathMappings` to the format used b
|
|
|
215
223
|
|
|
216
224
|
```json
|
|
217
225
|
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
"name": "Listen for XDebug",
|
|
227
|
+
"type": "php",
|
|
228
|
+
"request": "launch",
|
|
229
|
+
"port": 9003,
|
|
230
|
+
"pathMappings": {
|
|
231
|
+
"/var/www/html/wp-content/plugins/gutenberg": "${workspaceFolder}/"
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
```
|
|
227
235
|
|
|
236
|
+
After you create a `.vscode/launch.json` file in your repository, you probably want to add it to your [global gitignore file](https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer) so that it stays private for you and is not committed to the repository.
|
|
237
|
+
|
|
228
238
|
Once your IDEs Xdebug settings have been enabled, you should just have to launch the debugger, put a breakpoint on any line of PHP code, and then refresh your browser!
|
|
229
239
|
|
|
230
240
|
Here is a summary:
|
|
@@ -287,6 +297,24 @@ Positionals:
|
|
|
287
297
|
|
|
288
298
|
### `wp-env run [container] [command]`
|
|
289
299
|
|
|
300
|
+
The run command can be used to open shell sessions or invoke WP-CLI commands.
|
|
301
|
+
|
|
302
|
+
<div class="callout callout-alert">
|
|
303
|
+
To run a WP-CLI command that includes optional arguments, enclose the WP-CLI command in quotation marks; otherwise, the optional arguments are ignored. This is because flags are normally passed to `wp-env` itself, meaning that the flags are not considered part of the argument that specifies the WP-CLI command. With quotation marks, `wp-env` considers everything inside quotation marks the WP-CLI command argument.
|
|
304
|
+
|
|
305
|
+
For example, to list cron schedules with optional arguments that specify the fields returned and the format of the output:
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
wp-env run cli "wp cron schedule list --fields=name --format=csv"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Without the quotation marks, WP-CLI lists the schedule in its default format, ignoring the `fields` and `format` arguments.
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
Note that quotation marks are not required for a WP-CLI command that excludes optional arguments, although it does not hurt to include them. For example, the following command syntaxes return identical results: `wp-env run cli "wp cron schedule list"` or `wp-env run cli wp cron schedule list`.
|
|
315
|
+
|
|
316
|
+
For more information about all the available commands, see [WP-CLI Commands](https://developer.wordpress.org/cli/commands/).
|
|
317
|
+
|
|
290
318
|
```sh
|
|
291
319
|
wp-env run <container> [command..]
|
|
292
320
|
|
|
@@ -353,7 +381,7 @@ wp> ^C
|
|
|
353
381
|
#### Installing a plugin or theme on the development instance
|
|
354
382
|
|
|
355
383
|
```sh
|
|
356
|
-
wp-env run cli plugin install custom-post-type-ui
|
|
384
|
+
wp-env run cli wp plugin install custom-post-type-ui
|
|
357
385
|
|
|
358
386
|
Creating 500cd328b649d63e882d5c4695871d04_cli_run ... done
|
|
359
387
|
Installing Custom Post Type UI (1.9.2)
|
|
@@ -445,22 +473,22 @@ Additionally, the key `env` is available to override any of the above options on
|
|
|
445
473
|
|
|
446
474
|
```json
|
|
447
475
|
{
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
476
|
+
"plugins": ["."],
|
|
477
|
+
"config": {
|
|
478
|
+
"KEY_1": true,
|
|
479
|
+
"KEY_2": false
|
|
480
|
+
},
|
|
481
|
+
"env": {
|
|
482
|
+
"development": {
|
|
483
|
+
"themes": ["./one-theme"]
|
|
484
|
+
},
|
|
485
|
+
"tests": {
|
|
486
|
+
"config": {
|
|
487
|
+
"KEY_1": false
|
|
488
|
+
},
|
|
489
|
+
"port": 3000
|
|
490
|
+
}
|
|
491
|
+
}
|
|
464
492
|
}
|
|
465
493
|
```
|
|
466
494
|
|
|
@@ -501,8 +529,8 @@ This is useful for plugin development.
|
|
|
501
529
|
|
|
502
530
|
```json
|
|
503
531
|
{
|
|
504
|
-
|
|
505
|
-
|
|
532
|
+
"core": null,
|
|
533
|
+
"plugins": ["."]
|
|
506
534
|
}
|
|
507
535
|
```
|
|
508
536
|
|
|
@@ -512,8 +540,8 @@ This is useful for plugin development when upstream Core changes need to be test
|
|
|
512
540
|
|
|
513
541
|
```json
|
|
514
542
|
{
|
|
515
|
-
|
|
516
|
-
|
|
543
|
+
"core": "WordPress/WordPress#master",
|
|
544
|
+
"plugins": ["."]
|
|
517
545
|
}
|
|
518
546
|
```
|
|
519
547
|
|
|
@@ -525,8 +553,8 @@ If you are running a _build_ of `wordpress-develop`, point `core` to the `build`
|
|
|
525
553
|
|
|
526
554
|
```json
|
|
527
555
|
{
|
|
528
|
-
|
|
529
|
-
|
|
556
|
+
"core": "../wordpress-develop/build",
|
|
557
|
+
"plugins": ["."]
|
|
530
558
|
}
|
|
531
559
|
```
|
|
532
560
|
|
|
@@ -534,8 +562,8 @@ If you are running `wordpress-develop` in a dev mode (e.g. the watch command `de
|
|
|
534
562
|
|
|
535
563
|
```json
|
|
536
564
|
{
|
|
537
|
-
|
|
538
|
-
|
|
565
|
+
"core": "../wordpress-develop/src",
|
|
566
|
+
"plugins": ["."]
|
|
539
567
|
}
|
|
540
568
|
```
|
|
541
569
|
|
|
@@ -545,9 +573,9 @@ This is useful for integration testing: that is, testing how old versions of Wor
|
|
|
545
573
|
|
|
546
574
|
```json
|
|
547
575
|
{
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
576
|
+
"core": "WordPress/WordPress#5.2.0",
|
|
577
|
+
"plugins": ["WordPress/wp-lazy-loading", "WordPress/classic-editor"],
|
|
578
|
+
"themes": ["WordPress/theme-experiments"]
|
|
551
579
|
}
|
|
552
580
|
```
|
|
553
581
|
|
|
@@ -557,12 +585,12 @@ You can add mu-plugins via the mapping config. The mapping config also allows yo
|
|
|
557
585
|
|
|
558
586
|
```json
|
|
559
587
|
{
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
588
|
+
"plugins": ["."],
|
|
589
|
+
"mappings": {
|
|
590
|
+
"wp-content/mu-plugins": "./path/to/local/mu-plugins",
|
|
591
|
+
"wp-content/themes": "./path/to/local/themes",
|
|
592
|
+
"wp-content/themes/specific-theme": "./path/to/local/theme-1"
|
|
593
|
+
}
|
|
566
594
|
}
|
|
567
595
|
```
|
|
568
596
|
|
|
@@ -572,10 +600,10 @@ Since all plugins in the `plugins` key are activated by default, you should use
|
|
|
572
600
|
|
|
573
601
|
```json
|
|
574
602
|
{
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
603
|
+
"plugins": ["."],
|
|
604
|
+
"mappings": {
|
|
605
|
+
"wp-content/plugins/my-test-plugin": "./path/to/test/plugin"
|
|
606
|
+
}
|
|
579
607
|
}
|
|
580
608
|
```
|
|
581
609
|
|
|
@@ -585,12 +613,12 @@ If you need a plugin active in one environment but not the other, you can use `e
|
|
|
585
613
|
|
|
586
614
|
```json
|
|
587
615
|
{
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
616
|
+
"plugins": ["."],
|
|
617
|
+
"env": {
|
|
618
|
+
"tests": {
|
|
619
|
+
"plugins": [".", "path/to/test/plugin"]
|
|
620
|
+
}
|
|
621
|
+
}
|
|
594
622
|
}
|
|
595
623
|
```
|
|
596
624
|
|
|
@@ -600,13 +628,13 @@ You can tell `wp-env` to use a custom port number so that your instance does not
|
|
|
600
628
|
|
|
601
629
|
```json
|
|
602
630
|
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
631
|
+
"plugins": ["."],
|
|
632
|
+
"port": 4013,
|
|
633
|
+
"env": {
|
|
634
|
+
"tests": {
|
|
635
|
+
"port": 4012
|
|
636
|
+
}
|
|
637
|
+
}
|
|
610
638
|
}
|
|
611
639
|
```
|
|
612
640
|
|
|
@@ -616,8 +644,8 @@ You can tell `wp-env` to use a specific PHP version for compatibility and testin
|
|
|
616
644
|
|
|
617
645
|
```json
|
|
618
646
|
{
|
|
619
|
-
|
|
620
|
-
|
|
647
|
+
"phpVersion": "7.2",
|
|
648
|
+
"plugins": ["."]
|
|
621
649
|
}
|
|
622
650
|
```
|
|
623
651
|
|
package/lib/cli.js
CHANGED
|
@@ -14,14 +14,14 @@ const { execSync } = require( 'child_process' );
|
|
|
14
14
|
const env = require( './env' );
|
|
15
15
|
const parseXdebugMode = require( './parse-xdebug-mode' );
|
|
16
16
|
|
|
17
|
-
// Colors
|
|
17
|
+
// Colors.
|
|
18
18
|
const boldWhite = chalk.bold.white;
|
|
19
19
|
const wpPrimary = boldWhite.bgHex( '#00669b' );
|
|
20
20
|
const wpGreen = boldWhite.bgHex( '#4ab866' );
|
|
21
21
|
const wpRed = boldWhite.bgHex( '#d94f4f' );
|
|
22
22
|
const wpYellow = boldWhite.bgHex( '#f0b849' );
|
|
23
23
|
|
|
24
|
-
// Spinner
|
|
24
|
+
// Spinner.
|
|
25
25
|
const withSpinner = ( command ) => ( ...args ) => {
|
|
26
26
|
const spinner = ora().start();
|
|
27
27
|
args[ 0 ].spinner = spinner;
|
package/lib/config/db-env.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// Username and password used in all databases
|
|
1
|
+
// Username and password used in all databases.
|
|
2
2
|
const credentials = {
|
|
3
3
|
WORDPRESS_DB_USER: 'root',
|
|
4
4
|
WORDPRESS_DB_PASSWORD: 'password',
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// Environment for test database
|
|
7
|
+
// Environment for test database.
|
|
8
8
|
const tests = {
|
|
9
9
|
WORDPRESS_DB_NAME: 'tests-wordpress',
|
|
10
10
|
WORDPRESS_DB_HOST: 'tests-mysql',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// Environment for development database. DB host gets default value which is set
|
|
14
|
-
// elsewhere
|
|
14
|
+
// elsewhere.
|
|
15
15
|
const development = {
|
|
16
16
|
WORDPRESS_DB_NAME: 'wordpress',
|
|
17
17
|
};
|
package/lib/init-config.js
CHANGED
|
@@ -111,7 +111,7 @@ function checkXdebugPhpCompatibility( config ) {
|
|
|
111
111
|
const phpCompatibility = true;
|
|
112
112
|
|
|
113
113
|
// If PHP version is defined
|
|
114
|
-
// ensure it meets the Xdebug minimum compatibility requirment
|
|
114
|
+
// ensure it meets the Xdebug minimum compatibility requirment.
|
|
115
115
|
if ( config.env.development.phpVersion ) {
|
|
116
116
|
const versionTokens = config.env.development.phpVersion.split( '.' );
|
|
117
117
|
const majorVer = parseInt( versionTokens[ 0 ] );
|
|
@@ -124,7 +124,7 @@ function checkXdebugPhpCompatibility( config ) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// Xdebug 3 supports 7.2 and higher
|
|
127
|
-
// Ensure user has specified a compatible PHP version
|
|
127
|
+
// Ensure user has specified a compatible PHP version.
|
|
128
128
|
if ( majorVer < 7 || ( majorVer === 7 && minorVer < 2 ) ) {
|
|
129
129
|
throw new Error( 'Cannot use XDebug 3 on PHP < 7.2.' );
|
|
130
130
|
}
|
|
@@ -142,7 +142,7 @@ function checkXdebugPhpCompatibility( config ) {
|
|
|
142
142
|
* @return {string} The dockerfile contents.
|
|
143
143
|
*/
|
|
144
144
|
function dockerFileContents( image, config ) {
|
|
145
|
-
// Don't install XDebug unless it is explicitly required
|
|
145
|
+
// Don't install XDebug unless it is explicitly required.
|
|
146
146
|
let shouldInstallXdebug = false;
|
|
147
147
|
|
|
148
148
|
if ( config.xdebug !== 'off' ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/env",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3-next.a55ed9455a.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",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"scripts": {
|
|
52
52
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c5108185851b824d531bce55991a3589947e8551"
|
|
55
55
|
}
|