Skip to content

Commit a241c2d

Browse files
Merge branch 'trunk' into add/wp-now-command-wp-cli
2 parents e0395e6 + 0b42001 commit a241c2d

File tree

27 files changed

+177
-126
lines changed

27 files changed

+177
-126
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
33
"useWorkspaces": true,
4-
"version": "0.1.49",
4+
"version": "0.1.51",
55
"useNx": true
66
}

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/docs/site/docs/13-contributing/05-publishing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ npm login # this is required only once and it will store the credentials in ~/.
3131
npm run release
3232
```
3333

34+
### After publishing
35+
36+
To verify the publishing process went correctly:
37+
38+
1. Please verify https://translate.wordpress.org/projects/wp-plugins/contact-form-7/dev/de/default/playground/ loads as expected. If it doesn't load, something broke.
39+
2. Please run `npm install -g @wp-now/wp-now`. Verify you have the latest version with `wp-now --version`. Try `wp-now start` in a couple of modes to make sure everything is loaded as expected.
40+
3441
### When publishing packages goes wrong
3542

3643
Internet connections drop, APIs stop responding, and GitHub rules are nasty. Stuff happens. If the publishing process fails, you may need to bump the version again and force a publish. To do so, execute the following command:

packages/php-wasm/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/cli",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm CLI for node.js",
55
"repository": {
66
"type": "git",

packages/php-wasm/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/node",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm for Node.js",
55
"repository": {
66
"type": "git",

packages/php-wasm/progress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/progress",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm – loading progress monitoring",
55
"repository": {
66
"type": "git",

packages/php-wasm/scopes/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/scopes",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm – scoped URLs utils",
55
"repository": {
66
"type": "git",

packages/php-wasm/universal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/universal",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm – emscripten bindings for PHP",
55
"repository": {
66
"type": "git",

packages/php-wasm/util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/util",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"type": "commonjs",
55
"typedoc": {
66
"entryPoint": "./src/index.ts",

packages/php-wasm/web-service-worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/web-service-worker",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm – service worker utils",
55
"repository": {
66
"type": "git",

packages/php-wasm/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@php-wasm/web",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "PHP.wasm for the web",
55
"repository": {
66
"type": "git",

packages/playground/blueprints/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wp-playground/blueprints",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"exports": {
55
".": {
66
"import": "./index.js",

packages/playground/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wp-playground/client",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "WordPress Playground client",
55
"repository": {
66
"type": "git",

packages/wp-now/CONTRIBUTING.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Contributing
2+
3+
We welcome contributions from the community!
4+
5+
In order to contribute to `wp-now`, you'll need to first install a few global dependencies:
6+
7+
- Make sure you have `nvm` installed. If you need to install it first,
8+
[follow these installation instructions](https://github.com/nvm-sh/nvm#installation).
9+
- Install `nx` by running `npm install -g nx`.
10+
11+
Once the global dependencies are installed, you can start using the repo:
12+
13+
```bash
14+
git clone [email protected]:WordPress/wordpress-playground.git
15+
cd wordpress-playground
16+
nvm use
17+
npm install
18+
npm run build
19+
nx preview wp-now start --path=/path/to/wordpress-plugin-or-theme
20+
```
21+
22+
If you'd like to make the `wp-now` executable globally available when using this installation method, run `npm link`. It's not particularly reliable, however.
23+
24+
Please refer to the main [README.md](../../README.md) file for more detail on how to contribute to this project.
25+
26+
## Testing
27+
28+
To run the unit tests, use the following command:
29+
30+
```bash
31+
nx test wp-now
32+
```
33+
34+
## Publishing
35+
36+
The `wp-now` package is part of a larger monorepo, sharing its space with other sibling packages. To publish the `wp-now` package to npm, you must first understand the automated release process facilitated by lerna. This process includes automatically incrementing the version number, creating a new tag, and publishing all modified packages to npm simultaneously. Notably, all published packages share the same version number.
37+
38+
Each package identifies a distinct organization in its `package.json` file. To publish the `wp-now` package, you need access to the npm organizations `@wp-playground`, `@php-wasm`, and `@wp-now`.
39+
40+
To initiate the publishing process for the all the modified packages, execute the following commands:
41+
42+
```bash
43+
npm login # this is required only once and it will store the credentials in ~/.npmrc file.
44+
npm run release
45+
```
46+
47+
### When publishing goes wrong
48+
49+
Internet connections drop, APIs stop responding, and GitHub rules are nasty. Stuff happens. If the publishing process fails, you may need to bump the version again and force a publish. To do so, execute the following command:
50+
51+
```bash
52+
npm run release -- --force-publish
53+
```

packages/wp-now/README.md

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
It uses automatic mode detection to provide a fast setup process, regardless of whether you're working on a plugin or an entire site. You can easily switch between PHP and WordPress versions with just a configuration argument. Under the hood, `wp-now` is powered by WordPress Playground and only requires Node.js.
66

7+
![Demo GIF of wp-now](https://github.com/WordPress/wordpress-playground/assets/36432/474ecb85-d789-4db9-b820-a19c25da79ad)
8+
79
## Getting Started
810

911
To install `wp-now` directly from `npm`:
@@ -44,7 +46,8 @@ wp-now php my-file.php
4446
- **wp-content** mode: Presence of `plugins` and `themes` subdirectories.
4547
- **wordpress**: Runs the directory as a WordPress installation when WordPress files are detected. An existing `wp-config.php` file will be used if it exists; if it doesn't exist, it will be created along with a SQLite database.
4648
- **wordpress-develop**: Same as `wordpress` mode, except the `build` directory is served as the web root.
47-
- **index**: Starts a PHP webserver in the working directory and simply passes requests to `index.php`.
49+
- **index**: When an `index.php` file is present, starts a PHP webserver in the working directory and simply passes requests to the `index.php`.
50+
- **playground**: If no other conditions are matched, launches a completely virtualized WordPress site.
4851

4952
### Arguments
5053

@@ -55,11 +58,11 @@ wp-now php my-file.php
5558
- `--port=<port>`: the port number on which the server will listen. This is optional and if not provided, it will pick an open port number automatically. The default port number is set to `8881`(example of usage: `--port=3000`);
5659
- `--wp=<version>`: the version of WordPress to use. This is optional and if not provided, it will use a default version. The default version is set to the [latest WordPress version](https://wordpress.org/download/releases/)(example usage: `--wp=5.8`)
5760

58-
Of these, `wp-now php` currently supports the `--path=<path>`, `--php=<version>`, and `--wp=<version>` arguments.
61+
Of these, `wp-now php` currently supports the `--path=<path>` and `--php=<version>` arguments.
5962

6063
## Technical Details
6164

62-
- The `~/.wp-now` home directory is used to store the WP versions and the `wp-content` folders for projects using 'theme', 'plugin', and 'wp-content' modes. The path to `wp-content` directory for the 'plugin', 'theme', and 'wp-content' modes is `~/.wp-now/wp-content/${projectName}-${directoryHash}`.
65+
- The `~/.wp-now` home directory is used to store the WP versions and the `wp-content` folders for projects using 'theme', 'plugin', 'wp-content', and 'playground' modes. The path to `wp-content` directory for the 'plugin', 'theme', and 'wp-content' modes is `~/.wp-now/wp-content/${projectName}-${directoryHash}`. 'playground' mode shares the same `~/.wp-now/wp-content/playground` directory, regardless of where it's started.
6366
- For the database setup, `wp-now` is using [SQLite database integration plugin](https://wordpress.org/plugins/sqlite-database-integration/). The path to SQLite database is ` ~/.wp-now/wp-content/${projectName}-${directoryHash}/database/.ht.sqlite`
6467

6568
## Known Issues
@@ -107,54 +110,4 @@ Some similarities between `wp-env` and `wp-now` to be aware of:
107110

108111
## Contributing
109112

110-
We welcome contributions from the community!
111-
112-
In order to contribute to `wp-now`, you'll need to first install a few global dependencies:
113-
114-
- Make sure you have `nvm` installed. If you need to install it first,
115-
[follow these installation instructions](https://github.com/nvm-sh/nvm#installation).
116-
- Install `nx` by running `npm install -g nx`.
117-
118-
Once the global dependencies are installed, you can start using the repo:
119-
120-
```bash
121-
git clone [email protected]:WordPress/wordpress-playground.git
122-
cd wordpress-playground
123-
nvm use
124-
npm install
125-
npm run build
126-
nx preview wp-now start --path=/path/to/wordpress-plugin-or-theme
127-
```
128-
129-
If you'd like to make the `wp-now` executable globally available when using this installation method, run `npm link`. It's not particularly reliable, however.
130-
131-
Please refer to the main [README.md](../../README.md) file for more detail on how to contribute to this project.
132-
133-
## Testing
134-
135-
To run the unit tests, use the following command:
136-
137-
```bash
138-
nx test wp-now
139-
```
140-
141-
## Publishing
142-
143-
The `wp-now` package is part of a larger monorepo, sharing its space with other sibling packages. To publish the `wp-now` package to npm, you must first understand the automated release process facilitated by lerna. This process includes automatically incrementing the version number, creating a new tag, and publishing all modified packages to npm simultaneously. Notably, all published packages share the same version number.
144-
145-
Each package identifies a distinct organization in its `package.json` file. To publish the `wp-now` package, you need access to the npm organizations `@wp-playground`, `@php-wasm`, and `@wp-now`.
146-
147-
To initiate the publishing process for the all the modified packages, execute the following commands:
148-
149-
```bash
150-
npm login # this is required only once and it will store the credentials in ~/.npmrc file.
151-
npm run release
152-
```
153-
154-
### When publishing goes wrong
155-
156-
Internet connections drop, APIs stop responding, and GitHub rules are nasty. Stuff happens. If the publishing process fails, you may need to bump the version again and force a publish. To do so, execute the following command:
157-
158-
```bash
159-
npm run release --force-publish
160-
```
113+
See [Contributing](CONTRIBUTING.md)

packages/wp-now/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wp-now/wp-now",
3-
"version": "0.1.49",
3+
"version": "0.1.51",
44
"description": "WordPress Playground CLI",
55
"repository": {
66
"type": "git",

packages/wp-now/src/config.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const enum WPNowMode {
2626
WORDPRESS_DEVELOP = 'wordpress-develop',
2727
INDEX = 'index',
2828
WP_CONTENT = 'wp-content',
29+
PLAYGROUND = 'playground',
2930
AUTO = 'auto',
3031
}
3132

@@ -66,17 +67,17 @@ async function getAbsoluteURL() {
6667
return `http://127.0.0.1:${port}`;
6768
}
6869

