@stagepass/cli 2.4.0 → 2.5.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.
@@ -1,8 +1,16 @@
1
1
  import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { buildWebflowSnippets } from './snippets.js';
4
- import { CURSOR_RULE_PATH, buildCursorRule, buildManagedBlock } from './ai-guide.js';
4
+ import {
5
+ CURSOR_RULE_PATH,
6
+ STAGEPASS_AGENTS_REL,
7
+ buildAgentsPointerBlock,
8
+ buildCursorRule,
9
+ buildStagepassGuide,
10
+ renderStagepassAgentsFile,
11
+ } from './ai-guide.js';
5
12
  import { typesForModules } from './project-modules.js';
13
+ import { SNIPPET_LOADER_VERSION } from './cdn-base.js';
6
14
  import { LOADER_VERSION, packagesRange } from './versions.js';
7
15
 
8
16
  const __filename = fileURLToPath(import.meta.url);
@@ -70,6 +78,7 @@ export function scaffoldPhpTemplateMap(options = {}) {
70
78
  { template: 'api/lib/validate.php', out: 'api/lib/validate.php' },
71
79
  { template: 'api/env.example', out: 'api/.env.example' },
72
80
  { template: 'php-private/config.php', out: '.php/config.php' },
81
+ { template: 'htaccess', out: '.htaccess' },
73
82
  ];
74
83
  }
75
84
 
