@se-studio/site-check 2.25.0 → 2.25.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.25.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [d4ad977]
8
+ - @se-studio/contentful-rest-api@2.9.3
9
+ - @se-studio/core-data-types@2.2.1
10
+ - @se-studio/core-ui@1.48.7
11
+
12
+ ## 2.25.2
13
+
14
+ ### Patch Changes
15
+
16
+ - acd8820: site-check develop-published-gate: the sitemap-parity stage no longer fails on a valid but empty (or absent) `/sitemap-unindexed.xml`; `/sitemap.xml` must still list at least one URL, every listed path must still pass the slug guard, and a 5xx or non-sitemap body on the unindexed file still fails. Also fixes the `--compare-timeout-minutes` header text ("finite and > 0") and moves the end-to-end test setup inside its `try`.
17
+
18
+ core-ui: new `hasStaticAssetExtension(pathname)`, the pathname guard's static-asset list. The site proxy template's `applyCmsRedirects` uses it, so a CMS redirect whose From path contains a dot (`/blog/st.-louis/`) now applies; only static-asset extensions (`.pdf`, `.xml`, `.html`, ...) are skipped.
19
+ - Updated dependencies [acd8820]
20
+ - @se-studio/core-ui@1.48.6
21
+
22
+ ## 2.25.1
23
+
24
+ ### Patch Changes
25
+
26
+ - b65f49f: develop-published-gate: round the compare timeout to whole milliseconds (at least 1) and treat a non-finite `GATE_COMPARE_TIMEOUT_MINUTES` (Infinity, NaN) as unset, so `spawnSync` can no longer throw; an `Infinity` `--compare-timeout-minutes` is a usage error. Adds an end-to-end test of `main` with stubbed fetch, fixes the usage line (`--prod-url` is only needed with `--compare` or `--sitemap-roots`) and the docs and template timeout notes (job timeout above the compare limit). The release rule text in docs, the skills references and the promote-gate message now says a promote needs a green develop-published gate on the exact commit, and the prod compare is a manual run only when Nick asks for one.
27
+
3
28
  ## 2.25.0
4
29
 
5
30
  ### Minor Changes
@@ -11,7 +11,8 @@
11
11
  * Run it from the app root (where smoke.cases.json and vercel.json live).
12
12
  *
13
13
  * Usage:
14
- * develop-published-gate --url <deploymentUrl> --prod-url <productionUrl> [options]
14
+ * develop-published-gate --url <deploymentUrl> --host-prefix <prefix> [options]
15
+ * (--prod-url <productionUrl> is needed only with --compare or --sitemap-roots)
15
16
  *
16
17
  * Options:
17
18
  * --url <url> develop-published deployment URL (or DEPLOYMENT_URL)
@@ -24,7 +25,7 @@
24
25
  * --no-draft-canary skip the canary stage (site has no draft-only page). Without it, giving no
25
26
  * --draft-canary fails the gate. Ignored when a --draft-canary is also given
26
27
  * --compare-timeout-minutes <n> kill the spawned prod compare after n minutes (default 25, or the
27
- * GATE_COMPARE_TIMEOUT_MINUTES env when it is a positive number; the flag wins).
28
+ * GATE_COMPARE_TIMEOUT_MINUTES env when it is finite and > 0; the flag wins).
28
29
  * Only used when --compare is given
29
30
  * --sitemap-roots <list> sitemap roots this app owns, comma-separated paths or absolute URLs on the production
30
31
  * site (e.g. /marketing/sitemap.xml); repeatable. The prod compare walks only these
@@ -40,7 +41,7 @@
40
41
  * --json <file> write the result summary as JSON
41
42
  *
42
43
  * Env: VERCEL_PROTECTION_BYPASS_TOKEN (deployment protection bypass; never printed).
43
- * GATE_COMPARE_TIMEOUT_MINUTES (compare kill limit in minutes, default 25; ignored unless > 0).
44
+ * GATE_COMPARE_TIMEOUT_MINUTES (compare kill limit in minutes, default 25; ignored unless finite and > 0).
44
45
  * Exit 0 only when every stage passes, 1 when a stage fails, 2 on a usage or runtime error.
45
46
  * See docs/develop-published.md.
46
47
  */
