Skip to content

Commit 84e2e07

Browse files
authored
Merge branch 'trunk' into add/file-mounting-to-nodefs
2 parents 4f6fda4 + 62b0990 commit 84e2e07

File tree

10 files changed

+155
-32
lines changed

10 files changed

+155
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ These tools include:
7676

7777
- [Interactive Code Block for Gutenberg](https://github.com/WordPress/playground-tools/tree/trunk/packages/interactive-code-block/#readme)
7878
- [WordPress Playground for Visual Studio Code](https://github.com/WordPress/playground-tools/tree/trunk/packages/vscode-extension/#readme)
79-
- [wp-now](https://github.com/WordPress/playground-tools/tree/trunk/packages/wp-now/#readme) CLI local development environment.
79+
- [@wp-playground/cli](https://github.com/WordPress/wordpress-playground/tree/trunk/packages/playground/cli#readme) CLI local development environment.
8080

8181
## Cloning WordPress Playground repo
8282

packages/docs/site/docs/developers/05-local-development/01-wp-now.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ title: wp-now
33
slug: /developers/local-development/wp-now
44
---
55

6+
:::caution Package deprecated
7+
The NPM package @wp-now/wp-now is deprecated, won't receive updates in the future. To use a command-line tool on your developer flow, use the NPM package `@wp-playground/cli`.
8+
:::
9+
610
# wp-now NPM package
711

812
[wp-now](https://www.npmjs.com/package/@wp-now/wp-now) is a command-line tool designed to simplify the process of running WordPress locally. It provides a quick and easy way to set up a local WordPress environment with minimal configuration.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Playground CLI
3+
slug: /developers/local-development/wp-playground-cli
4+
---
5+
6+
# Playground CLI
7+
8+
[@wp-playground/cli](https://www.npmjs.com/package/@wp-playground/cli) is a command-line tool that simplifies the WordPress development and testing flow.
9+
Playground CLI supports auto-mounting a directory with a plugin, theme, or WordPress installation. But if you need flexibility, the CLI supports mounting commands to personalize your local environment.
10+
11+
**Key features:**
12+
13+
- **Quick Setup**: Set up a local WordPress environment in seconds.
14+
- **Flexibility**: Allows for configuration to adapt to different scenarios.
15+
- **Simple Environment**: No extra configuration, just a compatible Node version, and you are ready to use it.
16+
17+
## Requirements
18+
19+
The Playground CLI requires Node.js 20.18 or higher, which is the recommended Long-Term Support (LTS) version. You can download it from the [Node.js website](https://nodejs.org/en/download).
20+
21+
## Quickstart
22+
23+
Running the Playground CLI is as simple as go to a command-line and run:
24+
25+
```bash
26+
npx @wp-playground/cli@latest server
27+
```
28+
29+
![Playground CLI in Action](@site/static/img/developers/npx-wp-playground-server.gif)
30+
31+
With the previous command, you only get a fresh WordPress instance to test. Most of the developers want to see their work running. If this is your case, test a plugin or a theme. You can run the CLI on your project folder and run the Playground CLI with the `--auto-mount` flag:
32+
33+
```bash
34+
cd my-plugin-or-theme-directory
35+
npx @wp-playground/cli@latest server --auto-mount
36+
```
37+
38+
### Choosing a WordPress and PHP Version
39+
40+
By default, the CLI loads the latest stable version of WordPress and PHP 8.0 due to its improved performance. To specify your preferred versions, you can use the flag `--wp=<version>` and `--php=<version>`:
41+
42+
```bash
43+
npx @wp-playground/cli@latest server --wp=6.8 --php=8.4
44+
```
45+
46+
### Loading Blueprints
47+
48+
One way to take your Playground CLI development experience to the next level is to integrate with [Blueprints](/blueprints/getting-started/). For those unfamiliar with this technology, it allows developers to configure the initial state for their WordPress Playground instances.
49+
50+
Using the `--blueprint=<blueprint-address>` flag, developers can run a Playground with a custom initial state. We’ll use the example below to do this.
51+
52+
**(my-blueprint.json)**
53+
54+
```bash
55+
{
56+
"landingPage": "/wp-admin/options-general.php?page=akismet-key-config",
57+
"login": true,
58+
"plugins": [
59+
"hello-dolly",
60+
"https://raw.githubusercontent.com/adamziel/blueprints/trunk/docs/assets/hello-from-the-dashboard.zip"
61+
]
62+
}
63+
```
64+
65+
CLI command loading a blueprint:
66+
67+
```bash
68+
npx @wp-playground/cli@latest server --blueprint=my-blueprint.json
69+
```
70+
71+
### Mounting folders manually
72+
73+
Some projects have a specific structure that requires a custom configuration; for example, your repository contains all the files in the `/wp-content/` folder. So in this scenario, you can specify to the Playground CLI that it will mount your project from that folder using the `--mount` flag.
74+
75+
```bash
76+
npx @wp-playground/cli@latest server --mount=.:/wordpress/wp-content/plugins/MY-PLUGIN-DIRECTORY
77+
```
78+
79+
### Mounting before WordPress installation
80+
81+
Consider mounting your WordPress project files before the WordPress installation begins. This approach is beneficial if you want to override the Playground boot process, as it can help connect Playground with `WP-CLI`. The `--mount-before-install` flag supports this process.
82+
83+
```bash
84+
npx @wp-playground/cli@latest server --mount-before-install=.:/wordpress/
85+
```
86+
87+
:::info
88+
On Windows, the path format `/host/path:/vfs/path` can cause issues. To resolve this, use the flags `--mount-dir` and `--mount-dir-before-install`. These flags let you specify host and virtual file system paths in an alternative format`"/host/path"` `"/vfs/path"`.
89+
:::
90+
91+
## Command and Arguments
92+
93+
Playground CLI is simple, configurable, and unopinionated. You can set it up according
94+
to your unique WordPress setup. With the Playground CLI, you can use the following top-level commands:
95+
96+
- **`server`**: (Default) Starts a local WordPress server.
97+
- **`run-blueprint`**: Executes a Blueprint file without starting a web server.
98+
- **`build-snapshot`**: Builds a ZIP snapshot of a WordPress site based on a Blueprint.
99+
100+
The `server` command supports the following optional arguments:
101+
102+
- `--port=<port>`: The port number for the server to listen on. Defaults to 9400.
103+
- `--outfile`: When building, write to this output file.
104+
- `--wp=<version>`: The version of WordPress to use. Defaults to the latest.
105+
- `--auto-mount`: Automatically mount the current directory (plugin, theme, wp-content, etc.).
106+
- `--mount=<mapping>`: Manually mount a directory (can be used multiple times). Format: `"/host/path:/vfs/path"`.
107+
- `--mount-before-install`: Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: `"/host/path:/vfs/path"`.
108+
- `--mount-dir`: Mount a directory to the PHP runtime (can be used multiple times). Format: `"/host/path"` `"/vfs/path"`.
109+
- `--mount-dir-before-install`: Mount a directory before WordPress installation (can be used multiple times). Format: `"/host/path"` `"/vfs/path"`
110+
- `--blueprint=<path>`: The path to a JSON Blueprint file to execute.
111+
- `--blueprint-may-read-adjacent-files`: Consent flag: Allow "bundled" resources in a local blueprint to read files in the same directory as the blueprint file.
112+
- `--login`: Automatically log the user in as an administrator.
113+
- `--skip-wordpress-setup`: Do not download or install WordPress. Useful if you are mounting a full WordPress directory.
114+
- `--skip-sqlite-setup`: Do not set up the SQLite database integration.
115+
- `--quiet`: Do not output logs and progress messages.
116+
- `--debug`: Print the PHP error log if an error occurs during boot.
117+
118+
## Need some help with the CLI?
119+
120+
With the Playground CLI, you can use the `--help` to get some support about the available commands.
121+
122+
```bash
123+
npx @wp-playground/cli@latest --help
124+
```

packages/docs/site/docs/developers/05-local-development/intro.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ title: Local Development
33
slug: /developers/local-development
44
---
55

6-
## Local Development with WordPress Playground
6+
## Local WordPress Development with Playground
77

8-
Playground powers offers several development environments designed to streamline the process of setting up and managing WordPress sites.
8+
Playground offers various development environments to streamline setting up and managing WordPress sites.
99

10-
The easiest way to get WordPress site up and running is to open a [public Playground web instance](/web-instance) from https://playground.wordpress.net/ (you could also [host your own WordPress Playground](/developers/architecture/host-your-own-playground)).
10+
For a quick start, use a [public Playground web instance](/web-instance) at https://playground.wordpress.net/. Alternatively, you can [host your own WordPress Playground](/developers/architecture/host-your-own-playground).
1111

12-
Playground provides additional tools to check your code on a local WordPress environment. These tools are designed to enhance the development experience by prioritizing ease of installation and usability:
12+
Playground also provides tools for local WordPress development, prioritizing easy installation and usability:
1313

14-
- [`wp-now`](/developers/local-development/wp-now) - CLI tool to spin up a WordPress site with a single command
14+
- **[@wp-playground/cli](/developers/local-development/wp-playground-cli):** A command-line tool to quickly launch a WordPress site from your terminal.
15+
- **[Visual Studio Code Extension](/developers/local-development/vscode-extension):** Integrates WordPress development directly into VS Code for a seamless experience within the popular editor.
1516

16-
- [Visual Studio Code Extension](/developers/local-development/vscode-extension) - Integrates WordPress development directly into Visual Studio Code to get a seamless development experience within the popular code editor.
17+
For those needing more control, Playground offers tools for Node.js:
1718

18-
But Playground also provides tools to use WordPress Playground in Node.js:
19-
20-
- [WordPress Playground in Node.js](/developers/local-development/php-wasm-node) - If you need low-level control over the underlying WebAssembly PHP build, take a look at the [`@php-wasm/node` package](https://npmjs.org/@php-wasm/node) which ships the PHP WebAssembly runtime.
19+
- **[WordPress Playground in Node.js](/developers/local-development/php-wasm-node):** For low-level control over the WebAssembly PHP build, explore the [`@php-wasm/node` package](https://npmjs.org/@php-wasm/node), which includes the PHP WebAssembly runtime.

packages/docs/site/docs/main/about/build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ WordPress Playground can help you to create and learn WordPress quickly, even on
1111

1212
## Setting quickly a local WordPress environment
1313

14-
You can seamlessly integrate Playground into your development workflow to launch a local WordPress environment quickly for testing your code. You can do this directly [from the terminal](/developers/local-development/wp-now) or [your preferred IDE.](/developers/local-development/vscode-extension)
14+
You can seamlessly integrate Playground into your development workflow to launch a local WordPress environment quickly for testing your code. You can do this directly [from the terminal](/developers/local-development/wp-playground-cli) or [your preferred IDE.](/developers/local-development/vscode-extension)
1515

1616
## Save changes done on a Block Theme and create Github Pull Requests
1717

packages/docs/site/docs/main/contributing/contributor-day.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ slug: /contributing/contributor-day
44

55
# WordCamp Contributor Day
66

7-
The [WordPress Playground VS Code extension](https://marketplace.visualstudio.com/items?itemName=WordPressPlayground.wordpress-playground) and [wp-now](https://www.npmjs.com/package/@wp-now/wp-now) streamline the process of setting up a local WordPress environment. WordPress Playground powers both—no Docker, MySQL, or Apache required.
7+
The [WordPress Playground VS Code extension](https://marketplace.visualstudio.com/items?itemName=WordPressPlayground.wordpress-playground) and [@wp-playground/cli](https://www.npmjs.com/package/@wp-playground/cli) streamline the process of setting up a local WordPress environment. WordPress Playground powers both—no Docker, MySQL, or Apache required.
88

9-
Keep reading to learn how to use these tools for [local development](/developers/local-development/wp-now) when contributing to WordPress. Please note that the extension and the NPM package are under development, and not all [Make WordPress teams](https://make.wordpress.org/) are fully supported.
9+
Keep reading to learn how to use these tools for [local development](/developers/local-development/wp-playground-cli) when contributing to WordPress. Please note that the extension and the NPM package are under development, and not all [Make WordPress teams](https://make.wordpress.org/) are fully supported.
1010

1111
## Getting Started
1212

13-
If you’re a visual learner, here’s a step-by-step video tutorial. If you prefer reading at your own pace, skip to the written instructions below.
14-
15-
<iframe title="Getting Started with wp-now for WordPress development at Contributor Day" width="752" height="423" src="https://video.wordpress.com/embed/Gn7XOCAM?cover=1&amp;preloadContent=metadata&amp;useAverageColor=1&amp;hd=1&amp;metadata_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3b3JkcHJlc3MuY29tIiwiaWF0IjoxNjg2MTQ4ODQ5LCJleHAiOjE2ODYzMjE2NDksImJsb2dfaWQiOiIyMDMxMjIxMTIiLCJndWlkIjoiR243WE9DQU0iLCJhdXRoIjoidmlkZW9wcmVzc19wbGF5YmFja190b2tlbiIsImFjY2VzcyI6InZpZGVvIiwiZXhwaXJlcyI6MTY4NjMyMTY0OX0.DJWVfePHl2nUKo8ziG81CK2VlG5Ui8vNg-dZJ7dOSq8" allow="fullscreen" loading="eager"></iframe>
16-
1713
### VS Code Playground extension
1814

1915
The [Visual Studio Code Playground extension](https://marketplace.visualstudio.com/items?itemName=WordPressPlayground.wordpress-playground) is a friendly zero-setup development environment.
@@ -23,23 +19,23 @@ The [Visual Studio Code Playground extension](https://marketplace.visualstudio.c
2319
3. To interact with Playground, click the new icon in the **Activity Bar** and hit the **Start WordPress Server** button.
2420
4. A new tab will open in your browser within seconds.
2521

26-
### wp-now NPM package
22+
### @wp-playground/cli NPM package
2723

28-
`@wp-now/wp-now` is a CLI tool that allows you to spin up a WordPress site with a single command. No Docker, MySQL, or Apache are required.
24+
`@wp-playground/cli` is a CLI tool that allows you to spin up a WordPress site with a single command. No Docker, MySQL, or Apache are required.
2925

3026
#### Prerequisites
3127

32-
`wp-now` requires Node.js and NPM. If you haven’t yet, [download and install](https://nodejs.org/en/download) both before you begin.
28+
`@wp-playground/cli` requires Node.js 20.18 or newer and NPM. If you haven’t yet, [download and install](https://nodejs.org/en/download) both before you begin.
3329

3430
Depending on the Make WordPress team you contribute to, you may need a different Node.js version than the one you have installed. You can use Node Version Manager (NVM) to switch between versions. [Find the installation guide here](https://github.com/nvm-sh/nvm#installing-and-updating).
3531

36-
#### Run wp-now
32+
#### Running `@wp-playground/cli`
3733

38-
You don’t have to install `wp-now` on your device to use it. Navigate to your plugin or theme directory and start `wp-now` with the following commands:
34+
You don’t have to install `@wp-playground/cli` on your device to use it. Navigate to your plugin or theme directory and start `@wp-playground/cli` with the following commands:
3935

4036
```bash
4137
cd my-plugin-or-theme-directory
42-
npx @wp-now/wp-now start
38+
npx @wp-playground/cli@latest server --auto-mount
4339
```
4440

4541
## Ideas for contributors
@@ -59,15 +55,15 @@ npm run dev
5955

6056
:::info
6157

62-
If you’re unsure about the steps listed above, visit the official [Gutenberg Project Contributor Guide](https://developer.wordpress.org/block-editor/contributors/). Note that in this case, `wp-now` replaces `wp-env`.
58+
If you’re unsure about the steps listed above, visit the official [Gutenberg Project Contributor Guide](https://developer.wordpress.org/block-editor/contributors/). Note that in this case, `@wp-playground/cli` replaces `wp-env`.
6359

6460
:::
6561

66-
Open a new terminal terminal tab, navigate to the Gutenberg directory, and start WordPress using `wp-now`:
62+
Open a new terminal terminal tab, navigate to the Gutenberg directory, and start WordPress using `@wp-playground/cli`:
6763

6864
```bash
6965
cd gutenberg
70-
npx @wp-now/wp-now start
66+
npx @wp-playground/cli@latest server --auto-mount
7167
```
7268

7369
When you’re ready, commit and push your changes to your forked repository on GitHub and open a Pull Request on the Gutenberg repository.
@@ -87,7 +83,7 @@ npm install
8783
npm run dev
8884

8985
# In a different terminal inside the Gutenberg directory *
90-
npx @wp-now/wp-now start
86+
npx @wp-playground/cli@latest server --auto-mount
9187
```
9288

9389
#### Test a Gutenberg PR with Playground in the browser

packages/docs/site/docs/main/guides/for-plugin-developers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Here’s an example of a **[plugin that generates Custom Post Types](https://raw
193193

194194
From a plugins' folder in your local development environment, you can quickly load locally a Playground instance with that plugin loaded and activated.
195195

196-
Use the [`wp-now` command](/developers/local-development/wp-now) from your plugin's root directory using your preferred command line program.
196+
Use the [`@wp-playground/cli` command](/developers/local-development/wp-playground-cli) from your plugin's root directory using your preferred command line program.
197197

198198
With [Visual Studio Code](https://code.visualstudio.com/) IDE, you can also use the [Visual Studio Code extension](/developers/local-development/vscode-extension) while working in the root directory of your plugin.
199199

@@ -202,7 +202,7 @@ For example:
202202
```bash
203203
git clone [email protected]:wptrainingteam/devblog-dataviews-plugin.git
204204
cd devblog-dataviews-plugin
205-
npx @wp-now/wp-now start
205+
npx @wp-playground/cli server --auto-mount
206206
```
207207

208208
### See your local changes in a Playground instance and directly create PRs in a GitHub repo with your changes

packages/docs/site/docs/main/guides/for-theme-developers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ The ["Stylish Press"](https://github.com/WordPress/blueprints/tree/trunk/bluepri
214214

215215
### Local theme development and testing with Playground
216216

217-
From the root folder of a block theme's code, you can quickly load locally a Playground instance with that theme loaded and activated. You can do that by launching, in a theme directory, the [`wp-now` command](/developers/local-development/wp-now) from your preferred command line program or the [Visual Code Studio extension](/developers/local-development/vscode-extension) from the [Visual Studio Code](https://code.visualstudio.com/) IDE.
217+
From the root folder of a block theme's code, you can quickly load locally a Playground instance with that theme loaded and activated. You can do that by launching, in a theme directory, the [`@wp-playground/cli` command](/developers/local-development/wp-playground-cli) from your preferred command line program or the [Visual Code Studio extension](/developers/local-development/vscode-extension) from the [Visual Studio Code](https://code.visualstudio.com/) IDE.
218218

219219
For example:
220220

221221
```
222222
git clone [email protected]:WordPress/community-themes.git
223223
cd community-themes/blue-note
224-
npx @wp-now/wp-now start
224+
npx @wp-playground/cli server --auto-mount
225225
```
226226

227227
### Design your theme using the WordPress UI and save your changes as Pull Requests

packages/docs/site/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const sidebars = {
134134
id: 'developers/local-development/intro',
135135
},
136136
items: [
137-
'developers/local-development/wp-now',
137+
'developers/local-development/wp-playground-cli',
138138
'developers/local-development/vscode-extension',
139139
'developers/local-development/php-wasm-node',
140140
],
23.8 KB
Loading

0 commit comments

Comments
 (0)