@stagepass/cli 1.0.1 → 2.1.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/LICENSE +21 -0
- package/README.md +216 -0
- package/TESTING-macos.md +58 -0
- package/bin/index.js +2 -76
- package/package.json +10 -4
- package/src/cli.js +320 -0
- package/src/commands/autostart.js +85 -0
- package/src/commands/certs.js +185 -0
- package/src/commands/daemon.js +126 -0
- package/src/commands/doctor.js +56 -0
- package/src/commands/link.js +145 -57
- package/src/commands/new.js +368 -0
- package/src/commands/npm-run.js +84 -0
- package/src/commands/reload.js +14 -11
- package/src/commands/start.js +21 -4
- package/src/commands/stop.js +15 -0
- package/src/commands/unlink.js +17 -30
- package/src/commands/upgrade.js +198 -0
- package/src/lib/autostart.js +360 -0
- package/src/lib/caddyfile.js +338 -0
- package/src/lib/cdn-snippets.js +27 -0
- package/src/lib/certs.js +476 -0
- package/src/lib/doctor.js +503 -0
- package/src/lib/domain.js +125 -0
- package/src/lib/exec.js +71 -0
- package/src/lib/migrate.js +96 -0
- package/src/lib/origins.js +160 -0
- package/src/lib/paths.js +132 -0
- package/src/lib/platform.js +47 -0
- package/src/lib/project-name.js +47 -0
- package/src/lib/projects.js +181 -0
- package/src/lib/remote-url.js +63 -0
- package/src/lib/scaffold.js +186 -0
- package/src/lib/snippets.js +83 -0
- package/src/lib/spawn.js +30 -0
- package/templates/project/AGENTS.md.tmpl +37 -0
- package/templates/project/README.md.tmpl +44 -0
- package/templates/project/jsconfig.json.tmpl +14 -0
- package/templates/project/scripts/build.mjs +110 -0
- package/templates/project/src/main.js.tmpl +29 -0
- package/templates/project/src/main.ts.tmpl +29 -0
- package/templates/project/src/styles.css.tmpl +8 -0
- package/templates/project/src/styles.scss.tmpl +8 -0
- package/templates/project/stagepass.json.tmpl +8 -0
- package/templates/project/tsconfig.json.tmpl +13 -0
- package/src/commands/__tests__/link.test.js +0 -113
- package/src/commands/__tests__/reload.test.js +0 -72
- package/src/commands/__tests__/unlink.test.js +0 -90
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Herz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# `@stagepass/cli`
|
|
2
|
+
|
|
3
|
+
Local development orchestrator for Webflow projects.
|
|
4
|
+
|
|
5
|
+
The CLI sets up and manages the local Stagepass infrastructure (`.sp` domains, Caddy, DNS, PHP) so your live Webflow site can load local assets through the Stagepass loader.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Requires Node.js **18+** (`engines.node`: `>=18.0.0`) on **macOS** with Homebrew. Development and CI use Node 22 or 24; the published package keeps `engines.node` at `>=18.0.0` so existing consumers are not broken by an engines bump.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @stagepass/cli@2
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or without a global install:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @stagepass/cli@2 setup
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
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+ at runtime (`engines.node`); use Node 22 or 24 for local development and CI
|
|
25
|
+
- Homebrew
|
|
26
|
+
|
|
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).
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
Recommended order:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
stagepass setup
|
|
35
|
+
stagepass start
|
|
36
|
+
|
|
37
|
+
# inside your project folder
|
|
38
|
+
stagepass link my-project --origin www.example.com --origin my-project.webflow.io
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Your project is then available at `https://my-project.sp`. Success output:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
Linked: https://my-project.sp -> /absolute/path/to/project
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
| Command | Description |
|
|
50
|
+
| :--- | :--- |
|
|
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 background Caddy & PHP services. Migrates legacy Caddyfile blocks if needed. |
|
|
53
|
+
| `stagepass link [domain]` | Link the current directory to a `.sp` domain, write/update the Caddyfile + `~/.stagepass/projects.json`, reload Caddy. |
|
|
54
|
+
| `stagepass unlink [domain]` | Remove the site block and `projects.json` entry, reload Caddy. |
|
|
55
|
+
| `stagepass reload` | Reload Caddy configuration. Migrates legacy Caddyfile blocks if needed. |
|
|
56
|
+
| `stagepass stop` | Stop background services. Prints a hint when login autostart is enabled. |
|
|
57
|
+
| `stagepass doctor` | Read-only diagnostics (Homebrew, Caddy, PHP/php-fpm, dnsmasq, resolver, port 443, Caddyfile, projects, certs, LaunchAgent). Never uses sudo. `--json` available. Exit `1` if any fail. |
|
|
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
|
+
| `stagepass certs trust` | Run `caddy trust` after interactive confirmation (or `--yes`). |
|
|
60
|
+
| `stagepass autostart on\|off\|status` | Manage a user LaunchAgent (`io.github.arobertherz.stagepass`) that runs `stagepass daemon` at login. |
|
|
61
|
+
| `stagepass daemon` | Non-interactive foreground helper for the LaunchAgent (certs check log-only, then `caddy run`). Never uses sudo. |
|
|
62
|
+
| `stagepass new [name]` | Scaffold a lean Webflow project (TypeScript + SCSS by default). |
|
|
63
|
+
| `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 upgrade` | Bump `@stagepass/*` in the current `package.json` and print Webflow snippets. |
|
|
66
|
+
|
|
67
|
+
All commands support `-v, --verbose` where applicable.
|
|
68
|
+
|
|
69
|
+
### Doctor / certificates / autostart
|
|
70
|
+
|
|
71
|
+
- `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 (doctor warns if recommended snippets would use `@latest`).
|
|
73
|
+
- 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` inside `stagepass start`). If port 443 cannot be bound, `daemon` logs a clear error and exits `0` so launchd KeepAlive does not restart-loop. Use interactive `stagepass start` to resolve conflicts.
|
|
75
|
+
- Manual macOS checklist: [`TESTING-macos.md`](./TESTING-macos.md).
|
|
76
|
+
|
|
77
|
+
### `new` options
|
|
78
|
+
|
|
79
|
+
Scaffold a project with flags for every choice (interactive prompts only on a TTY without `--yes`):
|
|
80
|
+
|
|
81
|
+
| Option | Behaviour |
|
|
82
|
+
| :--- | :--- |
|
|
83
|
+
| `--dir <dir>` | Target directory (default: `./<name>`). |
|
|
84
|
+
| `--author <name>` | `package.json` author (default: `git config user.name`). |
|
|
85
|
+
| `--lang ts\|js` | Language (default: `ts`). |
|
|
86
|
+
| `--styles scss\|css` | Styles (default: `scss`). |
|
|
87
|
+
| `--modules` / `--no-modules` | Include `@stagepass/modules` (default: yes). |
|
|
88
|
+
| `--git` / `--no-git` | `git init` (default: yes). |
|
|
89
|
+
| `--remote <url>` | Set `origin` after git init (rejects URLs with embedded credentials). |
|
|
90
|
+
| `--install` / `--no-install` | Run `npm install` (default: no). |
|
|
91
|
+
| `-y, --yes` | Non-interactive; use defaults for omitted flags. |
|
|
92
|
+
| `--dry-run` | Print the file plan without writing. |
|
|
93
|
+
|
|
94
|
+
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` with `loader/dist/loader.min.js` and optional `modules/dist/{inject,cookies}.min.js`; also document `all` / `maintenance`), and an `AGENTS.md` with safe development rules.
|
|
95
|
+
|
|
96
|
+
### `upgrade` options
|
|
97
|
+
|
|
98
|
+
| Option | Behaviour |
|
|
99
|
+
| :--- | :--- |
|
|
100
|
+
| `--version <x>` | Target version (default: this CLI version from its `package.json`). Dist-tags such as `latest` resolve via `npm view`. (Implemented as `--target` internally so it does not collide with `stagepass --version`.) |
|
|
101
|
+
| `--dry-run` | Show changes without writing `package.json`. |
|
|
102
|
+
|
|
103
|
+
Only `package.json` is modified. `npm install` is printed, not run. Snippets use the major pin `@2` plus an optional exact pin note.
|
|
104
|
+
|
|
105
|
+
### Domain argument (`link` / `unlink`)
|
|
106
|
+
|
|
107
|
+
- Optional. When omitted, defaults to the **current folder name**.
|
|
108
|
+
- Values are lowercased; accidental `https://` and trailing `/` are stripped.
|
|
109
|
+
- The `.sp` suffix is **always** applied (pass `my-project` or `my-project.sp`).
|
|
110
|
+
- Labels must be DNS-safe (`[a-z0-9]`, inner hyphens). When derived from a folder and invalid, the CLI slugifies and prints a dim notice.
|
|
111
|
+
- Explicit invalid domains are rejected (nothing is written).
|
|
112
|
+
|
|
113
|
+
### `link` options
|
|
114
|
+
|
|
115
|
+
| Option | Behaviour |
|
|
116
|
+
| :--- | :--- |
|
|
117
|
+
| `--origin <host>` | Allow CORS from this live hostname (**repeatable**). Merges into the stored list (deduped). |
|
|
118
|
+
| `--remove-origin <host>` | Remove a previously stored CORS hostname (**repeatable**). |
|
|
119
|
+
| `--allow-all-origins` | Enable `Access-Control-Allow-Origin: *` (prints a security warning). Prefer `--origin`. |
|
|
120
|
+
| `--no-allow-all-origins` | Disable allow-all mode and use the origin allowlist. |
|
|
121
|
+
| `-v, --verbose` | Show Caddy reload output / errors. |
|
|
122
|
+
|
|
123
|
+
**`--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.
|
|
124
|
+
|
|
125
|
+
If Caddy reload fails after a successful write, the CLI warns and suggests `stagepass start`.
|
|
126
|
+
|
|
127
|
+
Examples:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
stagepass link my-project --origin www.example.com --origin example.com
|
|
131
|
+
stagepass link my-project --origin my-project.webflow.io
|
|
132
|
+
stagepass link my-project --remove-origin old.example.com
|
|
133
|
+
stagepass link my-project --no-allow-all-origins
|
|
134
|
+
stagepass link my-project --allow-all-origins # emergency / legacy compatibility only
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Re-running `stagepass link` keeps stored origins / allow-all setting unless you change them with flags. Omitting both `--allow-all-origins` and `--no-allow-all-origins` leaves the stored value unchanged. New projects default to `allowAllOrigins: false`.
|
|
138
|
+
|
|
139
|
+
If `projects.json` is missing an entry but a v2 Caddyfile block exists, CORS options are restored from the `# stagepass-options:` marker instead of being reset.
|
|
140
|
+
|
|
141
|
+
## Security
|
|
142
|
+
|
|
143
|
+
Linked sites are hardened automatically:
|
|
144
|
+
|
|
145
|
+
### Blocked paths (always)
|
|
146
|
+
|
|
147
|
+
These always return **404** (including `OPTIONS`), including with `--allow-all-origins`, and never reach PHP or `file_server`:
|
|
148
|
+
|
|
149
|
+
- Any path segment starting with `.` (covers `.git`, `.env`, `.env.local`, `.DS_Store`, `.ssh`, `.npmrc`, …)
|
|
150
|
+
- `node_modules/`
|
|
151
|
+
- Extensions: `.pem`, `.key`, `.p12`, `.pfx`, `.crt`, `.cer`, `.sqlite`, `.db`, `.log`
|
|
152
|
+
|
|
153
|
+
### CORS (cross-origin embedding)
|
|
154
|
+
|
|
155
|
+
Stagepass reflects `Access-Control-Allow-Origin` for **allowed** browser `Origin` values (no credentials):
|
|
156
|
+
|
|
157
|
+
**Default allowlist (always on):**
|
|
158
|
+
|
|
159
|
+
- `https://*.sp`
|
|
160
|
+
- `http(s)://localhost[:port]` and `http(s)://127.0.0.1[:port]`
|
|
161
|
+
- Per-project live domains from `--origin` / `~/.stagepass/projects.json`
|
|
162
|
+
|
|
163
|
+
Webflow staging/live hosts are **not** included by default. Add them per project, e.g. `--origin my-project.webflow.io`. An explicit `--origin *.webflow.io` (or `*.webflow.com`) is accepted but prints a warning (any Webflow user's site would then be allowed).
|
|
164
|
+
|
|
165
|
+
Matching responses also send `Vary: Origin`. Preflight (`OPTIONS`) for allowed origins returns `204` with reflected ACAO, `Access-Control-Allow-Methods: GET, HEAD, POST, OPTIONS`, reflected `Access-Control-Allow-Headers`, `Access-Control-Max-Age: 86400`, and `Access-Control-Allow-Private-Network: true` (Chrome Private Network Access from public HTTPS → loopback).
|
|
166
|
+
|
|
167
|
+
Non-matching origins get **no** ACAO. Non-allowlisted `OPTIONS` still get `204` without CORS headers.
|
|
168
|
+
|
|
169
|
+
### Domain & path validation
|
|
170
|
+
|
|
171
|
+
- Domains are lowercased, must be DNS-safe labels, and always end with `.sp`. Invalid folder names are slugified when the domain is omitted.
|
|
172
|
+
- Project roots refuse `/`, your home directory, and common system roots (`/Users`, `/System`, `/Library`, …). Paths are escaped for the Caddyfile.
|
|
173
|
+
|
|
174
|
+
### Project config
|
|
175
|
+
|
|
176
|
+
Per-domain settings live in `~/.stagepass/projects.json`:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"version": 1,
|
|
181
|
+
"projects": {
|
|
182
|
+
"my-project.sp": {
|
|
183
|
+
"root": "/Users/you/Sites/my-project",
|
|
184
|
+
"origins": ["www.example.com"],
|
|
185
|
+
"allowAllOrigins": false
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Migration from older CLI versions
|
|
192
|
+
|
|
193
|
+
On `stagepass link`, `reload`, and `start`, legacy Caddyfile blocks (no `# stagepass-block: v2` marker) are upgraded automatically:
|
|
194
|
+
|
|
195
|
+
1. A timestamped backup is written once: `~/.stagepass/Caddyfile.bak-YYYYMMDD-HHMMSS`
|
|
196
|
+
2. Blocks are rewritten with path blocking + the version marker
|
|
197
|
+
3. **`allowAllOrigins` is enabled** for migrated blocks so existing Webflow / live-domain embedding keeps working
|
|
198
|
+
4. A short notice recommends tightening CORS
|
|
199
|
+
|
|
200
|
+
Recommended after migration:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
stagepass link --origin www.example.com
|
|
204
|
+
stagepass link --no-allow-all-origins
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
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).
|
|
208
|
+
|
|
209
|
+
## Related Packages
|
|
210
|
+
|
|
211
|
+
- `@stagepass/loader`: browser runtime for swapping production assets.
|
|
212
|
+
- `@stagepass/modules`: optional runtime modules (`inject`, `cookies`).
|
|
213
|
+
|
|
214
|
+
## Repository
|
|
215
|
+
|
|
216
|
+
- Docs and full setup: [stagepass repository](https://github.com/arobertherz/stagepass)
|
package/TESTING-macos.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# macOS manual checklist (CLI operations)
|
|
2
|
+
|
|
3
|
+
Use this after installing a local build of `@stagepass/cli` on macOS with Homebrew.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node 18+ on PATH
|
|
8
|
+
- Homebrew installed
|
|
9
|
+
- A throwaway project folder (example: `~/Sites/my-project`)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g . # from repo packages/cli, or use npx against the workspace build
|
|
13
|
+
stagepass setup
|
|
14
|
+
stagepass link my-project --origin my-project.webflow.io
|
|
15
|
+
stagepass start
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## doctor
|
|
19
|
+
|
|
20
|
+
- [ ] `stagepass doctor` prints ok/warn/fail lines and a summary
|
|
21
|
+
- [ ] Exit code is `0` when there are no fails; `1` when any fail
|
|
22
|
+
- [ ] `stagepass doctor --json` prints valid JSON with `checks` and `summary`
|
|
23
|
+
- [ ] Missing Homebrew / Caddy / PHP / dnsmasq surfaces as fail (temporarily rename binaries to verify)
|
|
24
|
+
- [ ] Missing `/etc/resolver/sp` surfaces as fail
|
|
25
|
+
- [ ] Port 443 section reports the listener (or warns if empty / permission denied). Doctor must never ask for sudo
|
|
26
|
+
- [ ] Linked project whose folder was deleted surfaces as fail
|
|
27
|
+
- [ ] Chrome Local Network Access hint is printed
|
|
28
|
+
- [ ] CDN check reports recommended snippets use `@2` (not `@latest`)
|
|
29
|
+
|
|
30
|
+
## certs
|
|
31
|
+
|
|
32
|
+
- [ ] `stagepass certs check` reports root path under `~/Library/Application Support/Caddy/pki/authorities/local/root.crt`
|
|
33
|
+
- [ ] Warns when root expires in under 90 days (use a lab machine or mock if needed)
|
|
34
|
+
- [ ] Reports System keychain trust status for "Caddy Local Authority"
|
|
35
|
+
- [ ] Orphaned old Caddy roots are listed with SHA-1 and SHA-256 (never deleted by the CLI)
|
|
36
|
+
- [ ] Optional TLS handshake lines appear for each linked `.sp` domain while Caddy is running
|
|
37
|
+
- [ ] `stagepass certs check --json` works
|
|
38
|
+
- [ ] `stagepass certs trust` asks for confirmation; declining does nothing
|
|
39
|
+
- [ ] `stagepass certs trust --yes` runs `caddy trust`
|
|
40
|
+
- [ ] After trust, Safari / Chrome / Firefox show a valid certificate for `https://my-project.sp`
|
|
41
|
+
- [ ] There is **no** `certs renew` command in 2.1.0
|
|
42
|
+
|
|
43
|
+
## autostart / daemon
|
|
44
|
+
|
|
45
|
+
- [ ] `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
|
|
47
|
+
- [ ] Plist has `RunAtLoad` and `KeepAlive` / `SuccessfulExit` false
|
|
48
|
+
- [ ] Logs appear under `~/.stagepass/logs/`
|
|
49
|
+
- [ ] After logout/login (or `launchctl bootstrap`), daemon starts Caddy via `caddy run`
|
|
50
|
+
- [ ] `stagepass stop` still stops services; when autostart is on it prints a hint that login may restart Caddy
|
|
51
|
+
- [ ] `stagepass autostart off` boots out the agent and removes the plist
|
|
52
|
+
- [ ] If port 443 cannot be bound, daemon logs a clear message and exits `0` (no KeepAlive restart-loop; not a silent success)
|
|
53
|
+
- [ ] Cold-start daemon logs cert root/trust only (no TLS handshake attempts before `caddy run`)
|
|
54
|
+
|
|
55
|
+
## Regression (must stay unchanged)
|
|
56
|
+
|
|
57
|
+
- [ ] `stagepass start` / `stop` / `link` / `unlink` / `reload` / `setup` behave as in 2.0.0
|
|
58
|
+
- [ ] No dependency major upgrades required for these commands
|
package/bin/index.js
CHANGED
|
@@ -1,79 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import { setup } from '../src/commands/setup.js';
|
|
6
|
-
import { link } from '../src/commands/link.js';
|
|
7
|
-
import { unlink } from '../src/commands/unlink.js';
|
|
8
|
-
import { start } from '../src/commands/start.js';
|
|
9
|
-
import { stop } from '../src/commands/stop.js';
|
|
10
|
-
import { reload } from '../src/commands/reload.js';
|
|
3
|
+
import { createProgram, rewriteArgvForUpgrade } from '../src/cli.js';
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
.name('stagepass')
|
|
14
|
-
.description('The missing link between Webflow and local dev.')
|
|
15
|
-
.version('1.0.0');
|
|
16
|
-
|
|
17
|
-
// Command: SETUP
|
|
18
|
-
program
|
|
19
|
-
.command('setup')
|
|
20
|
-
.description('Install dependencies (Caddy, PHP, Dnsmasq) and configure .sp domain')
|
|
21
|
-
.option('-v, --verbose', 'Show detailed installation logs')
|
|
22
|
-
.action(async (options) => {
|
|
23
|
-
try {
|
|
24
|
-
await setup(options);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(chalk.red('\nSetup failed.'));
|
|
27
|
-
if (options.verbose) console.error(error);
|
|
28
|
-
else console.error(chalk.dim('Run with -v for details.'));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Command: LINK
|
|
33
|
-
program
|
|
34
|
-
.command('link')
|
|
35
|
-
.description('Link current directory to a .sp domain')
|
|
36
|
-
.argument('[domain]', 'Domain name (optional)')
|
|
37
|
-
.option('-v, --verbose', 'Show Caddy reload output')
|
|
38
|
-
.action(async (domain, options) => {
|
|
39
|
-
await link(domain, options);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Command: UNLINK
|
|
43
|
-
program
|
|
44
|
-
.command('unlink')
|
|
45
|
-
.description('Unlink current directory from .sp domain')
|
|
46
|
-
.argument('[domain]', 'Domain name (optional, defaults to current folder name)')
|
|
47
|
-
.option('-v, --verbose', 'Show Caddy reload output')
|
|
48
|
-
.action(async (domain, options) => {
|
|
49
|
-
await unlink(domain, options);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Command: RELOAD
|
|
53
|
-
program
|
|
54
|
-
.command('reload')
|
|
55
|
-
.description('Reload Caddy configuration')
|
|
56
|
-
.option('-v, --verbose', 'Show Caddy reload output')
|
|
57
|
-
.action(async (options) => {
|
|
58
|
-
await reload(options);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Command: START
|
|
62
|
-
program
|
|
63
|
-
.command('start')
|
|
64
|
-
.description('Start background services (Caddy & PHP)')
|
|
65
|
-
.option('-v, --verbose', 'Show detailed Caddy server logs')
|
|
66
|
-
.action(async (options) => {
|
|
67
|
-
await start(options);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Command: STOP
|
|
71
|
-
program
|
|
72
|
-
.command('stop')
|
|
73
|
-
.description('Stop all background services')
|
|
74
|
-
.option('-v, --verbose', 'Show detailed stop logs')
|
|
75
|
-
.action(async (options) => {
|
|
76
|
-
await stop(options);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
program.parse(process.argv);
|
|
5
|
+
createProgram().parse(rewriteArgvForUpgrade(process.argv));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stagepass/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Local Development Orchestrator for Webflow",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
12
|
-
"src"
|
|
12
|
+
"src/cli.js",
|
|
13
|
+
"src/commands/*.js",
|
|
14
|
+
"src/lib/*.js",
|
|
15
|
+
"templates",
|
|
16
|
+
"README.md",
|
|
17
|
+
"TESTING-macos.md",
|
|
18
|
+
"LICENSE"
|
|
13
19
|
],
|
|
14
20
|
"scripts": {
|
|
15
21
|
"start": "node bin/index.js",
|
|
@@ -42,9 +48,9 @@
|
|
|
42
48
|
"sudo-prompt": "^9.2.1"
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
45
|
-
"vitest": "^
|
|
51
|
+
"vitest": "^5.0.5"
|
|
46
52
|
},
|
|
47
53
|
"engines": {
|
|
48
54
|
"node": ">=18.0.0"
|
|
49
55
|
}
|
|
50
|
-
}
|
|
56
|
+
}
|