@domandigital/create-site 0.5.1 → 0.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/CHANGELOG.md +12 -0
- package/README.md +45 -5
- package/dist/cli.js +95 -9
- package/package.json +2 -2
- package/templates/shared/docs/site-programme.md +107 -0
- package/templates/shared/scripts/gates/check-direction.mjs +51 -0
- package/templates/shared/scripts/gates/copy-deck.mjs +84 -0
- package/templates/shared/scripts/gates/deploy-preview.mjs +63 -0
- package/templates/shared/scripts/gates/facts.mjs +65 -0
- package/templates/shared/scripts/gates/measure.mjs +229 -0
- package/templates/shared/scripts/gates/mobile-first.mjs +91 -0
- package/templates/shared/scripts/gates/night-contrast.mjs +68 -0
- package/templates/shared/scripts/gates/null-check.mjs +76 -0
- package/templates/shared/scripts/gates/prebuild.mjs +36 -0
- package/templates/shared/scripts/gates/programme.mjs +42 -0
- package/templates/shared/scripts/gates/tokens.mjs +79 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @domandigital/create-site
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5056c6a: Mobile first, gated (DOM-774, part of DOM-772). A new Stage 06 gate, `scripts/gates/mobile-first.mjs`, runs from `prebuild` and fails the build on a `max-width` media query (including the `width <` and `width <=` range syntax) or a Tailwind `max-*:` variant in the site's source, unless the exception is recorded with a reason: `mobile-first-ok: <reason>` on the line or the line above, or the file in `site.programme.json` `mobileFirst.exceptions` as `{ "file", "reason" }`. An exception with no reason fails. `measure.mjs` now measures phone first, at 375 x 812, then 390 x 844, then 1440 x 900, and at the two phone widths also fails a link, button, field or summary under 44 x 44 CSS px (a link inside a sentence is exempt, and a field's label counts as its target) and a text field set under 16px, which Safari on iOS zooms on. `docs/site-programme.md` says phone first at Stages 03 and 06 and lists the new gate; new sites get `mobileFirst: { "exceptions": [] }` in `site.programme.json`, and an existing one without the key is read as having no exceptions.
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 4f88631: The site programme's gates, as code (DOM-647). A new site gets `scripts/gates/`, lifted from the Doman Digital redesign: the programme issue (Stage 01), `check-direction` against the registered copy, the token generator writing both sides of the sheet, `night-contrast`, the governed-facts check, the copy deck and the null-set check, all run by `prebuild`; `measure` at 1440 and 390; and `deploy:preview`, which sets `PUBLIC_PREVIEW` itself, measures with noindex required and deploys a preview only. With `docs/site-programme.md`, `site.programme.json`, `art-direction.sheets.json`, a `--programme DOM-123` flag, and playwright and tsx as dev dependencies. A scaffolded site no longer builds until its programme exists and Stages 05 and 06 are done.
|
|
14
|
+
|
|
3
15
|
## 0.5.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -40,19 +40,56 @@ it is copied, which is the failure this exists to avoid.
|
|
|
40
40
|
| `tests/seo/*`, `tests/house.test.ts` | Route coverage, the redirect gate, JSON-LD integrity, the redirect wiring, and the rule that contact details live only in the facts file |
|
|
41
41
|
| `docs/HOUSE.md` | The house rules, imported by `CLAUDE.md` (created if missing, otherwise one import line is added) |
|
|
42
42
|
| `docs/DIRECTION.md`, `docs/seo-launch-checklist.md`, `docs/seo-baseline.md` | The site's decision and blocked registers, the listings to claim for its sector, and the launch, 90-day, 6-month and 12-month baseline |
|
|
43
|
-
| `docs/client-facts.entry.json` | The technology the builder says the site uses, as an entry for Doman Digital's client register.
|
|
43
|
+
| `docs/client-facts.entry.json` | The technology the builder says the site uses, as an entry for Doman Digital's client register. It records what the builder declared, so every tracking tool has `consent: null` until someone fills it in from what the site does. Skipped answers are simply absent |
|
|
44
44
|
| `.github/workflows/seo-check.yml` | Only if the project has no workflows yet. Written to pass `dd doctor`: actions pinned to a commit SHA, the runner chosen by `--visibility`, a timeout and a concurrency group |
|
|
45
45
|
| `pnpm-workspace.yaml` | pnpm projects: `minimumReleaseAge: 1440` (house packages exempt), added to the file create-next-app writes, or a new one. A project's own value is kept |
|
|
46
|
-
| `
|
|
46
|
+
| `scripts/gates/*`, `docs/site-programme.md` | The site programme's gates and the process they belong to: see below |
|
|
47
|
+
| `site.programme.json`, `art-direction.sheets.json` | The site's answers to the gates (the programme issue, paths, pages to measure, the null harvest, the preview host), and both sides of the sheet beyond the direction's own ground and accent. Unknown is `null` |
|
|
48
|
+
| `package.json` | `seo:check`, `launch:check`, `prebuild`, `tokens`, `deck`, `measure` and `deploy:preview` scripts, and the house packages |
|
|
47
49
|
|
|
48
50
|
It then runs `craft direction init` through the installed craft bin to start
|
|
49
51
|
`art-direction.json`, unless one exists.
|
|
50
52
|
|
|
53
|
+
## The site programme
|
|
54
|
+
|
|
55
|
+
Every site is made in ten stages (`docs/site-programme.md`, decided on
|
|
56
|
+
10 October 2026 in DOM-647 after the Doman Digital redesign, DOM-392). The
|
|
57
|
+
programme lives in Linear, opened from the "Site programme" template; the
|
|
58
|
+
scaffold carries its gates as code, lifted from `apps/site/scripts` in
|
|
59
|
+
Doman-Digital. `prebuild` runs them in stage order and the first failure stops
|
|
60
|
+
the build:
|
|
61
|
+
|
|
62
|
+
| Gate | Stage | Stops the build when |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| programme issue | 01 | `site.programme.json` names no Linear issue (`--programme DOM-123`) |
|
|
65
|
+
| `check-direction.mjs` | 05 | `art-direction.json` is missing, invalid, undecided, or differs from its registered copy in the craft estate |
|
|
66
|
+
| `tokens.mjs` | 05 | a day or night value is null. Writes the token stylesheet, both sides of the sheet |
|
|
67
|
+
| `night-contrast.mjs` | 05 | a text pair is under 4.5:1 by day or by night |
|
|
68
|
+
| `facts.mjs` | 06 | a price, term or response target is typed instead of imported from the facts |
|
|
69
|
+
| `copy-deck.mjs --check` | 06 | the copy deck is missing, empty or not rendered |
|
|
70
|
+
| `null-check.mjs` | 06 | the deck carries a phrase the null builds kept writing, without a reason |
|
|
71
|
+
| `mobile-first.mjs` | 06 | the source has a `max-width` media query or a Tailwind `max-*:` variant with no recorded exception: the phone is the base layout |
|
|
72
|
+
|
|
73
|
+
`pnpm measure` serves the last build and measures it phone first, at 375, 390
|
|
74
|
+
and 1440: it fails on sideways scroll, on text under 12px, and on a label
|
|
75
|
+
outside its container, and at the two phone widths on a target under 44px and
|
|
76
|
+
a form field set under 16px.
|
|
77
|
+
`pnpm deploy:preview` is the only deploy: it sets `PUBLIC_PREVIEW` itself,
|
|
78
|
+
builds, measures with noindex required, and deploys a preview to Cloudflare
|
|
79
|
+
or Vercel; it refuses a route, a custom domain or `--prod`. So a site made
|
|
80
|
+
with create-site cannot build until its programme exists and Stages 05 and 06
|
|
81
|
+
are done, and cannot reach a URL unmeasured.
|
|
82
|
+
|
|
83
|
+
The gate scripts are house files, identical on every site and reported by
|
|
84
|
+
`--check` when they drift. Everything that differs between sites is in
|
|
85
|
+
`site.programme.json`.
|
|
86
|
+
|
|
51
87
|
## What it never does
|
|
52
88
|
|
|
53
89
|
- Write outside the project, or anything at all when it refuses.
|
|
54
90
|
- Replace a data file (`site.facts.ts`, `site.routes.ts`, `links.json`,
|
|
55
|
-
`redirects.json`, `docs/DIRECTION.md`, the checklist, the baseline
|
|
91
|
+
`redirects.json`, `docs/DIRECTION.md`, the checklist, the baseline,
|
|
92
|
+
`site.programme.json`, `art-direction.sheets.json`), even with
|
|
56
93
|
`--force`. Delete one to regenerate it.
|
|
57
94
|
- Replace a house template file that differs, unless `--force`. Without it,
|
|
58
95
|
the difference is reported: a re-run is also a drift report.
|
|
@@ -66,7 +103,8 @@ It then runs `craft direction init` through the installed craft bin to start
|
|
|
66
103
|
```
|
|
67
104
|
create-site [dir] [--client <legal name>] [--trading-name <name>]
|
|
68
105
|
[--site-url <https://...>] [--sector trades|beauty|clinics|professional]
|
|
69
|
-
[--description "<one or two sentences>"] [--
|
|
106
|
+
[--description "<one or two sentences>"] [--programme DOM-123]
|
|
107
|
+
[--answers <file.json>]
|
|
70
108
|
[--visibility private|public] [--dry-run] [--check] [--force]
|
|
71
109
|
[--skip-install] [--yes] [--help] [--version]
|
|
72
110
|
```
|
|
@@ -83,7 +121,9 @@ same answers the site was made with (`--answers`).
|
|
|
83
121
|
`--answers` takes a JSON file with any of `legalName`, `tradingName`,
|
|
84
122
|
`siteUrl`, `sector`, `description`, `phone`, `email`, `locality`,
|
|
85
123
|
`postalCode`, `serviceAreas`, `registers` (ids from `src/sectors.ts`) and
|
|
86
|
-
`previousHosts`,
|
|
124
|
+
`previousHosts`, `programme` (the Linear issue, like `--programme`), and the
|
|
125
|
+
declared technology: `host` (`cloudflare` or `vercel` also becomes the preview
|
|
126
|
+
host in `site.programme.json`), `dns`, `cms`,
|
|
87
127
|
`analytics` (a list, e.g. `["ga4", "gtm", "posthog"]`), `errorMonitoring` and
|
|
88
128
|
`emailSending` (a list). Each can be skipped, and a skipped one is left out of
|
|
89
129
|
`docs/client-facts.entry.json`, never filled with a guess. Common names are
|
package/dist/cli.js
CHANGED
|
@@ -214,6 +214,8 @@ async function collectAnswers(sources) {
|
|
|
214
214
|
const previousHosts = list(await optional("previousHosts", "Previous website hostname, if moving from one"));
|
|
215
215
|
const stack = await collectStack(optional);
|
|
216
216
|
if (typeof stack === "string") return stack;
|
|
217
|
+
const programme = pick("programme") ?? text(await optional("programme", "Programme issue in Linear, e.g. DOM-123"));
|
|
218
|
+
if (programme !== null && !/^[A-Z]+-\d+$/.test(programme)) return `--programme takes a Linear issue id such as DOM-123, not "${programme}"`;
|
|
217
219
|
return {
|
|
218
220
|
legalName: values.legalName,
|
|
219
221
|
tradingName,
|
|
@@ -227,7 +229,8 @@ async function collectAnswers(sources) {
|
|
|
227
229
|
serviceAreas,
|
|
228
230
|
registers,
|
|
229
231
|
previousHosts,
|
|
230
|
-
stack
|
|
232
|
+
stack,
|
|
233
|
+
programme
|
|
231
234
|
};
|
|
232
235
|
}
|
|
233
236
|
|
|
@@ -275,10 +278,12 @@ Run it inside a fresh Next.js (App Router) or Astro TypeScript project:
|
|
|
275
278
|
Usage
|
|
276
279
|
create-site [dir] [--client <legal name>] [--trading-name <name>]
|
|
277
280
|
[--site-url <https://...>] [--sector trades|beauty|clinics|professional]
|
|
278
|
-
[--description "<one or two sentences>"] [--
|
|
279
|
-
[--
|
|
280
|
-
[--skip-install] [--yes] [--help] [--version]
|
|
281
|
+
[--description "<one or two sentences>"] [--programme DOM-123]
|
|
282
|
+
[--answers <file.json>] [--visibility private|public]
|
|
283
|
+
[--dry-run] [--check] [--force] [--skip-install] [--yes] [--help] [--version]
|
|
281
284
|
|
|
285
|
+
--programme The site's programme issue in Linear, opened from the Site programme
|
|
286
|
+
template. The build refuses to run until site.programme.json names it.
|
|
282
287
|
--dry-run Print the plan and stop. Writes nothing, runs nothing.
|
|
283
288
|
--check Like --dry-run, never prompts, and exits 3 when there is work to do,
|
|
284
289
|
a house file that differs from its template included. For CI.
|
|
@@ -303,6 +308,7 @@ function parseOptions(argv) {
|
|
|
303
308
|
"site-url": { type: "string" },
|
|
304
309
|
sector: { type: "string" },
|
|
305
310
|
description: { type: "string" },
|
|
311
|
+
programme: { type: "string" },
|
|
306
312
|
answers: { type: "string" },
|
|
307
313
|
"dry-run": { type: "boolean", default: false },
|
|
308
314
|
check: { type: "boolean", default: false },
|
|
@@ -323,6 +329,7 @@ function parseOptions(argv) {
|
|
|
323
329
|
siteUrl: values["site-url"],
|
|
324
330
|
sector: values.sector,
|
|
325
331
|
description: values.description,
|
|
332
|
+
programme: values.programme,
|
|
326
333
|
answers: values.answers,
|
|
327
334
|
dryRun: values["dry-run"] ?? false,
|
|
328
335
|
check: values.check ?? false,
|
|
@@ -419,6 +426,19 @@ import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as
|
|
|
419
426
|
import { join as join5 } from "path";
|
|
420
427
|
|
|
421
428
|
// src/adapters.ts
|
|
429
|
+
var GATES = [
|
|
430
|
+
"programme.mjs",
|
|
431
|
+
"prebuild.mjs",
|
|
432
|
+
"check-direction.mjs",
|
|
433
|
+
"tokens.mjs",
|
|
434
|
+
"night-contrast.mjs",
|
|
435
|
+
"facts.mjs",
|
|
436
|
+
"copy-deck.mjs",
|
|
437
|
+
"null-check.mjs",
|
|
438
|
+
"mobile-first.mjs",
|
|
439
|
+
"measure.mjs",
|
|
440
|
+
"deploy-preview.mjs"
|
|
441
|
+
];
|
|
422
442
|
function layoutFor(project) {
|
|
423
443
|
const base = project.srcBase;
|
|
424
444
|
const shared = [
|
|
@@ -429,7 +449,9 @@ function layoutFor(project) {
|
|
|
429
449
|
{ template: "shared/tests/seo/graph.test.ts", dest: "tests/seo/graph.test.ts" },
|
|
430
450
|
{ template: "shared/tests/house.test.ts", dest: "tests/house.test.ts" },
|
|
431
451
|
{ template: "shared/lib/consent.ts", dest: `${base}lib/consent.ts` },
|
|
432
|
-
{ template: "shared/lib/legal.ts", dest: `${base}lib/legal.ts` }
|
|
452
|
+
{ template: "shared/lib/legal.ts", dest: `${base}lib/legal.ts` },
|
|
453
|
+
{ template: "shared/docs/site-programme.md", dest: "docs/site-programme.md" },
|
|
454
|
+
...GATES.map((g) => ({ template: `shared/scripts/gates/${g}`, dest: `scripts/gates/${g}` }))
|
|
433
455
|
];
|
|
434
456
|
const siteKeys = {
|
|
435
457
|
facts: "site.facts.ts",
|
|
@@ -724,6 +746,41 @@ function renderRedirects() {
|
|
|
724
746
|
return `${JSON.stringify({ $schema: "./node_modules/@domandigital/seo/redirects.schema.json", redirects: [] }, null, 2)}
|
|
725
747
|
`;
|
|
726
748
|
}
|
|
749
|
+
function renderProgramme(a, project) {
|
|
750
|
+
const base = project.srcBase;
|
|
751
|
+
const source = base ? [base.replace(/\/$/, "")] : ["app", "components", "lib", "content"];
|
|
752
|
+
const host = a.stack.host === "cloudflare" || a.stack.host === "vercel" ? a.stack.host : null;
|
|
753
|
+
const programme = {
|
|
754
|
+
$comment: "Read by scripts/gates/ before every build and preview deploy. docs/site-programme.md says what each key is for. Written by @domandigital/create-site; yours to edit, never overwritten.",
|
|
755
|
+
issue: a.programme,
|
|
756
|
+
registeredDirection: null,
|
|
757
|
+
paths: {
|
|
758
|
+
tokens: `${base}styles/tokens.css`,
|
|
759
|
+
deck: `${base}content/deck.ts`,
|
|
760
|
+
deckMarkdown: "docs/copy-deck.md",
|
|
761
|
+
nullCheck: "docs/null-check.md",
|
|
762
|
+
source
|
|
763
|
+
},
|
|
764
|
+
measure: { pages: ["/"], minFontPx: 12, labels: null, port: 4410 },
|
|
765
|
+
nullCheck: { harvest: null, justified: {} },
|
|
766
|
+
facts: { importer: null },
|
|
767
|
+
mobileFirst: { exceptions: [] },
|
|
768
|
+
preview: { host }
|
|
769
|
+
};
|
|
770
|
+
return `${JSON.stringify(programme, null, 2)}
|
|
771
|
+
`;
|
|
772
|
+
}
|
|
773
|
+
function renderSheets() {
|
|
774
|
+
const inks = { ink: null, "ink-2": null, "ink-3": null, rule: null, "accent-soft": null };
|
|
775
|
+
const sheets = {
|
|
776
|
+
$comment: "The day side's ground and accent are art-direction.json's choices. Every other colour, and the whole night side, is decided here in Stage 05 with a reason in because, and measured by scripts/gates/night-contrast.mjs before every build.",
|
|
777
|
+
light: inks,
|
|
778
|
+
night: { ground: null, accent: null, ...inks },
|
|
779
|
+
because: null
|
|
780
|
+
};
|
|
781
|
+
return `${JSON.stringify(sheets, null, 2)}
|
|
782
|
+
`;
|
|
783
|
+
}
|
|
727
784
|
|
|
728
785
|
// src/versions.ts
|
|
729
786
|
var HOUSE_DEPENDENCIES = {
|
|
@@ -733,7 +790,11 @@ var HOUSE_DEPENDENCIES = {
|
|
|
733
790
|
var HOUSE_DEV_DEPENDENCIES = {
|
|
734
791
|
"@domandigital/craft": "^0.19.0",
|
|
735
792
|
"@types/node": "^22.0.0",
|
|
736
|
-
vitest: "^4.1.11"
|
|
793
|
+
vitest: "^4.1.11",
|
|
794
|
+
// scripts/gates/measure.mjs renders the pages at 375, 390 and 1440 before every
|
|
795
|
+
// preview deploy; tsx loads the copy deck on Node older than 22.18.
|
|
796
|
+
playwright: "^1.62.0",
|
|
797
|
+
tsx: "^4.20.0"
|
|
737
798
|
};
|
|
738
799
|
var ACTIONS = {
|
|
739
800
|
checkout: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1",
|
|
@@ -1067,6 +1128,14 @@ function hasWorkflows(root) {
|
|
|
1067
1128
|
const dir = join5(root, ".github", "workflows");
|
|
1068
1129
|
return existsSync5(dir) && readdirSync3(dir).some((f) => /\.ya?ml$/.test(f));
|
|
1069
1130
|
}
|
|
1131
|
+
function programmeIssueIn(root) {
|
|
1132
|
+
try {
|
|
1133
|
+
const issue = JSON.parse(readFileSync5(join5(root, "site.programme.json"), "utf8")).issue;
|
|
1134
|
+
return typeof issue === "string" && issue ? issue : null;
|
|
1135
|
+
} catch {
|
|
1136
|
+
return null;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1070
1139
|
function actionFor(root, path, contents, data, force) {
|
|
1071
1140
|
const abs = join5(root, path);
|
|
1072
1141
|
if (!existsSync5(abs)) return "create";
|
|
@@ -1101,8 +1170,13 @@ function planScaffold(project, answers, options) {
|
|
|
1101
1170
|
{ path: "docs/DIRECTION.md", contents: renderDirection(answers, options.today), data: true },
|
|
1102
1171
|
{ path: "docs/seo-launch-checklist.md", contents: renderChecklist(answers), data: true },
|
|
1103
1172
|
{ path: "docs/seo-baseline.md", contents: renderBaseline(answers, options.today), data: true },
|
|
1104
|
-
{ path: "docs/client-facts.entry.json", contents: renderStackEntry(answers, project.framework, options.today), data: true }
|
|
1173
|
+
{ path: "docs/client-facts.entry.json", contents: renderStackEntry(answers, project.framework, options.today), data: true },
|
|
1174
|
+
{ path: "site.programme.json", contents: renderProgramme(answers, project), data: true },
|
|
1175
|
+
{ path: "art-direction.sheets.json", contents: renderSheets(), data: true }
|
|
1105
1176
|
);
|
|
1177
|
+
if (!answers.programme && !programmeIssueIn(root)) {
|
|
1178
|
+
notes.push("site.programme.json names no programme issue, so the build refuses to run. Open the programme from the Site programme template in Linear and put its id in issue.");
|
|
1179
|
+
}
|
|
1106
1180
|
const workflowPath = ".github/workflows/seo-check.yml";
|
|
1107
1181
|
const workflow = renderWorkflow(project, options.visibility ?? "private");
|
|
1108
1182
|
if (existsSync5(join5(root, workflowPath)) || workflow && !hasWorkflows(root)) {
|
|
@@ -1119,7 +1193,15 @@ function planScaffold(project, answers, options) {
|
|
|
1119
1193
|
const pkg = patchPackageJson(
|
|
1120
1194
|
project.packageJson,
|
|
1121
1195
|
{
|
|
1122
|
-
scripts: {
|
|
1196
|
+
scripts: {
|
|
1197
|
+
"seo:check": "vitest run tests/seo tests/house.test.ts",
|
|
1198
|
+
"launch:check": "vitest run tests --mode launch",
|
|
1199
|
+
prebuild: "node scripts/gates/prebuild.mjs",
|
|
1200
|
+
tokens: "node scripts/gates/tokens.mjs && node scripts/gates/night-contrast.mjs",
|
|
1201
|
+
deck: "node scripts/gates/copy-deck.mjs",
|
|
1202
|
+
measure: "node scripts/gates/measure.mjs --serve",
|
|
1203
|
+
"deploy:preview": "node scripts/gates/deploy-preview.mjs"
|
|
1204
|
+
},
|
|
1123
1205
|
scriptsIfMissing: { test: "vitest run" },
|
|
1124
1206
|
dependencies: options.skipInstall ? { ...HOUSE_DEPENDENCIES } : {},
|
|
1125
1207
|
devDependencies: options.skipInstall ? { ...HOUSE_DEV_DEPENDENCIES } : {}
|
|
@@ -1239,7 +1321,8 @@ ${USAGE}`);
|
|
|
1239
1321
|
tradingName: options.tradingName,
|
|
1240
1322
|
siteUrl: options.siteUrl,
|
|
1241
1323
|
sector: options.sector,
|
|
1242
|
-
description: options.description
|
|
1324
|
+
description: options.description,
|
|
1325
|
+
programme: options.programme
|
|
1243
1326
|
},
|
|
1244
1327
|
file: options.answers,
|
|
1245
1328
|
cwd: io.cwd,
|
|
@@ -1275,6 +1358,9 @@ ${work.map((w) => ` ${w}`).join("\n")}`);
|
|
|
1275
1358
|
" Fill in legal in site.facts.ts and have the client confirm the legal pages match what the business does.",
|
|
1276
1359
|
" 3. Work through docs/seo-launch-checklist.md.",
|
|
1277
1360
|
` 4. ${pm} seo:check now, and ${pm} launch:check before go-live.`,
|
|
1361
|
+
" 5. The build runs the site programme's gates (docs/site-programme.md) and refuses until the",
|
|
1362
|
+
" programme issue, the Stage 05 direction and both sides of the sheet, and the Stage 06 copy deck exist.",
|
|
1363
|
+
` Preview deploys go through ${pm} deploy:preview only; it measures at 1440 and 390 first.`,
|
|
1278
1364
|
...pending.map((p) => ` Still to run: ${p}`)
|
|
1279
1365
|
].join("\n")
|
|
1280
1366
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domandigital/create-site",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The first thing that runs on a new Doman Digital client site: installs the house packages and writes the per-site files they read (the facts file, route policy, backlink register, redirects, JSON-LD, the designer credit, house docs and the SEO checks), so every build starts on the same foundation and stays upgradeable by bumping packages.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsup": "^8.3.5",
|
|
42
42
|
"typescript": "^5.6.3",
|
|
43
43
|
"vitest": "^4.0.0",
|
|
44
|
-
"@domandigital/craft": "^0.19.
|
|
44
|
+
"@domandigital/craft": "^0.19.1",
|
|
45
45
|
"@domandigital/graph": "^0.7.0",
|
|
46
46
|
"@domandigital/seo": "^0.3.1"
|
|
47
47
|
},
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# The site programme
|
|
2
|
+
|
|
3
|
+
Every Doman Digital site is made, or rearchitected, in ten stages. The process
|
|
4
|
+
ran first on the Doman Digital redesign (DOM-392, stages DOM-393 to DOM-402)
|
|
5
|
+
and was made the house way on 10 October 2026 (DOM-647). It is held in place by
|
|
6
|
+
structure and by code, never by memory:
|
|
7
|
+
|
|
8
|
+
- **In Linear**, the "Site programme" template on the DOM team opens the
|
|
9
|
+
programme issue with the ten stages as its children. A parent with an open
|
|
10
|
+
child cannot be closed (the nightly enforcer reopens it), so a site cannot
|
|
11
|
+
be finished with a stage skipped. The `new-client-build` skill opens it
|
|
12
|
+
first and will not scaffold before Stage 05 is accepted.
|
|
13
|
+
- **In this repo**, the gates under `scripts/gates/` run before every build
|
|
14
|
+
and before every preview deploy. A gate that fails stops the build and names
|
|
15
|
+
its stage.
|
|
16
|
+
|
|
17
|
+
This file is a house file: `create-site --check` reports it when it differs
|
|
18
|
+
from the template. The site's own answers live in `site.programme.json`,
|
|
19
|
+
`art-direction.json` and `art-direction.sheets.json`, which are never
|
|
20
|
+
replaced.
|
|
21
|
+
|
|
22
|
+
## Working rules
|
|
23
|
+
|
|
24
|
+
- Every stage has a deliverable, a review and a recorded exit decision.
|
|
25
|
+
- One rendered artefact per stage exit.
|
|
26
|
+
- Decisions go to a register, never a chat.
|
|
27
|
+
- Governed facts are imported, never retyped.
|
|
28
|
+
- The live site is untouched until Stage 09.
|
|
29
|
+
- Phone first, at every stage from 03: designed at 375px, built with the phone
|
|
30
|
+
as the base styles and `min-width` for wider layouts, measured at 375
|
|
31
|
+
before any wider width, and reviewed from the phone capture first
|
|
32
|
+
(`STANDARD.md` section 10 in `@domandigital/craft`, DOM-772).
|
|
33
|
+
- A gate is a script that blocks the build, never a reminder
|
|
34
|
+
(`docs/ops/time-tracking.md` in Doman-Digital for why: the one control that
|
|
35
|
+
needed a person to start it was never used once).
|
|
36
|
+
|
|
37
|
+
A stage issue moves to Done only with its deliverable linked and its exit
|
|
38
|
+
acceptance recorded on the issue: the artefact and version, the evidence and
|
|
39
|
+
its limits, the reviewer, the decision and date. Creating the issue or drafting
|
|
40
|
+
a file is not acceptance.
|
|
41
|
+
|
|
42
|
+
## The ten stages and their gates
|
|
43
|
+
|
|
44
|
+
| Stage | Deliverable | Exit | Gate in code |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| 01 Brief, scope and evidence constraints | The agreed brief, scope and exclusions, the evidence and claim inventory, success measures, owners and reviewers | A named person agrees the brief and scope; missing claims have owners and safe placeholders | `site.programme.json` names the programme issue |
|
|
47
|
+
| 02 Page roles, buyer journeys and the content model | Sitemap and page-role map, route register, journey maps, the call-to-action contract, the code and CMS ownership map | Each journey reaches a fitting next step; no orphan page or unrecorded removal | `site.routes.ts` and `tests/seo/coverage.test.ts` (every page on disk has a policy) |
|
|
48
|
+
| 03 Low-fidelity wireframes, phone first | A versioned wireframe set covering every page family at 375px first, then the desktop derived from it, annotated with evidence, destination and holds | Hierarchy and journey coverage accepted on the phone set first; missing proof is an obvious placeholder | None: wireframes are reviewed, not built |
|
|
49
|
+
| 04 Validate the prototype and iterate the journeys | Test tasks, the synthetic buyer panel's run, then human sessions; findings and a revised wireframe version | Critical task failures fixed and rechecked; the approved wireframe version is named | The buyer panel (`packages/buyer-panel` in dd-packages) run on the prototype; its report linked on the issue |
|
|
50
|
+
| 05 Visual direction, argued from evidence and measured | `art-direction.json`: the job, a hierarchy per page type and the seven choices with their reasons; the night side in `art-direction.sheets.json`; the accent test | The human choice and its reason recorded on the issue; no value adopted because an earlier pack showed it | `check-direction.mjs`, `tokens.mjs`, `night-contrast.mjs` |
|
|
51
|
+
| 06 Detailed pages, content and the component system | The real app on a preview, every page family, the copy deck through the gates, built phone first and measured at 375, then 390, then 1440 | Design and content accepted at an exact version, from the phone captures first; no invented price or claim in the deck | `facts.mjs`, `copy-deck.mjs`, `null-check.mjs`, `mobile-first.mjs`, `measure.mjs`, `deploy-preview.mjs` |
|
|
52
|
+
| 07 Implementation and content migration plan | Slices, the file and CMS ownership manifest, the route, SEO and redirect plan, tests per slice, release and rollback outline | A named reviewer accepts the plan and the first slice | `redirects.json` and `tests/seo/redirects.test.ts` |
|
|
53
|
+
| 08 Build the approved slices and verify rendered drafts | Reviewed PRs, protected CMS drafts, rendered previews, slice-level checks | Every slice matches the accepted design or has a recorded deviation | Every gate above, on every build and every preview |
|
|
54
|
+
| 09 QA across every journey, and the release decision | The acceptance report across every page family and journey; a named go or no-go | No release-critical defect open; residual risks accepted by the right person | `launch:check`, `craft direction validate --snapshot <preview> --strict`; the live domain is attached here and nowhere earlier |
|
|
55
|
+
| 10 Launch safely, measure, record what was learned | Release record, rollback reference, live checks, the observation-window review, lessons | Live checks pass; follow-ups have owners; the learning is recorded | `docs/seo-baseline.md` at 90 days, 6 and 12 months |
|
|
56
|
+
|
|
57
|
+
## The gates
|
|
58
|
+
|
|
59
|
+
Run in this order by `scripts/gates/prebuild.mjs` before every build. The first
|
|
60
|
+
failure stops the build.
|
|
61
|
+
|
|
62
|
+
| Gate | Stage | Reads | Fails when |
|
|
63
|
+
| --- | --- | --- | --- |
|
|
64
|
+
| `check-direction.mjs` | 05 | `art-direction.json`, the registered copy named in `site.programme.json` | the file is missing, craft finds it invalid, a layer is undecided, or it differs from the registered copy in the craft estate |
|
|
65
|
+
| `tokens.mjs` | 05 | `art-direction.json`, `art-direction.sheets.json` | a day or night value is still null, or the night side has no reason. Writes the token stylesheet (`paths.tokens`), both sides of the sheet |
|
|
66
|
+
| `night-contrast.mjs` | 05 | the token stylesheet | a text pair falls under 4.5:1 by day or by night |
|
|
67
|
+
| `facts.mjs` | 06 | the site's source (`paths.source`) and the deck | a price, response target, minimum term or notice period is typed rather than read from `site.facts.ts` or a generated facts file. Runs `facts.importer` first when one is named |
|
|
68
|
+
| `copy-deck.mjs --check` | 06 | the deck (`paths.deck`) | the deck is missing or empty, or the rendered deck (`paths.deckMarkdown`) is not current |
|
|
69
|
+
| `null-check.mjs` | 06 | the rendered deck, the null harvest (`nullCheck.harvest`) | a phrase the null builds kept writing is in the deck without a reason under `nullCheck.justified`. Skips when the harvest is not on the machine |
|
|
70
|
+
| `mobile-first.mjs` | 06 | the site's source (`paths.source`, and `src`, `app`, `components` and `styles` when present) | a `max-width` media query (or `width <` range syntax) or a Tailwind `max-*:` variant is written without a recorded exception: `mobile-first-ok: <reason>` on its line or the line above, or the file in `mobileFirst.exceptions` with a reason. An exception with no reason fails |
|
|
71
|
+
|
|
72
|
+
Run around a running build:
|
|
73
|
+
|
|
74
|
+
| Gate | Stage | Fails when |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `measure.mjs` | 06 | measured phone first, at 375, then 390, then 1440: a page in `measure.pages` does not answer, scrolls sideways, or shows text under `measure.minFontPx`; at 375 and 390, a link, button, field or summary is under 44 x 44 CSS px (a link inside a sentence is exempt) or a text field is set under 16px; a label in `measure.labels` leaves its container or covers a label or copy; with `--preview`, a page has no noindex |
|
|
77
|
+
| `deploy-preview.mjs` | 06 to 08 | the build, the measurement or the host's config refuses it (a route, a custom domain or `--prod`). Sets `PUBLIC_PREVIEW=1` and `NEXT_PUBLIC_PREVIEW=1` itself |
|
|
78
|
+
|
|
79
|
+
The site reads `PUBLIC_PREVIEW` (Astro, `import.meta.env.PUBLIC_PREVIEW`) or
|
|
80
|
+
`NEXT_PUBLIC_PREVIEW` (Next) to add `<meta name="robots" content="noindex">`
|
|
81
|
+
and to hold anything that must not run on a preview, such as a live form
|
|
82
|
+
handler. The measurement fails a preview that does not.
|
|
83
|
+
|
|
84
|
+
## The governed-facts importer
|
|
85
|
+
|
|
86
|
+
`site.facts.ts` is the governed source for the business's own facts, and pages
|
|
87
|
+
import it. When a figure is governed somewhere else (a price list in another
|
|
88
|
+
repo, a contract schedule), the site gets an importer: a script that reads the
|
|
89
|
+
governed modules and writes `src/generated/facts.json` before every build,
|
|
90
|
+
named in `site.programme.json` as `facts.importer`. The pages read the
|
|
91
|
+
generated file and nothing else, so a price on the site is always the price
|
|
92
|
+
the governed file holds. `apps/site/scripts/facts.ts` in Doman-Digital is the
|
|
93
|
+
worked example: it imports `docs/brand-facts.json` and the marketing app's
|
|
94
|
+
pricing modules and writes the facts the redesign renders.
|
|
95
|
+
|
|
96
|
+
## site.programme.json
|
|
97
|
+
|
|
98
|
+
| Key | What it is |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `issue` | The programme issue in Linear (`DOM-123`) |
|
|
101
|
+
| `registeredDirection` | The direction's registered copy in the craft estate, usually `~/dd-ops/<site>/art-direction.json`; null until registered |
|
|
102
|
+
| `paths` | Where the token stylesheet, the deck, the rendered deck and the null-check report live, and the source folders `facts.mjs` reads |
|
|
103
|
+
| `measure` | `pages`, `minFontPx` (12), `labels` (`{ "selector": ".label", "within": ".screen" }` or null), `port` |
|
|
104
|
+
| `nullCheck` | `harvest` (a path, `~/` allowed) and `justified` (phrase to reason) |
|
|
105
|
+
| `facts` | `importer`: the site's importer script, or null |
|
|
106
|
+
| `mobileFirst` | `exceptions`: the files allowed a `max-width` query or `max-*:` variant, each `{ "file": "src/styles/print.css", "reason": "..." }` |
|
|
107
|
+
| `preview` | `host`: `cloudflare` or `vercel`, or null to find it from the config |
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Stage 05 gate: the visual direction is decided before anything is built on
|
|
2
|
+
// it. Refuses the build when art-direction.json is missing, when craft does
|
|
3
|
+
// not find it valid, or when a layer is still undecided (the job, every
|
|
4
|
+
// declared page's hierarchy, at least five of the seven tokens). Then, when
|
|
5
|
+
// site.programme.json names a registered copy (the one in the craft estate on
|
|
6
|
+
// the work box), the two must match byte for byte, so a change made in one
|
|
7
|
+
// place reaches the other on purpose. Off the work box the registered copy is
|
|
8
|
+
// absent and the gate says so and passes on the site's own copy.
|
|
9
|
+
//
|
|
10
|
+
// Lifted from apps/site/scripts/check-direction.mjs in Doman-Digital (DOM-647).
|
|
11
|
+
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { craftBin, programme, root, sitePath, stop } from "./programme.mjs";
|
|
16
|
+
|
|
17
|
+
const GATE = "check-direction";
|
|
18
|
+
const file = join(root, "art-direction.json");
|
|
19
|
+
if (!existsSync(file)) stop(GATE, "05", "no art-direction.json. Run craft direction init, then decide the job, the hierarchy and the tokens with their reasons.");
|
|
20
|
+
|
|
21
|
+
const bin = craftBin();
|
|
22
|
+
if (!bin) stop(GATE, "05", "@domandigital/craft is not installed, so the direction cannot be validated. Install the site's dependencies.");
|
|
23
|
+
|
|
24
|
+
const run = spawnSync(process.execPath, [bin, "direction", "validate", "--json"], { cwd: root, encoding: "utf8" });
|
|
25
|
+
let report;
|
|
26
|
+
try {
|
|
27
|
+
report = JSON.parse(run.stdout);
|
|
28
|
+
} catch {
|
|
29
|
+
stop(GATE, "05", `craft direction validate did not report: ${(run.stderr || run.stdout).trim()}`);
|
|
30
|
+
}
|
|
31
|
+
const errors = report.problems.filter((p) => p.severity === "error");
|
|
32
|
+
if (!report.valid) stop(GATE, "05", `art-direction.json is not valid:\n${errors.map((p) => ` ${p.at || "(file)"} ${p.message}`).join("\n")}`);
|
|
33
|
+
if (!report.layers.complete) {
|
|
34
|
+
const l = report.layers;
|
|
35
|
+
const pages = l.hierarchy.map((h) => `${h.page} ${h.decided} of ${h.total}`).join(", ") || "none";
|
|
36
|
+
stop(GATE, "05", `the direction is not decided yet: job ${l.job ? "decided" : "not decided"}; hierarchy ${pages}; tokens ${l.tokens.decided} of ${l.tokens.total} (five is the least).`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { registeredDirection } = programme();
|
|
40
|
+
if (!registeredDirection) {
|
|
41
|
+
console.log(`${GATE}: decided; no registered copy named in site.programme.json`);
|
|
42
|
+
} else {
|
|
43
|
+
const registered = sitePath(registeredDirection);
|
|
44
|
+
if (!existsSync(registered)) {
|
|
45
|
+
console.log(`${GATE}: decided; no registered copy on this machine (${registeredDirection}), so the site's copy stands`);
|
|
46
|
+
} else if (readFileSync(file, "utf8") !== readFileSync(registered, "utf8")) {
|
|
47
|
+
stop(GATE, "05", `art-direction.json differs from ${registered}. Copy the newer one over the other and run craft direction validate on it.`);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(`${GATE}: decided, and matches the registered copy`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Stage 06 gate: every string the site carries lives in one copy deck (the
|
|
2
|
+
// TypeScript module site.programme.json names in paths.deck), and this
|
|
3
|
+
// renders it to one Markdown document in page order, so copy-check and a
|
|
4
|
+
// reviewer read the whole site in one place. `--check` fails when the deck is
|
|
5
|
+
// missing, empty, or newer than the committed document: copy that has not
|
|
6
|
+
// been through the deck has not been through the gates. Without --check it
|
|
7
|
+
// writes the document.
|
|
8
|
+
//
|
|
9
|
+
// Lifted from apps/site/scripts/copy-deck.mjs in Doman-Digital (DOM-647),
|
|
10
|
+
// with the page order taken from the deck itself instead of written out.
|
|
11
|
+
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname } from "node:path";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
15
|
+
import { programme, sitePath, stop } from "./programme.mjs";
|
|
16
|
+
|
|
17
|
+
const GATE = "copy-deck";
|
|
18
|
+
const check = process.argv.includes("--check");
|
|
19
|
+
const { paths } = programme();
|
|
20
|
+
const source = sitePath(paths.deck);
|
|
21
|
+
const out = sitePath(paths.deckMarkdown);
|
|
22
|
+
if (!existsSync(source)) stop(GATE, "06", `no copy deck at ${paths.deck}. Export \`deck\` from it: one key per page, every string the page shows.`);
|
|
23
|
+
|
|
24
|
+
// Node strips the types from a .ts module from 22.18; before that, tsx if the site has it.
|
|
25
|
+
let mod;
|
|
26
|
+
try {
|
|
27
|
+
mod = await import(pathToFileURL(source).href);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
try {
|
|
30
|
+
const { register } = await import("tsx/esm/api");
|
|
31
|
+
register();
|
|
32
|
+
mod = await import(pathToFileURL(source).href);
|
|
33
|
+
} catch {
|
|
34
|
+
stop(GATE, "06", `could not load ${paths.deck} (${error.message}). Use Node 22.18 or later, or add tsx.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const deck = mod.deck ?? mod.default;
|
|
38
|
+
if (!deck || typeof deck !== "object" || Object.keys(deck).length === 0) stop(GATE, "06", `${paths.deck} exports no copy. Export \`deck\` with one key per page.`);
|
|
39
|
+
|
|
40
|
+
const lines = [
|
|
41
|
+
"# Copy deck",
|
|
42
|
+
"",
|
|
43
|
+
`Generated from \`${paths.deck}\` by \`scripts/gates/copy-deck.mjs\`. Edit the deck, not this file. Figures are not in the deck: pages read them from the facts.`,
|
|
44
|
+
"",
|
|
45
|
+
];
|
|
46
|
+
const isLink = (v) => v && typeof v === "object" && typeof v.label === "string" && typeof v.href === "string" && Object.keys(v).length <= 3;
|
|
47
|
+
const inline = (v) =>
|
|
48
|
+
isLink(v)
|
|
49
|
+
? `[${v.label}](${v.href})`
|
|
50
|
+
: Array.isArray(v)
|
|
51
|
+
? v.map(inline).join(" · ")
|
|
52
|
+
: v && typeof v === "object"
|
|
53
|
+
? Object.values(v).map(inline).filter(Boolean).join(" · ")
|
|
54
|
+
: v === null || v === undefined || typeof v === "boolean"
|
|
55
|
+
? ""
|
|
56
|
+
: String(v);
|
|
57
|
+
|
|
58
|
+
function render(value, depth) {
|
|
59
|
+
for (const [key, v] of Object.entries(value)) {
|
|
60
|
+
if (v === null || v === undefined || typeof v === "boolean") continue;
|
|
61
|
+
if (Array.isArray(v)) {
|
|
62
|
+
lines.push(`**${key}**`, "", ...v.map((item) => `- ${inline(item)}`), "");
|
|
63
|
+
} else if (isLink(v)) {
|
|
64
|
+
lines.push(`**${key}**: ${inline(v)}`, "");
|
|
65
|
+
} else if (typeof v === "object") {
|
|
66
|
+
lines.push(`${"#".repeat(Math.min(depth, 6))} ${key}`, "");
|
|
67
|
+
render(v, depth + 1);
|
|
68
|
+
} else {
|
|
69
|
+
lines.push(`**${key}**: ${String(v)}`, "");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
render(deck, 2);
|
|
74
|
+
|
|
75
|
+
const text = `${lines.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd()}\n`;
|
|
76
|
+
if (check) {
|
|
77
|
+
const current = existsSync(out) ? readFileSync(out, "utf8") : "";
|
|
78
|
+
if (current !== text) stop(GATE, "06", `${paths.deckMarkdown} is not the current deck. Run the deck script, read it, and put it through copy-check.`);
|
|
79
|
+
console.log(`${GATE}: ${paths.deckMarkdown} is current`);
|
|
80
|
+
} else {
|
|
81
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
82
|
+
writeFileSync(out, text);
|
|
83
|
+
console.log(`${GATE}: ${paths.deckMarkdown} written`);
|
|
84
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Stages 06 to 08: the only deploy this site has until the Stage 09 release
|
|
2
|
+
// decision, and it can only make a preview. It sets PUBLIC_PREVIEW=1 (and
|
|
3
|
+
// NEXT_PUBLIC_PREVIEW=1) itself, so nobody has to remember to; builds, which
|
|
4
|
+
// runs every build gate; serves the build locally and measures it at 1440 and
|
|
5
|
+
// 390 with --preview (noindex required); and only then deploys, preview only:
|
|
6
|
+
//
|
|
7
|
+
// cloudflare wrangler deploy, refused while the wrangler config carries a
|
|
8
|
+
// route, a custom domain or workers_dev: false
|
|
9
|
+
// vercel vercel deploy, never --prod
|
|
10
|
+
//
|
|
11
|
+
// The host is preview.host in site.programme.json, or found from the
|
|
12
|
+
// wrangler config or .vercel/project.json. Going live is a separate,
|
|
13
|
+
// recorded decision in Stage 09; nothing here can do it. --dry-run does
|
|
14
|
+
// everything but the deploy.
|
|
15
|
+
//
|
|
16
|
+
// Lifted from the build:preview and deploy:preview scripts and wrangler.jsonc
|
|
17
|
+
// of apps/site in Doman-Digital (DOM-647).
|
|
18
|
+
|
|
19
|
+
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { programme, root, stop } from "./programme.mjs";
|
|
23
|
+
|
|
24
|
+
const GATE = "deploy-preview";
|
|
25
|
+
if (process.argv.includes("--prod")) stop(GATE, "09", "this script never deploys to production. Going live is the Stage 09 release decision.");
|
|
26
|
+
const dryRun = process.argv.includes("--dry-run");
|
|
27
|
+
const { preview = {} } = programme();
|
|
28
|
+
const env = { ...process.env, PUBLIC_PREVIEW: "1", NEXT_PUBLIC_PREVIEW: "1" };
|
|
29
|
+
const bin = (name) => join(root, "node_modules", ".bin", name);
|
|
30
|
+
|
|
31
|
+
const wranglerFile = ["wrangler.jsonc", "wrangler.json", "wrangler.toml"].find((f) => existsSync(join(root, f)));
|
|
32
|
+
const host = preview.host ?? (wranglerFile ? "cloudflare" : existsSync(join(root, ".vercel", "project.json")) ? "vercel" : null);
|
|
33
|
+
if (!host) stop(GATE, "06", "no preview host. Set preview.host in site.programme.json to cloudflare or vercel.");
|
|
34
|
+
|
|
35
|
+
if (host === "cloudflare") {
|
|
36
|
+
if (!wranglerFile) stop(GATE, "06", "preview.host is cloudflare but there is no wrangler config.");
|
|
37
|
+
// Comments out, so a commented-out route still counts as no route.
|
|
38
|
+
const text = readFileSync(join(root, wranglerFile), "utf8").replace(/^\s*(\/\/|#).*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
39
|
+
if (/["']?\broutes?\b["']?\s*[:=]/.test(text)) stop(GATE, "06", `${wranglerFile} carries a route. A preview has none: the live domain is attached only by the Stage 09 release.`);
|
|
40
|
+
if (/custom_domain/.test(text)) stop(GATE, "06", `${wranglerFile} carries a custom domain. A preview has none.`);
|
|
41
|
+
if (/workers_dev["']?\s*[:=]\s*false/.test(text)) stop(GATE, "06", `${wranglerFile} sets workers_dev to false, so a preview would have no address.`);
|
|
42
|
+
} else if (host !== "vercel") {
|
|
43
|
+
stop(GATE, "06", `preview.host is ${host}; this script knows cloudflare and vercel.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The package manager that ran this script, so the build is the one `build` names.
|
|
47
|
+
const pm = process.env.npm_execpath;
|
|
48
|
+
const build = pm ? spawnSync(process.execPath, [pm, "run", "build"], { cwd: root, env, stdio: "inherit" }) : spawnSync("npm", ["run", "build"], { cwd: root, env, stdio: "inherit" });
|
|
49
|
+
if (build.status !== 0) stop(GATE, "06", "the preview build failed. Nothing was deployed.");
|
|
50
|
+
|
|
51
|
+
const measured = spawnSync(process.execPath, [join(root, "scripts", "gates", "measure.mjs"), "--serve", "--preview"], { cwd: root, env, stdio: "inherit" });
|
|
52
|
+
if (measured.status !== 0) stop(GATE, "06", "the measurement failed. Nothing was deployed.");
|
|
53
|
+
|
|
54
|
+
if (dryRun) {
|
|
55
|
+
console.log(`${GATE}: built and measured; --dry-run, so nothing was deployed.`);
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
const deploy =
|
|
59
|
+
host === "cloudflare"
|
|
60
|
+
? spawnSync(existsSync(bin("wrangler")) ? bin("wrangler") : "npx", existsSync(bin("wrangler")) ? ["deploy"] : ["wrangler", "deploy"], { cwd: root, env, stdio: "inherit" })
|
|
61
|
+
: spawnSync("npx", ["vercel", "deploy", "--build-env", "PUBLIC_PREVIEW=1", "--build-env", "NEXT_PUBLIC_PREVIEW=1", "--env", "PUBLIC_PREVIEW=1", "--env", "NEXT_PUBLIC_PREVIEW=1"], { cwd: root, env, stdio: "inherit" });
|
|
62
|
+
if (deploy.status !== 0) stop(GATE, "06", `the ${host} deploy failed.`);
|
|
63
|
+
console.log(`${GATE}: measured and deployed to a ${host} preview. The live site is untouched.`);
|