@stagepass/cli 2.6.0 → 2.7.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
@@ -73,7 +73,7 @@ All commands support `-v, --verbose` where applicable.
73
73
  ### Doctor / certificates / autostart
74
74
 
75
75
  - `doctor` and `certs check` are read-only. They never delete keychain items or certificate files.
76
- - CLI 2.6.0 (not yet published) generates Webflow snippets on `https://cdn.stagepass.one` with exact pins and full file paths. `stagepass new --cdn jsdelivr` keeps the jsDelivr major pin `@2`. Doctor warns on unpinned CDN URLs on that host, on jsDelivr, and on existing unpkg (`@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).
76
+ - Unreleased CLI changes generate Webflow snippets on `https://cdn.stagepass.one` with the major aliases `loader@2` / `modules@2` (no `data-stagepass-version`). Exact pins remain documented. `stagepass new --cdn jsdelivr` keeps the jsDelivr major pin `@2`. Doctor warns on unpinned CDN URLs on that host, on jsDelivr, and on existing unpkg (`@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).
77
77
  - `certs renew` 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`.
78
78
  - Chrome may require Local Network Access permission for public HTTPS pages that load `https://*.sp` assets.
79
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`.
@@ -122,13 +122,13 @@ Scaffold a project with flags for every choice (interactive prompts only on a TT
122
122
  | `--remote <url>` | Set `origin` after git init (rejects URLs with embedded credentials). |
123
123
  | `--cursor-rule` | Write `.cursor/rules/stagepass.mdc` even when the target has no `.cursor/` directory. Without this flag the rule is written only if `.cursor/` already exists. |
124
124
  | `--install` / `--no-install` | Run `npm install` (default: no). |
125
- | `--cdn stagepass\|jsdelivr` | CDN for generated Webflow snippets, stored as `cdn` in `stagepass.json` (default: `stagepass`, exact pins on `https://cdn.stagepass.one`). `stagepass upgrade` reads it back. CLI 2.6.0 (not yet published). |
125
+ | `--cdn stagepass\|jsdelivr` | CDN for generated Webflow snippets, stored as `cdn` in `stagepass.json` (default: `stagepass`, major alias `@2` on `https://cdn.stagepass.one`). The wizard does not ask; pass `--cdn jsdelivr` to opt in. `stagepass upgrade` reads it back. |
126
126
  | `-y, --yes` | Non-interactive; use defaults for omitted flags. |
127
127
  | `--dry-run` | Print the file plan without writing. |
128
128
 
129
- 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 (Stagepass CDN first, exact pins, full file path, no `/dist/` segment; pass `--cdn jsdelivr` for the jsDelivr major pin `@2` alternative), `stagepass.json`, `AGENTS.stagepass.md` (the CLI-owned guide), a short pointer in `AGENTS.md`, and a `.gitignore`. `.cursor/rules/stagepass.mdc` (`alwaysApply: true`, pointer to `@AGENTS.stagepass.md`) is written only when the target already has a `.cursor/` directory or you pass `--cursor-rule`. `@stagepass/loader` / `@stagepass/modules` are added as `^2` (same major as the jsDelivr pin `@2`; the Stagepass CDN default uses an exact pin; npm installs the newest published 2.x). CLI 2.6.0 (not yet published). 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`.
129
+ 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 (Stagepass CDN first, major alias `@2`, no `data-stagepass-version`; pass `--cdn jsdelivr` for the jsDelivr alternative), `stagepass.json`, `AGENTS.stagepass.md` (the CLI-owned guide), a short pointer in `AGENTS.md`, and a `.gitignore`. `.cursor/rules/stagepass.mdc` (`alwaysApply: true`, pointer to `@AGENTS.stagepass.md`) is written only when the target already has a `.cursor/` directory or you pass `--cursor-rule`. `@stagepass/loader` / `@stagepass/modules` are added as `^2` (same major as the CDN pin `@2`; npm installs the newest published 2.x). Prefer `stagepass build`, `stagepass watch` and `stagepass dev` over calling the npm scripts directly. 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`.
130
130
 
131
- 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). Without a TTY (or with `--yes`) it uses `--site-modules`, then `--site` detection, else `[]` with a hint. The interactive wizard always asks for the snippet CDN (`stagepass` first, or `jsdelivr`) unless `--cdn` was passed, and whether to enable PHP unless `--php` / `--no-php` was passed. Staging / production prompts, `--staging` detection, and `link` reading `origin` / `production` from `stagepass.json` are part of this release.
131
+ 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). Without a TTY (or with `--yes`) it uses `--site-modules`, then `--site` detection, else `[]` with a hint. The interactive wizard defaults to the Stagepass CDN (no CDN question; pass `--cdn jsdelivr` to opt in) and asks whether to enable PHP unless `--php` / `--no-php` was passed. Staging / production prompts accept pasted `http(s)://` URLs (normalised to the hostname). `--staging` / `--production` and `link` reading `origin` / `production` from `stagepass.json` share that normalisation.
132
132
 
133
133
  ### PHP
134
134
 
