@stagepass/cli 2.2.6 → 2.3.0-beta.1
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 +61 -13
- package/TESTING-macos.md +35 -8
- package/bin/index.js +4 -1
- package/package.json +9 -8
- package/src/cli.js +62 -7
- package/src/commands/certs.js +375 -19
- package/src/commands/daemon.js +75 -7
- package/src/commands/dev.js +419 -0
- package/src/commands/link.js +66 -25
- package/src/commands/new.js +397 -41
- package/src/commands/npm-run.js +8 -0
- package/src/commands/reload.js +2 -2
- package/src/commands/setup.js +5 -5
- package/src/commands/start.js +386 -83
- package/src/commands/stop.js +50 -31
- package/src/commands/unlink.js +8 -6
- package/src/commands/upgrade.js +51 -12
- package/src/lib/apply-site-block.js +48 -0
- package/src/lib/autostart.js +300 -3
- package/src/lib/caddyfile.js +72 -13
- package/src/lib/cdn-snippets.js +145 -3
- package/src/lib/certs.js +334 -47
- package/src/lib/dev-port.js +45 -0
- package/src/lib/doctor-site.js +61 -5
- package/src/lib/doctor.js +48 -4
- package/src/lib/ensure-running.js +89 -0
- package/src/lib/exec.js +72 -24
- package/src/lib/live-server.js +484 -0
- package/src/lib/node-engine.js +55 -0
- package/src/lib/notify.js +62 -0
- package/src/lib/origins.js +27 -5
- package/src/lib/package-versions.js +9 -0
- package/src/lib/paths.js +18 -0
- package/src/lib/php-fpm.js +33 -0
- package/src/lib/project-sync.js +165 -20
- package/src/lib/projects.js +137 -7
- package/src/lib/prompts.js +19 -0
- package/src/lib/registry.js +27 -6
- package/src/lib/scaffold.js +288 -11
- package/src/lib/site-detect.js +78 -25
- package/src/lib/snippets.js +14 -11
- package/src/lib/spinner.js +60 -0
- package/src/lib/versions.js +20 -8
- package/templates/project/AGENTS.md.tmpl +4 -3
- package/templates/project/README.md.tmpl +35 -6
- package/templates/project/api/README.md.tmpl +7 -0
- package/templates/project/examples/php/README.md.tmpl +18 -0
- package/templates/project/examples/php/form.php +105 -0
- package/templates/project/examples/php/proxy.php +171 -0
- package/templates/project/scripts/build.mjs +200 -37
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The CLI sets up and manages the local Stagepass infrastructure (`.sp` domains, C
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Published CLI 2.2.7 requires Node.js **18+** (`engines.node`: `>=18.0.0`) on **macOS** with Homebrew. CLI 2.3.0 (unreleased) raises the floor to `>=20.17.0` because `@inquirer/prompts@8` requires it. Development and CI use Node 22 or 24.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install -g @stagepass/cli@2
|
|
@@ -21,7 +21,7 @@ npx @stagepass/cli@2 setup
|
|
|
21
21
|
## Requirements
|
|
22
22
|
|
|
23
23
|
- **macOS** (system commands refuse other platforms with exit code 1; this is not a breaking change because those commands never worked off macOS)
|
|
24
|
-
- Node.js 18+
|
|
24
|
+
- Published CLI 2.2.7: Node.js 18+ (`engines.node` `>=18.0.0`). CLI 2.3.0 (unreleased): Node.js `>=20.17.0`. Use Node 22 or 24 for local development and CI
|
|
25
25
|
- Homebrew
|
|
26
26
|
|
|
27
27
|
`stagepass --version` and `stagepass --help` work on any platform. For tests/CI only, set `STAGEPASS_SKIP_PLATFORM_CHECK=1` to bypass the macOS guard (not for production use).
|
|
@@ -49,31 +49,56 @@ Linked: https://my-project.sp -> /absolute/path/to/project
|
|
|
49
49
|
| Command | Description |
|
|
50
50
|
| :--- | :--- |
|
|
51
51
|
| `stagepass setup` | Install Caddy, PHP, Dnsmasq via Homebrew and configure the local `.sp` resolver (`address=/.sp/127.0.0.1` + `/etc/resolver/sp`). |
|
|
52
|
-
| `stagepass start` | Start
|
|
52
|
+
| `stagepass start` | Start Caddy & PHP. Runs `certs check` (offers repair when interactive). No unconditional root warm-up: inspects port 443 without sudo; signals only after confirm (TERM then optional KILL; sudo only if unprivileged kill fails). With autostart installed, bootstraps/kickstarts the LaunchAgent (else direct `caddy start`). Migrates legacy Caddyfile blocks if needed. |
|
|
53
53
|
| `stagepass link [domain]` | Link the current directory to a `.sp` domain, write/update the Caddyfile + `~/.stagepass/projects.json`, reload Caddy. |
|
|
54
54
|
| `stagepass unlink [domain]` | Remove the site block and `projects.json` entry, reload Caddy. |
|
|
55
55
|
| `stagepass reload` | Reload Caddy configuration. Migrates legacy Caddyfile blocks if needed. |
|
|
56
|
-
| `stagepass stop` | Stop
|
|
57
|
-
| `stagepass doctor` | Read-only diagnostics (Homebrew, Caddy, PHP/php-fpm, dnsmasq, resolver, port 443, Caddyfile, projects, certs, LaunchAgent,
|
|
56
|
+
| `stagepass stop` | Stop Caddy & PHP. If autostart is installed/loaded, `launchctl bootout` first (until next login); use `autostart off` to disable permanently. |
|
|
57
|
+
| `stagepass doctor` | Read-only diagnostics (Homebrew, Caddy, PHP/php-fpm, dnsmasq, resolver, port 443, Caddyfile, projects, certs, LaunchAgent, declared modules vs. live site). CDN pin warnings in docs + project files: **(unreleased, CLI 2.3.0)**. Never uses sudo. `--json`, `--skip-site`. Exit `1` if any fail. |
|
|
58
58
|
| `stagepass certs check` | Read-only Caddy local CA check (validity, System keychain trust, orphans, optional TLS handshake per linked domain). `--json`, `--skip-handshake`. |
|
|
59
59
|
| `stagepass certs trust` | Run `caddy trust` after interactive confirmation (or `--yes`). |
|
|
60
|
+
| `stagepass certs renew` | **(unreleased, CLI 2.3.0)** Repair failing linked site certs; `--root` moves the CA folder to a backup (double confirm, or `--yes --i-understand-root-renewal`); `--remove-orphans` deletes keychain orphans by SHA-1 after confirm. |
|
|
60
61
|
| `stagepass autostart on\|off\|status` | Manage a user LaunchAgent (`io.github.arobertherz.stagepass`) that runs `stagepass daemon` at login. |
|
|
61
|
-
| `stagepass daemon` | Non-interactive
|
|
62
|
+
| `stagepass daemon` | Non-interactive LaunchAgent helper (PHP-FPM ensure, certs log-only, `caddy run`, macOS notifications). Never uses sudo. |
|
|
62
63
|
| `stagepass new [name]` | Scaffold a lean Webflow project (TypeScript + SCSS by default). |
|
|
63
64
|
| `stagepass build` | Run `npm run build` in the current project (forwards exit code). |
|
|
64
|
-
| `stagepass watch` | Run `npm run watch` in the current project (forwards exit code). |
|
|
65
|
+
| `stagepass watch` | Run `npm run watch` in the current project (forwards exit code). If Stagepass is not running, asks to start it (TTY) or prints a `stagepass start` hint (non-TTY / CI); warns with `stagepass link` when the cwd is not linked. |
|
|
66
|
+
| `stagepass dev` | **(unreleased, CLI 2.3.0)** Like watch, plus live reload on the linked `.sp` domain. Same running check as watch; requires `stagepass link` (hard error if unlinked). |
|
|
65
67
|
| `stagepass upgrade` | Bump `@stagepass/*`, sync declared modules, `AGENTS.md`, the Cursor rule and `types`, print Webflow snippets. |
|
|
66
68
|
|
|
67
69
|
All commands support `-v, --verbose` where applicable.
|
|
68
70
|
|
|
69
71
|
### Doctor / certificates / autostart
|
|
70
72
|
|
|
73
|
+
Features marked **(unreleased, CLI 2.3.0)** are not in published npm `latest` (`2.2.7`).
|
|
74
|
+
|
|
71
75
|
- `doctor` and `certs check` are read-only. They never delete keychain items or certificate files.
|
|
72
|
-
- Prefer CDN major pin `@2` in Webflow custom code (
|
|
76
|
+
- Prefer CDN major pin `@2` in Webflow custom code. Doctor unpinned-CDN warnings (`@latest`, bare `@1`, or unversioned `@stagepass/loader` / `@stagepass/modules` in recommended snippets and in the current project's `README.md`, `stagepass.json`, and `*.html` files directly in the project root and in `snippets/` — non-recursive, regular files ≤ 1 MB, symlinks skipped): **(unreleased, CLI 2.3.0)**.
|
|
77
|
+
- `certs renew` **(unreleased, CLI 2.3.0)** is opt-in and confirmation-gated. Site repair only deletes `certificates/local/<linked-domain>` after checks fail. `--root` moves the CA folder to a timestamped backup (never deletes; needs two interactive confirmations without `--yes`, or `--yes --i-understand-root-renewal`). `--yes` alone always aborts for `--root` (TTY or not). Do not combine `--root` with `--remove-orphans`; run them as separate commands. Orphans are removed only by SHA-1 via `renew --remove-orphans`.
|
|
73
78
|
- Chrome may require Local Network Access permission for public HTTPS pages that load `https://*.sp` assets.
|
|
74
|
-
- Autostart runs as your user (same privilege model as `caddy start`
|
|
79
|
+
- Autostart runs as your user (same privilege model as interactive `caddy start`). `start` kickstarts the agent when present; `stop` bootouts until the next login. If port 443 cannot be bound, `daemon` logs a clear error, may notify, and exits `0` so launchd KeepAlive does not restart-loop. Interactive `start` confirms before signalling any non-caddy listener (name + PID; SIGTERM then optional SIGKILL). Own processes are signalled without elevated rights first; `sudo` only when needed after confirmation. There is no standby `sudo -v`.
|
|
80
|
+
- `stagepass autostart on` records a launchd-safe `PATH` from `brew --prefix` (Apple Silicon `/opt/homebrew`, Intel `/usr/local`) plus `/usr/bin:/bin:/usr/sbin:/sbin`. It does **not** copy your interactive shell environment. `brew` and `caddy` must resolve to shims under that prefix's `bin`/`sbin` (normal Homebrew Cellar symlinks are fine). Missing Homebrew/Caddy aborts **before** writing the plist.
|
|
81
|
+
- Published CLI requires Node `>=18.0.0`. CLI 2.3.0 (unreleased) raises it to `>=20.17.0`.
|
|
75
82
|
- Manual macOS checklist: [`TESTING-macos.md`](./TESTING-macos.md).
|
|
76
83
|
|
|
84
|
+
#### macOS permissions (keep these separate)
|
|
85
|
+
|
|
86
|
+
These are different prompts. Grant only the narrow dialog macOS shows. Stagepass never asks for Full Disk Access or any security bypass.
|
|
87
|
+
|
|
88
|
+
| Concern | What it is | Typical fix |
|
|
89
|
+
| :--- | :--- | :--- |
|
|
90
|
+
| **System CA trust** | Trusting Caddy's local CA in the System keychain (`stagepass certs trust` / `caddy trust`) so browsers accept `https://*.sp`. | Run `stagepass certs check`, then `certs trust` if needed. Unrelated to TCC file access. |
|
|
91
|
+
| **Browser Local Network Access** | Chrome (and similar) gating public HTTPS pages that fetch `https://*.sp` / loopback. | Allow Local Network for the **browser** when it prompts. Not a Node Desktop-files grant. |
|
|
92
|
+
| **Node files access (TCC)** | macOS may ask the **Node** binary for access to a folder (commonly **Desktop**) when the CLI or LaunchAgent reads a project / test package living there. | Grant that folder to Node if you intentionally keep projects on Desktop. Prefer installing the CLI in a stable location (below) so everyday use does not depend on Desktop TCC. |
|
|
93
|
+
|
|
94
|
+
#### Install location and LaunchAgent paths
|
|
95
|
+
|
|
96
|
+
- Prefer a **stable** global install (`npm install -g @stagepass/cli` into the normal npm prefix, or another fixed absolute path). Avoid pointing autostart at a temporary Desktop unpack / ad-hoc test tarball when you can use the published package instead.
|
|
97
|
+
- `autostart on` records **absolute** Node and CLI paths (often Homebrew Cellar Node + the realpathed `stagepass` entry) plus the validated Homebrew `PATH`. It does not follow later `brew` upgrades automatically.
|
|
98
|
+
- After a Homebrew Node upgrade/cleanup, moving the CLI, or changing the npm prefix, run `stagepass autostart on` again so ProgramArguments stay valid. A brief local outage while the agent reloads is expected.
|
|
99
|
+
- Upgrading the global CLI package does **not** rewrite an existing LaunchAgent that still points at an older test path. Switch deliberately: `stagepass autostart off` then `autostart on` with the stable CLI you want. Do **not** delete a test directory while a loaded agent still references it; disable/refresh the agent first.
|
|
100
|
+
- Development checkouts (`packages/cli`, Desktop test packs) and the published global install are different binaries; compare behaviour with one style at a time.
|
|
101
|
+
|
|
77
102
|
### `new` options
|
|
78
103
|
|
|
79
104
|
Scaffold a project with flags for every choice (interactive prompts only on a TTY without `--yes`):
|
|
@@ -85,17 +110,22 @@ Scaffold a project with flags for every choice (interactive prompts only on a TT
|
|
|
85
110
|
| `--lang ts\|js` | Language (default: `ts`). |
|
|
86
111
|
| `--styles scss\|css` | Styles (default: `scss`). |
|
|
87
112
|
| `--modules` / `--no-modules` | Include `@stagepass/modules` as npm dependency (default: yes; forced on when `--site-modules` lists a module). |
|
|
88
|
-
| `--site <host>` | Live Webflow site (https) to detect the loaded modules from.
|
|
113
|
+
| `--site <host>` | Live Webflow site (https) to detect the loaded modules from. Also sets `origin` in `stagepass.json`. |
|
|
114
|
+
| `--staging <domain>` | **(unreleased, CLI 2.3.0)** Staging hostname (hostname only; same validation as `--origin`). Stored as `origin`. Must match `--site` when both are set. |
|
|
115
|
+
| `--production <domain>` | **(unreleased, CLI 2.3.0)** Optional production hostname. Stored as `production`. When omitted, prints a short hint to add it later via `stagepass link --origin`. |
|
|
89
116
|
| `--site-modules <list>` | Modules the site loads: `none`, `all`, or a comma list of `inject`, `cookies`, `maintenance`. Takes precedence over `--site`. |
|
|
117
|
+
| `--php` / `--no-php` | **(unreleased, CLI 2.3.0)** Enable PHP for the project (`api/` + `php_fastcgi` on link). Default: off. Existing linked projects without `"php"` keep PHP on. |
|
|
118
|
+
| `--php-examples` / `--no-php-examples` | **(unreleased, CLI 2.3.0)** Include `examples/php/` samples (requires `--php`). Default: off. |
|
|
119
|
+
| `--link` / `--no-link` | **(unreleased, CLI 2.3.0)** After scaffolding, run `stagepass link` (macOS only). Default: off; interactive macOS may offer it. |
|
|
90
120
|
| `--git` / `--no-git` | `git init` (default: yes). |
|
|
91
121
|
| `--remote <url>` | Set `origin` after git init (rejects URLs with embedded credentials). |
|
|
92
122
|
| `--install` / `--no-install` | Run `npm install` (default: no). |
|
|
93
123
|
| `-y, --yes` | Non-interactive; use defaults for omitted flags. |
|
|
94
124
|
| `--dry-run` | Print the file plan without writing. |
|
|
95
125
|
|
|
96
|
-
The name must be DNS-safe (lowercase `a-z`, `0-9`, hyphens; 1 to 63 chars; no leading/trailing hyphen). Existing files are never overwritten. Generated projects include `scripts/build.mjs` (content-hashed `dist/` + `manifest.json`), Webflow head/footer snippets (jsDelivr `@2`, loader plus the declared modules), `stagepass.json`, an `AGENTS.md` with the full `sp` API reference, `.cursor/rules/stagepass.mdc`, and a `.gitignore`. `@stagepass/loader` / `@stagepass/modules` are added as `^2` (same major as the CDN pin `@2`; npm installs the newest published 2.x). Per-module types are written only when the published or installed `@stagepass/modules` ships them (2.2.0 and later); otherwise `types` lists the umbrella `@stagepass/modules`.
|
|
126
|
+
The name must be DNS-safe (lowercase `a-z`, `0-9`, hyphens; 1 to 63 chars; no leading/trailing hyphen). Existing files are never overwritten. Generated projects include `scripts/build.mjs` (content-hashed `dist/` + SRI `integrity` in `manifest.json`), scripts `build` / `watch` / `dev` (`dev` aliases `watch`), Webflow head/footer snippets (jsDelivr `@2`, loader plus the declared modules), `stagepass.json`, an `AGENTS.md` with the full `sp` API reference, `.cursor/rules/stagepass.mdc`, and a `.gitignore`. `@stagepass/loader` / `@stagepass/modules` are added as `^2` (same major as the CDN pin `@2`; npm installs the newest published 2.x). Per-module types are written only when the published or installed `@stagepass/modules` ships them (2.2.0 and later); otherwise `types` lists the umbrella `@stagepass/modules`.
|
|
97
127
|
|
|
98
|
-
Interactively, `new`
|
|
128
|
+
Interactively (macOS), `new` runs a read-only `doctor` preflight and can offer `stagepass setup` if the local stack looks incomplete (never automatic, never under `--yes` / no-TTY, never sudo by itself). On published CLI 2.2.7, without a TTY (or with `--yes`) it uses `--site-modules`, then `--site` detection, else `[]` with a hint. Staging / production prompts, PHP prompts, `--staging` detection, and `link` reading `origin` / `production` from `stagepass.json` are **(unreleased, CLI 2.3.0)**.
|
|
99
129
|
|
|
100
130
|
### Declared modules (`stagepass.json`)
|
|
101
131
|
|
|
@@ -113,7 +143,12 @@ The legacy boolean `"modules": true|false` is still read; `upgrade` replaces it
|
|
|
113
143
|
|
|
114
144
|
### Live site detection
|
|
115
145
|
|
|
116
|
-
`new --site`, `upgrade` and `doctor` read the modules from the live site: one public `GET` of the origin, https only, no cookies or auth headers, about 5 s timeout, a size cap, at most 3 redirects (all https). Only `<script src>` attributes are parsed with a regex (HTML comments ignored); nothing is executed. Recognised:
|
|
146
|
+
`new --site`, `upgrade` and `doctor` read the modules from the live site: one public `GET` of the origin, https only, no cookies or auth headers, about 5 s timeout, a size cap, at most 3 redirects (all https). Only `<script src>` attributes are parsed with a regex (HTML comments ignored); nothing is executed. Recognised:
|
|
147
|
+
|
|
148
|
+
- CDN (`cdn.jsdelivr.net/npm/` or `unpkg.com/`): full `/dist/{loader,inject,cookies,maintenance,all}(.min).js` paths, any version (`@2`, `@2.0.0`, none), and package-root URLs such as `…/@stagepass/loader@2` or `…/@stagepass/modules@2` (optional trailing slash / query). Package-root maps from each package’s `main` field (loader → `loader`, modules → `all`); there is no `unpkg` / `jsdelivr` / `exports` override in those packages.
|
|
149
|
+
- Self-hosted: a Stagepass build filename under a `/stagepass/` path segment (relative or other-origin absolute), a relative `…/@stagepass/…` path (e.g. copied from `node_modules`), or the same filename on a `<script>` that also has a `data-stagepass-*` attribute; renamed loader files that carry a loader-config attribute (`data-stagepass-version`, `data-stagepass-live-src`, …). Result `cdn` is `self`. Bare `loader.js` / `all.min.js` from other libraries without a Stagepass hint are ignored. Absolute URLs on foreign hosts that only mimic an `@stagepass` CDN path (no `/stagepass/` segment and no data attribute) are ignored.
|
|
150
|
+
|
|
151
|
+
Still not recognised: tags without `src`, `data-src` only, other hosts without a Stagepass hint, and module ids that cannot be inferred from the filename. `upgrade` syncs the detected modules list into the project; it does not rewrite self-hosted embeds to CDN URLs (printed Webflow snippets remain the recommended CDN form). The npm dependency in `package.json` is only a hint.
|
|
117
152
|
|
|
118
153
|
### `upgrade` options
|
|
119
154
|
|
|
@@ -153,6 +188,8 @@ Every change is printed as `file: action` (unchanged files are not listed; skipp
|
|
|
153
188
|
| `--no-allow-all-origins` | Disable allow-all mode and use the origin allowlist. |
|
|
154
189
|
| `-v, --verbose` | Show Caddy reload output / errors. |
|
|
155
190
|
|
|
191
|
+
Published CLI 2.2.7 still needs explicit `link --origin` for CORS (even when `new --site` wrote `origin` into `stagepass.json`). `link` reading `origin` / `production` from `stagepass.json` when no `--origin` / `--remove-origin` flags are passed is **(unreleased, CLI 2.3.0)**. The project's `"php"` flag (when set) controlling whether the Caddy site block includes `php_fastcgi` is also **(unreleased, CLI 2.3.0)**; missing `"php"` keeps the legacy PHP-on behaviour.
|
|
192
|
+
|
|
156
193
|
**`--origin` / `--remove-origin` format:** `example.com`, `www.example.com`, `*.example.com`, or `https://example.com`. Hostnames only (optional leading `*.`); no path, port, or `http://` for live origins.
|
|
157
194
|
|
|
158
195
|
If Caddy reload fails after a successful write, the CLI warns and suggests `stagepass start`.
|
|
@@ -239,6 +276,17 @@ stagepass link --no-allow-all-origins
|
|
|
239
276
|
|
|
240
277
|
Hand-written content outside `# START:` / `# END:` markers is left untouched. Unparsable legacy blocks are left unchanged with a warning. Migration is idempotent (second run does nothing and creates no new backup).
|
|
241
278
|
|
|
279
|
+
## Troubleshooting (CLI)
|
|
280
|
+
|
|
281
|
+
| Symptom | What to check |
|
|
282
|
+
| :--- | :--- |
|
|
283
|
+
| Autostart runs at login but `caddy: command not found` / daemon exits | Re-run `stagepass autostart on` so the plist embeds Homebrew `PATH`. Confirm `brew --prefix` and that `which caddy` points at `$prefix/bin/caddy` (Cellar symlink OK). |
|
|
284
|
+
| macOS asks Node for Desktop access | Normal TCC when the CLI/agent reads a project under Desktop. Grant the folder or move the project / use a stable global CLI install. Not the same as browser Local Network or CA trust. |
|
|
285
|
+
| Autostart still runs an old Desktop test binary after `npm i -g` | Global upgrade does not migrate LaunchAgent ProgramArguments. `autostart off` then `on` with the stable CLI; do not remove the old path while the agent still references it. |
|
|
286
|
+
| `stagepass start` spinner floods the terminal (weird ANSI) | Upgrade to a build with the spinner geometry guard. Rare with TTY width `0`. |
|
|
287
|
+
| `start` asks for a password at every boot | There is no unconditional `sudo -v`. Only confirmed conflict resolution may use `sudo kill` / `apachectl`. |
|
|
288
|
+
| Port 443 bind failure under LaunchAgent | Expected when something else owns 443; daemon exits `0` (no restart loop). Free the port or use interactive `stagepass start`. |
|
|
289
|
+
|
|
242
290
|
## Related Packages
|
|
243
291
|
|
|
244
292
|
- `@stagepass/loader`: browser runtime for swapping production assets.
|
package/TESTING-macos.md
CHANGED
|
@@ -4,7 +4,7 @@ Use this after installing a local build of `@stagepass/cli` on macOS with Homebr
|
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
- Node
|
|
7
|
+
- Node 20.17+ on PATH (22 or 24 recommended)
|
|
8
8
|
- Homebrew installed
|
|
9
9
|
- A throwaway project folder (example: `~/Sites/my-project`)
|
|
10
10
|
|
|
@@ -25,34 +25,61 @@ stagepass start
|
|
|
25
25
|
- [ ] Port 443 section reports the listener (or warns if empty / permission denied). Doctor must never ask for sudo
|
|
26
26
|
- [ ] Linked project whose folder was deleted surfaces as fail
|
|
27
27
|
- [ ] Chrome Local Network Access hint is printed
|
|
28
|
-
- [ ] CDN check reports recommended snippets use `@2` (not `@latest`)
|
|
28
|
+
- [ ] CDN check reports recommended snippets use `@2` (not `@latest` / `@1` / bare)
|
|
29
|
+
- [ ] With a project `README.md` containing `@stagepass/loader@latest` (or `@1` / bare), doctor warns on `cdn.project`
|
|
29
30
|
|
|
30
31
|
## certs
|
|
31
32
|
|
|
32
33
|
- [ ] `stagepass certs check` reports root path under `~/Library/Application Support/Caddy/pki/authorities/local/root.crt`
|
|
33
34
|
- [ ] Warns when root expires in under 90 days (use a lab machine or mock if needed)
|
|
34
35
|
- [ ] Reports System keychain trust status for "Caddy Local Authority"
|
|
35
|
-
- [ ] Orphaned old Caddy roots are listed with SHA-1 and SHA-256 (
|
|
36
|
+
- [ ] Orphaned old Caddy roots are listed with SHA-1 and SHA-256 (not deleted by `check`)
|
|
36
37
|
- [ ] Optional TLS handshake lines appear for each linked `.sp` domain while Caddy is running
|
|
37
38
|
- [ ] `stagepass certs check --json` works
|
|
38
39
|
- [ ] `stagepass certs trust` asks for confirmation; declining does nothing
|
|
39
40
|
- [ ] `stagepass certs trust --yes` runs `caddy trust`
|
|
40
41
|
- [ ] After trust, Safari / Chrome / Firefox show a valid certificate for `https://my-project.sp`
|
|
41
|
-
- [ ]
|
|
42
|
+
- [ ] `stagepass certs renew` with a failing site cert deletes only `certificates/local/<domain>` after confirmation, then reloads Caddy
|
|
43
|
+
- [ ] `stagepass certs renew --root` asks twice (or needs `--yes --i-understand-root-renewal`); CA folder is moved to a `.backup.*` path, not deleted; prints hint to run `certs trust`
|
|
44
|
+
- [ ] `stagepass certs renew --remove-orphans` confirms per SHA-1 (or `--yes`) and runs `security delete-certificate -Z <sha1>` (never by CN)
|
|
45
|
+
|
|
46
|
+
## start / stop / port conflict
|
|
47
|
+
|
|
48
|
+
- [ ] `stagepass start` prints certificate findings; interactive TTY can offer trust/renew
|
|
49
|
+
- [ ] Non-interactive `start` prints findings + hint and does not repair
|
|
50
|
+
- [ ] Port 443 conflict shows **process name and PID** and requires confirmation before any signal
|
|
51
|
+
- [ ] Confirmed conflict uses SIGTERM first; SIGKILL only after a second confirmation (or process already gone)
|
|
52
|
+
- [ ] Own-user listeners are signalled without sudo first; `sudo kill` only after unprivileged failure (EPERM / other uid)
|
|
53
|
+
- [ ] nginx conflicts try `valet stop` (then `brew services stop nginx`) before any sudo
|
|
54
|
+
- [ ] `start` never calls standby `sudo -v`
|
|
55
|
+
- [ ] With autostart enabled, `start` uses `launchctl kickstart` and prints that fact
|
|
56
|
+
- [ ] With autostart enabled, `stop` uses `launchctl bootout` and says services return at next login; `autostart off` removes permanently
|
|
57
|
+
|
|
58
|
+
## Permissions (do not conflate)
|
|
59
|
+
|
|
60
|
+
- [ ] **CA trust** checked via `certs check` / `certs trust` (System keychain); separate from TCC
|
|
61
|
+
- [ ] **Browser Local Network Access** granted in the browser if the live site loads `*.sp`; separate from Node
|
|
62
|
+
- [ ] If macOS prompts **Node** for **Desktop** (or another folder) access because the project/test pack lives there, grant that folder only, not Full Disk Access
|
|
63
|
+
- [ ] Prefer a stable `npm install -g @stagepass/cli` path for acceptance; temporary Desktop test packs are fine for a one-off check but refresh autostart before deleting them
|
|
42
64
|
|
|
43
65
|
## autostart / daemon
|
|
44
66
|
|
|
45
67
|
- [ ] `stagepass autostart status` shows label `io.github.arobertherz.stagepass`
|
|
46
|
-
- [ ] `stagepass autostart on` writes `~/Library/LaunchAgents/io.github.arobertherz.stagepass.plist` with absolute node + CLI paths
|
|
68
|
+
- [ ] `stagepass autostart on` writes `~/Library/LaunchAgents/io.github.arobertherz.stagepass.plist` with absolute node + CLI paths and an `EnvironmentVariables` `PATH` that includes Homebrew `bin`/`sbin` from `brew --prefix` (Cellar symlink for `caddy` is OK)
|
|
69
|
+
- [ ] With a sparse launchd-like PATH, `daemon` still finds `caddy` via the plist PATH
|
|
47
70
|
- [ ] Plist has `RunAtLoad` and `KeepAlive` / `SuccessfulExit` false
|
|
48
71
|
- [ ] Logs appear under `~/.stagepass/logs/`
|
|
72
|
+
- [ ] `stagepass start` does **not** prompt for sudo when port 443 is free / only caddy listens; with a foreign listener it asks before SIGTERM and again before SIGKILL
|
|
73
|
+
- [ ] With autostart on: bootstrap if needed, kickstart via `start`; `stop` bootouts (until next login) then stops Caddy/PHP; `autostart off` / `on` retained
|
|
74
|
+
- [ ] After moving Node/CLI or leaving a Desktop test path, `autostart off` then `on` with the stable CLI (upgrade alone does not migrate ProgramArguments)
|
|
49
75
|
- [ ] After logout/login (or `launchctl bootstrap`), daemon starts Caddy via `caddy run`
|
|
50
|
-
- [ ]
|
|
76
|
+
- [ ] Daemon ensures PHP-FPM without sudo
|
|
77
|
+
- [ ] Daemon shows a macOS notification on cert trust failure / PHP-FPM failure / permanent bind failure (notification must not block or crash the daemon)
|
|
51
78
|
- [ ] `stagepass autostart off` boots out the agent and removes the plist
|
|
52
79
|
- [ ] If port 443 cannot be bound, daemon logs a clear message and exits `0` (no KeepAlive restart-loop; not a silent success)
|
|
53
80
|
- [ ] Cold-start daemon logs cert root/trust only (no TLS handshake attempts before `caddy run`)
|
|
54
81
|
|
|
55
82
|
## Regression (must stay unchanged)
|
|
56
83
|
|
|
57
|
-
- [ ] `stagepass
|
|
58
|
-
- [ ]
|
|
84
|
+
- [ ] `stagepass link` / `unlink` / `reload` / `setup` behave as before
|
|
85
|
+
- [ ] Loader CDN `@2` behaviour is untouched by this CLI work
|
package/bin/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { assertNodeEngine } from '../src/lib/node-engine.js';
|
|
4
4
|
|
|
5
|
+
assertNodeEngine();
|
|
6
|
+
|
|
7
|
+
const { createProgram, rewriteArgvForUpgrade } = await import('../src/cli.js');
|
|
5
8
|
createProgram().parse(rewriteArgvForUpgrade(process.argv));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stagepass/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.1",
|
|
4
4
|
"description": "Local Development Orchestrator for Webflow",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"start": "node bin/index.js",
|
|
22
22
|
"build": "echo 'No build step required for CLI package'",
|
|
23
|
+
"prepack": "node ../../scripts/sync-cli-versions.mjs --check",
|
|
23
24
|
"test": "vitest run",
|
|
24
25
|
"test:watch": "vitest"
|
|
25
26
|
},
|
|
@@ -39,18 +40,18 @@
|
|
|
39
40
|
},
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"dependencies": {
|
|
43
|
+
"@inquirer/prompts": "^8.7.5",
|
|
42
44
|
"chalk": "^5.3.0",
|
|
43
|
-
"commander": "^
|
|
44
|
-
"execa": "^
|
|
45
|
-
"fs-extra": "^11.
|
|
46
|
-
"
|
|
47
|
-
"ora": "^7.0.1",
|
|
45
|
+
"commander": "^14.0.0",
|
|
46
|
+
"execa": "^9.6.0",
|
|
47
|
+
"fs-extra": "^11.4.1",
|
|
48
|
+
"ora": "^9.0.0",
|
|
48
49
|
"sudo-prompt": "^9.2.1"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"vitest": "^5.0
|
|
52
|
+
"vitest": "^5.1.0"
|
|
52
53
|
},
|
|
53
54
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
55
|
+
"node": ">=20.17.0"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/src/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ import { doctor as defaultDoctor } from './commands/doctor.js';
|
|
|
11
11
|
import {
|
|
12
12
|
certsCheck as defaultCertsCheck,
|
|
13
13
|
certsTrust as defaultCertsTrust,
|
|
14
|
+
certsRenew as defaultCertsRenew,
|
|
14
15
|
} from './commands/certs.js';
|
|
15
16
|
import { autostart as defaultAutostart } from './commands/autostart.js';
|
|
16
17
|
import { daemon as defaultDaemon } from './commands/daemon.js';
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
build as defaultBuild,
|
|
21
22
|
} from './commands/npm-run.js';
|
|
22
23
|
import { createNew as defaultCreateNew } from './commands/new.js';
|
|
24
|
+
import { dev as defaultDev } from './commands/dev.js';
|
|
23
25
|
import { assertSupportedPlatform } from './lib/platform.js';
|
|
24
26
|
|
|
25
27
|
const require = createRequire(import.meta.url);
|
|
@@ -73,12 +75,14 @@ export function rewriteArgvForUpgrade(argv) {
|
|
|
73
75
|
* @param {typeof defaultDoctor} [deps.doctor]
|
|
74
76
|
* @param {typeof defaultCertsCheck} [deps.certsCheck]
|
|
75
77
|
* @param {typeof defaultCertsTrust} [deps.certsTrust]
|
|
78
|
+
* @param {typeof defaultCertsRenew} [deps.certsRenew]
|
|
76
79
|
* @param {typeof defaultAutostart} [deps.autostart]
|
|
77
80
|
* @param {typeof defaultDaemon} [deps.daemon]
|
|
78
81
|
* @param {typeof defaultUpgrade} [deps.upgrade]
|
|
79
82
|
* @param {typeof defaultWatch} [deps.watch]
|
|
80
83
|
* @param {typeof defaultBuild} [deps.build]
|
|
81
84
|
* @param {typeof defaultCreateNew} [deps.createNew]
|
|
85
|
+
* @param {typeof defaultDev} [deps.dev]
|
|
82
86
|
* @param {string} [deps.version]
|
|
83
87
|
* @param {() => void} [deps.assertPlatform]
|
|
84
88
|
*/
|
|
@@ -92,12 +96,14 @@ export function createProgram(deps = {}) {
|
|
|
92
96
|
const doctor = deps.doctor || defaultDoctor;
|
|
93
97
|
const certsCheck = deps.certsCheck || defaultCertsCheck;
|
|
94
98
|
const certsTrust = deps.certsTrust || defaultCertsTrust;
|
|
99
|
+
const certsRenew = deps.certsRenew || defaultCertsRenew;
|
|
95
100
|
const autostart = deps.autostart || defaultAutostart;
|
|
96
101
|
const daemon = deps.daemon || defaultDaemon;
|
|
97
102
|
const upgrade = deps.upgrade || defaultUpgrade;
|
|
98
103
|
const watch = deps.watch || defaultWatch;
|
|
99
104
|
const build = deps.build || defaultBuild;
|
|
100
105
|
const createNew = deps.createNew || defaultCreateNew;
|
|
106
|
+
const runDev = deps.dev || defaultDev;
|
|
101
107
|
const version = deps.version || packageVersion;
|
|
102
108
|
const assertPlatform =
|
|
103
109
|
deps.assertPlatform || (() => assertSupportedPlatform());
|
|
@@ -154,7 +160,8 @@ export function createProgram(deps = {}) {
|
|
|
154
160
|
'Disable allow-all CORS and use the origin allowlist'
|
|
155
161
|
)
|
|
156
162
|
.action(async (domain, options) => {
|
|
157
|
-
await link(domain, options);
|
|
163
|
+
const code = await link(domain, options);
|
|
164
|
+
if (typeof code === 'number') process.exitCode = code;
|
|
158
165
|
});
|
|
159
166
|
|
|
160
167
|
program
|
|
@@ -163,7 +170,8 @@ export function createProgram(deps = {}) {
|
|
|
163
170
|
.argument('[domain]', 'Domain name (optional, defaults to current folder name)')
|
|
164
171
|
.option('-v, --verbose', 'Show Caddy reload output')
|
|
165
172
|
.action(async (domain, options) => {
|
|
166
|
-
await unlink(domain, options);
|
|
173
|
+
const code = await unlink(domain, options);
|
|
174
|
+
if (typeof code === 'number') process.exitCode = code;
|
|
167
175
|
});
|
|
168
176
|
|
|
169
177
|
program
|
|
@@ -176,15 +184,20 @@ export function createProgram(deps = {}) {
|
|
|
176
184
|
|
|
177
185
|
program
|
|
178
186
|
.command('start')
|
|
179
|
-
.description(
|
|
187
|
+
.description(
|
|
188
|
+
'Start background services (Caddy & PHP). Runs certs check; uses launchctl kickstart when autostart is enabled.'
|
|
189
|
+
)
|
|
180
190
|
.option('-v, --verbose', 'Show detailed Caddy server logs')
|
|
181
191
|
.action(async (options) => {
|
|
182
|
-
await start(options);
|
|
192
|
+
const code = await start(options);
|
|
193
|
+
if (typeof code === 'number') process.exitCode = code;
|
|
183
194
|
});
|
|
184
195
|
|
|
185
196
|
program
|
|
186
197
|
.command('stop')
|
|
187
|
-
.description(
|
|
198
|
+
.description(
|
|
199
|
+
'Stop background services. With autostart enabled, boots out the LaunchAgent until next login.'
|
|
200
|
+
)
|
|
188
201
|
.option('-v, --verbose', 'Show detailed stop logs')
|
|
189
202
|
.action(async (options) => {
|
|
190
203
|
await stop(options);
|
|
@@ -228,6 +241,27 @@ export function createProgram(deps = {}) {
|
|
|
228
241
|
process.exitCode = code;
|
|
229
242
|
});
|
|
230
243
|
|
|
244
|
+
certsCmd
|
|
245
|
+
.command('renew')
|
|
246
|
+
.description(
|
|
247
|
+
'Repair site/intermediate certs, optionally renew the root CA (move to backup), or remove orphaned keychain roots by SHA-1'
|
|
248
|
+
)
|
|
249
|
+
.option('--root', 'Move the local CA folder to a timestamped backup (double confirmation)')
|
|
250
|
+
.option(
|
|
251
|
+
'--i-understand-root-renewal',
|
|
252
|
+
'Required with --yes for non-interactive --root'
|
|
253
|
+
)
|
|
254
|
+
.option(
|
|
255
|
+
'--remove-orphans',
|
|
256
|
+
'Delete orphaned Caddy roots from the System keychain by SHA-1 (confirmation per cert)'
|
|
257
|
+
)
|
|
258
|
+
.option('-y, --yes', 'Skip interactive confirmation where allowed')
|
|
259
|
+
.option('-v, --verbose', 'Show detailed output')
|
|
260
|
+
.action(async (options) => {
|
|
261
|
+
const code = await certsRenew(options);
|
|
262
|
+
process.exitCode = code;
|
|
263
|
+
});
|
|
264
|
+
|
|
231
265
|
program
|
|
232
266
|
.command('autostart')
|
|
233
267
|
.description('Manage login LaunchAgent for Stagepass (macOS)')
|
|
@@ -247,7 +281,9 @@ export function createProgram(deps = {}) {
|
|
|
247
281
|
|
|
248
282
|
program
|
|
249
283
|
.command('daemon')
|
|
250
|
-
.description(
|
|
284
|
+
.description(
|
|
285
|
+
'Foreground daemon for LaunchAgent (ensures PHP-FPM, certs log-only, caddy run; never sudo; macOS notifications on problems)'
|
|
286
|
+
)
|
|
251
287
|
.action(async () => {
|
|
252
288
|
const code = await daemon();
|
|
253
289
|
process.exitCode = code;
|
|
@@ -289,6 +325,17 @@ export function createProgram(deps = {}) {
|
|
|
289
325
|
process.exitCode = code;
|
|
290
326
|
});
|
|
291
327
|
|
|
328
|
+
program
|
|
329
|
+
.command('dev')
|
|
330
|
+
.description(
|
|
331
|
+
'Run project watch plus live reload (SSE via /__stagepass/live on the linked .sp domain). No Vite.'
|
|
332
|
+
)
|
|
333
|
+
.option('-v, --verbose', 'Show detailed output')
|
|
334
|
+
.action(async (options) => {
|
|
335
|
+
const code = await runDev(options);
|
|
336
|
+
process.exitCode = code;
|
|
337
|
+
});
|
|
338
|
+
|
|
292
339
|
program
|
|
293
340
|
.command('build')
|
|
294
341
|
.description('Run `npm run build` in the current project')
|
|
@@ -308,8 +355,16 @@ export function createProgram(deps = {}) {
|
|
|
308
355
|
.option('--styles <styles>', 'scss or css (default: scss)')
|
|
309
356
|
.option('--modules', 'Include @stagepass/modules (npm, types)')
|
|
310
357
|
.option('--no-modules', 'Skip @stagepass/modules')
|
|
311
|
-
.option('--site <host>', 'Live Webflow site to detect loaded modules from (https)')
|
|
358
|
+
.option('--site <host>', 'Live Webflow site to detect loaded modules from (https); also sets staging origin')
|
|
359
|
+
.option('--staging <domain>', 'Staging hostname written to stagepass.json as origin')
|
|
360
|
+
.option('--production <domain>', 'Optional production hostname written to stagepass.json')
|
|
312
361
|
.option('--site-modules <list>', 'Modules the site loads: none, all, or inject,cookies,maintenance')
|
|
362
|
+
.option('--php', 'Enable PHP (api/ + php_fastcgi on link)')
|
|
363
|
+
.option('--no-php', 'Disable PHP for this project (default)')
|
|
364
|
+
.option('--php-examples', 'Include examples/php samples (requires --php)')
|
|
365
|
+
.option('--no-php-examples', 'Skip PHP examples (default)')
|
|
366
|
+
.option('--link', 'Run stagepass link after scaffolding (macOS)')
|
|
367
|
+
.option('--no-link', 'Do not link after scaffolding (default)')
|
|
313
368
|
.option('--git', 'Initialize a git repository')
|
|
314
369
|
.option('--no-git', 'Do not initialize git')
|
|
315
370
|
.option('--remote <url>', 'Git remote URL (requires git)')
|