@@ -178,7 +187,7 @@ export function buildStagepassExtraLines(options) {
178
187
  * @returns {Promise<{ relativePath: string, contents: string }[]>}
179
188
  */
180
189
  export async function planScaffoldFiles(options, deps = {}) {
181
- const version = options.loaderVersion || LOADER_VERSION;
190
+ const version = options.loaderVersion || SNIPPET_LOADER_VERSION;
182
191
  const isTs = options.lang === 'ts';
183
192
  const useSass = options.styles === 'scss';
184
193
  const entryJs = isTs ? 'src/main.ts' : 'src/main.js';
@@ -191,6 +200,9 @@ export async function planScaffoldFiles(options, deps = {}) {
191
200
  const snippets = buildWebflowSnippets({
192
201
  version,
193
202
  moduleList: siteModules,
203
+ gitRemote: options.git ? options.remote || '' : '',
204
+ gitBranch: options.git ? 'main' : '',
205
+ projectName: options.name,
194
206
  });
195
207
  const types = typesForModules(siteModules, {
196
208
  modulesDependency: options.modules === true,
@@ -206,10 +218,12 @@ export async function planScaffoldFiles(options, deps = {}) {
206
218
  ORIGIN_LINE: buildStagepassExtraLines(options),
207
219
  TYPES_JSON: JSON.stringify(types),
208
220
  TYPES_INLINE: JSON.stringify(types).replace(/","/g, '", "'),
209
- STAGEPASS_BLOCK: buildManagedBlock(siteModules),
221
+ STAGEPASS_BLOCK: buildAgentsPointerBlock(),
210
222
  LOADER_VERSION: version,
211
223
  HEAD_SNIPPET: snippets.head,
212
224
  FOOTER_SNIPPET: snippets.footer,
225
+ ASSET_EXAMPLE_URL: snippets.assetExampleUrl,
226
+ ASSET_URL_HINT: snippets.assetHint,
213
227
  ENTRY_JS: entryJs,
214
228
  ENTRY_CSS: entryCss,
215
229
  USE_SASS: useSass ? 'true' : 'false',
@@ -222,7 +236,8 @@ export async function planScaffoldFiles(options, deps = {}) {
222
236
  '## PHP',
223
237
  '',
224
238
  `PHP is on. Caddy serves \`https://${options.name}.sp/api/action.php\` with \`php_fastcgi\`.`,
225
- 'Read `api/README.md`. Copy `api/.env.example` to `.env` (do not commit it) and set `ALLOWED_ORIGINS` to exact origins, including that `.sp` URL.',
239
+ 'Read `api/README.md` and the PHP section of `AGENTS.stagepass.md`. Copy `api/.env.example` to `.env` in the project root (do not commit it) and set `ALLOWED_ORIGINS` to exact origins, including that `.sp` URL. From Webflow, call the PHP host with its absolute URL, not `window.location.origin`.',
240
+ 'Apache uses the project `.htaccess`. nginx needs the snippet in `api/README.md` before the PHP location.',
226
241
  '',
227
242
  ].join('\n')
228
243
  : [
@@ -263,7 +278,27 @@ export async function planScaffoldFiles(options, deps = {}) {
263
278
 
264
279
  // Generated in code (not a template): npm drops dotfiles and dot folders
265
280
  // are easy to lose in the published package.
266
- files.push({ relativePath: CURSOR_RULE_PATH, contents: buildCursorRule(siteModules) });
281
+ files.push({
282
+ relativePath: STAGEPASS_AGENTS_REL,
283
+ contents: renderStagepassAgentsFile(
284
+ buildStagepassGuide({
285
+ name: options.name,
286
+ domain: `${options.name}.sp`,
287
+ modules: siteModules,
288
+ php,
289
+ phpBoilerplate: php,
290
+ lang: options.lang,
291
+ origin: options.origin || null,
292
+ production: options.production || null,
293
+ configFile,
294
+ types,
295
+ modulesDependency: options.modules === true,
296
+ })
297
+ ),
298
+ });
299
+ if (options.cursorRule === true) {
300
+ files.push({ relativePath: CURSOR_RULE_PATH, contents: buildCursorRule() });
301
+ }
267
302
 
268
303
  return files;
269
304
  }
@@ -1,5 +1,25 @@
1
- import { normalizeModulesList } from './project-modules.js';
2
- import { LOADER_VERSION, MODULES_VERSION } from './versions.js';
1
+ import { execFile as nodeExecFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import {
4
+ SNIPPET_LOADER_VERSION,
5
+ SNIPPET_MODULES_VERSION,
6
+ stagepassPackageUrl,
7
+ } from './cdn-base.js';
8
+ import { validateProjectName } from './project-name.js';
9
+ import { expandModules, normalizeModulesList } from './project-modules.js';
10
+
11
+ const execFileAsync = promisify(nodeExecFile);
12
+
13
+ /** Same body as snippet versions, without the optional ^/~ range prefix. */
14
+ const SNIPPET_TOKEN_BODY = '[0-9A-Za-z][0-9A-Za-z._+-]*';
15
+ const SNIPPET_VERSION_RE = new RegExp(`^[~^]?${SNIPPET_TOKEN_BODY}$`);
16
+ const SNIPPET_TOKEN_RE = new RegExp(`^${SNIPPET_TOKEN_BODY}$`);
17
+
18
+ const GITHUB_HTTPS_RE =
19
+ /^https?:\/\/(?:www\.)?github\.com(?::\d+)?\/([^/?#\s]+)\/([^/?#\s]+?)(?:\.git)?\/?(?:[?#].*)?$/i;
20
+ const GITHUB_SSH_URL_RE =
21
+ /^ssh:\/\/(?:git@)?github\.com(?::\d+)?\/([^/?#\s]+)\/([^/?#\s]+?)(?:\.git)?\/?$/i;
22
+ const GITHUB_SCP_RE = /^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/i;
3
23
 
4
24
  /**
5
25
  * Safe token for CDN pins and data-stagepass-version (blocks HTML/attr injection).
@@ -8,8 +28,7 @@ import { LOADER_VERSION, MODULES_VERSION } from './versions.js';
8
28
  */
9
29
  export function sanitizeSnippetVersion(version) {
10
30
  const value = String(version == null ? '' : version).trim();
11
- // Allow optional ^/~ range prefixes used in package.json; reject quotes and HTML.
12
- if (!/^[~^]?[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value)) {
31
+ if (!SNIPPET_VERSION_RE.test(value)) {
13
32
  throw new Error(
14
33
  'Invalid version for Webflow snippets (use a semver or npm dist-tag).'
15
34
  );
@@ -18,16 +37,145 @@ export function sanitizeSnippetVersion(version) {
18
37
  }
19
38
 
20
39
  /**
21
- * Build recommended Webflow Custom Code snippets (jsDelivr major pin @2).
40
+ * Owner/repo token. Same character rules as {@link sanitizeSnippetVersion}.
41
+ * @param {unknown} value
42
+ * @returns {string}
43
+ */
44
+ export function sanitizeSnippetToken(value) {
45
+ const token = String(value == null ? '' : value).trim();
46
+ if (!SNIPPET_TOKEN_RE.test(token)) {
47
+ throw new Error(
48
+ 'Invalid name for Webflow snippets (owner and repo must be plain tokens).'
49
+ );
50
+ }
51
+ return token;
52
+ }
53
+
54
+ /**
55
+ * @param {unknown} remote
56
+ * @returns {{ owner: string, repo: string } | null}
57
+ */
58
+ function parseGitHubRemote(remote) {
59
+ const value = String(remote == null ? '' : remote).trim();
60
+ if (!value) return null;
61
+
62
+ const match =
63
+ GITHUB_HTTPS_RE.exec(value) ||
64
+ GITHUB_SSH_URL_RE.exec(value) ||
65
+ GITHUB_SCP_RE.exec(value);
66
+ const githubShaped =
67
+ /^(?:https?:\/\/(?:www\.)?github\.com(?::\d+)?(?:\/|$)|ssh:\/\/(?:git@)?github\.com(?::\d+)?(?:\/|$)|git@github\.com:)/i.test(
68
+ value
69
+ );
70
+ if (!match) {
71
+ if (githubShaped && /[<>"'`\\\s]/.test(value)) {
72
+ throw new Error(
73
+ 'Invalid name for Webflow snippets (owner and repo must be plain tokens).'
74
+ );
75
+ }
76
+ return null;
77
+ }
78
+
79
+ let owner = match[1];
80
+ let repo = match[2];
81
+ try {
82
+ owner = decodeURIComponent(owner);
83
+ repo = decodeURIComponent(repo);
84
+ } catch {
85
+ throw new Error(
86
+ 'Invalid name for Webflow snippets (owner and repo must be plain tokens).'
87
+ );
88
+ }
89
+ return {
90
+ owner: sanitizeSnippetToken(owner),
91
+ repo: sanitizeSnippetToken(repo),
92
+ };
93
+ }
94
+
95
+ // Missing or unsafe branch names fall back to main (slashes are allowed).
96
+ function safeBranch(branch) {
97
+ const value = String(branch == null ? '' : branch).trim();
98
+ if (!value || value === 'HEAD') return 'main';
99
+ if (!/^[0-9A-Za-z][0-9A-Za-z._+/-]*$/.test(value)) return 'main';
100
+ if (value.includes('..') || value.includes('//') || value.endsWith('/')) return 'main';
101
+ return value;
102
+ }
103
+
104
+ /**
105
+ * @param {object} [options]
106
+ * @param {unknown} [options.gitRemote]
107
+ * @param {unknown} [options.gitBranch]
108
+ * @param {unknown} [options.projectName]
109
+ */
110
+ function describeProjectAssets(options = {}) {
111
+ const parsed = parseGitHubRemote(options.gitRemote);
112
+ if (!parsed) {
113
+ const name = validateProjectName(options.projectName);
114
+ const segment = name.ok ? name.name : 'project';
115
+ return {
116
+ kind: 'placeholder',
117
+ js: 'https://YOUR-PRODUCTION-URL/js/main.js',
118
+ css: 'https://YOUR-PRODUCTION-URL/css/styles.css',
119
+ exampleJs: `https://YOUR-PRODUCTION-URL/${segment}/main.a1b2c3d4.js`,
120
+ hint: 'Replace YOUR-PRODUCTION-URL with the host that serves your production assets.',
121
+ };
122
+ }
123
+ const branch = safeBranch(options.gitBranch);
124
+ const base = `https://cdn.jsdelivr.net/gh/${parsed.owner}/${parsed.repo}@${branch}`;
125
+ return {
126
+ kind: 'github',
127
+ js: `${base}/dist/main.js`,
128
+ css: `${base}/dist/styles.css`,
129
+ exampleJs: `${base}/dist/main.a1b2c3d4.js`,
130
+ 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.',
131
+ };
132
+ }
133
+
134
+ /**
135
+ * @param {{ kind: string, js: string, css: string }} assets
136
+ * @returns {string}
137
+ */
138
+ function footerFor(assets) {
139
+ const notes =
140
+ assets.kind === 'github'
141
+ ? [
142
+ '<!-- jsDelivr only serves public repos. A tag is a better production pin than a branch. -->',
143
+ '<!-- After `npm run build`, commit the dist folder, or check dist/manifest.json for hashed file names. -->',
144
+ ]
145
+ : [
146
+ '<!-- Replace YOUR-PRODUCTION-URL with the host that serves your production assets. -->',
147
+ '<!-- After `npm run build`, check dist/manifest.json for hashed file names. -->',
148
+ ];
149
+ return [
150
+ ...notes,
151
+ '<script',
152
+ ` data-src="${assets.js}"`,
153
+ ' data-stagepass="true"',
154
+ ' data-stagepass-path="dist/main.js"',
155
+ '></script>',
156
+ '<link',
157
+ ' rel="stylesheet"',
158
+ ` data-href="${assets.css}"`,
159
+ ' data-stagepass="true"',
160
+ ' data-stagepass-path="dist/styles.css"',
161
+ '>',
162
+ ].join('\n');
163
+ }
164
+
165
+ /**
166
+ * Build recommended Webflow Custom Code snippets (major pin @2).
22
167
  *
23
168
  * @param {object} options
24
169
  * @param {string} options.version Exact package version for data-stagepass-version / docs
25
170
  * @param {boolean} [options.modules] Legacy: true = inject + cookies tags
26
171
  * @param {string[]} [options.moduleList] Declared modules (wins over `modules`)
27
- * @returns {{ head: string, footer: string, majorPin: string, exactPin: string }}
172
+ * @param {string} [options.gitRemote] `origin` URL. GitHub https/ssh becomes a jsDelivr `/gh/` URL.
173
+ * @param {string} [options.gitBranch] Current branch. Missing or unsafe values use `main`.
174
+ * @param {string} [options.projectName] Used in the README placeholder example path.
175
+ * @returns {{ head: string, footer: string, majorPin: string, exactPin: string, assetExampleUrl: string, assetHint: string }}
28
176
  */
29
177
  export function buildWebflowSnippets(options) {
30
- const version = sanitizeSnippetVersion(options.version || LOADER_VERSION);
178
+ const version = sanitizeSnippetVersion(options.version || SNIPPET_LOADER_VERSION);
31
179
  /** @type {string[]} */
32
180
  let moduleFiles = [];
33
181
  if (Array.isArray(options.moduleList)) {
@@ -39,45 +187,105 @@ export function buildWebflowSnippets(options) {
39
187
  }
40
188
  const majorPin = '@2';
41
189
  const exactPin = `@${version}`;
190
+ const assets = describeProjectAssets(options);
42
191
 
43
192
  const loaderLines = [
44
193
  '<!-- Stagepass loader (major pin @2; optional exact pin shown in data-stagepass-version) -->',
45
194
  '<script',
46
- ` src="https://cdn.jsdelivr.net/npm/@stagepass/loader${majorPin}/dist/loader.min.js"`,
195
+ ` src="${stagepassPackageUrl('loader', majorPin, 'loader.min.js')}"`,
47
196
  ` data-stagepass-version="${version}"`,
48
197
  '></script>',
49
198
  ];
50
199
 
51
200
  for (const id of moduleFiles) {
52
201
  loaderLines.push(
53
- `<script src="https://cdn.jsdelivr.net/npm/@stagepass/modules${majorPin}/dist/${id}.min.js"></script>`
202
+ `<script src="${stagepassPackageUrl('modules', majorPin, `${id}.min.js`)}"></script>`
54
203
  );
55
204
  }
56
205
 
57
- const footerLines = [
58
- '<!-- Project assets: production URLs in data-src / data-href; local paths for Stagepass -->',
59
- '<!-- After `npm run build`, check dist/manifest.json for content-hashed filenames. -->',
60
- '<script',
61
- ' data-src="https://cdn.example.com/js/main.js"',
62
- ' data-stagepass="true"',
63
- ' data-stagepass-path="dist/main.js"',
64
- '></script>',
65
- '<link',
66
- ' rel="stylesheet"',
67
- ' data-href="https://cdn.example.com/css/styles.css"',
68
- ' data-stagepass="true"',
69
- ' data-stagepass-path="dist/styles.css"',
70
- '>',
71
- ];
72
-
73
206
  return {
74
207
  head: loaderLines.join('\n'),
75
- footer: footerLines.join('\n'),
208
+ footer: footerFor(assets),
76
209
  majorPin,
77
210
  exactPin,
211
+ assetExampleUrl: assets.exampleJs,
212
+ assetHint: assets.hint,
78
213
  };
79
214
  }
80
215
 
216
+ /**
217
+ * Head snippet for the loader and the declared modules. Used by `stagepass start`.
218
+ * `all` expands to inject, cookies, maintenance, in that order. An empty list is the loader only.
219
+ * @param {object} [options]
220
+ * @param {string} [options.version]
221
+ * @param {string[]} [options.moduleList] Declared modules (`[]` when none)
222
+ */
223
+ export function buildOfficialHeadSnippets(options = {}) {
224
+ const raw = Array.isArray(options.moduleList) ? options.moduleList : [];
225
+ const parsed = normalizeModulesList(raw);
226
+ if (!parsed.ok) throw new Error(parsed.error);
227
+ return buildWebflowSnippets({
228
+ version: options.version,
229
+ moduleList: expandModules(parsed.modules),
230
+ });
231
+ }
232
+
233
+ /**
234
+ * `origin` URL and current branch for footer asset URLs. Empty remote if git is missing.
235
+ * @param {string} cwd
236
+ * @param {import('./exec.js').ExecFn} [exec]
237
+ * @returns {Promise<{ gitRemote: string, gitBranch: string }>}
238
+ */
239
+ export async function readSnippetGitRef(cwd, exec) {
240
+ const gitRemote = await gitText(cwd, ['remote', 'get-url', 'origin'], exec);
241
+ // symbolic-ref and branch --show-current still work on an unborn branch
242
+ // (no commits yet). rev-parse --abbrev-ref HEAD does not.
243
+ let gitBranch = await gitText(cwd, ['symbolic-ref', '--short', 'HEAD'], exec);
244
+ if (!gitBranch) gitBranch = await gitText(cwd, ['branch', '--show-current'], exec);
245
+ if (!gitBranch || gitBranch === 'HEAD') gitBranch = 'main';
246
+ return { gitRemote, gitBranch };
247
+ }
248
+
249
+ /**
250
+ * @param {string} cwd
251
+ * @param {string[]} args
252
+ * @param {import('./exec.js').ExecFn} [exec]
253
+ * @returns {Promise<string>}
254
+ */
255
+ async function gitText(cwd, args, exec) {
256
+ try {
257
+ const result = exec
258
+ ? await exec('git', args, { cwd })
259
+ : await execFileAsync('git', args, {
260
+ cwd,
261
+ encoding: 'utf8',
262
+ timeout: 5000,
263
+ maxBuffer: 64 * 1024,
264
+ });
265
+ return String(result?.stdout || '').trim();
266
+ } catch {
267
+ return '';
268
+ }
269
+ }
270
+
271
+ function logExactPin(log, snippets) {
272
+ const loader = String(snippets?.exactPin || '').replace(/^@/, '') || SNIPPET_LOADER_VERSION;
273
+ log(
274
+ `\nOptional exact pin example (instead of @2): loader @${loader}, modules @${SNIPPET_MODULES_VERSION}.`
275
+ );
276
+ }
277
+
278
+ /**
279
+ * Print the loader/modules head snippet.
280
+ * @param {{ head: string }} snippets
281
+ * @param {(msg: string) => void} [log]
282
+ */
283
+ export function printWebflowHeadSnippets(snippets, log = console.log) {
284
+ log('\nWebflow Custom Code (Head):');
285
+ log(snippets.head);
286
+ logExactPin(log, snippets);
287
+ }
288
+
81
289
  /**
82
290
  * Print head/footer snippets with section labels.
83
291
  * @param {{ head: string, footer: string }} snippets
@@ -88,7 +296,5 @@ export function printWebflowSnippets(snippets, log = console.log) {
88
296
  log(snippets.head);
89
297
  log('\nWebflow Custom Code (Footer):');
90
298
  log(snippets.footer);
91
- log(
92
- `\nOptional exact pin example (instead of @2): loader @${LOADER_VERSION}, modules @${MODULES_VERSION}.`
93
- );
299
+ logExactPin(log, snippets);
94
300
  }
@@ -2,11 +2,13 @@
2
2
  * Versions of @stagepass/loader and @stagepass/modules this CLI targets.
3
3
  *
4
4
  * Values come from the generated `package-versions.js` (run
5
- * `node scripts/sync-cli-versions.mjs`). Used for docs and snippet examples.
6
- * Dependency ranges never come from the CLI version: new projects use the
7
- * major range (`^2`) and `stagepass upgrade` only writes ranges a published
8
- * version satisfies. A drift test keeps the generated file in sync with
9
- * packages/loader and packages/modules.
5
+ * `node scripts/sync-cli-versions.mjs`). They track the monorepo packages.
6
+ * Snippet exact pins do not use them: those live in `cdn-base.js`
7
+ * (`SNIPPET_LOADER_VERSION`, `SNIPPET_MODULES_VERSION`). Dependency ranges
8
+ * never come from the CLI version: new projects use the major range (`^2`)
9
+ * and `stagepass upgrade` only writes ranges a published version satisfies.
10
+ * A drift test keeps the generated file in sync with packages/loader and
11
+ * packages/modules.
10
12
  */
11
13
 
12
14
  import { LOADER_VERSION, MODULES_VERSION } from './package-versions.js';
@@ -14,9 +16,8 @@ import { LOADER_VERSION, MODULES_VERSION } from './package-versions.js';
14
16
  export { LOADER_VERSION, MODULES_VERSION };
15
17
 
16
18
  /**
17
- * @deprecated Prefer `LOADER_VERSION` for loader snippets / pins /
18
- * `data-stagepass-version`, and `MODULES_VERSION` where modules are meant.
19
- * Kept as an alias of `LOADER_VERSION` for older call sites and tests.
19
+ * @deprecated Alias of `LOADER_VERSION` for older call sites and tests.
20
+ * Snippet pins use `SNIPPET_LOADER_VERSION` in `cdn-base.js`.
20
21
  */
21
22
  export const STAGEPASS_PACKAGES_VERSION = LOADER_VERSION;
22
23
 
@@ -1,40 +1,7 @@
1
1
  # {{NAME}} (Stagepass project)
2
2
 
3
- Profile for AI coding agents and humans working on this Webflow + Stagepass project.
3
+ Local Webflow project. Stagepass rules for `src/`, `api/`, and Webflow code are in `AGENTS.stagepass.md`.
4
4
 
5
- ## Stagepass feature set
6
-
7
- - **CLI:** local `.sp` HTTPS domains (Caddy), DNS, optional PHP, `link` / `unlink` / `start` / `stop` / `reload`, plus `doctor` / `certs` / `autostart` / `daemon` and project helpers `new` / `build` / `watch` / `upgrade`
8
- - **Loader:** swaps tagged production assets for local URLs when a session is active (`?stagepass={{NAME}}.sp`)
9
- - **Session:** `localStorage` JSON `{ domain, expires }` (default 12 h)
10
- - **Modules (optional):** separate script tags after `loader.min.js`: `inject`, `cookies`, `maintenance`, or `all`. This project declares the modules its Webflow site loads in `stagepass.json` (`modules`); the API reference below only covers those.
11
- - **Runtime API:** use `sp` (see "Stagepass runtime API" below)
12
- - **CDN:** Prefer jsDelivr with major pin `@2` (exact pin optional), e.g. `https://cdn.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js`. unpkg serves the same paths if you need an alternative CDN.
13
-
14
- ## Safe development rules (beginners)
15
-
16
- 1. **No secrets in frontend code.** API keys, tokens, and passwords must never ship in JS/CSS served to the browser.
17
- 2. **No `innerHTML` with untrusted data.** Prefer `textContent`, `createElement`, or trusted, sanitized markup only.
18
- 3. **No `eval` or string-built scripts** with user or CMS input.
19
- 4. **Pin versions** for production embeds (`@2` major pin, or an exact pin when you need a lockstep deploy).
20
- 5. **Review before publishing.** Read the diff for asset tags, CORS origins, and anything that touches live Webflow Custom Code.
21
- 6. **Keep Stagepass tags intact.** Use `data-src` / `data-href` + `data-stagepass` (+ optional `data-stagepass-path`) so production users keep production URLs.
22
- 7. **Do not commit secrets.** Keep `.env*` out of git (see `.gitignore`).
23
- 8. **PHP (if enabled):** never hard-code secrets; read them from the environment. Keep proxy allowlists exact-host and https-only.
24
-
25
- ## Local workflow
26
-
27
- ```bash
28
- npm run watch
29
- # or: npm run dev (alias of watch)
30
- stagepass start
31
- stagepass link {{NAME}}
32
- ```
33
-
34
- `stagepass.json` stores staging as `origin` ({{STAGING_HOST}}) and optional `production`. `link` without `--origin` uses those hosts. Then open `https://{{STAGING_HOST}}/?stagepass={{NAME}}.sp`.
35
-
36
- ## Types
37
-
38
- `{{CONFIG_FILE}}` lists `types: {{TYPES_INLINE}}`, generated from `stagepass.json`. Modules that are not declared have no types, so the editor flags `sp.<module>` calls that would fail on the live site. After enabling a module (Webflow script tag + `stagepass.json`), run `stagepass upgrade`.
5
+ ## Notes
39
6
 
40
7
  {{STAGEPASS_BLOCK}}
@@ -61,13 +61,15 @@ After each production upload, set `data-src` / `data-href` to your hosted URLs.
61
61
 
62
62
  Use those values on production tags (and keep `crossorigin="anonymous"` when the asset host sends CORS headers):
63
63
 
64
+ {{ASSET_URL_HINT}}
65
+
64
66
  ```html
65
67
  <script
66
- src="https://cdn.example.com/{{NAME}}/main.a1b2c3d4.js"
68
+ src="{{ASSET_EXAMPLE_URL}}"
67
69
  integrity="sha384-..."
68
70
  crossorigin="anonymous"
69
71
  data-stagepass
70
- data-src="https://cdn.example.com/{{NAME}}/main.a1b2c3d4.js"
72
+ data-src="{{ASSET_EXAMPLE_URL}}"
71
73
  data-stagepass-path="/dist/main.js"
72
74
  ></script>
73
75
  ```