@wp-operations/wp-ops 0.2.0 → 0.3.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 +30 -27
- package/bin/wp-app.js +2 -0
- package/bin/wp-code.js +2 -0
- package/bin/wp-ide.js +2 -0
- package/package.json +8 -3
- package/src/commands/sandbox.js +3 -3
- package/src/main.js +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
# @wp-operations/wp-ops
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The wp-operations tool. One install gives you all four commands:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install -g @wp-operations/wp-ops
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Command | What it is |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `wp-ops` | Platform repository: init, apps, plugins, composer, sandbox |
|
|
12
|
+
| `wp-app` | Local WordPress / ClassicPress server ([wp-app](../wp-app)) |
|
|
13
|
+
| `wp-ide` | Local browser editor with live preview ([wp-ide](../wp-ide)) |
|
|
14
|
+
| `wp-code` | Coding agent in the terminal ([wp-code](../wp-code)) |
|
|
15
|
+
|
|
16
|
+
Requires Node.js 20.10 or later and git. Composer is needed for plugins. If you installed `@wp-operations/wp-app`, `wp-ide` or `wp-code` globally on their own before, uninstall them first, since wp-ops now provides those commands.
|
|
10
17
|
|
|
11
|
-
##
|
|
18
|
+
## Commands
|
|
12
19
|
|
|
13
20
|
```bash
|
|
14
|
-
wp-ops init my-platform --platform=path/to/wp-operations
|
|
21
|
+
wp-ops init my-platform --platform=path/to/wp-operations # the theme folder, for its platform.json
|
|
15
22
|
cd my-platform
|
|
16
|
-
wp-ops new plugin acme/forms
|
|
23
|
+
wp-ops new plugin acme/forms
|
|
17
24
|
wp-ops new app service-apps shop --server=prod-1 --app-path=/var/www/shop
|
|
18
25
|
wp-ops composer add --apps=service-apps/shop --packages="acme/forms"
|
|
19
26
|
wp-ops apps
|
|
@@ -23,35 +30,31 @@ wp-ops doctor
|
|
|
23
30
|
|
|
24
31
|
| Command | What it does |
|
|
25
32
|
|---|---|
|
|
26
|
-
| `init [dir] [--platform=]` | Creates `.github/platform.json`, the
|
|
27
|
-
| `new app <kind> <slug>` | Creates the app
|
|
28
|
-
| `new plugin <vendor/name>` | Creates `packages/<vendor>/<name>`
|
|
29
|
-
| `apps`, `plugins` |
|
|
30
|
-
| `composer <add\|remove\|update> --apps= --packages=` |
|
|
31
|
-
| `sandbox` |
|
|
32
|
-
| `edit` | Opens
|
|
33
|
-
| `
|
|
33
|
+
| `init [dir] [--platform=]` | Creates `.github/platform.json`, the app manifests, `packages/`, the app folders, `.github/workflows/composer.yml` and `.gitignore`, then runs `git init`. Never overwrites a file. `--platform` copies the theme's `platform.json` to the root. |
|
|
34
|
+
| `new app <kind> <slug>` | Creates the app (composer type `wp-app`) and adds it to the kind's manifest. |
|
|
35
|
+
| `new plugin <vendor/name>` | Creates `packages/<vendor>/<name>` (composer type `psr4-plugin`) with `src/Plugin.php`. |
|
|
36
|
+
| `apps`, `plugins` | Lists apps and plugins, which app uses which plugin, and any problems. |
|
|
37
|
+
| `composer <add\|remove\|update> --apps= --packages=` | Edits the apps' composer.json the same way the platform does and refreshes `composer.lock`. This is what `composer.yml` runs. |
|
|
38
|
+
| `sandbox` | Preview runtime for the platform. See below. |
|
|
39
|
+
| `edit` | Opens wp-ide for this repository. |
|
|
40
|
+
| `start`, `dev`, `build` | Runs one app with wp-app. |
|
|
41
|
+
| `doctor` | Checks the environment and the repository. |
|
|
42
|
+
|
|
43
|
+
Running `wp-ops` with no arguments opens a menu.
|
|
34
44
|
|
|
35
|
-
## Sandbox
|
|
45
|
+
## Sandbox
|
|
36
46
|
|
|
37
47
|
```bash
|
|
38
48
|
SANDBOX_TOKEN=… wp-ops sandbox --port=8080 --url=https://sandbox.example.com --git
|
|
39
49
|
```
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
- **Git mode.** With `--git`, the runtime must be a clone with a remote. Each app is served from its own worktree under `.local/sandbox/`, refreshed on every page load: from `vibe/{slug}` (the AI work branch; change it with `--work-branch`) when that branch exists on the remote, otherwise from the deploy branch (`--branch`, default the remote's default branch). New commits show up when the preview reloads.
|
|
47
|
-
- **Without `--git`.** The runtime serves your working tree as it is.
|
|
48
|
-
- **Memory.** At most `--max` sites (default 3) stay running. The least recently used idle site is stopped and starts again on its next request.
|
|
49
|
-
|
|
50
|
-
`--url` must be the public address the platform loads previews from, because WordPress builds its links from it.
|
|
51
|
-
|
|
52
|
-
## Single app
|
|
51
|
+
- Serves every app at `/{kind}/{slug}/`, each on its own WordPress site.
|
|
52
|
+
- `GET /` is the health check. With `SANDBOX_TOKEN` set, it needs `Authorization: Bearer <token>`; set the same value in the platform under Settings → Operations → Sandboxes.
|
|
53
|
+
- The platform shows previews in an iframe: `--frame-ancestors` sets who may do that (default `*`; use the platform's address in production).
|
|
54
|
+
- With `--git`, each app follows `platform/{slug}` (the AI work branch) when it exists on the remote, otherwise the deploy branch (`--branch`). New commits show on the next reload. Without `--git`, it serves your working tree.
|
|
55
|
+
- At most `--max` sites (default 3) run at once.
|
|
53
56
|
|
|
54
|
-
`
|
|
57
|
+
`--url` must be the public address the platform loads previews from.
|
|
55
58
|
|
|
56
59
|
## License
|
|
57
60
|
|
package/bin/wp-app.js
ADDED
package/bin/wp-code.js
ADDED
package/bin/wp-ide.js
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-operations/wp-ops",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "The wp-operations tool. One install gives wp-ops, wp-app, wp-ide and wp-code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"wp-ops": "cli.js"
|
|
8
|
+
"wp-ops": "cli.js",
|
|
9
|
+
"wp-app": "bin/wp-app.js",
|
|
10
|
+
"wp-ide": "bin/wp-ide.js",
|
|
11
|
+
"wp-code": "bin/wp-code.js"
|
|
9
12
|
},
|
|
10
13
|
"files": [
|
|
11
14
|
"cli.js",
|
|
15
|
+
"bin",
|
|
12
16
|
"src",
|
|
13
17
|
"LICENSE",
|
|
14
18
|
"README.md"
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"@clack/prompts": "0.7.0",
|
|
33
37
|
"@wp-operations/wp-app": "^0.4.1",
|
|
38
|
+
"@wp-operations/wp-code": "^0.1.1",
|
|
34
39
|
"@wp-operations/wp-ide": "^0.3.0",
|
|
35
40
|
"picocolors": "1.1.1"
|
|
36
41
|
},
|
package/src/commands/sandbox.js
CHANGED
|
@@ -74,11 +74,11 @@ function sendJson(res, status, body) {
|
|
|
74
74
|
* The sandbox runtime the platform theme leases: one HTTP server that
|
|
75
75
|
* answers health checks at --health (Bearer token optional) and serves
|
|
76
76
|
* every app of the platform repository at /{kind}/{slug}/ on its own
|
|
77
|
-
* wp-app WordPress site,
|
|
77
|
+
* wp-app WordPress site, which the platform can show in an iframe.
|
|
78
78
|
*
|
|
79
79
|
* Without --git it serves the working tree as it is. With --git it serves
|
|
80
80
|
* each app from its own worktree, refreshed from the remote on every page
|
|
81
|
-
* load: the app's work branch (--work-branch, default
|
|
81
|
+
* load: the app's work branch (--work-branch, default platform/{slug}) when it
|
|
82
82
|
* exists, else the deploy branch.
|
|
83
83
|
*/
|
|
84
84
|
export async function sandbox(options) {
|
|
@@ -96,7 +96,7 @@ export async function sandbox(options) {
|
|
|
96
96
|
const max = Math.max(1, Number(options.max ?? 3));
|
|
97
97
|
const useGit = Boolean(options.git);
|
|
98
98
|
const remote = options.remote || 'origin';
|
|
99
|
-
const workBranch = options.workBranch === false ? '' : String(options.workBranch || '
|
|
99
|
+
const workBranch = options.workBranch === false ? '' : String(options.workBranch || 'platform/{slug}');
|
|
100
100
|
|
|
101
101
|
readLayout(root);
|
|
102
102
|
if (!process.env.WP_APP_HOME) useLocalData(root);
|
package/src/main.js
CHANGED
|
@@ -27,7 +27,7 @@ Platform repository:
|
|
|
27
27
|
wp-ops new plugin <vendor/name> [--description=]
|
|
28
28
|
wp-ops composer <add|remove|update> --apps=<a,b> --packages="<x y>" [--constraint=*] [--no-lock]
|
|
29
29
|
edit composer.json and refresh composer.lock (what composer.yml runs)
|
|
30
|
-
wp-ops sandbox [--port=8080] [--url=<public url>] [--git] [--branch=] [--work-branch=
|
|
30
|
+
wp-ops sandbox [--port=8080] [--url=<public url>] [--git] [--branch=] [--work-branch=platform/{slug}]
|
|
31
31
|
[--health=/] [--token-env=SANDBOX_TOKEN] [--frame-ancestors="*"] [--max=3] [--php=] [--wp=]
|
|
32
32
|
serve every app at /{kind}/{slug}/ for the platform's previews
|
|
33
33
|
wp-ops edit [--port=4500] [--preview=<sandbox url>]
|