@@ -188,12 +189,14 @@ export const COMPARE_TIMEOUT_MS = DEFAULT_COMPARE_TIMEOUT_MINUTES * 60_000;
188
189
 
189
190
  /**
190
191
  * Whole-process limit for the spawned site-check compare, so a stall inside it cannot hang the run either.
191
- * `--compare-timeout-minutes` wins, then a positive GATE_COMPARE_TIMEOUT_MINUTES, else the 25-minute default.
192
+ * `--compare-timeout-minutes` wins, then a finite positive GATE_COMPARE_TIMEOUT_MINUTES (junk, zero, negative and
193
+ * Infinity count as unset), else the 25-minute default. The result is a whole number of milliseconds, at least 1.
192
194
  */
193
195
  export function resolveCompareTimeoutMs(flagMinutes, env = process.env) {
194
- if (flagMinutes !== undefined) return flagMinutes * 60_000;
196
+ const toMs = (minutes) => Math.max(1, Math.round(minutes * 60_000));
197
+ if (flagMinutes !== undefined) return toMs(flagMinutes);
195
198
  const fromEnv = Number(env.GATE_COMPARE_TIMEOUT_MINUTES);
196
- return (fromEnv > 0 ? fromEnv : DEFAULT_COMPARE_TIMEOUT_MINUTES) * 60_000;
199
+ return toMs(Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : DEFAULT_COMPARE_TIMEOUT_MINUTES);
197
200
  }
198
201
 
199
202
  /** fetch() with a hard per-request timeout. The abort surfaces as a TimeoutError, which withRetry treats as transient. */
