create-ailk 0.46.6 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -43
- package/component-catalog.json +223 -285
- package/component-catalog.md +1 -1
- package/dist/apply-design.d.ts +26 -68
- package/dist/apply-design.js +150 -322
- package/dist/cli.js +152 -17
- package/dist/compare-chrome.d.ts +108 -0
- package/dist/compare-chrome.js +481 -0
- package/dist/compare-look.d.ts +94 -0
- package/dist/compare-look.js +378 -0
- package/dist/copy.js +1 -1
- package/dist/design-compile.d.ts +17 -21
- package/dist/design-compile.js +32 -56
- package/dist/design-files.d.ts +93 -0
- package/dist/design-files.js +312 -0
- package/dist/design-home.d.ts +4 -2
- package/dist/design-home.js +88 -6
- package/dist/design-names.d.ts +13 -0
- package/dist/design-names.js +76 -0
- package/dist/design-package.d.ts +46 -56
- package/dist/design-package.js +285 -288
- package/dist/design-presets.d.ts +41 -0
- package/dist/design-presets.js +83 -4
- package/dist/design-scaffold.d.ts +12 -2
- package/dist/design-scaffold.js +72 -34
- package/dist/generated/design-settings.d.ts +56 -0
- package/dist/generated/design-settings.js +237 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/inventory.d.ts +3 -2
- package/dist/inventory.js +10 -4
- package/dist/lib/design-checks.d.ts +46 -0
- package/dist/lib/design-checks.js +79 -1
- package/dist/lib/env-catalog.js +5 -1
- package/dist/lib/module-license-gate.d.ts +1 -1
- package/dist/lib/module-license-gate.js +1 -1
- package/dist/lib/render-verdict.d.ts +13 -1
- package/dist/lib/render-verdict.js +41 -1
- package/dist/look-hub.d.ts +44 -0
- package/dist/look-hub.js +130 -0
- package/dist/look-record.d.ts +35 -0
- package/dist/look-record.js +85 -0
- package/dist/look-samples.d.ts +66 -0
- package/dist/look-samples.js +456 -0
- package/dist/look-settings.d.ts +53 -0
- package/dist/look-settings.js +363 -0
- package/dist/module-architecture.js +12 -0
- package/dist/parse-args.d.ts +10 -6
- package/dist/parse-args.js +26 -13
- package/dist/programmatic.d.ts +1 -19
- package/dist/programmatic.js +65 -103
- package/dist/retired-design-bodies.d.ts +29 -0
- package/dist/retired-design-bodies.js +51 -0
- package/dist/seed-flows.d.ts +1 -1
- package/dist/seed-flows.js +12 -14
- package/dist/seed-workspace.d.ts +4 -1
- package/dist/seed-workspace.js +139 -17
- package/dist/site-chrome.d.ts +41 -41
- package/dist/site-chrome.js +50 -70
- package/dist/site-fonts.d.ts +10 -14
- package/dist/site-fonts.js +5 -1
- package/dist/starter-grid.d.ts +2 -2
- package/dist/strip-look-copies.d.ts +67 -0
- package/dist/strip-look-copies.js +591 -0
- package/dist/template-manifest.d.ts +6 -14
- package/dist/template-manifest.js +0 -9
- package/dist/template-record.d.ts +3 -1
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +15 -0
- package/dist/topology.js +60 -0
- package/dist/update.d.ts +57 -1
- package/dist/update.js +742 -13
- package/package.json +3 -4
- package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/designs/minimalism/DESIGN.md +163 -297
- package/site-templates/designs/minimalism/LOOK.md +42 -0
- package/site-templates/designs/minimalism/design.yaml +167 -0
- package/site-templates/designs/standard/DESIGN.md +145 -149
- package/site-templates/designs/standard/LOOK.md +42 -0
- package/site-templates/designs/standard/design.yaml +72 -0
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/content/_site.mdx +0 -26
- package/templates/.claude/rules/extending.md +3 -2
- package/templates/.env.example +11 -4
- package/templates/CLAUDE.md +1 -1
- package/templates/DESIGN.md +145 -149
- package/templates/README.md +15 -16
- package/templates/apps/api/.env.example +29 -4
- package/templates/apps/api/CLAUDE.md +7 -4
- package/templates/apps/api/src/__tests__/vercel-handler.test.ts +176 -2
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +30 -4
- package/templates/apps/api/src/vercel-handler.ts +32 -2
- package/templates/apps/mcp/.env.example +8 -0
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/.env.example +10 -3
- package/templates/apps/web/CLAUDE.md +31 -4
- package/templates/apps/web/app/[locale]/layout.tsx +141 -77
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +13 -3
- package/templates/apps/web/app/not-found.tsx +11 -11
- package/templates/apps/web/auth.ts +48 -35
- package/templates/apps/web/jest.config.cjs +5 -0
- package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +542 -10
- package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
- package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +233 -0
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
- package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
- package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +19 -1
- package/templates/apps/web/lib/__tests__/site-navigation.test.ts +288 -0
- package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
- package/templates/apps/web/lib/deck-page.ts +3 -10
- package/templates/apps/web/lib/deploy-fonts.ts +12 -0
- package/templates/apps/web/lib/hub-site-config.ts +237 -29
- package/templates/apps/web/lib/library-fonts.ts +41 -0
- package/templates/apps/web/lib/mcp-oauth.ts +11 -4
- package/templates/apps/web/lib/page-chrome.ts +105 -20
- package/templates/apps/web/lib/section-look.ts +28 -0
- package/templates/apps/web/lib/site-design.ts +205 -0
- package/templates/apps/web/lib/site-navigation.ts +208 -0
- package/templates/apps/web/lib/site-theme-head.ts +98 -13
- package/templates/apps/web/lib/site-theme.ts +40 -62
- package/templates/apps/web/messages/en.json +0 -6
- package/templates/apps/web/next.config.mjs +213 -11
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +4 -2
- package/templates/content/_site.mdx +0 -26
- package/templates/design.yaml +75 -0
- package/templates/project.yaml +14 -0
- package/versions.json +52 -51
- package/site-templates/marketing-site/DESIGN.md +0 -259
- package/site-templates/marketing-site-free/DESIGN.md +0 -259
- package/site-templates/saas-product/DESIGN.md +0 -259
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
- package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
- package/templates/apps/web/lib/site-chrome.ts +0 -46
- package/templates/apps/web/lib/site-fonts.ts +0 -15
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `create-ailk look-settings` (#12476 D2, spec
|
|
3
|
+
* docs/specs/12476-import-each-live-site-s-spec.md): the design settings a
|
|
4
|
+
* live site's hub design record will hold, and the byte-for-byte proof that
|
|
5
|
+
* they are what the site's three generated look files were compiled from.
|
|
6
|
+
*
|
|
7
|
+
* It reads the site's `design.yaml`, its roster (`.ailk-site-manifest.json`,
|
|
8
|
+
* else the legacy `TEMPLATE-MANIFEST.json`), `content/_site.mdx`,
|
|
9
|
+
* `apps/web/lib/site-chrome.ts` and `apps/web/lib/site-fonts.ts` — each once,
|
|
10
|
+
* as text, never run. The settings are the design package with its layout
|
|
11
|
+
* replaced by the one create-ailk rendered into `site-chrome.ts`; the run
|
|
12
|
+
* hands them over only when they compile, by create-ailk's own compile and
|
|
13
|
+
* renderers, to each generated file exactly. It writes one file outside the
|
|
14
|
+
* checkout (`--out`, created mode 0600, never overwritten) binding the
|
|
15
|
+
* settings to the checkout by the digest of every file it read, and records
|
|
16
|
+
* the settings' own digest, which it also prints. The hub CLI
|
|
17
|
+
* `import-site-design` reads that file.
|
|
18
|
+
*
|
|
19
|
+
* Exit codes: 0 handed over · 1 a failure (a file missing, outside the site,
|
|
20
|
+
* not a regular file, over 1 MB, or refused by the reader) · 2 a bad flag, or
|
|
21
|
+
* an `--out` that exists or sits in the checkout · 3 a generated file that
|
|
22
|
+
* differs from what `design.yaml` compiles to.
|
|
23
|
+
*
|
|
24
|
+
* Pure module: no `import.meta.url`, so jest imports it directly.
|
|
25
|
+
*/
|
|
26
|
+
import { createHash } from "node:crypto";
|
|
27
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync, unlinkSync, writeSync, } from "node:fs";
|
|
28
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
29
|
+
import { parseArgs } from "node:util";
|
|
30
|
+
import { compileDesignFonts, compileDesignTheme } from "./design-compile.js";
|
|
31
|
+
import { DESIGN_SETTINGS_FILE } from "./design-files.js";
|
|
32
|
+
import { DesignPackageError, readDesignPackageText } from "./design-package.js";
|
|
33
|
+
import { spliceThemeBlock } from "./design-scaffold.js";
|
|
34
|
+
import { SITE_MDX_PATH } from "./look-hub.js";
|
|
35
|
+
import { ParseError } from "./parse-args.js";
|
|
36
|
+
import { renderSiteChrome, resolveSiteChrome, SITE_CHROME_PATH } from "./site-chrome.js";
|
|
37
|
+
import { renderSiteFonts, SITE_FONTS_PATH } from "./site-fonts.js";
|
|
38
|
+
import { LEGACY_SITE_ROSTER_PATH, parseSiteRoster, SITE_ROSTER_PATH } from "./site-roster.js";
|
|
39
|
+
const TAG = "[look:settings]";
|
|
40
|
+
/** A site file larger than this is refused (D2). */
|
|
41
|
+
export const LOOK_SITE_FILE_MAX_BYTES = 1_048_576;
|
|
42
|
+
/** The hand-off file's `kind` and `format` (D2). */
|
|
43
|
+
export const LOOK_SETTINGS_KIND = "ailk-look-settings";
|
|
44
|
+
export const LOOK_SETTINGS_FORMAT = 1;
|
|
45
|
+
/** The most characters a printed site or hub value keeps (D2's printing rule). */
|
|
46
|
+
const PRINTED_MAX = 120;
|
|
47
|
+
// ── Shared rules (D2) ────────────────────────────────────────────────────────
|
|
48
|
+
/**
|
|
49
|
+
* D2's printing rule: every character outside `[A-Za-z0-9._:/@ -]` becomes
|
|
50
|
+
* `\xNN`, one escape per UTF-8 byte, and the result is cut to 120 characters,
|
|
51
|
+
* so no site or hub value can carry a terminal escape or a forged line.
|
|
52
|
+
*/
|
|
53
|
+
export function printable(value) {
|
|
54
|
+
let out = "";
|
|
55
|
+
for (const ch of value) {
|
|
56
|
+
out += /^[A-Za-z0-9._:/@ -]$/.test(ch)
|
|
57
|
+
? ch
|
|
58
|
+
: [...Buffer.from(ch, "utf8")].map((byte) => `\\x${byte.toString(16).padStart(2, "0")}`).join("");
|
|
59
|
+
if (out.length >= PRINTED_MAX)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return out.slice(0, PRINTED_MAX);
|
|
63
|
+
}
|
|
64
|
+
function sortKeys(value) {
|
|
65
|
+
if (Array.isArray(value))
|
|
66
|
+
return value.map(sortKeys);
|
|
67
|
+
if (typeof value !== "object" || value === null)
|
|
68
|
+
return value;
|
|
69
|
+
return Object.fromEntries(Object.keys(value)
|
|
70
|
+
.sort()
|
|
71
|
+
.map((key) => [key, sortKeys(value[key])]));
|
|
72
|
+
}
|
|
73
|
+
/** The canonical JSON of a value (D2): every object's keys sorted, no whitespace. */
|
|
74
|
+
export function canonicalJson(value) {
|
|
75
|
+
return JSON.stringify(sortKeys(value));
|
|
76
|
+
}
|
|
77
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
78
|
+
/** The settings digest (D2): the SHA-256 of the settings' canonical JSON, UTF-8. */
|
|
79
|
+
export function settingsDigest(settings) {
|
|
80
|
+
return sha256(Buffer.from(canonicalJson(settings), "utf8"));
|
|
81
|
+
}
|
|
82
|
+
// ── Reading the site ─────────────────────────────────────────────────────────
|
|
83
|
+
/** The run's refusal or failure: its exit code and the lines it prints. */
|
|
84
|
+
class Stop extends Error {
|
|
85
|
+
code;
|
|
86
|
+
lines;
|
|
87
|
+
constructor(code, lines) {
|
|
88
|
+
super(lines.join("\n"));
|
|
89
|
+
this.code = code;
|
|
90
|
+
this.lines = lines;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const fail = (line) => new Stop(1, [`${TAG} ${line}`]);
|
|
94
|
+
/** Whether `real` (a real path) sits under `root` (a real path), `root` itself excluded. */
|
|
95
|
+
function under(root, real) {
|
|
96
|
+
const rel = relative(root, real);
|
|
97
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !rel.startsWith(sep);
|
|
98
|
+
}
|
|
99
|
+
/** Whether anything — a file, a directory, a link, a dangling link — is at `path`. */
|
|
100
|
+
function present(path) {
|
|
101
|
+
try {
|
|
102
|
+
lstatSync(path);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* One site file, read once (D2): its real path must sit under the site's;
|
|
111
|
+
* it is opened there with `O_NOFOLLOW`, checked with `fstat` on that
|
|
112
|
+
* descriptor (a regular file, at most 1 MB) and read into one buffer — the
|
|
113
|
+
* buffer that is hashed, parsed and compared.
|
|
114
|
+
*/
|
|
115
|
+
function readOnce(root, rel) {
|
|
116
|
+
let real;
|
|
117
|
+
try {
|
|
118
|
+
real = realpathSync(join(root, rel));
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
throw fail(`${rel}: not found`);
|
|
122
|
+
}
|
|
123
|
+
if (!under(root, real))
|
|
124
|
+
throw fail(`${rel}: resolves outside the site`);
|
|
125
|
+
let fd;
|
|
126
|
+
try {
|
|
127
|
+
fd = openSync(real, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
throw fail(`${rel}: is unreadable`);
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const stat = fstatSync(fd);
|
|
134
|
+
if (!stat.isFile())
|
|
135
|
+
throw fail(`${rel}: is not a regular file`);
|
|
136
|
+
if (stat.size > LOOK_SITE_FILE_MAX_BYTES)
|
|
137
|
+
throw fail(`${rel}: is over 1 MB`);
|
|
138
|
+
const buffer = readFileSync(fd);
|
|
139
|
+
if (buffer.length > LOOK_SITE_FILE_MAX_BYTES)
|
|
140
|
+
throw fail(`${rel}: is over 1 MB`);
|
|
141
|
+
return buffer;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
closeSync(fd);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** The 1-based number of the first line where `a` and `b` differ. */
|
|
148
|
+
function firstDifferingLine(a, b) {
|
|
149
|
+
const left = a.split("\n");
|
|
150
|
+
const right = b.split("\n");
|
|
151
|
+
for (let i = 0; i < Math.max(left.length, right.length); i += 1) {
|
|
152
|
+
if (left[i] !== right[i])
|
|
153
|
+
return i + 1;
|
|
154
|
+
}
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
const differs = (file, line) => `${TAG} ${file}: differs from what ${DESIGN_SETTINGS_FILE} compiles to at line ${line} — not imported`;
|
|
158
|
+
/** The roster name `readSiteRoster` would read: the current name when present, else the legacy one, else none. */
|
|
159
|
+
function rosterNameIn(root) {
|
|
160
|
+
return [SITE_ROSTER_PATH, LEGACY_SITE_ROSTER_PATH].find((name) => present(join(root, name)));
|
|
161
|
+
}
|
|
162
|
+
/** `--out`'s checks before anything is read (exit 2): it must not exist, and its directory must sit outside the site. */
|
|
163
|
+
function checkOut(root, out) {
|
|
164
|
+
const path = resolve(out);
|
|
165
|
+
if (present(path))
|
|
166
|
+
throw new Stop(2, [`${TAG} --out ${printable(out)} already exists`]);
|
|
167
|
+
let parent;
|
|
168
|
+
try {
|
|
169
|
+
parent = realpathSync(dirname(path));
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
throw new Stop(2, [`${TAG} --out ${printable(out)}: its directory does not exist`]);
|
|
173
|
+
}
|
|
174
|
+
if (parent === root || under(root, parent)) {
|
|
175
|
+
throw new Stop(2, [`${TAG} --out ${printable(out)} sits inside the site; write it outside the checkout`]);
|
|
176
|
+
}
|
|
177
|
+
// Opened inside the directory just checked, never through its unresolved path.
|
|
178
|
+
return join(parent, basename(path));
|
|
179
|
+
}
|
|
180
|
+
/** Every check in one pass (D2 steps 2–4); the lines of each generated file that differs. */
|
|
181
|
+
function differences(pkg, settings, siteMdx, chrome, fonts) {
|
|
182
|
+
const lines = [];
|
|
183
|
+
// Step 2 — the theme, compiled from the settings the record stores.
|
|
184
|
+
if (!/^---\r?\n[\s\S]*?\r?\n---/.test(siteMdx))
|
|
185
|
+
throw fail(`${SITE_MDX_PATH}: has no frontmatter`);
|
|
186
|
+
const spliced = (from) => spliceThemeBlock(siteMdx, compileDesignTheme(from), SITE_MDX_PATH);
|
|
187
|
+
const theme = spliced(settings);
|
|
188
|
+
if (theme !== siteMdx) {
|
|
189
|
+
lines.push(spliced(pkg) === siteMdx
|
|
190
|
+
? `${TAG} ${SITE_MDX_PATH}: compiled with the design's own deck grounds, which a non-deck home drops — this piece cannot import it`
|
|
191
|
+
: differs(SITE_MDX_PATH, firstDifferingLine(siteMdx, theme)));
|
|
192
|
+
}
|
|
193
|
+
// Step 3 — the layout.
|
|
194
|
+
const chromeNext = renderSiteChrome(settings.layout);
|
|
195
|
+
if (chromeNext !== chrome)
|
|
196
|
+
lines.push(differs(SITE_CHROME_PATH, firstDifferingLine(chrome, chromeNext)));
|
|
197
|
+
// Step 4 — the faces; an absent file is equal only when the settings source none.
|
|
198
|
+
const faces = compileDesignFonts(settings);
|
|
199
|
+
if (fonts === undefined) {
|
|
200
|
+
if (faces !== undefined) {
|
|
201
|
+
lines.push(`${TAG} ${SITE_FONTS_PATH}: missing, but ${DESIGN_SETTINGS_FILE} sources faces — not imported`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const fontsNext = renderSiteFonts(faces);
|
|
206
|
+
if (fontsNext !== fonts)
|
|
207
|
+
lines.push(differs(SITE_FONTS_PATH, firstDifferingLine(fonts, fontsNext)));
|
|
208
|
+
}
|
|
209
|
+
return lines;
|
|
210
|
+
}
|
|
211
|
+
/** The summary lines printed after the settings (D2 "On success"). */
|
|
212
|
+
function summary(pkg, settings, digest, siteMdx) {
|
|
213
|
+
const faces = compileDesignFonts(settings);
|
|
214
|
+
const faceList = ["display", "body"].flatMap((role) => {
|
|
215
|
+
const face = faces?.[role];
|
|
216
|
+
return face === undefined ? [] : [`${role} ${printable(face.family)} (google)`];
|
|
217
|
+
});
|
|
218
|
+
const pageTypes = Object.keys(settings.sections).map(printable);
|
|
219
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(siteMdx)?.[1] ?? "";
|
|
220
|
+
return [
|
|
221
|
+
`settings sha256: ${digest}`,
|
|
222
|
+
`layout: ${canonicalJson(settings.layout) === canonicalJson(pkg.layout) ? DESIGN_SETTINGS_FILE : `the template's layout over ${DESIGN_SETTINGS_FILE}`}`,
|
|
223
|
+
`faces: ${faceList.length === 0 ? "none" : faceList.join(" ")}`,
|
|
224
|
+
`sections: ${pageTypes.length === 0 ? "none" : pageTypes.join(", ")}`,
|
|
225
|
+
...(/^brand:/m.test(frontmatter) ? ["brand: set in _site.mdx — stays there"] : []),
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
/** Reads, checks and hands over (D2); answers the exit code. */
|
|
229
|
+
export function lookSettings(o) {
|
|
230
|
+
const line = o.onLine ?? (() => { });
|
|
231
|
+
const error = o.onError ?? (() => { });
|
|
232
|
+
try {
|
|
233
|
+
let root;
|
|
234
|
+
try {
|
|
235
|
+
root = realpathSync(o.dir);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
throw fail(`the site ${printable(o.dir)} was not found`);
|
|
239
|
+
}
|
|
240
|
+
const out = checkOut(root, o.out);
|
|
241
|
+
const files = {};
|
|
242
|
+
const read = (rel) => {
|
|
243
|
+
const buffer = readOnce(root, rel);
|
|
244
|
+
files[rel] = sha256(buffer);
|
|
245
|
+
return buffer.toString("utf8");
|
|
246
|
+
};
|
|
247
|
+
// The design package, parsed from exactly the bytes hashed.
|
|
248
|
+
const designText = read(DESIGN_SETTINGS_FILE);
|
|
249
|
+
let pkg;
|
|
250
|
+
try {
|
|
251
|
+
pkg = readDesignPackageText(designText, DESIGN_SETTINGS_FILE);
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
// The field only, never the message: it can quote a value.
|
|
255
|
+
const field = err instanceof DesignPackageError ? `${printable(err.field)} ` : "";
|
|
256
|
+
throw fail(`${DESIGN_SETTINGS_FILE}: ${field}refused by the reader`);
|
|
257
|
+
}
|
|
258
|
+
// The roster `readSiteRoster` would read, and no other.
|
|
259
|
+
const rosterName = rosterNameIn(root);
|
|
260
|
+
let roster;
|
|
261
|
+
if (rosterName !== undefined) {
|
|
262
|
+
const rosterText = read(rosterName);
|
|
263
|
+
try {
|
|
264
|
+
roster = parseSiteRoster(rosterText, rosterName);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
throw fail(`${rosterName}: refused by the reader`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const siteMdx = read(SITE_MDX_PATH);
|
|
271
|
+
const chrome = read(SITE_CHROME_PATH);
|
|
272
|
+
const fonts = present(join(root, SITE_FONTS_PATH)) ? read(SITE_FONTS_PATH) : undefined;
|
|
273
|
+
// Step 1 — the settings: the package with the layout `site-chrome.ts` holds.
|
|
274
|
+
const templateLayoutOf = o.templateLayoutOf ?? ((r) => r.template.layout);
|
|
275
|
+
const settings = {
|
|
276
|
+
...pkg,
|
|
277
|
+
layout: resolveSiteChrome(roster === undefined ? undefined : templateLayoutOf(roster), pkg.layout),
|
|
278
|
+
};
|
|
279
|
+
const refused = differences(pkg, settings, siteMdx, chrome, fonts);
|
|
280
|
+
if (refused.length > 0)
|
|
281
|
+
throw new Stop(3, refused);
|
|
282
|
+
const digest = settingsDigest(settings);
|
|
283
|
+
const handOff = {
|
|
284
|
+
kind: LOOK_SETTINGS_KIND,
|
|
285
|
+
format: LOOK_SETTINGS_FORMAT,
|
|
286
|
+
files,
|
|
287
|
+
settingsSha256: digest,
|
|
288
|
+
settings,
|
|
289
|
+
};
|
|
290
|
+
// Created exclusively, mode 0600: an existing file is never overwritten.
|
|
291
|
+
let fd;
|
|
292
|
+
try {
|
|
293
|
+
fd = openSync(out, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
throw new Stop(2, [`${TAG} --out ${printable(o.out)} could not be created`]);
|
|
297
|
+
}
|
|
298
|
+
try {
|
|
299
|
+
writeSync(fd, `${JSON.stringify(handOff, null, 2)}\n`);
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// A partial hand-off is never left behind for the next run to refuse.
|
|
303
|
+
closeSync(fd);
|
|
304
|
+
unlinkSync(out);
|
|
305
|
+
throw fail(`--out ${printable(o.out)} could not be written`);
|
|
306
|
+
}
|
|
307
|
+
closeSync(fd);
|
|
308
|
+
line(JSON.stringify(settings, null, 2));
|
|
309
|
+
for (const entry of summary(pkg, settings, digest, siteMdx))
|
|
310
|
+
line(entry);
|
|
311
|
+
return { exitCode: 0 };
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
if (!(err instanceof Stop))
|
|
315
|
+
throw err;
|
|
316
|
+
for (const entry of err.lines)
|
|
317
|
+
error(entry);
|
|
318
|
+
return { exitCode: err.code };
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
export const LOOK_SETTINGS_HELP = `create-ailk look-settings — the design settings a site's hub design record will hold.
|
|
322
|
+
|
|
323
|
+
Usage:
|
|
324
|
+
create-ailk look-settings [<dir>] --out <file>
|
|
325
|
+
|
|
326
|
+
Arguments:
|
|
327
|
+
<dir> The site checkout. Defaults to the current dir.
|
|
328
|
+
|
|
329
|
+
Options:
|
|
330
|
+
--out <file> Where the settings are handed over: a new file outside the checkout.
|
|
331
|
+
-h, --help Show this help.
|
|
332
|
+
|
|
333
|
+
Reads design.yaml, the site roster, content/_site.mdx, apps/web/lib/site-chrome.ts and
|
|
334
|
+
apps/web/lib/site-fonts.ts as text, and hands the settings over only when they compile
|
|
335
|
+
to the three generated look files byte for byte. Runs no site code and needs no credential.
|
|
336
|
+
The runbook is docs/internal/runbooks/site-design-import.md.
|
|
337
|
+
Exit 0 handed over, 1 a failure, 2 a bad flag or --out, 3 a generated file that differs.
|
|
338
|
+
`;
|
|
339
|
+
export function parseLookSettingsArgs(argv) {
|
|
340
|
+
let parsed;
|
|
341
|
+
try {
|
|
342
|
+
parsed = parseArgs({
|
|
343
|
+
args: argv,
|
|
344
|
+
strict: true,
|
|
345
|
+
allowPositionals: true,
|
|
346
|
+
options: {
|
|
347
|
+
out: { type: "string" },
|
|
348
|
+
help: { type: "boolean", default: false, short: "h" },
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
catch (err) {
|
|
353
|
+
throw new ParseError(`look-settings: ${err.message}`);
|
|
354
|
+
}
|
|
355
|
+
const [target, ...rest] = parsed.positionals;
|
|
356
|
+
if (rest.length > 0) {
|
|
357
|
+
throw new ParseError(`look-settings takes at most one site directory, got ${parsed.positionals.length} arguments`);
|
|
358
|
+
}
|
|
359
|
+
const help = parsed.values.help === true;
|
|
360
|
+
if (!help && parsed.values.out === undefined)
|
|
361
|
+
throw new ParseError("look-settings: --out is required");
|
|
362
|
+
return { target, out: parsed.values.out, help };
|
|
363
|
+
}
|
|
@@ -1868,6 +1868,18 @@ export const EXCLUDE_TEMPLATE_DIRS = [
|
|
|
1868
1868
|
// (after `--install`), in `update` and by `add-module`, never snapshotted.
|
|
1869
1869
|
"apps/web/app/[locale]/docs",
|
|
1870
1870
|
"apps/web/app/[locale]/blog",
|
|
1871
|
+
// #12593 — these five suites test the site's reading of the hub design
|
|
1872
|
+
// record (#12473, #12477, #12506) against the monorepo's own design library,
|
|
1873
|
+
// `packages/create-ailk/site-templates/designs/*/design.yaml`, which no
|
|
1874
|
+
// scaffold carries (two read it at load time, so the whole suite fails to
|
|
1875
|
+
// run). They keep running in this monorepo on every PR; a scaffold has
|
|
1876
|
+
// no library to read. page-chrome.test.ts ships (#10704 AC-3) and skips
|
|
1877
|
+
// its one library-reading block when the library is absent.
|
|
1878
|
+
"apps/web/lib/__tests__/deck-page.test.ts",
|
|
1879
|
+
"apps/web/lib/__tests__/deploy-fonts-build.test.ts",
|
|
1880
|
+
"apps/web/lib/__tests__/look-files-retired.test.ts",
|
|
1881
|
+
"apps/web/lib/__tests__/site-design.test.ts",
|
|
1882
|
+
"apps/web/lib/__tests__/site-theme-head.test.ts",
|
|
1871
1883
|
];
|
|
1872
1884
|
export function paidModuleTemplateExclusions(snapshotRoots, repoRoot) {
|
|
1873
1885
|
const roots = new Set(snapshotRoots);
|
package/dist/parse-args.d.ts
CHANGED
|
@@ -16,16 +16,14 @@ export type ModuleName = (typeof RECOGNIZED_MODULES)[number];
|
|
|
16
16
|
* Declared HERE rather than imported from `template-manifest.ts` for the
|
|
17
17
|
* reason `RECOGNIZED_MODULES` is: importing the registry closes the runtime
|
|
18
18
|
* cycle `template-names.ts`'s header records. `parse-args.test.ts` pins this
|
|
19
|
-
* list
|
|
20
|
-
*
|
|
19
|
+
* list and `RESERVED_SHAPES` to their authorities (`STARTER_SHAPES`,
|
|
20
|
+
* `SHAPE_ROSTERS`). The `--design` names are read from the installer's design
|
|
21
|
+
* directory (`shippedDesigns()`, #12500 D6), never typed here.
|
|
21
22
|
*/
|
|
22
23
|
export declare const RECOGNIZED_SHAPES: readonly ["organization-product", "organization-service", "local-business-service", "person-service"];
|
|
23
24
|
export type ShapeName = (typeof RECOGNIZED_SHAPES)[number];
|
|
24
25
|
/** Shapes the contract names but no release builds yet. */
|
|
25
26
|
export declare const RESERVED_SHAPES: readonly ["local-business-product"];
|
|
26
|
-
/** The `--design` vocabulary (#6754 D1) — `STARTER_DESIGNS`, pinned by test. */
|
|
27
|
-
export declare const RECOGNIZED_DESIGNS: readonly ["standard", "minimalism"];
|
|
28
|
-
export type DesignName = (typeof RECOGNIZED_DESIGNS)[number];
|
|
29
27
|
/**
|
|
30
28
|
* The `--topology` vocabulary (#7426 D1) — orthogonal to `--shape`: any shape
|
|
31
29
|
* can be scaffolded as either. Declared here rather than imported from
|
|
@@ -51,7 +49,7 @@ export interface CliOptions {
|
|
|
51
49
|
/**
|
|
52
50
|
* The starter's design (`--design`, #6754; widened to a path #6813 D1/D3):
|
|
53
51
|
* a recognized name, lowercased, or an absolute directory holding a
|
|
54
|
-
* `
|
|
52
|
+
* `design.yaml`, case preserved. Never set with `template`.
|
|
55
53
|
*/
|
|
56
54
|
design?: string;
|
|
57
55
|
/**
|
|
@@ -133,6 +131,12 @@ export interface ParseEnv {
|
|
|
133
131
|
/** The two lines that install the `ailk` plugin in a Claude Code session (#7298). */
|
|
134
132
|
export declare const PLUGIN_INSTALL_LINES: readonly ["/plugin marketplace add working-theory-labs/claude-plugins", "/plugin install ailk@working-theory"];
|
|
135
133
|
export declare const helpText: string;
|
|
134
|
+
/**
|
|
135
|
+
* The help's list of `--design` names (#12500 D6), read from the installer's
|
|
136
|
+
* design directory when the help is printed — never at import, so `helpText`
|
|
137
|
+
* stays a constant that names no look.
|
|
138
|
+
*/
|
|
139
|
+
export declare function designsHelp(): string;
|
|
136
140
|
/**
|
|
137
141
|
* Parse `create-ailk` argv. `env.interactive` defaults to false —
|
|
138
142
|
* fail-closed: a caller that does not assert a human is present gets refusal
|
package/dist/parse-args.js
CHANGED
|
@@ -11,6 +11,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
11
11
|
import { join, resolve } from "node:path";
|
|
12
12
|
import { createInterface } from "node:readline/promises";
|
|
13
13
|
import { parseArgs } from "node:util";
|
|
14
|
+
import { shippedDesigns } from "./design-names.js";
|
|
14
15
|
import { assertLicenseKeyShape } from "./lib/license-key-files.js";
|
|
15
16
|
import { RECOGNIZED_SURFACES, parseSurfaces } from "./surfaces.js";
|
|
16
17
|
import { RECOGNIZED_TEMPLATES } from "./template-names.js";
|
|
@@ -38,8 +39,9 @@ export const RECOGNIZED_MODULES = [
|
|
|
38
39
|
* Declared HERE rather than imported from `template-manifest.ts` for the
|
|
39
40
|
* reason `RECOGNIZED_MODULES` is: importing the registry closes the runtime
|
|
40
41
|
* cycle `template-names.ts`'s header records. `parse-args.test.ts` pins this
|
|
41
|
-
* list
|
|
42
|
-
*
|
|
42
|
+
* list and `RESERVED_SHAPES` to their authorities (`STARTER_SHAPES`,
|
|
43
|
+
* `SHAPE_ROSTERS`). The `--design` names are read from the installer's design
|
|
44
|
+
* directory (`shippedDesigns()`, #12500 D6), never typed here.
|
|
43
45
|
*/
|
|
44
46
|
export const RECOGNIZED_SHAPES = [
|
|
45
47
|
"organization-product",
|
|
@@ -49,8 +51,6 @@ export const RECOGNIZED_SHAPES = [
|
|
|
49
51
|
];
|
|
50
52
|
/** Shapes the contract names but no release builds yet. */
|
|
51
53
|
export const RESERVED_SHAPES = ["local-business-product"];
|
|
52
|
-
/** The `--design` vocabulary (#6754 D1) — `STARTER_DESIGNS`, pinned by test. */
|
|
53
|
-
export const RECOGNIZED_DESIGNS = ["standard", "minimalism"];
|
|
54
54
|
/** What each shape is, for the prompt (D3). A shape without one is a type error. */
|
|
55
55
|
const SHAPE_DESCRIPTIONS = {
|
|
56
56
|
"organization-product": "a company selling a product",
|
|
@@ -110,9 +110,9 @@ Options:
|
|
|
110
110
|
Installs that shape's Free starter. A run naming
|
|
111
111
|
neither --shape nor --template asks for a shape on
|
|
112
112
|
a terminal, and refuses without one.
|
|
113
|
-
--design <design> The look to render the starter in:
|
|
114
|
-
|
|
115
|
-
directory holding a
|
|
113
|
+
--design <design> The look to render the starter in: the name of a
|
|
114
|
+
look this installer ships (listed below) or a
|
|
115
|
+
directory holding a design.yaml. Defaults to the
|
|
116
116
|
starter's own.
|
|
117
117
|
--template <name> The site template to install (recognized:
|
|
118
118
|
${RECOGNIZED_TEMPLATES.join(", ")}).
|
|
@@ -202,6 +202,14 @@ ${PLUGIN_INSTALL_LINES.map((line) => ` ${line}`).join("\n")}
|
|
|
202
202
|
|
|
203
203
|
Reference: ADR 0007 — \`pnpm create ailk@latest\` is the canonical install path.
|
|
204
204
|
`;
|
|
205
|
+
/**
|
|
206
|
+
* The help's list of `--design` names (#12500 D6), read from the installer's
|
|
207
|
+
* design directory when the help is printed — never at import, so `helpText`
|
|
208
|
+
* stays a constant that names no look.
|
|
209
|
+
*/
|
|
210
|
+
export function designsHelp() {
|
|
211
|
+
return `Looks this installer ships (--design): ${shippedDesigns().join(", ")}\n`;
|
|
212
|
+
}
|
|
205
213
|
/**
|
|
206
214
|
* Parse `create-ailk` argv. `env.interactive` defaults to false —
|
|
207
215
|
* fail-closed: a caller that does not assert a human is present gets refusal
|
|
@@ -421,20 +429,24 @@ function isExistingDir(path) {
|
|
|
421
429
|
}
|
|
422
430
|
/**
|
|
423
431
|
* `dir` (resolved from `raw`) as a design path: an existing directory
|
|
424
|
-
* holding a `
|
|
432
|
+
* holding a `design.yaml`, else `ParseError` naming `raw` (#6813 D1 rule 2;
|
|
433
|
+
* #12468 — a `DESIGN.md` is a design's guide, never its settings).
|
|
425
434
|
*/
|
|
426
435
|
function validateDesignDir(dir, raw) {
|
|
427
436
|
if (!isExistingDir(dir)) {
|
|
428
437
|
throw new ParseError(`design directory "${raw}" does not exist`);
|
|
429
438
|
}
|
|
430
|
-
if (!existsSync(join(dir, "
|
|
431
|
-
|
|
439
|
+
if (!existsSync(join(dir, "design.yaml"))) {
|
|
440
|
+
if (existsSync(join(dir, "DESIGN.md"))) {
|
|
441
|
+
throw new ParseError(`design directory "${raw}" holds a DESIGN.md but no design.yaml — a design's settings are its design.yaml`);
|
|
442
|
+
}
|
|
443
|
+
throw new ParseError(`design directory "${raw}" holds no design.yaml`);
|
|
432
444
|
}
|
|
433
445
|
return dir;
|
|
434
446
|
}
|
|
435
447
|
/**
|
|
436
448
|
* Validate `--design` (#6754 D2 step 2, widened #6813 D1): a recognized
|
|
437
|
-
* name, or a directory holding a `
|
|
449
|
+
* name, or a directory holding a `design.yaml`. A value with no `/` or `\` is
|
|
438
450
|
* classified as a name first (trimmed and lowercased, filesystem never
|
|
439
451
|
* consulted) — falling back to a path only when it names an existing
|
|
440
452
|
* directory in `process.cwd()`, so `--design mydesign` and `--design
|
|
@@ -450,14 +462,15 @@ function parseDesign(raw) {
|
|
|
450
462
|
const hasSeparator = trimmed.includes("/") || trimmed.includes("\\");
|
|
451
463
|
if (!hasSeparator) {
|
|
452
464
|
const name = trimmed.toLowerCase();
|
|
453
|
-
|
|
465
|
+
const shipped = shippedDesigns();
|
|
466
|
+
if (shipped.includes(name)) {
|
|
454
467
|
return name;
|
|
455
468
|
}
|
|
456
469
|
const dir = resolve(process.cwd(), trimmed);
|
|
457
470
|
if (isExistingDir(dir)) {
|
|
458
471
|
return validateDesignDir(dir, raw);
|
|
459
472
|
}
|
|
460
|
-
throw new ParseError(`unknown design "${raw}". Recognized: ${
|
|
473
|
+
throw new ParseError(`unknown design "${raw}". Recognized: ${shipped.join(", ")}`);
|
|
461
474
|
}
|
|
462
475
|
return validateDesignDir(resolve(process.cwd(), trimmed), raw);
|
|
463
476
|
}
|
package/dist/programmatic.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ import { type SyncClaudeMdResult } from "./claude-md.js";
|
|
|
20
20
|
import { CATALOG_TARGET_PATH } from "./component-catalog.js";
|
|
21
21
|
import { type ModuleName } from "./parse-args.js";
|
|
22
22
|
import { type RemoveModuleResult } from "./remove-module.js";
|
|
23
|
-
import { type TemplateLayout } from "./site-chrome.js";
|
|
24
23
|
import { type SyncRoutesResult } from "./sync-routes.js";
|
|
25
24
|
import { type StarterShape } from "./template-manifest.js";
|
|
26
25
|
import { type Topology } from "./topology.js";
|
|
@@ -112,16 +111,7 @@ export interface ScaffoldOptions {
|
|
|
112
111
|
/** Injected fetch for tests. Never a live network call in CI or in this repo's evidence runs. */
|
|
113
112
|
fetchImpl?: typeof fetch;
|
|
114
113
|
/**
|
|
115
|
-
*
|
|
116
|
-
* `scaffold()` from the resolved template's `layout` block (the code
|
|
117
|
-
* registry's `TemplateManifest.layout`) before calling `scaffoldSync`. Never
|
|
118
|
-
* set by a CLI/MCP caller directly. `scaffoldSync` fills every unset field
|
|
119
|
-
* with `DEFAULT_SITE_CHROME`, so a call naming no `layout` (every existing
|
|
120
|
-
* caller) writes the same defaults `site-chrome.ts` always has.
|
|
121
|
-
*/
|
|
122
|
-
layout?: TemplateLayout;
|
|
123
|
-
/**
|
|
124
|
-
* A design name or a directory holding a DESIGN.md (#6638; widened to a
|
|
114
|
+
* A design name or a directory holding a design.yaml (#6638; widened to a
|
|
125
115
|
* path #6813 D1/D3). `scaffold()` sets it from the resolved template's
|
|
126
116
|
* `design`; a caller may name one to OVERRIDE the template's — the
|
|
127
117
|
* shape × design pairing `verify-scaffold.mjs --design` renders (#6638
|
|
@@ -130,14 +120,6 @@ export interface ScaffoldOptions {
|
|
|
130
120
|
* (#6760): a non-Free design needs a Pro or Pro Plus level.
|
|
131
121
|
*/
|
|
132
122
|
design?: string;
|
|
133
|
-
/**
|
|
134
|
-
* INTERNAL — the resolved design's own layout knobs (#6813 D2/D4/D8),
|
|
135
|
-
* populated by `scaffold()` from `resolveDesign(...).pkg.layout` before
|
|
136
|
-
* calling `scaffoldSync`. Never set by a CLI/MCP caller. Replaces the
|
|
137
|
-
* design-NAME lookup `scaffoldSync` used to do internally through the
|
|
138
|
-
* code registry that has since been deleted (#6638's per-name table).
|
|
139
|
-
*/
|
|
140
|
-
designLayout?: TemplateLayout;
|
|
141
123
|
/**
|
|
142
124
|
* The scaffold's topology (`--topology`, #7426 D1). `"hub"` — the default
|
|
143
125
|
* — is the whole site. `"spoke"` is the same scaffold with nodes removed
|