@wordpress/env 5.16.0 → 7.0.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 +189 -120
- package/lib/build-docker-compose-config.js +67 -96
- package/lib/cache.js +1 -0
- package/lib/cli.js +23 -3
- package/lib/commands/clean.js +14 -1
- package/lib/commands/destroy.js +12 -37
- package/lib/commands/index.js +1 -0
- package/lib/commands/install-path.js +1 -0
- package/lib/commands/logs.js +1 -0
- package/lib/commands/run.js +79 -15
- package/lib/commands/start.js +32 -10
- package/lib/commands/stop.js +1 -0
- package/lib/config/add-or-replace-port.js +41 -0
- package/lib/config/db-env.js +1 -0
- package/lib/config/detect-directory-type.js +1 -1
- package/lib/config/get-cache-directory.js +39 -0
- package/lib/config/get-config-from-environment-vars.js +86 -0
- package/lib/config/index.js +7 -5
- package/lib/config/load-config.js +92 -0
- package/lib/config/merge-configs.js +104 -0
- package/lib/config/parse-config.js +418 -157
- package/lib/config/parse-source-string.js +164 -0
- package/lib/config/post-process-config.js +202 -0
- package/lib/config/read-raw-config-file.js +7 -33
- package/lib/config/test/__snapshots__/config-integration.js.snap +271 -0
- package/lib/config/test/add-or-replace-port.js +81 -0
- package/lib/config/test/config-integration.js +143 -0
- package/lib/config/test/get-cache-directory.js +57 -0
- package/lib/config/test/merge-configs.js +111 -0
- package/lib/config/test/parse-config.js +342 -0
- package/lib/config/test/parse-source-string.js +154 -0
- package/lib/config/test/post-process-config.js +295 -0
- package/lib/config/test/read-raw-config-file.js +19 -63
- package/lib/config/test/validate-config.js +305 -0
- package/lib/config/validate-config.js +103 -40
- package/lib/env.js +2 -0
- package/lib/execute-after-setup.js +51 -0
- package/lib/get-host-user.js +31 -0
- package/lib/init-config.js +181 -63
- package/lib/md5.js +1 -0
- package/lib/parse-xdebug-mode.js +1 -0
- package/lib/retry.js +1 -0
- package/lib/test/__snapshots__/md5.js.snap +9 -0
- package/lib/test/build-docker-compose-config.js +134 -0
- package/lib/test/cache.js +154 -0
- package/lib/test/cli.js +149 -0
- package/lib/test/execute-after-setup.js +66 -0
- package/lib/test/md5.js +35 -0
- package/lib/test/parse-xdebug-mode.js +41 -0
- package/lib/wordpress.js +5 -33
- package/package.json +2 -2
- package/lib/config/config.js +0 -357
- package/lib/config/test/__snapshots__/config.js.snap +0 -83
- package/lib/config/test/config.js +0 -1203
package/README.md
CHANGED
|
@@ -18,9 +18,11 @@ The database credentials are: user `root`, password `password`. For a comprehens
|
|
|
18
18
|
|
|
19
19
|
## Prerequisites
|
|
20
20
|
|
|
21
|
-
`wp-env`
|
|
21
|
+
`wp-env` relies on a few commonly used developer tools:
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
- **Docker**. `wp-env` is powered by Docker. There are instructions available for installing Docker on [Windows](https://docs.docker.com/desktop/install/windows-install/) (we recommend the WSL2 backend), [macOS](https://docs.docker.com/docker-for-mac/install/), and [Linux](https://docs.docker.com/desktop/install/linux-install/).
|
|
24
|
+
- **Node.js**. `wp-env` is written as a Node script. We recommend using a Node version manager like [nvm](https://github.com/nvm-sh/nvm) to install the latest LTS version. Alternatively, you can [download it directly here](https://nodejs.org/en/download).
|
|
25
|
+
- **git**. Git is used for downloading software from source control, such as WordPress, plugins, and themes. [You can find the installation instructions here.](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
@@ -173,32 +175,33 @@ $ wp-env destroy
|
|
|
173
175
|
$ wp-env start
|
|
174
176
|
```
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
## Using included WordPress PHPUnit test files
|
|
177
179
|
|
|
178
|
-
`wp-env`
|
|
180
|
+
Out of the box `wp-env` includes the [WordPress' PHPUnit test files](https://develop.svn.wordpress.org/trunk/tests/phpunit/) corresponding to the version of WordPress installed. There is an environment variable, `WP_TESTS_DIR`, which points to the location of these files within each container. By including these files in the environment, we remove the need for you to use a package or install and mount them yourself. If you do not want to use these files, you should ignore the `WP_TESTS_DIR` environment variable and load them from the location of your choosing.
|
|
179
181
|
|
|
180
|
-
|
|
182
|
+
### Customizing the `wp-tests-config.php` file
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
wp-env start --debug
|
|
184
|
-
```
|
|
184
|
+
While we do provide a default `wp-tests-config.php` file within the environment, there may be cases where you want to use your own. WordPress provides a `WP_TESTS_CONFIG_FILE_PATH` constant that you can use to change the `wp-config.php` file used for testing. Set this to a desired path in your `bootstrap.php` file and the file you've chosen will be used instead of the one included in the environment.
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
## Using `composer`, `phpunit`, and `wp-cli` tools.
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
ℹ Config:
|
|
190
|
-
...
|
|
191
|
-
"dockerComposeConfigPath": "/Users/$USERNAME/.wp-env/5a619d332a92377cd89feb339c67b833/docker-compose.yml",
|
|
192
|
-
...
|
|
193
|
-
```
|
|
188
|
+
For ease of use, Composer, PHPUnit, and wp-cli are available for in the environment. To run these executables, use `wp-env run <env> <tool> <command>`. For example, `wp-env run cli composer install`, or `wp-env run tests-cli phpunit`. You can also access various shells like `wp-env run cli bash` or `wp-env run cli wp shell`.
|
|
194
189
|
|
|
195
|
-
|
|
190
|
+
For the `env` part, `cli` and `wordpress` share a database and mapped volumes, but more tools are available in the cli environment. You should use the `tests-cli` / `tests-wordpress` environments for a separate testing database.
|
|
196
191
|
|
|
197
|
-
|
|
192
|
+
By default, the cwd of the run command is the root of the WordPress install. If you're working on a plugin, you likely need to pass `--env-cwd` to make sure composer/phpunit commands are executed relative to the plugin you're working on. For example, `wp-env run cli --env-cwd=wp-content/plugins/gutenberg composer install`.
|
|
198
193
|
|
|
199
|
-
|
|
194
|
+
To make this easier, it's often helpful to add scripts in your `package.json` file:
|
|
200
195
|
|
|
201
|
-
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"scripts": {
|
|
199
|
+
"composer": "wp-env run cli --env-cwd=wp-content/plugins/gutenberg composer"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Then, `npm run composer install` would run composer install in the environment. You could also do this for phpunit, wp-cli, etc.
|
|
202
205
|
|
|
203
206
|
## Using Xdebug
|
|
204
207
|
|
|
@@ -237,13 +240,13 @@ You should only have to translate `port` and `pathMappings` to the format used b
|
|
|
237
240
|
|
|
238
241
|
```json
|
|
239
242
|
{
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
"name": "Listen for XDebug",
|
|
244
|
+
"type": "php",
|
|
245
|
+
"request": "launch",
|
|
246
|
+
"port": 9003,
|
|
247
|
+
"pathMappings": {
|
|
248
|
+
"/var/www/html/wp-content/plugins/gutenberg": "${workspaceFolder}/"
|
|
249
|
+
}
|
|
247
250
|
}
|
|
248
251
|
```
|
|
249
252
|
|
|
@@ -270,15 +273,14 @@ The start command installs and initializes the WordPress environment, which incl
|
|
|
270
273
|
```sh
|
|
271
274
|
wp-env start
|
|
272
275
|
|
|
273
|
-
Starts WordPress for development on port 8888 (
|
|
274
|
-
tests on port 8889 (
|
|
275
|
-
|
|
276
|
-
.wp-env.json file. After
|
|
277
|
-
|
|
276
|
+
Starts WordPress for development on port 8888 (http://localhost:8888)
|
|
277
|
+
(override with WP_ENV_PORT) and tests on port 8889 (http://localhost:8889)
|
|
278
|
+
(override with WP_ENV_TESTS_PORT). The current working directory must be a
|
|
279
|
+
WordPress installation, a plugin, a theme, or contain a .wp-env.json file. After
|
|
280
|
+
first install, use the '--update' flag to download updates to mapped sources and
|
|
281
|
+
to re-apply WordPress configuration options.
|
|
278
282
|
|
|
279
283
|
Options:
|
|
280
|
-
--help Show help [boolean]
|
|
281
|
-
--version Show version number [boolean]
|
|
282
284
|
--debug Enable debug output. [boolean] [default: false]
|
|
283
285
|
--update Download source updates and apply WordPress configuration.
|
|
284
286
|
[boolean] [default: false]
|
|
@@ -287,6 +289,7 @@ Options:
|
|
|
287
289
|
them in a comma-separated list: `--xdebug=develop,coverage`. See
|
|
288
290
|
https://xdebug.org/docs/all_settings#mode for information about
|
|
289
291
|
Xdebug modes. [string]
|
|
292
|
+
--scripts Execute any configured lifecycle scripts. [boolean] [default: true]
|
|
290
293
|
```
|
|
291
294
|
|
|
292
295
|
### `wp-env stop`
|
|
@@ -295,6 +298,9 @@ Options:
|
|
|
295
298
|
wp-env stop
|
|
296
299
|
|
|
297
300
|
Stops running WordPress for development and tests and frees the ports.
|
|
301
|
+
|
|
302
|
+
Options:
|
|
303
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
298
304
|
```
|
|
299
305
|
|
|
300
306
|
### `wp-env clean [environment]`
|
|
@@ -307,28 +313,31 @@ Cleans the WordPress databases.
|
|
|
307
313
|
Positionals:
|
|
308
314
|
environment Which environments' databases to clean.
|
|
309
315
|
[string] [choices: "all", "development", "tests"] [default: "tests"]
|
|
316
|
+
|
|
317
|
+
Options:
|
|
318
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
319
|
+
--scripts Execute any configured lifecycle scripts. [boolean] [default: true]
|
|
310
320
|
```
|
|
311
321
|
|
|
312
322
|
### `wp-env run [container] [command]`
|
|
313
323
|
|
|
314
324
|
The run command can be used to open shell sessions or invoke WP-CLI commands.
|
|
315
325
|
|
|
316
|
-
<div class="callout callout-alert">
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
back to using quotation marks; `wp-env` considers everything inside the
|
|
326
|
+
<div class="callout callout-alert">In some cases, <code>wp-env</code> may consume options that you are attempting to pass to
|
|
327
|
+
the container. This happens with options that <code>wp-env</code> has already declared,
|
|
328
|
+
such as <code>--env-cwd</code>, <code>--debug</code>, <code>--help</code>, and <code>--version</code>. When this happens, you should fall
|
|
329
|
+
back to using quotation marks; <code>wp-env</code> considers everything inside the
|
|
321
330
|
quotation marks to be command argument.
|
|
322
331
|
|
|
323
|
-
For example, to ask
|
|
332
|
+
For example, to ask <code>WP-CLI</code> for its help text:
|
|
324
333
|
|
|
325
|
-
|
|
326
|
-
wp-env run cli "wp --help"
|
|
327
|
-
```
|
|
334
|
+
<pre>sh
|
|
335
|
+
<code class="language-sh">wp-env run cli "wp --help"</code></pre>
|
|
328
336
|
|
|
329
|
-
Without the quotation marks,
|
|
337
|
+
Without the quotation marks, <code>wp-env</code> will print its own help text instead of
|
|
330
338
|
passing it to the container. If you experience any problems where the command
|
|
331
339
|
is not being passed correctly, fall back to using quotation marks.
|
|
340
|
+
|
|
332
341
|
</div>
|
|
333
342
|
|
|
334
343
|
```sh
|
|
@@ -346,9 +355,10 @@ Positionals:
|
|
|
346
355
|
command The command to run. [array] [default: []]
|
|
347
356
|
|
|
348
357
|
Options:
|
|
349
|
-
--help Show help [boolean]
|
|
350
|
-
--version Show version number [boolean]
|
|
351
358
|
--debug Enable debug output. [boolean] [default: false]
|
|
359
|
+
--env-cwd The command's working directory inside of the container. Paths
|
|
360
|
+
without a leading slash are relative to the WordPress root.
|
|
361
|
+
[string] [default: "."]
|
|
352
362
|
```
|
|
353
363
|
|
|
354
364
|
For example:
|
|
@@ -406,11 +416,22 @@ Success: Installed 1 of 1 plugins.
|
|
|
406
416
|
✔ Ran `plugin install custom-post-type-ui` in 'cli'. (in 6s 483ms)
|
|
407
417
|
```
|
|
408
418
|
|
|
409
|
-
|
|
419
|
+
#### Changing the permalink structure
|
|
410
420
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
421
|
+
You might want to do this to enable access to the REST API (`wp-env/wp/v2/`) endpoint in your wp-env environment. The endpoint is not available with plain permalinks.
|
|
422
|
+
|
|
423
|
+
**Examples**
|
|
424
|
+
|
|
425
|
+
To set the permalink to just the post name:
|
|
426
|
+
|
|
427
|
+
```
|
|
428
|
+
wp-env run cli "wp rewrite structure /%postname%/"
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
To set the permalink to the year, month, and post name:
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
wp-env run cli "wp rewrite structure /%year%/%monthnum%/%postname%/"
|
|
414
435
|
```
|
|
415
436
|
|
|
416
437
|
### `wp-env destroy`
|
|
@@ -420,6 +441,9 @@ wp-env destroy
|
|
|
420
441
|
|
|
421
442
|
Destroy the WordPress environment. Deletes docker containers, volumes, and
|
|
422
443
|
networks associated with the WordPress environment and removes local files.
|
|
444
|
+
|
|
445
|
+
Options:
|
|
446
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
423
447
|
```
|
|
424
448
|
|
|
425
449
|
### `wp-env logs [environment]`
|
|
@@ -434,15 +458,13 @@ Positionals:
|
|
|
434
458
|
[string] [choices: "development", "tests", "all"] [default: "development"]
|
|
435
459
|
|
|
436
460
|
Options:
|
|
437
|
-
--help Show help [boolean]
|
|
438
|
-
--version Show version number [boolean]
|
|
439
461
|
--debug Enable debug output. [boolean] [default: false]
|
|
440
462
|
--watch Watch for logs as they happen. [boolean] [default: true]
|
|
441
463
|
```
|
|
442
464
|
|
|
443
465
|
### `wp-env install-path`
|
|
444
466
|
|
|
445
|
-
|
|
467
|
+
Get the path where all of the environment files are stored. This includes the Docker files, WordPress, PHPUnit files, and any sources that were downloaded.
|
|
446
468
|
|
|
447
469
|
Example:
|
|
448
470
|
|
|
@@ -465,7 +487,7 @@ You can customize the WordPress installation, plugins and themes that the develo
|
|
|
465
487
|
| `"plugins"` | `string[]` | `[]` | A list of plugins to install and activate in the environment. |
|
|
466
488
|
| `"themes"` | `string[]` | `[]` | A list of themes to install in the environment. |
|
|
467
489
|
| `"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'. |
|
|
468
|
-
| `"testsPort"`
|
|
490
|
+
| `"testsPort"` | `integer` | `8889` | The port number for the test site. You'll access the instance through the port: 'http://localhost:8889'. |
|
|
469
491
|
| `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. |
|
|
470
492
|
| `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. |
|
|
471
493
|
|
|
@@ -473,13 +495,13 @@ _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PO
|
|
|
473
495
|
|
|
474
496
|
Several types of strings can be passed into the `core`, `plugins`, `themes`, and `mappings` fields.
|
|
475
497
|
|
|
476
|
-
| Type | Format | Example(s)
|
|
477
|
-
| ----------------- | -------------------------------------------- |
|
|
478
|
-
| Relative path | `.<path>\|~<path>` | `"./a/directory"`, `"../a/directory"`, `"~/a/directory"`
|
|
479
|
-
| Absolute path | `/<path>\|<letter>:\<path>` | `"/a/directory"`, `"C:\\a\\directory"`
|
|
498
|
+
| Type | Format | Example(s) |
|
|
499
|
+
| ----------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
500
|
+
| Relative path | `.<path>\|~<path>` | `"./a/directory"`, `"../a/directory"`, `"~/a/directory"` |
|
|
501
|
+
| Absolute path | `/<path>\|<letter>:\<path>` | `"/a/directory"`, `"C:\\a\\directory"` |
|
|
480
502
|
| GitHub repository | `<owner>/<repo>[#<ref>]` | `"WordPress/WordPress"`, `"WordPress/gutenberg#trunk"`, if no branch is provided wp-env will fall back to the repos default branch |
|
|
481
|
-
| SSH repository | `ssh://user@host/<owner>/<repo>.git[#<ref>]` | `"ssh://git@github.com/WordPress/WordPress.git"`
|
|
482
|
-
| ZIP File | `http[s]://<host>/<path>.zip` | `"https://wordpress.org/wordpress-5.4-beta2.zip"`
|
|
503
|
+
| SSH repository | `ssh://user@host/<owner>/<repo>.git[#<ref>]` | `"ssh://git@github.com/WordPress/WordPress.git"` |
|
|
504
|
+
| ZIP File | `http[s]://<host>/<path>.zip` | `"https://wordpress.org/wordpress-5.4-beta2.zip"` |
|
|
483
505
|
|
|
484
506
|
Remote sources will be downloaded into a temporary directory located in `~/.wp-env`.
|
|
485
507
|
|
|
@@ -487,22 +509,22 @@ Additionally, the key `env` is available to override any of the above options on
|
|
|
487
509
|
|
|
488
510
|
```json
|
|
489
511
|
{
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
512
|
+
"plugins": [ "." ],
|
|
513
|
+
"config": {
|
|
514
|
+
"KEY_1": true,
|
|
515
|
+
"KEY_2": false
|
|
516
|
+
},
|
|
517
|
+
"env": {
|
|
518
|
+
"development": {
|
|
519
|
+
"themes": [ "./one-theme" ]
|
|
520
|
+
},
|
|
521
|
+
"tests": {
|
|
522
|
+
"config": {
|
|
523
|
+
"KEY_1": false
|
|
524
|
+
},
|
|
525
|
+
"port": 3000
|
|
526
|
+
}
|
|
527
|
+
}
|
|
506
528
|
}
|
|
507
529
|
```
|
|
508
530
|
|
|
@@ -537,16 +559,30 @@ These can be overridden by setting a value within the `config` configuration. Se
|
|
|
537
559
|
|
|
538
560
|
Additionally, the values referencing a URL include the specified port for the given environment. So if you set `testsPort: 3000, port: 2000`, `WP_HOME` (for example) will be `http://localhost:3000` on the tests instance and `http://localhost:2000` on the development instance.
|
|
539
561
|
|
|
540
|
-
|
|
562
|
+
## Lifecycle Hooks
|
|
563
|
+
|
|
564
|
+
These hooks are executed at certain points during the lifecycle of a command's execution. Keep in mind that these will be executed on both fresh and existing
|
|
565
|
+
environments, so, ensure any commands you build won't break on subsequent executions.
|
|
566
|
+
|
|
567
|
+
### After Setup
|
|
568
|
+
|
|
569
|
+
Using the `afterSetup` option in `.wp-env.json` files will allow you to configure an arbitrary command to execute after the environment's setup is complete:
|
|
541
570
|
|
|
542
|
-
|
|
571
|
+
- `wp-env start`: Runs when the config changes, WordPress updates, or you pass the `--update` flag.
|
|
572
|
+
- `wp-env clean`: Runs after the selected environments have been cleaned.
|
|
573
|
+
|
|
574
|
+
You can override the `afterSetup` option using the `WP_ENV_AFTER_SETUP` environment variable.
|
|
575
|
+
|
|
576
|
+
## Examples
|
|
577
|
+
|
|
578
|
+
### Latest stable WordPress + current directory as a plugin
|
|
543
579
|
|
|
544
580
|
This is useful for plugin development.
|
|
545
581
|
|
|
546
582
|
```json
|
|
547
583
|
{
|
|
548
|
-
|
|
549
|
-
|
|
584
|
+
"core": null,
|
|
585
|
+
"plugins": [ "." ]
|
|
550
586
|
}
|
|
551
587
|
```
|
|
552
588
|
|
|
@@ -556,12 +592,12 @@ This is useful for plugin development when upstream Core changes need to be test
|
|
|
556
592
|
|
|
557
593
|
```json
|
|
558
594
|
{
|
|
559
|
-
|
|
560
|
-
|
|
595
|
+
"core": "WordPress/WordPress#master",
|
|
596
|
+
"plugins": [ "." ]
|
|
561
597
|
}
|
|
562
598
|
```
|
|
563
599
|
|
|
564
|
-
|
|
600
|
+
### Local `wordpress-develop` + current directory as a plugin
|
|
565
601
|
|
|
566
602
|
This is useful for working on plugins and WordPress Core at the same time.
|
|
567
603
|
|
|
@@ -569,8 +605,8 @@ If you are running a _build_ of `wordpress-develop`, point `core` to the `build`
|
|
|
569
605
|
|
|
570
606
|
```json
|
|
571
607
|
{
|
|
572
|
-
|
|
573
|
-
|
|
608
|
+
"core": "../wordpress-develop/build",
|
|
609
|
+
"plugins": [ "." ]
|
|
574
610
|
}
|
|
575
611
|
```
|
|
576
612
|
|
|
@@ -578,93 +614,126 @@ If you are running `wordpress-develop` in a dev mode (e.g. the watch command `de
|
|
|
578
614
|
|
|
579
615
|
```json
|
|
580
616
|
{
|
|
581
|
-
|
|
582
|
-
|
|
617
|
+
"core": "../wordpress-develop/src",
|
|
618
|
+
"plugins": [ "." ]
|
|
583
619
|
}
|
|
584
620
|
```
|
|
585
621
|
|
|
586
|
-
|
|
622
|
+
### A complete testing environment
|
|
587
623
|
|
|
588
624
|
This is useful for integration testing: that is, testing how old versions of WordPress and different combinations of plugins and themes impact each other.
|
|
589
625
|
|
|
590
626
|
```json
|
|
591
627
|
{
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
628
|
+
"core": "WordPress/WordPress#5.2.0",
|
|
629
|
+
"plugins": [ "WordPress/wp-lazy-loading", "WordPress/classic-editor" ],
|
|
630
|
+
"themes": [ "WordPress/theme-experiments" ]
|
|
595
631
|
}
|
|
596
632
|
```
|
|
597
633
|
|
|
598
|
-
|
|
634
|
+
### Add mu-plugins and other mapped directories
|
|
599
635
|
|
|
600
636
|
You can add mu-plugins via the mapping config. The mapping config also allows you to mount a directory to any location in the wordpress install, so you could even mount a subdirectory. Note here that theme-1, will not be activated.
|
|
601
637
|
|
|
602
638
|
```json
|
|
603
639
|
{
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
640
|
+
"plugins": [ "." ],
|
|
641
|
+
"mappings": {
|
|
642
|
+
"wp-content/mu-plugins": "./path/to/local/mu-plugins",
|
|
643
|
+
"wp-content/themes": "./path/to/local/themes",
|
|
644
|
+
"wp-content/themes/specific-theme": "./path/to/local/theme-1"
|
|
645
|
+
}
|
|
610
646
|
}
|
|
611
647
|
```
|
|
612
648
|
|
|
613
|
-
|
|
649
|
+
### Avoid activating plugins or themes on the instance
|
|
614
650
|
|
|
615
651
|
Since all plugins in the `plugins` key are activated by default, you should use the `mappings` key to avoid this behavior. This might be helpful if you have a test plugin that should not be activated all the time.
|
|
616
652
|
|
|
617
653
|
```json
|
|
618
654
|
{
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
655
|
+
"plugins": [ "." ],
|
|
656
|
+
"mappings": {
|
|
657
|
+
"wp-content/plugins/my-test-plugin": "./path/to/test/plugin"
|
|
658
|
+
}
|
|
623
659
|
}
|
|
624
660
|
```
|
|
625
661
|
|
|
626
|
-
|
|
662
|
+
### Map a plugin only in the tests environment
|
|
627
663
|
|
|
628
664
|
If you need a plugin active in one environment but not the other, you can use `env.<envName>` to set options specific to one environment. Here, we activate cwd and a test plugin on the tests instance. This plugin is not activated on any other instances.
|
|
629
665
|
|
|
630
666
|
```json
|
|
631
667
|
{
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
668
|
+
"plugins": [ "." ],
|
|
669
|
+
"env": {
|
|
670
|
+
"tests": {
|
|
671
|
+
"plugins": [ ".", "path/to/test/plugin" ]
|
|
672
|
+
}
|
|
673
|
+
}
|
|
638
674
|
}
|
|
639
675
|
```
|
|
640
676
|
|
|
641
|
-
|
|
677
|
+
### Custom Port Numbers
|
|
642
678
|
|
|
643
679
|
You can tell `wp-env` to use a custom port number so that your instance does not conflict with other `wp-env` instances.
|
|
644
680
|
|
|
645
681
|
```json
|
|
646
682
|
{
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
683
|
+
"plugins": [ "." ],
|
|
684
|
+
"port": 4013,
|
|
685
|
+
"env": {
|
|
686
|
+
"tests": {
|
|
687
|
+
"port": 4012
|
|
688
|
+
}
|
|
689
|
+
}
|
|
654
690
|
}
|
|
655
691
|
```
|
|
656
692
|
|
|
657
|
-
|
|
693
|
+
### Specific PHP Version
|
|
658
694
|
|
|
659
695
|
You can tell `wp-env` to use a specific PHP version for compatibility and testing. This can also be set via the environment variable `WP_ENV_PHP_VERSION`.
|
|
660
696
|
|
|
661
697
|
```json
|
|
662
698
|
{
|
|
663
|
-
|
|
664
|
-
|
|
699
|
+
"phpVersion": "7.2",
|
|
700
|
+
"plugins": [ "." ]
|
|
701
|
+
}
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
### Node Lifecycle Script
|
|
705
|
+
|
|
706
|
+
This is useful for performing some actions after setting up the environment, such as bootstrapping an E2E test environment.
|
|
707
|
+
|
|
708
|
+
```json
|
|
709
|
+
{
|
|
710
|
+
"afterSetup": "node tests/e2e/bin/setup-env.js"
|
|
665
711
|
}
|
|
666
712
|
```
|
|
667
713
|
|
|
714
|
+
### Advanced PHP settings
|
|
715
|
+
|
|
716
|
+
You can set PHP settings by mapping an `.htaccess` file. This maps an `.htaccess` file to the WordPress root (`/var/www/html`) from the directory in which you run `wp-env`.
|
|
717
|
+
|
|
718
|
+
```json
|
|
719
|
+
{
|
|
720
|
+
"mappings": {
|
|
721
|
+
".htaccess": ".htaccess"
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
Then, your .htaccess file can contain various settings like this:
|
|
727
|
+
|
|
728
|
+
```
|
|
729
|
+
# Note: the default upload value is 1G.
|
|
730
|
+
php_value post_max_size 2G
|
|
731
|
+
php_value upload_max_filesize 2G
|
|
732
|
+
php_value memory_limit 2G
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
This is useful if there are options you'd like to add to `php.ini`, which is difficult to access in this environment.
|
|
736
|
+
|
|
668
737
|
## Contributing to this package
|
|
669
738
|
|
|
670
739
|
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.
|