@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 CHANGED
@@ -1,19 +1,26 @@
1
1
  # @wp-operations/wp-ops
2
2
 
3
- The operations CLI for wp-operations platform repositories: the GitHub repository the wp-operations theme manages, holding every app (WordPress theme) and every plugin.
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
- Requires Node.js 20.10 or later and git. Composer is needed for plugins.
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
- ## Platform repository
18
+ ## Commands
12
19
 
13
20
  ```bash
14
- wp-ops init my-platform --platform=path/to/wp-operations-theme # layout + composer.yml + git init
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 # packages/acme/forms (type psr4-plugin)
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 kind manifests, the `packages/` and kind folders, `.github/workflows/composer.yml` and `.gitignore`, then runs `git init` (branch `main`). It never overwrites a file. `--platform` copies the theme's `platform.json` to the root. |
27
- | `new app <kind> <slug>` | Creates the app folder: composer.json `type: wp-app`, style.css, index.php, and a functions.php that boots every installed plugin. It also adds the slug to the kind's manifest, with `--server`, `--app-path` and `--theme-slug`. |
28
- | `new plugin <vendor/name>` | Creates `packages/<vendor>/<name>` with composer.json `type: psr4-plugin`, version 0.1.0, PSR-4 autoload and `extra.wp-operations.plugin-class`, plus `src/Plugin.php` with `init()`. |
29
- | `apps`, `plugins` | List what is in the repository, with deploy targets, which apps use which plugin, and any contract problems. |
30
- | `composer <add\|remove\|update> --apps= --packages=` | Makes the same composer.json edit the theme commits (a no-op when the theme already did it), then refreshes `composer.lock` without installing anything. `update` with no `--apps` covers every app that requires the plugins. This is what `composer.yml` runs on GitHub Actions. |
31
- | `sandbox` | The preview runtime. See below. |
32
- | `edit` | Opens the wp-ide editor for this repository. |
33
- | `doctor` | Checks the environment and the repository contract. |
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 runtime
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
- One server for every app, matching the theme's sandbox contract:
42
-
43
- - **Health.** `GET /` (change it with `--health`) answers 200. When `$SANDBOX_TOKEN` is set (or the variable named by `--token-env`), health checks need `Authorization: Bearer <token>`. In Settings → Operations → Sandboxes, set the token constant to the same value.
44
- - **Preview.** Each app runs at `/{kind}/{slug}/` on its own WordPress site (wp-app engine, SQLite), with the app active as the theme. Its plugins are installed with `composer install` and booted.
45
- - **Framing.** `X-Frame-Options` is removed and `Content-Security-Policy: frame-ancestors` is set from `--frame-ancestors` (default `*`; use the platform's origin in production).
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
- `wp-ops start [dir]`, `wp-ops dev [dir]` and `wp-ops build` delegate to [`wp-app`](../wp-app). Running `wp-ops` with no arguments opens the interactive menu.
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '@wp-operations/wp-app/cli.js';
package/bin/wp-code.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '@wp-operations/wp-code/cli.js';
package/bin/wp-ide.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '@wp-operations/wp-ide/cli.js';
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@wp-operations/wp-ops",
3
- "version": "0.2.0",
4
- "description": "Operations CLI and TUI for wp-operations platform repositories: init, apps, plugins, composer, sandbox runtime, start, build, doctor.",
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
  },
@@ -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, framable from the platform.
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 vibe/{slug}) when it
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 || 'vibe/{slug}');
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=vibe/{slug}]
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>]