@@ -307,10 +310,15 @@ export function isNonPageUrl(url) {
307
310
  * Production page URLs listed under the given sitemap roots only. A root that is a sitemap index is
308
311
  * followed one level (its child sitemaps are fetched and must answer 2xx; a nested index is an error);
309
312
  * a root that is a urlset contributes its own URLs. A root that does not answer 2xx, or lists nothing,
310
- * throws: the compare never passes on an empty or unreadable root.
313
+ * throws: the compare never passes on an empty or unreadable root. `allowEmpty` (optional roots only, such as
314
+ * the build's `/sitemap-unindexed.xml`) lets a valid sitemap with zero URLs pass; a non-sitemap body still throws.
311
315
  * `fetchText(url)` resolves {status, text}.
312
316
  */
313
- export async function collectRootPageUrls(rootUrls, fetchText, { rebaseChildren = false } = {}) {
317
+ export async function collectRootPageUrls(
318
+ rootUrls,
319
+ fetchText,
320
+ { rebaseChildren = false, allowEmpty = false } = {},
321
+ ) {
314
322
  const pages = [];
315
323
  for (const root of rootUrls) {
316
324
  const origin = new URL(root).origin;
@@ -336,7 +344,11 @@ export async function collectRootPageUrls(rootUrls, fetchText, { rebaseChildren
336
344
  rootPages.push(...extractLocs(c.text));
337
345
  }
338
346
  }
339
- if (rootPages.length === 0) throw new Error(`sitemap root ${root} lists no URLs`);
347
+ if (rootPages.length === 0) {
348
+ const isSitemap = isIndex || /<urlset[\s>]/.test(res.text);
349
+ if (!allowEmpty) throw new Error(`sitemap root ${root} lists no URLs`);
350
+ if (!isSitemap) throw new Error(`sitemap root ${root} is not a sitemap`);
351
+ }
340
352
  pages.push(...rootPages);
341
353
  }
342
354
  return [...new Set(pages)];
@@ -426,7 +438,7 @@ export function findImpossibleSitemapPaths(urls, isImpossible = pathnameHasImpos
426
438
 
427
439
  /**
428
440
  * Sitemap-parity stage: every page the deployment's own sitemap lists must pass the core slug guard. Roots are
429
- * the build's sitemap roots (default `/sitemap.xml`, plus `/sitemap-unindexed.xml` when the build serves it; a 5xx on it fails). Index children are fetched from the build origin even when the build's sitemap lists them on the production domain.
441
+ * the build's sitemap roots (default `/sitemap.xml`, which must list at least one URL, plus `/sitemap-unindexed.xml` when the build serves it: absent or valid-but-empty passes, a 5xx or a non-sitemap body fails). Index children are fetched from the build origin even when the build's sitemap lists them on the production domain.
430
442
  * A sitemap that cannot be read FAILS (never a silent pass). `fetchText(url)` resolves {status, text}.
431
443
  */
432
444
  export async function checkSitemapSlugParity({
@@ -444,7 +456,12 @@ export async function checkSitemapSlugParity({
444
456
  if (probe.status >= 500)
445
457
  throw new Error(`optional sitemap ${root} returned HTTP ${probe.status}`);
446
458
  if (probe.status >= 200 && probe.status < 300)
447
- urls = [...new Set([...urls, ...(await collectRootPageUrls([root], fetchText, rebase))])];
459
+ urls = [
460
+ ...new Set([
461
+ ...urls,
462
+ ...(await collectRootPageUrls([root], fetchText, { ...rebase, allowEmpty: true })),
463
+ ]),
464
+ ];
448
465
  }
449
466
  } catch (err) {
450
467
  return {
@@ -16,7 +16,7 @@ One persistent Vercel preview build of a site's integration branch that reads **
16
16
  2. Merge them. The first push creates `develop-published` at develop's head. The branch only ever fast-forwards: the job uses a plain push and fails, pushing nothing, if it cannot. Never edit the branch or force-push it.
17
17
  3. In the Vercel project, add a **branch-scoped Preview** env var for git branch `develop-published` that switches the site to published content. Find the flag in the app (for example `DRAFT_ONLY=false`; read the app's server config). The CDA token usually already exists as a Preview var. Vercel only accepts a branch-scoped var once the branch exists, so this comes after step 2. Never touch Production env vars.
18
18
  4. **Trigger the build.** Vercel's Git integration does not build a second branch that points at a commit it already built (verified twice on the pilot site, with a new develop-published pushed by the Action and a probe branch pushed by a person, both at a SHA develop had already built: no deployment either time). So the first build, and every refresh, needs an explicit trigger: a Vercel **deploy hook** for ref `develop-published`, or the deployments API with `gitSource {ref: develop-published, sha}`. The update workflow template has a commented trigger step for the deploy-hook route. Until a trigger is set up, the template alone creates no deployment. (Pilot: API call from the worker; a deploy hook is the proposal for automation.)
19
- **One gate run per commit:** the push and the deploy hook usually produce two READY deployments of the same SHA, and each sends its own `vercel.deployment.ready` event, so the gate would run twice. The template's `concurrency` group is keyed on the commit (and the Vercel project): the newer run cancels the older, and a cancelled run posts no status. Every compare and sitemap fetch has a 30s timeout that counts as a transient failure (3 tries); the spawned `site-check` compare is killed after 25 minutes (a healthy compare of a large sitemap takes about 20) and is not retried. The gate job has `timeout-minutes: 35` so a hung run cannot hold a runner for hours (a timed-out job counts as cancelled and posts no status). **Already green, skipped:** the first step of a Vercel-triggered run reads the commit statuses on the promoted SHA and, if the newest `develop-published gate` status (the `GATE_CONTEXT` job env; where one repo gates several apps, give each app's workflow copy its own context) is `success`, skips every later step and posts no new status, so a third deploy of the same SHA cannot re-run the gate. A `failure`, `error`, `pending` or missing status, or an API error, runs the gate; a manual `workflow_dispatch` always runs it.
19
+ **One gate run per commit:** the push and the deploy hook usually produce two READY deployments of the same SHA, and each sends its own `vercel.deployment.ready` event, so the gate would run twice. The template's `concurrency` group is keyed on the commit (and the Vercel project): the newer run cancels the older, and a cancelled run posts no status. Every compare and sitemap fetch has a 30s timeout that counts as a transient failure (3 tries). On a manual compare run, the spawned `site-check` compare is killed after 25 minutes by default (a healthy compare of a large sitemap takes about 20; `--compare-timeout-minutes` or `GATE_COMPARE_TIMEOUT_MINUTES` change it) and is not retried. The gate job has `timeout-minutes: 35`, above that 25 minute default, so a hung run cannot hold a runner for hours; raise it above any longer compare limit (60 for a 45 minute compare). A timed-out job counts as cancelled and posts no status. **Already green, skipped:** the first step of a Vercel-triggered run reads the commit statuses on the promoted SHA and, if the newest `develop-published gate` status (the `GATE_CONTEXT` job env; where one repo gates several apps, give each app's workflow copy its own context) is `success`, skips every later step and posts no new status, so a third deploy of the same SHA cannot re-run the gate. A `failure`, `error`, `pending` or missing status, or an API error, runs the gate; a manual `workflow_dispatch` always runs it.
20
20
  5. Revalidation: content changes reach the build through the site's Contentful webhook, not rebuilds. The existing webhooks target production and the develop branch alias, so they do not reach develop-published. A webhook for the `develop-published` branch alias (same topics and filter as the production one) is a Contentful write: it needs an owner's go.
21
21
 
22
22
  ## The gate
@@ -29,11 +29,11 @@ develop-published-gate --url https://<project>-git-develop-published-<team>.verc
29
29
  --deployment-sha <built sha> --expect-sha <promoted sha> --draft-canary /a-draft-only-path/ [--compare]
30
30
  ```
31
31
 
32
- **Running the compare on demand.** In the workflow template, `workflow_dispatch` has a boolean input `compare` (default false). The gate step passes `--compare` only when the run is a manual one with `compare` ticked (`COMPARE_FLAG` env); the `repository_dispatch` deployment.ready path never does. A manual run is never skipped by skip-if-green. It posts the same `develop-published gate` status context as the normal gate, with the description saying whether the compare ran (`... (prod compare not run, on-demand)` or `... and prod compare (manual) ...`), so the promote PR keeps reading one context. A manual compare that fails posts `failure`, and being newest it re-opens the gate; one that passes posts `success`. A manual compare run has its own concurrency group (`...-compare`), so a later deployment.ready event for the same SHA cannot cancel it. The job `timeout-minutes: 35` is the same for both and stays above the compare's own 25 minute limit.
32
+ **Running the compare on demand.** In the workflow template, `workflow_dispatch` has a boolean input `compare` (default false). The gate step passes `--compare` only when the run is a manual one with `compare` ticked (`COMPARE_FLAG` env); the `repository_dispatch` deployment.ready path never does. A manual run is never skipped by skip-if-green. It posts the same `develop-published gate` status context as the normal gate, with the description saying whether the compare ran (`... (prod compare not run, on-demand)` or `... and prod compare (manual) ...`), so the promote PR keeps reading one context. A manual compare that fails posts `failure`, and being newest it re-opens the gate; one that passes posts `success`. A manual compare run has its own concurrency group (`...-compare`), so a later deployment.ready event for the same SHA cannot cancel it. The job `timeout-minutes: 35` is the same for both kinds of run and stays above the compare's default 25 minute limit; a site that raises `--compare-timeout-minutes` (Pedestal and Headwater use 45) must raise the job timeout above it too (60).
33
33
 
34
34
  **Sitemap parity does not depend on the compare.** The slug-guard parity stage fetches the build's own sitemap (`<deployment>/sitemap.xml`, plus `/sitemap-unindexed.xml` when served, or the `--sitemap-roots` rebased onto the deployment) with its own requests; it never reads the compare's output or the production sitemap, so it runs unchanged with the compare off.
35
35
 
36
- Options for sites that differ from the default: `--no-draft-canary` skips the draft-canary stage (recorded as a passing, clearly labelled `SKIPPED` stage) for a site with no draft-only page; it is ignored when a `--draft-canary` is also given, and giving neither still fails the gate. `--compare-timeout-minutes <n>` (or the `GATE_COMPARE_TIMEOUT_MINUTES` env, used only when it is a positive number; the flag wins) sets how long the spawned prod compare may run before it is killed; both apply only when `--compare` is given. The default is 25 minutes, which suits compares of up to about 20 minutes; give a slower site more (Pedestal, whose cold compare takes about 30 minutes, uses 45) and raise the job `timeout-minutes` above it.
36
+ Options for sites that differ from the default: `--no-draft-canary` skips the draft-canary stage (recorded as a passing, clearly labelled `SKIPPED` stage) for a site with no draft-only page; it is ignored when a `--draft-canary` is also given, and giving neither still fails the gate. `--compare-timeout-minutes <n>` (or the `GATE_COMPARE_TIMEOUT_MINUTES` env, used only when it is a finite positive number, so junk, zero, negative and `Infinity` count as unset; the flag wins and an `Infinity` flag is a usage error; the value is rounded to whole milliseconds) sets how long the spawned prod compare may run before it is killed; both apply only when `--compare` is given. The default is 25 minutes, which suits compares of up to about 20 minutes; give a slower site more (Pedestal, whose cold compare takes about 30 minutes, uses 45) and raise the job `timeout-minutes` above it.
37
37
 
38
38
  Stages (exit 0 only if every stage that ran passes): exact commit (built from the promoted SHA, or from an ancestor when every file changed since is in `vercel.json`'s `ignoreCommand` pathspec); noindex; draft canary 404s; full smoke; content smoke (cases with `contentAssert`); prod compare, **only with `--compare`** (every production sitemap page that is live (200) on production exists on the build; a page that is 404/410 on production too is a "prod sitemap lists dead URL" warning, not a failure; transient fetch errors are retried 3 times with backoff; and the visible text of up to 5 representative pages matches, similarity >= 0.9). `--sitemap-roots <paths>` (comma-separated or repeated, default none) limits the sitemap compare to the sitemap roots this app owns, e.g. `--sitemap-roots /marketing/sitemap.xml` when the production domain is shared with other apps; without it the full production sitemap index (`/sitemap.xml` and `/sitemap-unindexed.xml`) is compared. An index root is followed one level; an unreadable, nested-index or empty root fails the stage. `--json` writes the result. `--host-prefix` is required. The bypass token goes only to the deployment host, which must be `<host-prefix>*.vercel.app`, the gate's own requests follow redirects by hand so a redirect off that host never carries it, and in compare mode `site-check` sends the bypass to the deployment only, never to production. (`site-check` itself still follows redirects automatically, so a deployment that redirects a sitemap path to another host would carry the header there; the Vercel deployment hosts do not.) **Sitemap slug guard parity** (a hard failure, not a warning): every path in the build's own sitemap (the `--sitemap-roots` rebased onto the deployment, else `/sitemap.xml` plus `/sitemap-unindexed.xml` when served) must pass core's `pathnameHasImpossibleCmsSlug` from `@se-studio/core-ui/impossible-cms-slug`, so the sitemap never advertises a path the app would 404; an unreadable build sitemap also fails. Noindex is read from `robots.txt` (disallow all) or the home page (`x-robots-tag` or meta robots).
39
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/site-check",
3
- "version": "2.25.0",
3
+ "version": "2.25.3",
4
4
  "description": "Validate SE marketing sites (sitemap, llms.txt) and download markdown files preserving structure",
5
5
  "repository": {
6
6
  "type": "git",
@@ -110,9 +110,9 @@
110
110
  "url": "https://github.com/Something-Else-Studio/se-core-product/issues"
111
111
  },
112
112
  "dependencies": {
113
- "@se-studio/contentful-rest-api": "2.9.2",
114
- "@se-studio/core-data-types": "2.2.0",
115
- "@se-studio/core-ui": "1.48.5"
113
+ "@se-studio/contentful-rest-api": "2.9.3",
114
+ "@se-studio/core-data-types": "2.2.1",
115
+ "@se-studio/core-ui": "1.48.7"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@biomejs/biome": "^2.6.8",
@@ -60,8 +60,9 @@ jobs:
60
60
  runs-on: ubuntu-latest
61
61
  # A healthy prod compare of a large sitemap takes about 20 minutes (only on a manual run with compare
62
62
  # on; the default gate takes a few minutes); this only stops a hung run. Kept at 35 for both so it stays
63
- # above the compare's own 25 minute kill limit. A timed-out job counts as cancelled, so it posts no
64
- # status (the promote PR shows none, not green).
63
+ # above the compare's default 25 minute kill limit. If you give the compare a longer limit with
64
+ # --compare-timeout-minutes (for example 45), raise this above it (60). A timed-out job counts as
65
+ # cancelled, so it posts no status (the promote PR shows none, not green).
65
66
  timeout-minutes: 35
66
67
  env:
67
68
  GATE_CONTEXT: develop-published gate