@se-studio/site-check 0.0.0-next16-20260822103555
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 +948 -0
- package/README.md +220 -0
- package/check-no-context-workarounds.mjs +235 -0
- package/develop-sites-timing.mjs +609 -0
- package/dist/check-pages-exist.d.ts +19 -0
- package/dist/check-pages-exist.d.ts.map +1 -0
- package/dist/check-pages-exist.js +25 -0
- package/dist/check-pages-exist.js.map +1 -0
- package/dist/check-rewrites.d.ts +21 -0
- package/dist/check-rewrites.d.ts.map +1 -0
- package/dist/check-rewrites.js +69 -0
- package/dist/check-rewrites.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +231 -0
- package/dist/cli.js.map +1 -0
- package/dist/cms-integrity/article-link-integrity.d.ts +4 -0
- package/dist/cms-integrity/article-link-integrity.d.ts.map +1 -0
- package/dist/cms-integrity/article-link-integrity.js +8 -0
- package/dist/cms-integrity/article-link-integrity.js.map +1 -0
- package/dist/cms-integrity/evaluate-article-link-integrity.d.ts +11 -0
- package/dist/cms-integrity/evaluate-article-link-integrity.d.ts.map +1 -0
- package/dist/cms-integrity/evaluate-article-link-integrity.js +49 -0
- package/dist/cms-integrity/evaluate-article-link-integrity.js.map +1 -0
- package/dist/cms-integrity/fetch-article-links.d.ts +8 -0
- package/dist/cms-integrity/fetch-article-links.d.ts.map +1 -0
- package/dist/cms-integrity/fetch-article-links.js +27 -0
- package/dist/cms-integrity/fetch-article-links.js.map +1 -0
- package/dist/cms-integrity/index.d.ts +7 -0
- package/dist/cms-integrity/index.d.ts.map +1 -0
- package/dist/cms-integrity/index.js +6 -0
- package/dist/cms-integrity/index.js.map +1 -0
- package/dist/cms-integrity/report.d.ts +4 -0
- package/dist/cms-integrity/report.d.ts.map +1 -0
- package/dist/cms-integrity/report.js +42 -0
- package/dist/cms-integrity/report.js.map +1 -0
- package/dist/cms-integrity/routing-config.d.ts +3 -0
- package/dist/cms-integrity/routing-config.d.ts.map +1 -0
- package/dist/cms-integrity/routing-config.js +5 -0
- package/dist/cms-integrity/routing-config.js.map +1 -0
- package/dist/cms-integrity/types.d.ts +32 -0
- package/dist/cms-integrity/types.d.ts.map +1 -0
- package/dist/cms-integrity/types.js +2 -0
- package/dist/cms-integrity/types.js.map +1 -0
- package/dist/collect-markdown-urls.d.ts +29 -0
- package/dist/collect-markdown-urls.d.ts.map +1 -0
- package/dist/collect-markdown-urls.js +144 -0
- package/dist/collect-markdown-urls.js.map +1 -0
- package/dist/discovery/endpoints.d.ts +4 -0
- package/dist/discovery/endpoints.d.ts.map +1 -0
- package/dist/discovery/endpoints.js +34 -0
- package/dist/discovery/endpoints.js.map +1 -0
- package/dist/discovery/index.d.ts +6 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +5 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/resolve-config.d.ts +5 -0
- package/dist/discovery/resolve-config.d.ts.map +1 -0
- package/dist/discovery/resolve-config.js +21 -0
- package/dist/discovery/resolve-config.js.map +1 -0
- package/dist/discovery/types.d.ts +60 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +2 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/discovery/validate-content.d.ts +30 -0
- package/dist/discovery/validate-content.d.ts.map +1 -0
- package/dist/discovery/validate-content.js +244 -0
- package/dist/discovery/validate-content.js.map +1 -0
- package/dist/discovery/validate-endpoints.d.ts +4 -0
- package/dist/discovery/validate-endpoints.d.ts.map +1 -0
- package/dist/discovery/validate-endpoints.js +143 -0
- package/dist/discovery/validate-endpoints.js.map +1 -0
- package/dist/download.d.ts +19 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +48 -0
- package/dist/download.js.map +1 -0
- package/dist/fetch-options.d.ts +19 -0
- package/dist/fetch-options.d.ts.map +1 -0
- package/dist/fetch-options.js +48 -0
- package/dist/fetch-options.js.map +1 -0
- package/dist/production-audit/index.d.ts +96 -0
- package/dist/production-audit/index.d.ts.map +1 -0
- package/dist/production-audit/index.js +855 -0
- package/dist/production-audit/index.js.map +1 -0
- package/dist/screaming-frog/audit.d.ts +9 -0
- package/dist/screaming-frog/audit.d.ts.map +1 -0
- package/dist/screaming-frog/audit.js +254 -0
- package/dist/screaming-frog/audit.js.map +1 -0
- package/dist/screaming-frog/compare-report.d.ts +22 -0
- package/dist/screaming-frog/compare-report.d.ts.map +1 -0
- package/dist/screaming-frog/compare-report.js +142 -0
- package/dist/screaming-frog/compare-report.js.map +1 -0
- package/dist/screaming-frog/compare.d.ts +5 -0
- package/dist/screaming-frog/compare.d.ts.map +1 -0
- package/dist/screaming-frog/compare.js +42 -0
- package/dist/screaming-frog/compare.js.map +1 -0
- package/dist/screaming-frog/crawl-state.d.ts +19 -0
- package/dist/screaming-frog/crawl-state.d.ts.map +1 -0
- package/dist/screaming-frog/crawl-state.js +30 -0
- package/dist/screaming-frog/crawl-state.js.map +1 -0
- package/dist/screaming-frog/crawl.d.ts +12 -0
- package/dist/screaming-frog/crawl.d.ts.map +1 -0
- package/dist/screaming-frog/crawl.js +93 -0
- package/dist/screaming-frog/crawl.js.map +1 -0
- package/dist/screaming-frog/csv.d.ts +6 -0
- package/dist/screaming-frog/csv.d.ts.map +1 -0
- package/dist/screaming-frog/csv.js +71 -0
- package/dist/screaming-frog/csv.js.map +1 -0
- package/dist/screaming-frog/env.d.ts +4 -0
- package/dist/screaming-frog/env.d.ts.map +1 -0
- package/dist/screaming-frog/env.js +53 -0
- package/dist/screaming-frog/env.js.map +1 -0
- package/dist/screaming-frog/index.d.ts +15 -0
- package/dist/screaming-frog/index.d.ts.map +1 -0
- package/dist/screaming-frog/index.js +15 -0
- package/dist/screaming-frog/index.js.map +1 -0
- package/dist/screaming-frog/list-crawls.d.ts +22 -0
- package/dist/screaming-frog/list-crawls.d.ts.map +1 -0
- package/dist/screaming-frog/list-crawls.js +107 -0
- package/dist/screaming-frog/list-crawls.js.map +1 -0
- package/dist/screaming-frog/load-config.d.ts +9 -0
- package/dist/screaming-frog/load-config.d.ts.map +1 -0
- package/dist/screaming-frog/load-config.js +86 -0
- package/dist/screaming-frog/load-config.js.map +1 -0
- package/dist/screaming-frog/load-profile.d.ts +9 -0
- package/dist/screaming-frog/load-profile.d.ts.map +1 -0
- package/dist/screaming-frog/load-profile.js +32 -0
- package/dist/screaming-frog/load-profile.js.map +1 -0
- package/dist/screaming-frog/paths.d.ts +5 -0
- package/dist/screaming-frog/paths.d.ts.map +1 -0
- package/dist/screaming-frog/paths.js +34 -0
- package/dist/screaming-frog/paths.js.map +1 -0
- package/dist/screaming-frog/rules.d.ts +14 -0
- package/dist/screaming-frog/rules.d.ts.map +1 -0
- package/dist/screaming-frog/rules.js +211 -0
- package/dist/screaming-frog/rules.js.map +1 -0
- package/dist/screaming-frog/sf-runner.d.ts +12 -0
- package/dist/screaming-frog/sf-runner.d.ts.map +1 -0
- package/dist/screaming-frog/sf-runner.js +37 -0
- package/dist/screaming-frog/sf-runner.js.map +1 -0
- package/dist/screaming-frog/types.d.ts +136 -0
- package/dist/screaming-frog/types.d.ts.map +1 -0
- package/dist/screaming-frog/types.js +2 -0
- package/dist/screaming-frog/types.js.map +1 -0
- package/dist/screaming-frog-cli.d.ts +4 -0
- package/dist/screaming-frog-cli.d.ts.map +1 -0
- package/dist/screaming-frog-cli.js +326 -0
- package/dist/screaming-frog-cli.js.map +1 -0
- package/dist/smoke-test/analytics-context-bundle.d.ts +30 -0
- package/dist/smoke-test/analytics-context-bundle.d.ts.map +1 -0
- package/dist/smoke-test/analytics-context-bundle.js +148 -0
- package/dist/smoke-test/analytics-context-bundle.js.map +1 -0
- package/dist/smoke-test/build-route-policy.d.ts +39 -0
- package/dist/smoke-test/build-route-policy.d.ts.map +1 -0
- package/dist/smoke-test/build-route-policy.js +121 -0
- package/dist/smoke-test/build-route-policy.js.map +1 -0
- package/dist/smoke-test/cache-log-audit.d.ts +22 -0
- package/dist/smoke-test/cache-log-audit.d.ts.map +1 -0
- package/dist/smoke-test/cache-log-audit.js +85 -0
- package/dist/smoke-test/cache-log-audit.js.map +1 -0
- package/dist/smoke-test/config.d.ts +7 -0
- package/dist/smoke-test/config.d.ts.map +1 -0
- package/dist/smoke-test/config.js +61 -0
- package/dist/smoke-test/config.js.map +1 -0
- package/dist/smoke-test/index.d.ts +15 -0
- package/dist/smoke-test/index.d.ts.map +1 -0
- package/dist/smoke-test/index.js +9 -0
- package/dist/smoke-test/index.js.map +1 -0
- package/dist/smoke-test/runner.d.ts +9 -0
- package/dist/smoke-test/runner.d.ts.map +1 -0
- package/dist/smoke-test/runner.js +340 -0
- package/dist/smoke-test/runner.js.map +1 -0
- package/dist/smoke-test/static.d.ts +23 -0
- package/dist/smoke-test/static.d.ts.map +1 -0
- package/dist/smoke-test/static.js +126 -0
- package/dist/smoke-test/static.js.map +1 -0
- package/dist/smoke-test/types.d.ts +89 -0
- package/dist/smoke-test/types.d.ts.map +1 -0
- package/dist/smoke-test/types.js +2 -0
- package/dist/smoke-test/types.js.map +1 -0
- package/dist/validate.d.ts +48 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +140 -0
- package/dist/validate.js.map +1 -0
- package/dist/vercel-env.d.ts +13 -0
- package/dist/vercel-env.d.ts.map +1 -0
- package/dist/vercel-env.js +93 -0
- package/dist/vercel-env.js.map +1 -0
- package/docs/llms.md +137 -0
- package/fixtures/revalidation/entry-publish.json +10 -0
- package/markdown-accuracy-audit.mjs +432 -0
- package/package.json +102 -0
- package/revalidation-matrix-test.mjs +467 -0
- package/smoke-test-deploy-check.mjs +70 -0
- package/smoke-test-live.mjs +63 -0
- package/smoke-test-one.mjs +442 -0
- package/templates/biome-ssg-guardrails.override.json +27 -0
- package/templates/route-build-policy.example.json +18 -0
- package/validate-build-routes.mjs +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# @se-studio/site-check
|
|
2
|
+
|
|
3
|
+
Validate SE marketing sites (sitemap.xml, sitemap-unindexed.xml, llms.txt) and download all markdown files into a local directory, preserving URL path structure.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @se-studio/site-check <baseUrl> [-o dir] [-H "Name: value"] [--vercel-bypass [secret]] [--check-against <devUrl>] [--check-rewrites] [--ignore-missing-child-sitemaps]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Examples
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Local site
|
|
15
|
+
npx @se-studio/site-check http://localhost:3015
|
|
16
|
+
|
|
17
|
+
# Custom output directory
|
|
18
|
+
npx @se-studio/site-check http://localhost:3015 -o ./out
|
|
19
|
+
|
|
20
|
+
# Compare production vs development: use production sitemap, check pages exist on dev
|
|
21
|
+
npx @se-studio/site-check https://example.com --check-against http://localhost:3010
|
|
22
|
+
|
|
23
|
+
# Enable rewrite check (optional; off by default)
|
|
24
|
+
npx @se-studio/site-check https://example.com --check-rewrites
|
|
25
|
+
|
|
26
|
+
# Vercel Deployment Protection: use env secret (preferred name)
|
|
27
|
+
VERCEL_PROTECTION_BYPASS_TOKEN=your-secret npx @se-studio/site-check https://preview.vercel.app --vercel-bypass
|
|
28
|
+
|
|
29
|
+
# Legacy alias still works
|
|
30
|
+
VERCEL_AUTOMATION_BYPASS_SECRET=your-secret npx @se-studio/site-check https://preview.vercel.app --vercel-bypass
|
|
31
|
+
|
|
32
|
+
# Vercel bypass with explicit secret
|
|
33
|
+
npx @se-studio/site-check https://preview.vercel.app --vercel-bypass your-secret
|
|
34
|
+
|
|
35
|
+
# Custom headers
|
|
36
|
+
npx @se-studio/site-check https://example.com -H "Authorization: Bearer token" -H "X-Custom: value"
|
|
37
|
+
|
|
38
|
+
# Sitemap index lists a child that does not exist locally (404) — skip it and use remaining children
|
|
39
|
+
npx @se-studio/site-check http://localhost:3016 --ignore-missing-child-sitemaps -o ./out
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What it does
|
|
43
|
+
|
|
44
|
+
1. **Validates** the site by fetching:
|
|
45
|
+
- `sitemap.xml` (required) — must return 200 and contain `<loc>` entries; if it is a sitemap index, child sitemaps are fetched and must return valid urlset content (or use `--ignore-missing-child-sitemaps` to skip child URLs that return **404**)
|
|
46
|
+
- `sitemap-unindexed.xml` (optional) — if 404, a warning is printed and the run continues. When it exists (returns 200), its page URLs are included in all checks (existence on dev, optional rewrite check, markdown collection).
|
|
47
|
+
- `llms.txt` (optional by default) — if 404, a warning is printed and the run continues; use `--strict-discovery` to require all four discovery endpoints (`llms.txt`, `markdown-index.txt`, `cms.txt`, `site-info.md`) with content validation
|
|
48
|
+
|
|
49
|
+
2. **Collects markdown URLs** from **sitemap.xml** and **sitemap-unindexed.xml** (Option B): when either URL returns a **sitemap index** (e.g. `<sitemapindex>` with child `<sitemap><loc>...</loc></sitemap>`), the tool follows those links and collects page URLs from each child sitemap’s urlset (one level only). When the response is a normal urlset, every `<loc>` is treated as a page URL. Each page URL is then converted to a `.md` URL (path + `.md`). This ensures all indexed and unindexed pages are checked.
|
|
50
|
+
|
|
51
|
+
3. **Checks for unexpected rewrites** (only when `--check-rewrites` is set): For each page URL from the sitemaps, the tool sends a HEAD request and reads the `x-nextjs-rewritten-path` response header. If the header is present and the rewritten path is different from the requested path (after normalisation), the run **fails** (exit 1). This catches cases where the sitemap lists one URL (e.g. `/learning-hub/blog/`) but the app rewrites to another (e.g. `/articles/blog`). Rewrites that only add or remove a locale prefix are allowed when `SITE_CHECK_LOCALES` is set (see [Options](#options)). By default the rewrite check is **disabled**.
|
|
52
|
+
|
|
53
|
+
4. **Checks and downloads**: For each markdown URL, the tool fetches it. If any return non-2xx, the run **fails** (exit 1) and reports which URLs are missing or errored. Otherwise it saves each response to the output directory, preserving path structure (e.g. `blog/foo.md` → `./markdown-export/blog/foo.md`, `es-US/about.md` → `./markdown-export/es-US/about.md`).
|
|
54
|
+
|
|
55
|
+
### Compare mode (`--check-against`)
|
|
56
|
+
|
|
57
|
+
When `--check-against <devUrl>` is set, the tool runs in **compare mode**:
|
|
58
|
+
|
|
59
|
+
- **Production** (the `<baseUrl>`) is the source of the URL list: sitemap.xml and sitemap-unindexed.xml are fetched from production. Validation (and llms.txt) applies to production.
|
|
60
|
+
- **Development** (`<devUrl>`) is the site checked: each production sitemap page URL (including from sitemap-unindexed.xml when present) is mapped to the same path on the development origin. The tool then checks that each of those development URLs returns 2xx (HEAD). If `--check-rewrites` is set, it also runs the rewrite check against the development site. Markdown collection and download are **not** performed in compare mode.
|
|
61
|
+
|
|
62
|
+
Use this to ensure a development or staging build has the same pages as production (e.g. before release). Page title comparison is not yet implemented; a future option may add it.
|
|
63
|
+
|
|
64
|
+
## Options
|
|
65
|
+
|
|
66
|
+
| Option | Description |
|
|
67
|
+
|--------|-------------|
|
|
68
|
+
| `baseUrl` | Base URL of the site (required). In compare mode this is the **production** URL (sitemap source). Trailing slash is stripped. |
|
|
69
|
+
| `-o`, `--out <dir>` | Output directory for markdown files (default: `./markdown-export`). Ignored in compare mode. |
|
|
70
|
+
| `-H`, `--header "Name: value"` | Add a request header (repeatable). Applied to both production and development requests in compare mode. |
|
|
71
|
+
| `--check-against <devUrl>` | Compare mode: use production sitemap(s) but check that each page exists on development (same path on `<devUrl>`). No markdown download. |
|
|
72
|
+
| `--check-rewrites` | Enable checking for unexpected rewrites (x-nextjs-rewritten-path). Default: off. When set, the run fails if any sitemap page URL rewrites to a different path (locale-only rewrites allowed with `SITE_CHECK_LOCALES`). |
|
|
73
|
+
| `--ignore-missing-child-sitemaps` | When the root sitemap (or `sitemap-unindexed.xml`) is a **sitemap index**, any child `<loc>` that returns **404** is skipped instead of failing validation. Other non-2xx responses still fail. After skipping, at least one page URL must still be collected from the remaining children. |
|
|
74
|
+
| `--vercel-bypass [secret]` | Set `x-vercel-protection-bypass` for [Vercel Deployment Protection](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation). If `secret` is omitted, uses `VERCEL_PROTECTION_BYPASS_TOKEN` from the environment (aliases: `VERCEL_AUTOMATION_BYPASS_SECRET`, `VERCEL_BYPASS_TOKEN`). |
|
|
75
|
+
|
|
76
|
+
Headers from `-H` override the Vercel bypass header if the same name is used.
|
|
77
|
+
|
|
78
|
+
### Environment
|
|
79
|
+
|
|
80
|
+
| Variable | Description |
|
|
81
|
+
|----------|-------------|
|
|
82
|
+
| `SITE_CHECK_LOCALES` | Comma-separated list of locale path segments (e.g. `en,en-gb,de`). When set, a rewrite is considered acceptable if the only difference between the requested path and the rewritten path is a leading locale segment. If unset, any rewrite to a different path fails. |
|
|
83
|
+
| `PREVIEW_SITE_URL` | Vercel develop/preview deployment base URL (preview smoke tests, protected preview fetches). Trailing slash is stripped. |
|
|
84
|
+
| `SITEMAP_PROD_URL` | Public production site base URL (sitemap-validate scripts, smoke case curation). Trailing slash is stripped. |
|
|
85
|
+
| `PRODUCTION_SITE_URL` | Production site base URL for audits and tooling that need a canonical prod origin. Trailing slash is stripped. |
|
|
86
|
+
| `VERCEL_PROTECTION_BYPASS_TOKEN` | Vercel Deployment Protection bypass secret (Vercel → Settings → Deployment Protection). Sent as `x-vercel-protection-bypass`. Aliases: `VERCEL_AUTOMATION_BYPASS_SECRET`, `VERCEL_BYPASS_TOKEN`. |
|
|
87
|
+
|
|
88
|
+
## Production HTML audit (`@se-studio/site-check/production-audit`)
|
|
89
|
+
|
|
90
|
+
Programmatic module for live production SEO audits (used by per-app `pnpm seo:audit:production` scripts). Import from `@se-studio/site-check/production-audit`:
|
|
91
|
+
|
|
92
|
+
- `runProductionSeoAudit`, `writeProductionSeoAuditOutputs`, `buildRichResultsSpotChecks`, `getProductionAuditExitCode`
|
|
93
|
+
|
|
94
|
+
**URL sources:** `sitemap.xml` and `sitemap-unindexed.xml` (same resolver as the CLI — follows sitemap indexes). `sitemap-unindexed.xml` 404 is optional.
|
|
95
|
+
|
|
96
|
+
**Markdown checks:** Every sitemap page URL must return **200** for its `.md` mirror (`/about/` → `/about.md`, `/` → `/index.md`). Excluded: `/download/` paths and static file extensions (`.pdf`, etc.) via `isNonPageAssetUrl`. Additional exclusions: `skipMarkdownPathPrefixes` in config.
|
|
97
|
+
|
|
98
|
+
**Discovery endpoints:** Production audit validates all four discovery routes (`llms.txt`, `markdown-index.txt`, `cms.txt`, `site-info.md`) with content checks; issues appear in `discoveryIssues` on the audit report.
|
|
99
|
+
|
|
100
|
+
**markdown-index.txt:** Fetched for a supplementary `missing_from_markdown_index` report; not used to gate `.md` existence checks.
|
|
101
|
+
|
|
102
|
+
**Exit code:** `getProductionAuditExitCode` returns `1` when any row has `severity: 'error'` (including `markdown_missing`).
|
|
103
|
+
|
|
104
|
+
## Smoke tests (`@se-studio/site-check/smoke-test`)
|
|
105
|
+
|
|
106
|
+
Curated local smoke tests for marketing sites: verify HTML and `.md` for URLs listed in **`smoke.cases.json`**, plus optional **discovery endpoint** checks (`llms.txt`, `markdown-index.txt`, `cms.txt`, `site-info.md`) via the `discovery` block (see skill `se-marketing-sites-smoke-test-setup`).
|
|
107
|
+
|
|
108
|
+
Optional **`cmsIntegrity`** in `smoke.cases.json` adds a **local-only** Contentful article-link check (parallel with `pnpm smoke-test` server boot). Deployment / live smoke remains HTTP-only.
|
|
109
|
+
|
|
110
|
+
Requires **^2.6.1** when using `cmsIntegrity` or `pnpm smoke-test` with integrity enabled.
|
|
111
|
+
|
|
112
|
+
Import from `@se-studio/site-check/smoke-test`:
|
|
113
|
+
|
|
114
|
+
- `loadStaticSmokeConfig`, `runStaticSmokeTest`, `runStaticSmokeTestWithIntegrity`, `runPreviewStaticSmokeTest`, `runSmokeTest`
|
|
115
|
+
- `formatSmokeTestReport`, `formatCombinedSmokeReport`, `getSmokeTestExitCode`, `getCombinedSmokeExitCode`
|
|
116
|
+
|
|
117
|
+
**Per-app usage** (see `apps/example-empty`):
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pnpm build --filter @se-studio/site-check # once, or after package changes
|
|
121
|
+
cd apps/example-empty
|
|
122
|
+
pnpm smoke-test:run # dev server must be running on app port
|
|
123
|
+
pnpm smoke-test # dev server + smoke (default dev:dev) + stop
|
|
124
|
+
pnpm smoke-test:preview # curated cases against Vercel preview (no local server)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Add `smoke.cases.json`, `scripts/smoke-test-run.ts`, and optionally `scripts/smoke-test-preview.ts` (or use `node ../../scripts/smoke-test-preview.mjs` from the app directory). No Contentful or `cms-server` imports required. Set `SMOKE_TEST_IGNORE=true` in `.env.local` to skip the full `smoke-test` CI script.
|
|
128
|
+
|
|
129
|
+
**Preview smoke** (`runPreviewStaticSmokeTest`): reads `PREVIEW_SITE_URL` and `VERCEL_PROTECTION_BYPASS_TOKEN` from `.env.local` (or `process.env`), applies the bypass header, and runs the same curated cases against the live preview deployment. No local dev server required.
|
|
130
|
+
|
|
131
|
+
**`smoke-test-one` env:**
|
|
132
|
+
|
|
133
|
+
| Variable | Purpose |
|
|
134
|
+
|----------|---------|
|
|
135
|
+
| `SMOKE_TEST_SERVER_SCRIPT=dev:dev` | Default dev server; use `start` for prod-like server (runs `pnpm build` first) |
|
|
136
|
+
| `SMOKE_TEST_SKIP_BUILD=true` | Skip `pnpm build` when `SERVER_SCRIPT=start` (use after Vercel `next build`) |
|
|
137
|
+
| `SMOKE_TEST_VERIFY_CACHE=true` | Run smoke twice; assert `x-nextjs-cache` on HTML (meaningful with `start`, soft in `next dev`) |
|
|
138
|
+
| `SMOKE_TEST_AUDIT_CACHE_LOGS=true` | Pipe server/build logs and scan for 2MB cache failures, `cache skip`, and `hard refresh` |
|
|
139
|
+
| `SMOKE_TEST_CACHE_SKIP_SEVERITY=warn` | `warn` or `error` for cache-skip log lines (default `warn`) |
|
|
140
|
+
| `SMOKE_TEST_READY_PATH=/` | Path polled until the server responds |
|
|
141
|
+
| `SMOKE_TEST_USE_RUNNING_SERVER=false` | Force a fresh server (default `true` for local dev) |
|
|
142
|
+
| `SMOKE_TEST_SKIP_INTEGRITY=true` | HTTP smoke only (set by `smoke-test-one` when `cmsIntegrity` runs in parallel) |
|
|
143
|
+
|
|
144
|
+
`LOG_CMS_FETCH=1` is set when verify-cache or audit-cache-logs is enabled. The smoke HTTP client never sends `Cache-Control: no-cache`.
|
|
145
|
+
|
|
146
|
+
### CMS article-link integrity (`cmsIntegrity` in `smoke.cases.json`)
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"cmsIntegrity": {
|
|
151
|
+
"enabled": true,
|
|
152
|
+
"routing": {
|
|
153
|
+
"articleTypesBasePath": "/resources",
|
|
154
|
+
"tagsBasePath": "/topics",
|
|
155
|
+
"peopleBasePath": "/team",
|
|
156
|
+
"defaultTopic": "other",
|
|
157
|
+
"enablePrimaryTagPartOfSlug": true,
|
|
158
|
+
"topiclessArticleTypeSlugs": ["ebooks"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Map `routing` from the app’s `constants.ts` / URL rules. Use `runStaticSmokeTestWithIntegrity` in `scripts/smoke-test-run.ts` (see `apps/example-empty`).
|
|
165
|
+
|
|
166
|
+
Import from `@se-studio/site-check/cms-integrity` for standalone checks: `runArticleLinkIntegrityFromSmokeConfig`, `evaluateArticleLinkIntegrity`, `getArticleLinkIntegrityExitCode`.
|
|
167
|
+
|
|
168
|
+
### Vercel build cache (`VERCEL_FORCE_NO_BUILD_CACHE`)
|
|
169
|
+
|
|
170
|
+
Not a smoke variable — set on the **Vercel project** when `next build` fails intermittently with webpack `WasmHash` errors (often with stale remote build cache; local `pnpm build` may still pass).
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
vercel env add VERCEL_FORCE_NO_BUILD_CACHE preview develop --value 1 --yes
|
|
174
|
+
vercel env add VERCEL_FORCE_NO_BUILD_CACHE production --value 1 --yes
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Cannot be set in `vercel.json` — Vercel restores cache before install/build commands. Tradeoff: slower cold builds, more reliable compiles.
|
|
178
|
+
|
|
179
|
+
**Deploy check** (`smoke-test-deploy-check`): post-build gate for Vercel — starts `pnpm start` without rebuilding, runs `pnpm smoke-test:run`, exits non-zero on failure. Port defaults from `smoke.cases.json`. Set `SMOKE_TEST_IGNORE=true` in Vercel env to bypass in an emergency.
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"buildCommand": "pnpm build && pnpm smoke-test:deploy-check"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Per-app script: `"smoke-test:deploy-check": "smoke-test-deploy-check"` (or `node ../../scripts/smoke-test-deploy-check.mjs` in the monorepo).
|
|
188
|
+
|
|
189
|
+
**Cross-site develop timing** (`develop-sites-timing`): probes all client marketing sites (smoke paths from each repo’s `smoke.cases.json`) against develop and production. Runs **N sequential full passes** (default 5) over every path — one request at a time. Reads `VERCEL_PROTECTION_BYPASS_TOKEN` from each site’s `.env.local`; never hardcodes secrets.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
pnpm develop-sites-timing
|
|
193
|
+
pnpm develop-sites-timing --site pointme --passes 3 --output /tmp/timing.json
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Option | Purpose |
|
|
197
|
+
|--------|---------|
|
|
198
|
+
| `--site <key>` | One site: `se2026`, `om1`, `brightline`, `brightlifekids`, `pedestal`, `headwater`, `pointme` |
|
|
199
|
+
| `--passes <n>` | Full passes over all paths (default `5`) |
|
|
200
|
+
| `--output <path>` | JSON report (default `./develop-sites-timing.json`) |
|
|
201
|
+
| `--delay-ms <n>` | Pause between requests |
|
|
202
|
+
| `--develop-only` / `--production-only` | Probe one environment |
|
|
203
|
+
| `--source-root <path>` | Client repos root (default `~/source`, or `SE_SOURCE_ROOT`) |
|
|
204
|
+
|
|
205
|
+
**Live deployment smoke** (`smoke-test-live` / `runLiveSmokeTest`): HTTP checks against a deployed URL — use with Vercel `repository_dispatch` (`vercel.deployment.ready`) and [Deployment Checks](https://vercel.com/docs/deployment-checks) to hold production domain aliasing until smoke passes.
|
|
206
|
+
|
|
207
|
+
**Discovery URL origins on production deploys:** Production builds often emit canonical URLs in `llms.txt` / `markdown-index.txt` (e.g. `https://www.example.com/...`) while Deployment Checks smoke the pre-alias `*.vercel.app` hostname. By default `discovery.urlOrigin` is `auto`: when every discovery URL shares one consistent HTTPS origin, **content validation** accepts that canonical origin. **Key pages spot-checks** then fetch the same paths on the smoke **deployment** base URL (not live CDN/www, which may still be the previous alias or an incomplete edge). Set `urlOrigin: "deployment"` for strict matching of URLs in the body, or `canonicalBaseUrl` to pin the expected content origin explicitly.
|
|
208
|
+
|
|
209
|
+
| Variable | Purpose |
|
|
210
|
+
|----------|---------|
|
|
211
|
+
| `DEPLOYMENT_URL` | Live deployment base URL (e.g. `github.event.client_payload.url`) |
|
|
212
|
+
| `SMOKE_TEST_BASE_URL` | Alias for `DEPLOYMENT_URL` |
|
|
213
|
+
| `PREVIEW_SITE_URL` | Fallback for local runs (same as preview smoke) |
|
|
214
|
+
|
|
215
|
+
Per-app script: `"smoke-test:live": "smoke-test-live"`. GitHub Actions: set `DEPLOYMENT_URL` from the dispatch payload, report status with `vercel/repository-dispatch/actions/status@v1`, register the check name in Vercel Deployment Checks settings.
|
|
216
|
+
|
|
217
|
+
## Exit codes
|
|
218
|
+
|
|
219
|
+
- `0` — Validation passed (sitemap.xml required; llms.txt and sitemap-unindexed.xml optional). If `--check-rewrites` was set, no unexpected rewrites. Every sitemap page returned 200 for its `.md` URL and files were saved (or in compare mode: all production sitemap pages exist on development and, if `--check-rewrites`, no unexpected rewrites).
|
|
220
|
+
- `1` — Usage error (missing baseUrl), validation failed (sitemap.xml), one or more sitemap pages rewrite to a different path when `--check-rewrites` was set, one or more markdown URLs returned non-2xx (pages missing or broken), or in compare mode one or more development URLs did not return 2xx. Validation does not fail when llms.txt returns 404.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Fail CI/validate if a repo uses dodgy dual-package workarounds for React
|
|
4
|
+
* context libraries (especially @se-studio/core-ui).
|
|
5
|
+
*
|
|
6
|
+
* Allowed on feature branches only via ALLOW_CONTEXT_WORKAROUNDS=1.
|
|
7
|
+
* Never allowed on develop / production integration branches.
|
|
8
|
+
*
|
|
9
|
+
* Usage (repo root):
|
|
10
|
+
* check-no-context-workarounds
|
|
11
|
+
* node node_modules/@se-studio/site-check/check-no-context-workarounds.mjs
|
|
12
|
+
*
|
|
13
|
+
* Proper monorepo pattern (allowed):
|
|
14
|
+
* - peerDependencies for @se-studio/core-ui (etc.) on shared packages
|
|
15
|
+
* - dependenciesMeta.injected on the app → shared package
|
|
16
|
+
* - @se-studio/core-ui singleton (package itself)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
|
|
22
|
+
const root = process.cwd();
|
|
23
|
+
|
|
24
|
+
/** Packages that must never be force-aliased / override-pinned for dual-instance hacks. */
|
|
25
|
+
const CONTEXT_PACKAGES = ['@se-studio/core-ui', '@se-studio/ab-testing'];
|
|
26
|
+
|
|
27
|
+
const findings = [];
|
|
28
|
+
|
|
29
|
+
function rel(filePath) {
|
|
30
|
+
return path.relative(root, filePath) || filePath;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function addFinding(file, rule, detail) {
|
|
34
|
+
findings.push({ file: rel(file), rule, detail });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function walkFiles(dir, predicate, out = []) {
|
|
38
|
+
if (!fs.existsSync(dir)) return out;
|
|
39
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
40
|
+
if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === '.next') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const full = path.join(dir, entry.name);
|
|
44
|
+
if (entry.isDirectory()) {
|
|
45
|
+
walkFiles(full, predicate, out);
|
|
46
|
+
} else if (entry.isFile() && predicate(full)) {
|
|
47
|
+
out.push(full);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function read(filePath) {
|
|
54
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function scanNextConfigs() {
|
|
58
|
+
const files = walkFiles(root, (f) => /next\.config\.(js|mjs|cjs|ts|mts|cts)$/.test(f));
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const content = read(file);
|
|
61
|
+
for (const pkg of CONTEXT_PACKAGES) {
|
|
62
|
+
// webpack resolve.alias targeting the package (including $ exact and subpaths)
|
|
63
|
+
const aliasPatterns = [
|
|
64
|
+
new RegExp(`['"\`]${escapeRegExp(pkg)}(?:\\$|/)[^'"\`]*['"\`]\\s*:`),
|
|
65
|
+
new RegExp(`['"\`]${escapeRegExp(pkg)}['"\`]\\s*:`),
|
|
66
|
+
new RegExp(`alias[^\\n]*${escapeRegExp(pkg)}`),
|
|
67
|
+
new RegExp(`resolve\\.alias[^}]*${escapeRegExp(pkg)}`, 's'),
|
|
68
|
+
];
|
|
69
|
+
for (const re of aliasPatterns) {
|
|
70
|
+
if (re.test(content) && content.includes('alias')) {
|
|
71
|
+
addFinding(
|
|
72
|
+
file,
|
|
73
|
+
'webpack-alias',
|
|
74
|
+
`webpack/resolve alias for ${pkg} is banned on integration branches. ` +
|
|
75
|
+
'Use peerDependencies + dependenciesMeta.injected on the shared package instead.',
|
|
76
|
+
);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function scanYamlOverrides(file, content) {
|
|
85
|
+
const lines = content.split('\n');
|
|
86
|
+
let inOverrides = false;
|
|
87
|
+
for (const line of lines) {
|
|
88
|
+
if (/^overrides:\s*$/.test(line.trimEnd()) || /^overrides:\s*$/.test(line)) {
|
|
89
|
+
inOverrides = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (inOverrides) {
|
|
93
|
+
// Top-level key ends the overrides block (no leading whitespace)
|
|
94
|
+
if (line.length > 0 && !/^[ \t]/.test(line) && !line.trimStart().startsWith('#')) {
|
|
95
|
+
inOverrides = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!inOverrides) continue;
|
|
99
|
+
for (const pkg of CONTEXT_PACKAGES) {
|
|
100
|
+
if (line.includes(pkg)) {
|
|
101
|
+
addFinding(
|
|
102
|
+
file,
|
|
103
|
+
'pnpm-override',
|
|
104
|
+
`pnpm override for ${pkg} is banned. Use peerDependencies + dependenciesMeta.injected, not overrides.`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function scanPnpmWorkspaceAndPackageJson() {
|
|
112
|
+
const candidates = [
|
|
113
|
+
path.join(root, 'pnpm-workspace.yaml'),
|
|
114
|
+
path.join(root, 'package.json'),
|
|
115
|
+
...walkFiles(
|
|
116
|
+
root,
|
|
117
|
+
(f) => f.endsWith('package.json') && !f.includes(`${path.sep}node_modules${path.sep}`),
|
|
118
|
+
),
|
|
119
|
+
];
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
for (const file of candidates) {
|
|
122
|
+
if (!fs.existsSync(file) || seen.has(file)) continue;
|
|
123
|
+
seen.add(file);
|
|
124
|
+
const content = read(file);
|
|
125
|
+
|
|
126
|
+
if (file.endsWith('.yaml') || file.endsWith('.yml')) {
|
|
127
|
+
scanYamlOverrides(file, content);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (file.endsWith('package.json')) {
|
|
132
|
+
try {
|
|
133
|
+
const json = JSON.parse(content);
|
|
134
|
+
const overrides = json.pnpm?.overrides ?? json.overrides;
|
|
135
|
+
if (overrides && typeof overrides === 'object') {
|
|
136
|
+
for (const pkg of CONTEXT_PACKAGES) {
|
|
137
|
+
if (pkg in overrides) {
|
|
138
|
+
addFinding(
|
|
139
|
+
file,
|
|
140
|
+
'pnpm-override',
|
|
141
|
+
`package.json overrides for ${pkg} is banned (${overrides[pkg]}).`,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch {
|
|
147
|
+
// ignore invalid json
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function scanNpmrc() {
|
|
154
|
+
const file = path.join(root, '.npmrc');
|
|
155
|
+
if (!fs.existsSync(file)) return;
|
|
156
|
+
const content = read(file);
|
|
157
|
+
const lines = content.split('\n');
|
|
158
|
+
for (const line of lines) {
|
|
159
|
+
const trimmed = line.trim();
|
|
160
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
161
|
+
if (trimmed.startsWith('public-hoist-pattern')) {
|
|
162
|
+
for (const pkg of CONTEXT_PACKAGES) {
|
|
163
|
+
const short = pkg.replace('@se-studio/', '');
|
|
164
|
+
if (trimmed.includes(pkg) || trimmed.includes(short) || trimmed.includes('core-ui')) {
|
|
165
|
+
addFinding(
|
|
166
|
+
file,
|
|
167
|
+
'public-hoist',
|
|
168
|
+
`public-hoist-pattern for context packages is banned (${trimmed}). Prefer peerDependencies + injected shared packages.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Broad hoist of all react is also a smell when used to fix dual core-ui
|
|
174
|
+
if (
|
|
175
|
+
trimmed.startsWith('public-hoist-pattern') &&
|
|
176
|
+
(trimmed.includes('*react*') || trimmed.includes('react-dom'))
|
|
177
|
+
) {
|
|
178
|
+
addFinding(
|
|
179
|
+
file,
|
|
180
|
+
'public-hoist',
|
|
181
|
+
`public-hoist-pattern for react is banned as a dual-package workaround (${trimmed}).`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function escapeRegExp(value) {
|
|
188
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function main() {
|
|
192
|
+
if (
|
|
193
|
+
(process.env.ALLOW_CONTEXT_WORKAROUNDS ?? '').toLowerCase() === '1' ||
|
|
194
|
+
(process.env.ALLOW_CONTEXT_WORKAROUNDS ?? '').toLowerCase() === 'true'
|
|
195
|
+
) {
|
|
196
|
+
console.warn(
|
|
197
|
+
'check-no-context-workarounds: SKIPPED (ALLOW_CONTEXT_WORKAROUNDS is set). ' +
|
|
198
|
+
'Do not merge this to develop/main without removing the workarounds.',
|
|
199
|
+
);
|
|
200
|
+
process.exit(0);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
scanNextConfigs();
|
|
204
|
+
scanPnpmWorkspaceAndPackageJson();
|
|
205
|
+
scanNpmrc();
|
|
206
|
+
|
|
207
|
+
if (findings.length === 0) {
|
|
208
|
+
console.log('check-no-context-workarounds: ok');
|
|
209
|
+
process.exit(0);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
console.error('check-no-context-workarounds: FAILED');
|
|
213
|
+
console.error('');
|
|
214
|
+
console.error(
|
|
215
|
+
'Banned dual-package workarounds for React context libraries (@se-studio/core-ui, etc.).',
|
|
216
|
+
);
|
|
217
|
+
console.error('These must never land on develop or production.');
|
|
218
|
+
console.error('');
|
|
219
|
+
for (const f of findings) {
|
|
220
|
+
console.error(` [${f.rule}] ${f.file}`);
|
|
221
|
+
console.error(` ${f.detail}`);
|
|
222
|
+
}
|
|
223
|
+
console.error('');
|
|
224
|
+
console.error('Allowed:');
|
|
225
|
+
console.error(' - peerDependencies on shared packages for @se-studio/core-ui (etc.)');
|
|
226
|
+
console.error(' - dependenciesMeta.<shared-pkg>.injected: true on apps');
|
|
227
|
+
console.error(' - @se-studio/core-ui singleton (package release)');
|
|
228
|
+
console.error('');
|
|
229
|
+
console.error(
|
|
230
|
+
'Feature-branch escape hatch only: ALLOW_CONTEXT_WORKAROUNDS=1 (never on develop/main).',
|
|
231
|
+
);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
main();
|