69-
function getWpContentHomePath(projectPath: string) {
70+
function getWpContentHomePath(projectPath: string, mode: string) {
7071
const basename = path.basename(projectPath);
7172
const directoryHash = crypto
7273
.createHash('sha1')
7374
.update(projectPath)
7475
.digest('hex');
75-
return path.join(
76-
getWpNowPath(),
77-
'wp-content',
78-
`${basename}-${directoryHash}`
79-
);
76+
const projectDirectory =
77+
mode === WPNowMode.PLAYGROUND
78+
? 'playground'
79+
: `${basename}-${directoryHash}`;
80+
return path.join(getWpNowPath(), 'wp-content', projectDirectory);
8081
}
8182

8283
export default async function getWpNowConfig(
@@ -100,12 +101,15 @@ export default async function getWpNowConfig(
100101
}
101102
});
102103

103-
if (!options.wpContentPath) {
104-
options.wpContentPath = getWpContentHomePath(options.projectPath);
105-
}
106104
if (!options.mode || options.mode === 'auto') {
107105
options.mode = inferMode(options.projectPath);
108106
}
107+
if (!options.wpContentPath) {
108+
options.wpContentPath = getWpContentHomePath(
109+
options.projectPath,
110+
options.mode
111+
);
112+
}
109113
if (!options.absoluteUrl) {
110114
options.absoluteUrl = await getAbsoluteURL();
111115
}

packages/wp-now/src/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import os from 'os';
2-
import path from 'path';
3-
41
/**
52
* The hidden folder name for storing WP Now related files.
63
*/

0 commit comments

Comments
 (0)