@@ -160,7 +160,7 @@ location ~* /\.(?!well-known\/) {
160
160
 
161
161
  Both rules were tested on 12 November 2026 on php:8.2-apache (`AllowOverride All`, `a2enmod rewrite`) and on nginx 1.27 with php:8.2-fpm. `/.env`, `/.php/config.php`, `/api/.env.example`, and `/.git/HEAD` returned HTTP 403, with no secret or config leak. `/api/action.php?action=ping` returned HTTP 200, `{"status":"success","data":{"pong":true},"message":null}`. `/.well-known/test.txt` returned HTTP 200, body `well-known-ok`. `/.well-known/` as a directory with no index file returned HTTP 403 on both servers (no DirectoryIndex). Visible files under `/.well-known/` stay reachable. CLI 2.4.0 and older still need these rules added by hand. Since 2.4.1 the Apache rule ships in the PHP scaffold, and `stagepass upgrade` writes a missing project `.htaccess` when `"php": true` ([quYArF43](https://trello.com/c/quYArF43)). nginx still needs the snippet on the host.
162
162
 
163
- `stagepass dev` / `watch` serve PHP from the project root, so edits show up on the next request. When `"php": true`, `stagepass dev` also watches `api/` and `.php/` and reloads the browser on that same live-reload stream and debounce as `dist/`. It ignores `.env`, `.php/.env`, `.php/rate-limit/`, logs, pid files, key, certificate, and database files (`.pem`, `.key`, `.p12`, `.pfx`, `.crt`, `.cer`, `.sqlite`, `.db`), and editor temp files (`~`, `.swp`, `.DS_Store`). A missing `api/` or `.php/` does not stop the command. The start log names those directories. Without `"php": true` live reload stays on the output directory. From the folder that contains `api/`, `php -S 127.0.0.1:8080 -t .` matches `/api/action.php`. `php -S` does not apply Caddy's hidden-path 404. Do not point it at a folder that already contains a real `.env`. Prefer `stagepass dev` or the linked `.sp` domain. `sp.resolveLocalUrl` returns a URL only during an active `.sp` session. On Webflow, `window.location.origin` is the Webflow host, which does not run PHP. Fetch the absolute PHP host, for example `https://php.example.com/api/action.php`. `rate_limit_allows()` logs storage faults (directory, file, `flock`, or a thrown error). The response is HTTP 503, JSend `error`, `Retry-After: 60`, and no internals, unless `APP_ENV` is `local`, `development`, or `dev` (trimmed, any case). Empty, unset, and every other value stay closed. A limit hit stays HTTP 429. `client_ip()` uses `REMOTE_ADDR` unless that peer is in `TRUSTED_PROXIES`, then reads `TRUSTED_PROXY_HEADER` (`x-forwarded-for` or RFC 7239 `forwarded`) from right to left. This applies to projects created with CLI 2.5.0. CLI 2.4.1 and older stay fail-open and use only `REMOTE_ADDR`. `stagepass upgrade` does not change `api/`. Copy `api/lib/security.php`, `api/lib/request.php`, `api/lib/config.php`, `.php/config.php`, and `api/action.php` from a new scaffold, or re-scaffold. [sgt7wKlT](https://trello.com/c/sgt7wKlT). `stagepass upgrade` does not add the `api/` or `.php/` boilerplate. When `"php": true` and the project root has no `.htaccess`, it writes the shipped template (same bytes as `stagepass new --php`). An existing `.htaccess` is left unchanged. If that file has no `RewriteRule "(^|/)\." - [F]` line, upgrade prints a hint and still exits 0. CLI 2.4.0 and older do not write that file. The website guide is live at [https://stagepass.one/docs/php/](https://stagepass.one/docs/php/) (source outline: [docs/php.md](https://github.com/arobertherz/stagepass/blob/master/docs/php.md)).
163
+ `stagepass dev` / `watch` serve PHP from the project root, so edits show up on the next request. When `"php": true`, `stagepass dev` also watches `api/` and `.php/` and reloads the browser on that same live-reload stream and debounce as `dist/`. It ignores `.env`, `.php/.env`, `.php/rate-limit/`, logs, pid files, key, certificate, and database files (`.pem`, `.key`, `.p12`, `.pfx`, `.crt`, `.cer`, `.sqlite`, `.db`), and editor temp files (`~`, `.swp`, `.DS_Store`). A missing `api/` or `.php/` does not stop the command. The start log names those directories. Without `"php": true` live reload stays on the output directory. From the folder that contains `api/`, `php -S 127.0.0.1:8080 -t .` matches `/api/action.php`. `php -S` does not apply Caddy's hidden-path 404. Do not point it at a folder that already contains a real `.env`. Prefer `stagepass dev` or the linked `.sp` domain. `sp.resolveLocalUrl` returns a URL only during an active `.sp` session. On Webflow, `window.location.origin` is the Webflow host, which does not run PHP. Fetch the absolute PHP host, for example `https://php.example.com/api/action.php`. `rate_limit_allows()` logs storage faults (directory, file, `flock`, or a thrown error). The response is HTTP 503, JSend `error`, `Retry-After: 60`, and no internals, unless `APP_ENV` is `local`, `development`, or `dev` (trimmed, any case). Empty, unset, and every other value stay closed. A limit hit stays HTTP 429. `client_ip()` uses `REMOTE_ADDR` unless that peer is in `TRUSTED_PROXIES`, then reads `TRUSTED_PROXY_HEADER` (`x-forwarded-for` or RFC 7239 `forwarded`) from right to left. This applies to projects created with CLI 2.5.0. CLI 2.4.1 and older stay fail-open and use only `REMOTE_ADDR`. `stagepass upgrade` does not change `api/`. Copy `api/lib/security.php`, `api/lib/request.php`, `api/lib/config.php`, `.php/config.php`, and `api/action.php` from a new scaffold, or re-scaffold. [sgt7wKlT](https://trello.com/c/sgt7wKlT). `stagepass upgrade` does not add the `api/` or `.php/` boilerplate. When `"php": true` and the project root has no `.htaccess`, it writes the shipped template (same bytes as `stagepass new --php`). An existing `.htaccess` is left unchanged. If that file has no `RewriteRule "(^|/)\." - [F]` line, upgrade prints a hint and still exits 0. CLI 2.4.0 and older do not write that file. The website guide is live at [https://stagepass.one/docs/php/](https://stagepass.one/docs/php/) (source outline: [docs/php.md](https://github.com/stagepass-one/os/blob/master/docs/php.md)).
164
164
 
165
165
  ### Declared modules (`stagepass.json`)
166
166
 
@@ -181,7 +181,7 @@ The legacy boolean `"modules": true|false` is still read; `upgrade` replaces it
181
181
 
182
182
  `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:
183
183
 
184
- - the Stagepass CDN (`cdn.stagepass.one`) first: full file paths such as `/loader@2.5.0/loader.min.js` and short aliases such as `/loader@2.5.0` (no `/dist/` segment). jsDelivr (`cdn.jsdelivr.net/npm/`) and existing unpkg (`unpkg.com/`) tags are still recognised so current sites keep working: 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. Recommended new embeds use `https://cdn.stagepass.one` (full file path, no `/dist/` segment).
184
+ - the Stagepass CDN (`cdn.stagepass.one`) first: full file paths such as `/loader@2.5.1/loader.min.js` and short aliases such as `/loader@2.5.1` (no `/dist/` segment). jsDelivr (`cdn.jsdelivr.net/npm/`) and existing unpkg (`unpkg.com/`) tags are still recognised so current sites keep working: 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. Recommended new embeds use `https://cdn.stagepass.one` (full file path, no `/dist/` segment).
185
185
  - 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.
186
186
 
187
187
  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.
@@ -219,7 +219,7 @@ Since 2.5.0, when the editor reports `Cannot find name 'sp'` and the page still
219
219
  2. `npm install`
220
220
  3. In the editor command palette: `TypeScript: Restart TS Server`.
221
221
 
222
- Every change is printed as `file: action` (unchanged files are not listed; skipped files appear as hints). `npm install` is printed, not run. CLI 2.6.0 (not yet published) prints snippets on the Stagepass CDN with an exact pin, plus a jsDelivr alternative line. With `"cdn": "jsdelivr"` the snippets use the major pin `@2` and an optional exact pin note.
222
+ Every change is printed as `file: action` (unchanged files are not listed; skipped files appear as hints). `npm install` is printed, not run. Default snippets use the Stagepass CDN major alias `@2` (no jsDelivr alternative line in CLI output). With `"cdn": "jsdelivr"` the snippets use the jsDelivr major pin `@2` and an optional exact pin note. A concrete `production` host in `stagepass.json` fills footer `data-src` / `data-href`.
223
223
 
224
224
  ### Domain argument (`link` / `unlink`)
225
225
 
@@ -350,4 +350,4 @@ The v3 block needs Caddy 2.9 or newer (`brew upgrade caddy`). Homebrew does not
350
350
 
351
351
  ## Repository
352
352
 
353
- - Docs and full setup: [stagepass repository](https://github.com/arobertherz/stagepass)
353
+ - Docs and full setup: [stagepass repository](https://github.com/stagepass-one/os)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stagepass/cli",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Local Development Orchestrator for Webflow",
5
5
  "type": "module",
6
6
  "main": "bin/index.js",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "repository": {
37
37
  "type": "git",
38
- "url": "https://github.com/arobertherz/stagepass.git",
38
+ "url": "https://github.com/stagepass-one/os.git",
39
39
  "directory": "packages/cli"
40
40
  },
41
41
  "license": "MIT",
@@ -85,6 +85,9 @@ export async function link(domain, options = {}, deps = {}) {
85
85
  return 1;
86
86
  }
87
87
  originsFromFlags = check.origins;
88
+ for (const host of check.normalised || []) {
89
+ log(`Using ${host}`);
90
+ }
88
91
  for (const entry of check.origins) {
89
92
  if (isBroadWebflowWildcard(entry)) {
90
93
  log(
@@ -102,6 +105,9 @@ export async function link(domain, options = {}, deps = {}) {
102
105
  log(chalk.red(`❌ Invalid --remove-origin: ${check.error}`));
103
106
  return 1;
104
107
  }
108
+ for (const host of check.normalised || []) {
109
+ log(`Using ${host}`);
110
+ }
105
111
  }
106
112
 
107
113
  let allowAllOriginsFlag;
@@ -81,7 +81,11 @@ export function parseOriginFlag(raw, label) {
81
81
  if (!check.ok) {
82
82
  return { ok: false, error: `Invalid --${label}: ${check.error}` };
83
83
  }
84
- return { ok: true, value: check.value };
84
+ return {
85
+ ok: true,
86
+ value: check.value,
87
+ ...(check.normalised ? { normalised: true } : {}),
88
+ };
85
89
  }
86
90
 
87
91
  /**
@@ -221,11 +225,13 @@ export async function resolveNewOptions(nameArg, options = {}, deps = {}) {
221
225
  };
222
226
  }
223
227
  origin = check.value;
228
+ if (check.normalised) log(`Using ${check.value}`);
224
229
  }
225
230
  if (options.production != null && String(options.production) !== '') {
226
231
  const check = parseOriginFlag(String(options.production), 'production');
227
232
  if (!check.ok) return check;
228
233
  production = check.value;
234
+ if (check.normalised) log(`Using ${check.value}`);
229
235
  } else if (
230
236
  Object.prototype.hasOwnProperty.call(options, 'production') &&
231
237
  (options.production === '' || options.production == null) &&
@@ -292,6 +298,7 @@ export async function resolveNewOptions(nameArg, options = {}, deps = {}) {
292
298
  const check = validateOriginEntry(raw);
293
299
  if (check.ok) {
294
300
  origin = check.value;
301
+ if (check.normalised) log(`Using ${check.value}`);
295
302
  if (isBroadWebflowWildcard(origin)) {
296
303
  log(
297
304
  chalk.yellow(
@@ -310,6 +317,7 @@ export async function resolveNewOptions(nameArg, options = {}, deps = {}) {
310
317
  const check = validateOriginEntry(raw);
311
318
  if (check.ok) {
312
319
  production = check.value;
320
+ if (check.normalised) log(`Using ${check.value}`);
313
321
  if (isBroadWebflowWildcard(production)) {
314
322
  log(
315
323
  chalk.yellow(
@@ -341,32 +349,7 @@ export async function resolveNewOptions(nameArg, options = {}, deps = {}) {
341
349
  else log(chalk.yellow(` ${parsed.error}`));
342
350
  }
343
351
  }
344
- if (!cdn) {
345
- // Bound retries: an invalid answer (for example "n" after y/N prompts)
346
- // must not spin forever and grow memory.
347
- const maxAttempts = 5;
348
- let attempts = 0;
349
- while (!cdn) {
350
- const raw = await ask(
351
- rl,
352
- 'CDN for Webflow snippets (stagepass | jsdelivr)',
353
- 'stagepass'
354
- );
355
- const parsed = normalizeCdnChoice(raw);
356
- if (parsed) {
357
- cdn = parsed;
358
- break;
359
- }
360
- attempts += 1;
361
- log(chalk.yellow(' Use stagepass (cdn.stagepass.one) or jsdelivr.'));
362
- if (attempts >= maxAttempts) {
363
- return {
364
- ok: false,
365
- error: 'Invalid --cdn: use stagepass (default) or jsdelivr.',
366
- };
367
- }
368
- }
369
- }
352
+ // CDN defaults to Stagepass (cdn.stagepass.one). Use --cdn jsdelivr to opt in.
370
353
  if (php === undefined) {
371
354
  php = await askYesNo(rl, 'Enable PHP for this project?', false);
372
355
  }
@@ -877,7 +860,7 @@ export async function createNew(nameArg, options = {}, deps = {}) {
877
860
  if (!config.install) {
878
861
  log(` cd ${path.relative(cwd, targetDir) || '.'} && npm install`);
879
862
  }
880
- log(' npm run build');
863
+ log(' stagepass build');
881
864
  if (config.origin || config.production) {
882
865
  log(` stagepass link ${config.name}`);
883
866
  } else {
@@ -893,6 +876,7 @@ export async function createNew(nameArg, options = {}, deps = {}) {
893
876
  const snippets = buildWebflowSnippets({
894
877
  version: config.loaderVersion,
895
878
  moduleList: config.siteModules,
879
+ production: config.production,
896
880
  gitRemote: config.git ? config.remote || '' : '',
897
881
  gitBranch: config.git ? 'main' : '',
898
882
  projectName: config.name,
@@ -532,9 +532,12 @@ export async function upgrade(options = {}, deps = {}) {
532
532
  try {
533
533
  const readGitRef = deps.readGitRef || readSnippetGitRef;
534
534
  const gitRef = await readGitRef(cwd);
535
+ const production =
536
+ sp.data && typeof sp.data.production === 'string' ? sp.data.production : '';
535
537
  snippets = buildWebflowSnippets({
536
538
  version: snippetVersion,
537
539
  moduleList: resolved.modules,
540
+ production,
538
541
  gitRemote: gitRef && gitRef.gitRemote,
539
542
  gitBranch: gitRef && gitRef.gitBranch,
540
543
  projectName: pkg.name,
@@ -91,7 +91,7 @@ if (sp.can('localStorage')) localStorage.setItem('seen', '1');
91
91
  const MODULE_SECTIONS = {
92
92
  inject: `### Module: inject (\`sp.inject\`)
93
93
 
94
- Loads extra scripts and stylesheets. Webflow script tag: \`https://cdn.stagepass.one/modules@${SNIPPET_MODULES_VERSION}/inject.min.js\` after \`loader.min.js\`.
94
+ Loads extra scripts and stylesheets. Webflow script tag: \`https://cdn.stagepass.one/modules@2/inject.min.js\` after the loader (exact pin optional: \`modules@${SNIPPET_MODULES_VERSION}/inject.min.js\`).
95
95
 
96
96
  \`\`\`ts
97
97
  if (sp.inject) {
@@ -105,7 +105,7 @@ Argument: one options object, an array of them, or \`{ scripts?, styles? }\`. Re
105
105
  Options: \`src\` (required), \`type\` (\`'script' \\| 'style'\`), \`stagepass\` (default true: during a session the file is served from the local project via \`localPath\`/\`path\` or the file name; \`false\` always uses \`src\`), \`localPath\`, \`path\`, \`id\`, \`async\`, \`defer\`, \`version\` (adds \`?v=\` in production), \`attributes\`, \`position\` (\`'head' \\| 'body-start' \\| 'body-end' \\| { target, action: 'before' \\| 'after' }\`), \`integrity\`, \`crossorigin\`, \`nonce\`, \`allowedHosts\`.`,
106
106
  cookies: `### Module: cookies (\`sp.cookies\`, alias \`sp.cookie\`, plus \`sp.consent\`)
107
107
 
108
- Webflow script tag: \`https://cdn.stagepass.one/modules@${SNIPPET_MODULES_VERSION}/cookies.min.js\` after \`loader.min.js\`.
108
+ Webflow script tag: \`https://cdn.stagepass.one/modules@2/cookies.min.js\` after the loader (exact pin optional: \`modules@${SNIPPET_MODULES_VERSION}/cookies.min.js\`).
109
109
 
110
110
  \`\`\`ts
111
111
  if (sp.cookies) {
@@ -126,7 +126,7 @@ Write options: \`days\`, \`maxAge\`, \`path\`, \`domain\`, \`secure\`, \`sameSit
126
126
  Consent: \`allows(category)\`, \`set(fn)\`, \`update()\`.`,
127
127
  maintenance: `### Module: maintenance (\`sp.maintenance\`)
128
128
 
129
- Webflow script tag: \`https://cdn.stagepass.one/modules@${SNIPPET_MODULES_VERSION}/maintenance.min.js\` after \`loader.min.js\` (optional attributes \`data-stagepass-maintenance="true"\`, \`data-stagepass-maintenance-title\`, \`data-stagepass-maintenance-text\`).
129
+ Webflow script tag: \`https://cdn.stagepass.one/modules@2/maintenance.min.js\` after the loader (exact pin optional: \`modules@${SNIPPET_MODULES_VERSION}/maintenance.min.js\`; optional attributes \`data-stagepass-maintenance="true"\`, \`data-stagepass-maintenance-title\`, \`data-stagepass-maintenance-text\`).
130
130
 
131
131
  \`\`\`ts
132
132
  if (sp.maintenance && !sp.maintenance.isActive()) {
@@ -371,7 +371,10 @@ export function buildStagepassGuide(ctx) {
371
371
  const types = Array.isArray(ctx.types) ? ctx.types : ['@stagepass/loader'];
372
372
  const loaderVersion = ctx.loaderVersion || SNIPPET_LOADER_VERSION;
373
373
  const cdnChoice = normalizeCdnChoice(ctx.cdn) || 'stagepass';
374
- const officialLoaderUrl = stagepassPackageUrl(
374
+ const officialLoaderUrl = stagepassPackageUrl('loader', '@2', 'loader.min.js', {
375
+ cdn: 'stagepass',
376
+ });
377
+ const officialExactLoaderUrl = stagepassPackageUrl(
375
378
  'loader',
376
379
  `@${loaderVersion}`,
377
380
  'loader.min.js',
@@ -385,8 +388,8 @@ export function buildStagepassGuide(ctx) {
385
388
  );
386
389
  const cdnLine =
387
390
  cdnChoice === 'jsdelivr'
388
- ? `- **CDN:** This project uses jsDelivr (major pin \`@2\`), for example \`${jsdelivrLoaderUrl}\`. The Stagepass CDN exact pin is the alternative (\`${officialLoaderUrl}\`).`
389
- : `- **CDN:** Stagepass CDN first, exact pin, full file path, no \`/dist/\` segment, for example \`${officialLoaderUrl}\`. jsDelivr is the alternative (\`${jsdelivrLoaderUrl}\`).`;
391
+ ? `- **CDN:** This project uses jsDelivr (major pin \`@2\`), for example \`${jsdelivrLoaderUrl}\`. The Stagepass CDN major alias is the alternative (\`${officialLoaderUrl}\`); exact pin example: \`${officialExactLoaderUrl}\`.`
392
+ : `- **CDN:** Stagepass CDN first, major alias \`@2\` (no \`data-stagepass-version\`), for example \`${officialLoaderUrl}\`. Exact pin when needed: \`${officialExactLoaderUrl}\`. jsDelivr is the documented alternative (\`${jsdelivrLoaderUrl}\`).`;
390
393
  const parts = [
391
394
  `# Stagepass (${name})`,
392
395
  '',
@@ -419,7 +422,7 @@ export function buildStagepassGuide(ctx) {
419
422
  '1. **No secrets in frontend code.** API keys, tokens, and passwords must never ship in JS or CSS served to the browser.',
420
423
  '2. **No `innerHTML` with untrusted data.** Prefer `textContent`, `createElement`, or trusted, sanitized markup.',
421
424
  '3. **No `eval` or string-built scripts** with user or CMS input.',
422
- '4. **Pin versions** for production embeds (exact pin on the Stagepass CDN, or jsDelivr major pin `@2`).',
425
+ '4. **Default embeds use the major alias `@2`.** Exact pin on the Stagepass CDN (full path + optional `data-stagepass-version`) when a specific build must load.',
423
426
  '5. **Review before publishing.** Read the diff for asset tags, CORS origins, and Webflow Custom Code.',
424
427
  '6. **Keep Stagepass tags intact.** Use `data-src` / `data-href` plus `data-stagepass` (and optional `data-stagepass-path`) so production visitors keep production URLs.',
425
428
  '7. **Do not commit secrets.** Keep `.env*` out of git.',
@@ -22,7 +22,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
22
22
  export const BUILD_SCRIPT_REL = 'scripts/build.mjs';
23
23
 
24
24
  export const BUILD_SCRIPT_DOC_URL =
25
- 'https://github.com/arobertherz/stagepass/blob/master/docs/cli.md#upgrade';
25
+ 'https://github.com/stagepass-one/os/blob/master/docs/cli.md#upgrade';
26
26
 
27
27
  export const BUILD_SCRIPT_CUSTOM_HINT = [
28
28
  'scripts/build.mjs has local edits, so stagepass upgrade left it unchanged.',
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Official loader/modules CDN.
3
3
  *
4
- * Default host is https://cdn.stagepass.one: exact pins, full file path,
5
- * no `/dist/` segment. jsDelivr remains an alternative (npm package paths,
6
- * often a major pin, `/dist/` segment). Do not recommend unpkg.
4
+ * Default host is https://cdn.stagepass.one: major alias `@2` (short loader URL,
5
+ * no `data-stagepass-version`). Exact pins (full file path + optional
6
+ * `data-stagepass-version`) stay documented. jsDelivr remains an alternative
7
+ * (npm package paths, major pin, `/dist/` segment). Do not recommend unpkg.
7
8
  */
8
9
  export const STAGEPASS_CDN_ORIGIN = 'https://cdn.stagepass.one';
9
10
  export const STAGEPASS_JSDELIVR_CDN = 'https://cdn.jsdelivr.net/npm';
@@ -11,11 +12,12 @@ export const STAGEPASS_JSDELIVR_CDN = 'https://cdn.jsdelivr.net/npm';
11
12
  export const STAGEPASS_PACKAGE_CDN = STAGEPASS_CDN_ORIGIN;
12
13
 
13
14
  /**
14
- * Published npm versions for snippet exact pins (loader `latest`, modules `latest`).
15
+ * Published npm versions for documented exact-pin examples (loader / modules).
15
16
  * Literals only: not read from the CLI package version, and not copied
16
17
  * automatically when the monorepo is ahead of npm.
18
+ * Default generated snippets use {@link SNIPPET_MAJOR_PIN}, not these.
17
19
  */
18
- export const SNIPPET_LOADER_VERSION = '2.5.0';
20
+ export const SNIPPET_LOADER_VERSION = '2.5.1';
19
21
  export const SNIPPET_MODULES_VERSION = '2.2.2';
20
22
  export const SNIPPET_MAJOR_PIN = '@2';
21
23
 
@@ -32,15 +34,14 @@ export function normalizeCdnChoice(raw) {
32
34
 
33
35
  /**
34
36
  * Pins used in generated Webflow snippets for a CDN host.
35
- * Stagepass CDN uses exact pins from the resolved loader version (the same
36
- * value as `data-stagepass-version`). jsDelivr keeps the major pin `@2`.
37
+ * Stagepass CDN and jsDelivr both default to the major pin `@2`.
37
38
  * @param {unknown} [cdn]
38
- * @param {{ loaderVersion?: string, modulesVersion?: string }} [options]
39
+ * @param {{ loaderVersion?: string, modulesVersion?: string, exact?: boolean }} [options]
39
40
  * @returns {{ cdn: 'stagepass' | 'jsdelivr', loaderPin: string, modulesPin: string }}
40
41
  */
41
42
  export function defaultSnippetPins(cdn, options = {}) {
42
43
  const host = normalizeCdnChoice(cdn) || 'stagepass';
43
- if (host === 'jsdelivr') {
44
+ if (host === 'jsdelivr' || options.exact !== true) {
44
45
  return {
45
46
  cdn: host,
46
47
  loaderPin: SNIPPET_MAJOR_PIN,
@@ -59,14 +60,27 @@ export function defaultSnippetPins(cdn, options = {}) {
59
60
  /**
60
61
  * @param {string} name Package short name (`loader` or `modules`)
61
62
  * @param {string} pin CDN pin including `@` (for example `@2` or `@2.5.0`)
62
- * @param {string} file File under the host path (`loader.min.js`)
63
+ * @param {string} [file] File under the host path (`loader.min.js`). Omitted for
64
+ * the Stagepass CDN major-alias loader short URL (`/loader@2`).
63
65
  * @param {{ cdn?: string }} [options]
64
66
  * @returns {string}
65
67
  */
66
68
  export function stagepassPackageUrl(name, pin, file, options = {}) {
67
69
  const cdn = normalizeCdnChoice(options.cdn) || 'stagepass';
68
70
  if (cdn === 'jsdelivr') {
69
- return `${STAGEPASS_JSDELIVR_CDN}/@stagepass/${name}${pin}/dist/${file}`;
71
+ const distFile = file || (name === 'loader' ? 'loader.min.js' : `${name}.min.js`);
72
+ return `${STAGEPASS_JSDELIVR_CDN}/@stagepass/${name}${pin}/dist/${distFile}`;
73
+ }
74
+ // Short major-alias form for the loader: /loader@2 (no /loader.min.js).
75
+ if (
76
+ pin === SNIPPET_MAJOR_PIN &&
77
+ name === 'loader' &&
78
+ (file == null || file === '' || file === 'loader.min.js')
79
+ ) {
80
+ return `${STAGEPASS_CDN_ORIGIN}/loader${pin}`;
81
+ }
82
+ if (!file) {
83
+ return `${STAGEPASS_CDN_ORIGIN}/${name}${pin}`;
70
84
  }
71
85
  return `${STAGEPASS_CDN_ORIGIN}/${name}${pin}/${file}`;
72
86
  }
@@ -7,7 +7,7 @@ const pins = defaultSnippetPins('stagepass');
7
7
  /**
8
8
  * Canonical CDN embed snippets recommended by Stagepass docs.
9
9
  * Doctor checks these so generated / documented snippets never drift to @latest.
10
- * Default host is the Stagepass CDN with exact pins.
10
+ * Default host is the Stagepass CDN with the major alias `@2`.
11
11
  */
12
12
  export const RECOMMENDED_CDN_SNIPPETS = Object.freeze([
13
13
  stagepassPackageUrl('loader', pins.loaderPin, 'loader.min.js'),
@@ -20,10 +20,11 @@ export const RECOMMENDED_CDN_SNIPPETS = Object.freeze([
20
20
  /**
21
21
  * Unpinned / legacy CDN pins for @stagepass/loader and @stagepass/modules:
22
22
  * - `@latest`
23
- * - bare major `@1` (not `@1.2.0` exact pins)
23
+ * - bare major `@1` (not `@2` or `@1.2.0` exact pins)
24
24
  * - package URL with no `@version` at all
25
25
  *
26
26
  * Matches the Stagepass CDN, jsDelivr, and existing unpkg paths.
27
+ * The current major alias `@2` is the recommended default and is not flagged.
27
28
  */
28
29
  export const UNPINNED_CDN_RE =
29
30
  /(?:cdn\.stagepass\.one\/(?:loader|modules)|(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@stagepass\/(?:loader|modules))(?:@latest|@1(?![0-9.])|(?!@))(?=[/"'?\s]|$)/gi;
@@ -15,6 +15,8 @@ const HOSTNAME_LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
15
15
  const HOST_WHITESPACE_OR_CONTROL_RE = /[\s\x00-\x1f\x7f]/;
16
16
  export const HOST_WHITESPACE_ERROR =
17
17
  'Host must not contain whitespace or control characters.';
18
+ export const ORIGIN_PORT_ERROR =
19
+ 'Origin allowlist is hostname-only (https, no port). Omit the port or use the default https port :443.';
18
20
 
19
21
  /**
20
22
  * Reject hosts / site inputs that contain whitespace or control characters.
@@ -53,14 +55,70 @@ export function isBroadWebflowWildcard(entry) {
53
55
  return entry === '*.webflow.io' || entry === '*.webflow.com';
54
56
  }
55
57
 
58
+ /**
59
+ * Strip a pasted URL (or bare host with path/port) down to a hostname candidate.
60
+ * http(s) only; keeps a leading `*.` wildcard; strips path/query/fragment;
61
+ * strips default HTTPS port `:443` and rejects any other port.
62
+ *
63
+ * @param {string} input Lowercased raw string (no whitespace/controls).
64
+ * @returns {{ ok: true, host: string } | { ok: false, error: string }}
65
+ */
66
+ function extractOriginHostname(input) {
67
+ let raw = input;
68
+
69
+ if (/^[a-z][a-z0-9+.-]*:\/\//.test(raw)) {
70
+ if (raw.startsWith('https://')) {
71
+ raw = raw.slice('https://'.length);
72
+ } else if (raw.startsWith('http://')) {
73
+ // Input convenience only; stored allowlist entries remain https origins.
74
+ raw = raw.slice('http://'.length);
75
+ } else {
76
+ return {
77
+ ok: false,
78
+ error: 'Origin must use http:// or https:// (or a bare hostname).',
79
+ };
80
+ }
81
+ }
82
+
83
+ if (raw.includes('@')) {
84
+ return { ok: false, error: 'Origin must not contain credentials.' };
85
+ }
86
+
87
+ // Host only: drop path, query, and fragment (including a trailing slash).
88
+ const hostPart = raw.split(/[/?#]/, 1)[0];
89
+ if (!hostPart) {
90
+ return { ok: false, error: 'Origin entry is empty.' };
91
+ }
92
+
93
+ // Ports: allow stripping the default HTTPS port; reject any other.
94
+ const lastColon = hostPart.lastIndexOf(':');
95
+ if (lastColon !== -1) {
96
+ // IPv6 is out of scope; a colon means an explicit port on a hostname.
97
+ const maybePort = hostPart.slice(lastColon + 1);
98
+ if (/^\d+$/.test(maybePort)) {
99
+ if (maybePort === '443') {
100
+ return { ok: true, host: hostPart.slice(0, lastColon) };
101
+ }
102
+ return { ok: false, error: ORIGIN_PORT_ERROR };
103
+ }
104
+ return {
105
+ ok: false,
106
+ error: 'Origin must be a hostname (optional leading *.), no path or port.',
107
+ };
108
+ }
109
+
110
+ return { ok: true, host: hostPart };
111
+ }
112
+
56
113
  /**
57
114
  * Validate a single live-domain / origin entry.
58
- * Accepts: example.com | www.example.com | *.example.com | https://example.com
115
+ * Accepts: example.com | www.example.com | *.example.com |
116
+ * https://example.com[/…] | http://example.com[/…] (http is input-only).
59
117
  * Also accepts full Webflow staging hosts (my-project.webflow.io) and explicit
60
118
  * wildcards (*.webflow.io) when passed by the user.
61
119
  *
62
120
  * @param {string} input
63
- * @returns {{ ok: true, value: string } | { ok: false, error: string }}
121
+ * @returns {{ ok: true, value: string, normalised?: boolean } | { ok: false, error: string }}
64
122
  */
65
123
  export function validateOriginEntry(input) {
66
124
  if (typeof input !== 'string' || input === '') {
@@ -70,20 +128,10 @@ export function validateOriginEntry(input) {
70
128
  const ws = rejectWhitespaceOrControls(input, 'Origin');
71
129
  if (!ws.ok) return ws;
72
130
 
73
- let raw = input.toLowerCase();
74
-
75
- // Optional https:// only (http reserved for localhost defaults)
76
- if (raw.startsWith('http://')) {
77
- return { ok: false, error: 'Live origins must use https:// (or a bare hostname).' };
78
- }
79
- if (raw.startsWith('https://')) {
80
- raw = raw.slice('https://'.length);
81
- }
131
+ const extracted = extractOriginHostname(input.toLowerCase());
132
+ if (!extracted.ok) return extracted;
82
133
 
83
- // Reject paths / query / credentials leftovers
84
- if (raw.includes('/') || raw.includes('?') || raw.includes('@') || raw.includes(':')) {
85
- return { ok: false, error: 'Origin must be a hostname (optional leading *.), no path or port.' };
86
- }
134
+ let raw = extracted.host;
87
135
 
88
136
  let wildcard = false;
89
137
  if (raw.startsWith('*.')) {
@@ -106,25 +154,30 @@ export function validateOriginEntry(input) {
106
154
  }
107
155
 
108
156
  const value = wildcard ? `*.${raw}` : raw;
109
- return { ok: true, value };
157
+ const normalised = value !== input.toLowerCase();
158
+ return normalised ? { ok: true, value, normalised: true } : { ok: true, value };
110
159
  }
111
160
 
112
161
  /**
113
162
  * @param {string[]} entries
114
- * @returns {{ ok: true, origins: string[] } | { ok: false, error: string }}
163
+ * @returns {{ ok: true, origins: string[], normalised: string[] } | { ok: false, error: string }}
115
164
  */
116
165
  export function validateOriginList(entries) {
117
166
  const out = [];
167
+ const normalised = [];
118
168
  const seen = new Set();
119
169
  for (const entry of entries || []) {
120
170
  const result = validateOriginEntry(entry);
121
171
  if (!result.ok) return result;
172
+ if (result.normalised && !normalised.includes(result.value)) {
173
+ normalised.push(result.value);
174
+ }
122
175
  if (!seen.has(result.value)) {
123
176
  seen.add(result.value);
124
177
  out.push(result.value);
125
178
  }
126
179
  }
127
- return { ok: true, origins: out };
180
+ return { ok: true, origins: out, normalised };
128
181
  }
129
182
 
130
183
  /**
@@ -5,5 +5,5 @@
5
5
  * Sourced from packages/loader and packages/modules package.json at generate time.
6
6
  * The published CLI ships this snapshot; it cannot read the monorepo at runtime.
7
7
  */
8
- export const LOADER_VERSION = "2.5.1";
9
- export const MODULES_VERSION = "2.2.2";
8
+ export const LOADER_VERSION = "2.5.2";
9
+ export const MODULES_VERSION = "2.2.3";
@@ -204,6 +204,7 @@ export async function planScaffoldFiles(options, deps = {}) {
204
204
  const snippets = buildWebflowSnippets({
205
205
  version,
206
206
  moduleList: siteModules,
207
+ production: options.production,
207
208
  gitRemote: options.git ? options.remote || '' : '',
208
209
  gitBranch: options.git ? 'main' : '',
209
210
  projectName: options.name,
@@ -3,9 +3,12 @@ import { promisify } from 'node:util';
3
3
  import {
4
4
  SNIPPET_LOADER_VERSION,
5
5
  SNIPPET_MODULES_VERSION,
6
+ SNIPPET_MAJOR_PIN,
6
7
  defaultSnippetPins,
8
+ normalizeCdnChoice,
7
9
  stagepassPackageUrl,
8
10
  } from './cdn-base.js';
11
+ import { validateOriginEntry } from './origins.js';
9
12
  import { validateProjectName } from './project-name.js';
10
13
  import { expandModules, normalizeModulesList } from './project-modules.js';
11
14
 
@@ -54,6 +57,20 @@ export function sanitizeSnippetToken(value) {
54
57
  return token;
55
58
  }
56
59
 
60
+ /**
61
+ * Concrete production hostname for footer asset URLs (no wildcard).
62
+ * Accepts a stored hostname or a pasted URL (same rules as #168).
63
+ * @param {unknown} production
64
+ * @returns {string | null}
65
+ */
66
+ function concreteProductionHost(production) {
67
+ if (production == null || String(production) === '') return null;
68
+ // Config may have incidental spaces; CLI flags are validated raw elsewhere.
69
+ const check = validateOriginEntry(String(production).trim());
70
+ if (!check.ok || check.value.startsWith('*.')) return null;
71
+ return check.value;
72
+ }
73
+
57
74
  /**
58
75
  * @param {unknown} remote
59
76
  * @returns {{ owner: string, repo: string } | null}
@@ -106,11 +123,26 @@ function safeBranch(branch) {
106
123
 
107
124
  /**
108
125
  * @param {object} [options]
126
+ * @param {unknown} [options.production]
109
127
  * @param {unknown} [options.gitRemote]
110
128
  * @param {unknown} [options.gitBranch]
111
129
  * @param {unknown} [options.projectName]
112
130
  */
113
131
  function describeProjectAssets(options = {}) {
132
+ const productionHost = concreteProductionHost(options.production);
133
+ if (productionHost) {
134
+ const base = `https://${productionHost}`;
135
+ const name = validateProjectName(options.projectName);
136
+ const segment = name.ok ? name.name : 'project';
137
+ return {
138
+ kind: 'production',
139
+ js: `${base}/js/main.js`,
140
+ css: `${base}/css/styles.css`,
141
+ exampleJs: `${base}/${segment}/main.a1b2c3d4.js`,
142
+ hint: 'After stagepass build, check dist/manifest.json for hashed file names.',
143
+ };
144
+ }
145
+
114
146
  const parsed = parseGitHubRemote(options.gitRemote);
115
147
  if (!parsed) {
116
148
  const name = validateProjectName(options.projectName);
@@ -130,7 +162,7 @@ function describeProjectAssets(options = {}) {
130
162
  js: `${base}/dist/main.js`,
131
163
  css: `${base}/dist/styles.css`,
132
164
  exampleJs: `${base}/dist/main.a1b2c3d4.js`,
133
- hint: 'jsDelivr only serves public repos. A tag is a better production pin than a branch. After npm run build, commit the dist folder, or check dist/manifest.json for hashed file names.',
165
+ hint: 'jsDelivr only serves public repos. A tag is a better production pin than a branch. After stagepass build, commit the dist folder, or check dist/manifest.json for hashed file names.',
134
166
  };
135
167
  }
136
168
 
@@ -139,16 +171,23 @@ function describeProjectAssets(options = {}) {
139
171
  * @returns {string}
140
172
  */
141
173
  function footerFor(assets) {
142
- const notes =
143
- assets.kind === 'github'
144
- ? [
145
- '<!-- jsDelivr only serves public repos. A tag is a better production pin than a branch. -->',
146
- '<!-- After `npm run build`, commit the dist folder, or check dist/manifest.json for hashed file names. -->',
147
- ]
148
- : [
149
- '<!-- Replace YOUR-PRODUCTION-URL with the host that serves your production assets. -->',
150
- '<!-- After `npm run build`, check dist/manifest.json for hashed file names. -->',
151
- ];
174
+ /** @type {string[]} */
175
+ let notes;
176
+ if (assets.kind === 'github') {
177
+ notes = [
178
+ '<!-- jsDelivr only serves public repos. A tag is a better production pin than a branch. -->',
179
+ '<!-- After `stagepass build`, commit the dist folder, or check dist/manifest.json for hashed file names. -->',
180
+ ];
181
+ } else if (assets.kind === 'production') {
182
+ notes = [
183
+ '<!-- After `stagepass build`, check dist/manifest.json for hashed file names. -->',
184
+ ];
185
+ } else {
186
+ notes = [
187
+ '<!-- Replace YOUR-PRODUCTION-URL with the host that serves your production assets. -->',
188
+ '<!-- After `stagepass build`, check dist/manifest.json for hashed file names. -->',
189
+ ];
190
+ }
152
191
  return [
153
192
  ...notes,
154
193
  '<script',
@@ -167,23 +206,27 @@ function footerFor(assets) {
167
206
 
168
207
  /**
169
208
  * Build recommended Webflow Custom Code snippets.
170
- * Default host is the Stagepass CDN with exact pins. Pass `cdn: 'jsdelivr'`
171
- * for the jsDelivr major pin `@2` alternative.
209
+ * Default host is the Stagepass CDN with the major alias `@2` and no
210
+ * `data-stagepass-version`. Pass `cdn: 'jsdelivr'` for the jsDelivr major pin.
211
+ * Pass `exact: true` (with `version`) for a documented Stagepass CDN exact pin.
172
212
  *
173
213
  * @param {object} options
174
- * @param {string} options.version Exact package version for the Stagepass CDN URL pin and data-stagepass-version
214
+ * @param {string} [options.version] Exact semver for jsDelivr `data-stagepass-version` or Stagepass exact pins
215
+ * @param {boolean} [options.exact] Stagepass CDN exact pin (full path + data-stagepass-version)
175
216
  * @param {boolean} [options.modules] Legacy: true = inject + cookies tags
176
217
  * @param {string[]} [options.moduleList] Declared modules (wins over `modules`)
218
+ * @param {string} [options.production] Concrete production host for footer asset URLs
177
219
  * @param {string} [options.gitRemote] `origin` URL. GitHub https/ssh becomes a jsDelivr `/gh/` URL.
178
220
  * @param {string} [options.gitBranch] Current branch. Missing or unsafe values use `main`.
179
221
  * @param {string} [options.projectName] Used in the README placeholder example path.
180
222
  * @param {string} [options.cdn] `stagepass` (default) or `jsdelivr`
181
223
  * @returns {{ head: string, footer: string, majorPin: string, exactPin: string, assetExampleUrl: string, assetHint: string, cdn: string }}
182
224
  */
183
- export function buildWebflowSnippets(options) {
225
+ export function buildWebflowSnippets(options = {}) {
226
+ const exact = options.exact === true;
184
227
  // Fail closed on an explicit unresolvable version (empty or invalid).
185
- // Omitted version falls back to the bundled exact pin, used for both the
186
- // Stagepass CDN URL and data-stagepass-version (single source of truth).
228
+ // Omitted version falls back to the bundled exact-pin literal (jsDelivr
229
+ // data-stagepass-version / documented exact pins only).
187
230
  const version = sanitizeSnippetVersion(
188
231
  options.version == null ? SNIPPET_LOADER_VERSION : options.version
189
232
  );
@@ -196,23 +239,32 @@ export function buildWebflowSnippets(options) {
196
239
  } else if (options.modules === true) {
197
240
  moduleFiles = ['inject', 'cookies'];
198
241
  }
199
- const pins = defaultSnippetPins(options.cdn, { loaderVersion: version });
242
+ const cdnHost = normalizeCdnChoice(options.cdn) || 'stagepass';
243
+ const pins = defaultSnippetPins(cdnHost, {
244
+ loaderVersion: version,
245
+ exact: exact && cdnHost === 'stagepass',
246
+ });
200
247
  const loaderPin = pins.loaderPin;
201
248
  const modulesPin = pins.modulesPin;
202
249
  const exactPin = `@${version}`;
203
250
  const assets = describeProjectAssets(options);
251
+ const useVersionAttr = pins.cdn === 'jsdelivr' || (exact && pins.cdn === 'stagepass');
204
252
  const loaderComment =
205
253
  pins.cdn === 'jsdelivr'
206
254
  ? '<!-- Stagepass loader (jsDelivr major pin @2; optional exact pin shown in data-stagepass-version) -->'
207
- : '<!-- Stagepass loader (Stagepass CDN, exact pin) -->';
255
+ : exact
256
+ ? '<!-- Stagepass loader (Stagepass CDN, exact pin) -->'
257
+ : '<!-- Stagepass loader (Stagepass CDN, major pin @2) -->';
208
258
 
209
259
  const loaderLines = [
210
260
  loaderComment,
211
261
  '<script',
212
262
  ` src="${stagepassPackageUrl('loader', loaderPin, 'loader.min.js', { cdn: pins.cdn })}"`,
213
- ` data-stagepass-version="${version}"`,
214
- '></script>',
215
263
  ];
264
+ if (useVersionAttr) {
265
+ loaderLines.push(` data-stagepass-version="${version}"`);
266
+ }
267
+ loaderLines.push('></script>');
216
268
 
217
269
  for (const id of moduleFiles) {
218
270
  loaderLines.push(
@@ -223,7 +275,7 @@ export function buildWebflowSnippets(options) {
223
275
  return {
224
276
  head: loaderLines.join('\n'),
225
277
  footer: footerFor(assets),
226
- majorPin: loaderPin,
278
+ majorPin: SNIPPET_MAJOR_PIN,
227
279
  exactPin,
228
280
  assetExampleUrl: assets.exampleJs,
229
281
  assetHint: assets.hint,
@@ -237,6 +289,8 @@ export function buildWebflowSnippets(options) {
237
289
  * @param {object} [options]
238
290
  * @param {string} [options.version]
239
291
  * @param {string[]} [options.moduleList] Declared modules (`[]` when none)
292
+ * @param {string} [options.cdn]
293
+ * @param {boolean} [options.exact]
240
294
  */
241
295
  export function buildOfficialHeadSnippets(options = {}) {
242
296
  const raw = Array.isArray(options.moduleList) ? options.moduleList : [];
@@ -246,6 +300,7 @@ export function buildOfficialHeadSnippets(options = {}) {
246
300
  version: options.version,
247
301
  moduleList: expandModules(parsed.modules),
248
302
  cdn: options.cdn,
303
+ exact: options.exact,
249
304
  });
250
305
  }
251
306
 
@@ -288,16 +343,12 @@ async function gitText(cwd, args, exec) {
288
343
  }
289
344
 
290
345
  function logExactPin(log, snippets) {
291
- // exactPin is `@` plus the sanitized version already used in the head snippet.
346
+ // Only when the user opted into jsDelivr: optional exact-pin note.
347
+ // Default Stagepass CDN output does not advertise the jsDelivr alternative.
348
+ if (snippets?.cdn !== 'jsdelivr') return;
292
349
  const loader = String(snippets?.exactPin || '').replace(/^@/, '') || SNIPPET_LOADER_VERSION;
293
- if (snippets?.cdn === 'jsdelivr') {
294
- log(
295
- `\nOptional exact pin example (instead of @2): loader @${loader}, modules @${SNIPPET_MODULES_VERSION}.`
296
- );
297
- return;
298
- }
299
350
  log(
300
- `\njsDelivr alternative (major pin @2): <script src="https://cdn.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js" data-stagepass-version="${loader}"></script>`
351
+ `\nOptional exact pin example (instead of @2): loader @${loader}, modules @${SNIPPET_MODULES_VERSION}.`
301
352
  );
302
353
  }
303
354