create-ailk 0.40.3 → 0.42.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 +31 -1
- package/component-catalog.json +6 -0
- package/dist/add-route.d.ts +2 -6
- package/dist/add-route.js +2 -43
- package/dist/export-content.js +11 -3
- package/dist/language-import.js +5 -2
- package/dist/lib/env-catalog.js +5 -1
- package/dist/lib/import-mdx.js +10 -7
- package/dist/magnet-page.d.ts +36 -0
- package/dist/magnet-page.js +70 -0
- package/dist/module-architecture.js +14 -48
- package/dist/routes.d.ts +44 -2
- package/dist/routes.js +766 -33
- package/dist/surfaces.d.ts +18 -2
- package/dist/surfaces.js +85 -21
- package/dist/topology.js +0 -1
- package/dist/update.d.ts +16 -1
- package/dist/update.js +273 -7
- package/package.json +3 -3
- package/templates/.claude/hooks/template-guard.sh +145 -36
- package/templates/CLAUDE.md +1 -1
- package/templates/apps/api/.env.example +2 -1
- package/templates/apps/api/CLAUDE.md +1 -0
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/.env.example +5 -6
- package/templates/apps/web/CLAUDE.md +41 -7
- package/templates/apps/web/app/[locale]/layout.tsx +6 -3
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +37 -1
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +28 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +17 -0
- package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +1 -0
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +42 -0
- package/templates/apps/web/lib/__tests__/route-paths.test.ts +57 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +22 -7
- package/templates/apps/web/lib/deck-page.ts +20 -1
- package/templates/apps/web/lib/mcp-oauth.ts +14 -10
- package/templates/apps/web/lib/page-chrome.ts +11 -5
- package/templates/apps/web/lib/route-paths.ts +22 -0
- package/templates/apps/web/lib/services-path.ts +27 -18
- package/templates/apps/web/messages/en.json +0 -9
- package/templates/apps/web/middleware.ts +2 -1
- package/templates/apps/web/next.config.mjs +123 -2
- package/templates/apps/web/src/lib/routes.ts +4 -2
- package/versions.json +50 -50
- package/templates/apps/web/lib/deliverable-grant.ts +0 -18
package/dist/routes.js
CHANGED
|
@@ -48,6 +48,27 @@
|
|
|
48
48
|
* later slice): it is REPORTED as kept by the site, never stray, and
|
|
49
49
|
* `--write` never touches it.
|
|
50
50
|
*
|
|
51
|
+
* Site pages (#11700). Every other routing file under `app/[locale]/` that the
|
|
52
|
+
* generator, `add-route magnet` (byte for byte) and the template did not
|
|
53
|
+
* write — not a `.ailk-template-files.json` key, not on `architecture.yaml`'s
|
|
54
|
+
* `customizations.scaffold_paths` — is a site page. A site page, and a
|
|
55
|
+
* recorded package route, needs a DECIDED `customizations.yaml` entry
|
|
56
|
+
* (`build-in: site — <decider>, <YYYY-MM-DD>, <reason>` or
|
|
57
|
+
* `build-in: ailk#<N>`, the scaffold lint's grammar): check mode fails one
|
|
58
|
+
* that has none, or whose entry is `undecided` — `undecided_ok_until` does
|
|
59
|
+
* not apply to a page. Each reported `page.tsx` names the `add-route magnet`
|
|
60
|
+
* command or the installed package page that already serves its address.
|
|
61
|
+
* With no template record, a page outside every prefix cannot be told from a
|
|
62
|
+
* template page, so that rule is skipped and the report says so.
|
|
63
|
+
*
|
|
64
|
+
* Adoption (#11657 D2). A manifest may list `adopts` — routing files OUTSIDE
|
|
65
|
+
* its own prefixes, each one of its entries, that another installed
|
|
66
|
+
* manifest names in its `siteOwned` list (the signal-collectors package's
|
|
67
|
+
* two careers walks, under site-pages' `careers` prefix). An adopted entry is
|
|
68
|
+
* carried only while some installed manifest lists its path as `siteOwned`;
|
|
69
|
+
* with no such owner it is not carried — neither written, missing nor stray.
|
|
70
|
+
* Two installed manifests adopting one path are refused, naming both.
|
|
71
|
+
*
|
|
51
72
|
* A page package's strings ship in its own catalog (ADR 0040 rule 5), named
|
|
52
73
|
* by the manifest's `messages.catalog` (one `<locale>.json` per locale); a
|
|
53
74
|
* site's `messages/<locale>.json` holds overrides only. Check mode also
|
|
@@ -89,8 +110,11 @@
|
|
|
89
110
|
* The locale root (#11259 D5). A manifest that sets `"root": true` may list
|
|
90
111
|
* the entry `page.tsx` — the home page at `app/[locale]/page.tsx`; its stray
|
|
91
112
|
* scope there is that one file, never the tree beneath it. One installed
|
|
92
|
-
* manifest at most may claim the root, and no two may claim
|
|
93
|
-
*
|
|
113
|
+
* manifest at most may claim the root, and no two may claim the same
|
|
114
|
+
* prefix. One package's prefix may sit strictly inside another's (#11659 D9:
|
|
115
|
+
* site-pages' `private/[slug]` under ui-scheduling's `private`); the inner
|
|
116
|
+
* prefix then owns its subtree, and an outer route inside it is refused.
|
|
117
|
+
* Each refusal names both packages.
|
|
94
118
|
*
|
|
95
119
|
* The site's surfaces (#11259 D5). A manifest that sets `"siteGated": true`
|
|
96
120
|
* ships routes a site carries only when it selected them. On a site whose
|
|
@@ -101,14 +125,32 @@
|
|
|
101
125
|
* canonicalized) is not carried either. A site with no readable header
|
|
102
126
|
* carries every entry. A manifest without the flag is never gated.
|
|
103
127
|
*
|
|
128
|
+
* Route-family renames (#11385 D5–D7). A site renames a family's first
|
|
129
|
+
* segment with `<family>: { path: /<segment> }` in `content/_site.mdx`
|
|
130
|
+
* (`readSiteRouteRenames`, which refuses frontmatter it cannot read with
|
|
131
|
+
* certainty). Each locale entry under the family's convention segment is then
|
|
132
|
+
* planned under the new one — its file text unchanged, its topology and
|
|
133
|
+
* surface gates read on the convention path — and both segments are the
|
|
134
|
+
* prefix's stray scope. `--write` vacates the old directory: it deletes only
|
|
135
|
+
* generated routing files there, never follows a link, re-checks each file at
|
|
136
|
+
* delete time, and lists each deletion as `removed`. A rename that collides
|
|
137
|
+
* (`routeRenameRefusals`, an installed prefix, a content page `[slug]`
|
|
138
|
+
* serves), would strand a site file, moves a recorded route, lands on an
|
|
139
|
+
* occupied target or meets a symbolic link is refused before anything is
|
|
140
|
+
* written or deleted.
|
|
141
|
+
*
|
|
104
142
|
* Pure module: no `import.meta.url`, so jest imports it directly.
|
|
105
143
|
*/
|
|
106
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
144
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmdirSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
107
145
|
import { dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
108
146
|
import { parseArgs } from "node:util";
|
|
109
147
|
import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
|
|
148
|
+
import { declinedRouteOfPath, readDeclinedRoutes } from "./declined-routes.js";
|
|
110
149
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
111
|
-
import {
|
|
150
|
+
import { MAGNET_COMMAND_RE, MAGNET_PAGE_MARKER, isGeneratedMagnetPage } from "./magnet-page.js";
|
|
151
|
+
import { LEGACY_SITE_ROSTER_PATH, SITE_ROSTER_PATH, readRosterPageRoutes } from "./site-roster.js";
|
|
152
|
+
import { GATEABLE_SURFACES, RENAMABLE_ROUTE_FAMILIES, RESERVED_ROUTE_SEGMENTS, ROUTE_ROOT, ROUTES_FIRST_SEGMENTS, canonicalizeSurface, isRemovedPublicRoutePath, } from "./surfaces.js";
|
|
153
|
+
import { TEMPLATE_RECORD_PATH, TemplateRecordError, parseTemplateRecord } from "./template-record.js";
|
|
112
154
|
import { isSpokeExcluded, readSpokeShape } from "./topology.js";
|
|
113
155
|
/** The app a page package's routes mount in, relative to the site root. */
|
|
114
156
|
export const ROUTES_APP_DIR = "apps/web";
|
|
@@ -232,6 +274,16 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
232
274
|
throw new RoutesRefusedError(`${at}: siteOwned ${JSON.stringify(path)} must be a routing file under ${prefix.map((p) => `${p}/`).join(" or ")}`);
|
|
233
275
|
}
|
|
234
276
|
}
|
|
277
|
+
const adopts = stringList(raw.adopts, `${at}: adopts`);
|
|
278
|
+
for (const path of adopts) {
|
|
279
|
+
if (!isPlainPath(path) || !ROUTING_FILES.has(posix.basename(path))) {
|
|
280
|
+
throw new RoutesRefusedError(`${at}: adopts ${JSON.stringify(path)} must be a plain path ending in page.tsx, layout.tsx or route.ts`);
|
|
281
|
+
}
|
|
282
|
+
if (underPrefix(path))
|
|
283
|
+
throw new RoutesRefusedError(`${at}: adopts ${path} is under the manifest's own ${prefixNamed}`);
|
|
284
|
+
}
|
|
285
|
+
if (new Set(adopts).size !== adopts.length)
|
|
286
|
+
throw new RoutesRefusedError(`${at}: adopts must be distinct`);
|
|
235
287
|
let messages;
|
|
236
288
|
if (raw.messages !== undefined) {
|
|
237
289
|
if (!isRecord(raw.messages) || !isPlainPath(raw.messages.catalog)) {
|
|
@@ -273,7 +325,7 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
273
325
|
if (!root)
|
|
274
326
|
throw new RoutesRefusedError(`${where}: ${path} is the locale root, which only a manifest with "root": true ships`);
|
|
275
327
|
}
|
|
276
|
-
else if (!underPrefix(path)) {
|
|
328
|
+
else if (!underPrefix(path) && !adopts.includes(path)) {
|
|
277
329
|
throw new RoutesRefusedError(`${where}: ${path} is outside the manifest's ${prefixNamed}`);
|
|
278
330
|
}
|
|
279
331
|
if (seen.has(path) || siteOwned.includes(path)) {
|
|
@@ -334,6 +386,13 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
334
386
|
}
|
|
335
387
|
return { path, kind, module: entry.module, exports, segmentConfig, config, metadataConfig, mount, waiver };
|
|
336
388
|
});
|
|
389
|
+
for (const path of adopts) {
|
|
390
|
+
const adopted = routes.find((entry) => entry.path === path);
|
|
391
|
+
if (adopted === undefined)
|
|
392
|
+
throw new RoutesRefusedError(`${at}: adopts ${path}, which none of its routes is`);
|
|
393
|
+
if (adopted.mount === "app")
|
|
394
|
+
throw new RoutesRefusedError(`${at}: adopts ${path}, which is mounted under app/`);
|
|
395
|
+
}
|
|
337
396
|
const oss = raw.oss === false ? false : undefined;
|
|
338
397
|
return {
|
|
339
398
|
package: pkg,
|
|
@@ -345,6 +404,7 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
345
404
|
siteSeam: raw.siteSeam === true,
|
|
346
405
|
config: raw.config,
|
|
347
406
|
siteOwned,
|
|
407
|
+
adopts,
|
|
348
408
|
messages,
|
|
349
409
|
oss,
|
|
350
410
|
routes,
|
|
@@ -412,9 +472,20 @@ export function readRouteManifests(siteDir) {
|
|
|
412
472
|
throw new RoutesRefusedError(`${name}'s route manifest claims the locale root, which ${other.package}'s already does`);
|
|
413
473
|
}
|
|
414
474
|
for (const mine of manifest.prefix) {
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
475
|
+
for (const theirs of other.prefix) {
|
|
476
|
+
if (!overlaps(mine, theirs))
|
|
477
|
+
continue;
|
|
478
|
+
if (mine === theirs) {
|
|
479
|
+
throw new RoutesRefusedError(`${name}'s route manifest: prefix ${JSON.stringify(mine)} overlaps ${other.package}'s ${JSON.stringify(theirs)}`);
|
|
480
|
+
}
|
|
481
|
+
// #11659 D9 — a prefix strictly nested in another package's is
|
|
482
|
+
// allowed; the inner prefix owns its subtree, so the outer package
|
|
483
|
+
// may ship no route inside it.
|
|
484
|
+
const [outer, inner, innerPrefix] = mine.startsWith(`${theirs}/`) ? [other, manifest, mine] : [manifest, other, theirs];
|
|
485
|
+
const intruder = outer.routes.find((entry) => entry.mount === "locale" && entry.path.startsWith(`${innerPrefix}/`));
|
|
486
|
+
if (intruder !== undefined) {
|
|
487
|
+
throw new RoutesRefusedError(`${outer.package}'s route manifest: route ${JSON.stringify(intruder.path)} sits under ${inner.package}'s prefix ${JSON.stringify(innerPrefix)}`);
|
|
488
|
+
}
|
|
418
489
|
}
|
|
419
490
|
}
|
|
420
491
|
for (const mine of manifest.appPrefixes) {
|
|
@@ -426,6 +497,14 @@ export function readRouteManifests(siteDir) {
|
|
|
426
497
|
}
|
|
427
498
|
manifests.push({ ...manifest, root: dirname(installed) });
|
|
428
499
|
}
|
|
500
|
+
for (const [i, manifest] of manifests.entries()) {
|
|
501
|
+
for (const other of manifests.slice(i + 1)) {
|
|
502
|
+
const both = manifest.adopts.find((path) => other.adopts.includes(path));
|
|
503
|
+
if (both !== undefined) {
|
|
504
|
+
throw new RoutesRefusedError(`${both} is adopted by both ${manifest.package}'s and ${other.package}'s route manifests`);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
429
508
|
return manifests;
|
|
430
509
|
}
|
|
431
510
|
/** The header line of every generated route file begins with this; `remove-module` reads it as module code. */
|
|
@@ -486,6 +565,13 @@ export function isGenerated(text) {
|
|
|
486
565
|
const first = lines[0] === OSS_FALSE_MARKER ? (lines[1] ?? "") : (lines[0] ?? "");
|
|
487
566
|
return first.startsWith(GENERATED_ROUTE_HEADER);
|
|
488
567
|
}
|
|
568
|
+
/** The scaffold lint's two decided forms (`template-overlay/tools/lint-architecture.ts`), byte-identical; a test pins them equal. */
|
|
569
|
+
const DECISION_AILK = /^build-in: ailk#(\d+)(?: [—-] .+)?$/;
|
|
570
|
+
const DECISION_SITE = /^build-in: site [—-] [^,]+, \d{4}-\d{2}-\d{2}, .+$/;
|
|
571
|
+
/** Whether an entry records a decision (#11700 D2): `undecided`, no decision or any other text is not one. */
|
|
572
|
+
function isDecided(entry) {
|
|
573
|
+
return entry.decision !== undefined && (DECISION_SITE.test(entry.decision) || DECISION_AILK.test(entry.decision));
|
|
574
|
+
}
|
|
489
575
|
/** The scaffold lint's own glob (`template-overlay/tools/lint-architecture.ts`): `**` is zero or more whole segments, `*` stays inside one. */
|
|
490
576
|
function globToRegExp(glob) {
|
|
491
577
|
const segments = glob.split("/");
|
|
@@ -506,7 +592,8 @@ function globToRegExp(glob) {
|
|
|
506
592
|
* The entries of `<site>/customizations.yaml`, when the site has one — read
|
|
507
593
|
* by line, in the shape the scaffold's own file documents (create-ailk
|
|
508
594
|
* carries no YAML parser): under `customizations:`, each `- id: <id>` entry's
|
|
509
|
-
* `paths:` list of quoted or bare globs, block or flow form
|
|
595
|
+
* `paths:` list of quoted or bare globs, block or flow form, and its
|
|
596
|
+
* `decision:`. An entry with no id or no paths
|
|
510
597
|
* records nothing; the overlay lint owns the file's full validation.
|
|
511
598
|
*/
|
|
512
599
|
function readRecorded(siteDir) {
|
|
@@ -520,7 +607,7 @@ function readRecorded(siteDir) {
|
|
|
520
607
|
const unquote = (raw) => raw.trim().replace(/^["']|["']$/g, "");
|
|
521
608
|
const flush = () => {
|
|
522
609
|
if (current?.id !== undefined && current.paths.length > 0) {
|
|
523
|
-
out.push({ id: current.id, patterns: current.paths.map(globToRegExp) });
|
|
610
|
+
out.push({ id: current.id, patterns: current.paths.map(globToRegExp), decision: current.decision });
|
|
524
611
|
}
|
|
525
612
|
current = undefined;
|
|
526
613
|
};
|
|
@@ -542,7 +629,7 @@ function readRecorded(siteDir) {
|
|
|
542
629
|
const rest = entry ? entry[3] : (/^\s+(\w+):(.*)$/.exec(line)?.[2] ?? "");
|
|
543
630
|
if (entry) {
|
|
544
631
|
flush();
|
|
545
|
-
current = { id: undefined, paths: [] };
|
|
632
|
+
current = { id: undefined, paths: [], decision: undefined };
|
|
546
633
|
}
|
|
547
634
|
if (current === undefined)
|
|
548
635
|
continue;
|
|
@@ -550,6 +637,10 @@ function readRecorded(siteDir) {
|
|
|
550
637
|
current.id = unquote(rest);
|
|
551
638
|
inPaths = false;
|
|
552
639
|
}
|
|
640
|
+
else if (key === "decision") {
|
|
641
|
+
current.decision = unquote(rest);
|
|
642
|
+
inPaths = false;
|
|
643
|
+
}
|
|
553
644
|
else if (key === "paths") {
|
|
554
645
|
// The flow form, `paths: ["a/**", "b/**"]`, or the block form below it.
|
|
555
646
|
const flow = /^\s*\[(.*)\]\s*$/.exec(rest);
|
|
@@ -572,9 +663,307 @@ function readRecorded(siteDir) {
|
|
|
572
663
|
function recordFor(recorded, sitePath) {
|
|
573
664
|
return recorded.find((entry) => entry.patterns.some((re) => re.test(sitePath)));
|
|
574
665
|
}
|
|
666
|
+
/** The id of the first `customizations:` entry whose paths match, per path; reads the file once (#11511). */
|
|
667
|
+
export function customizationsRecord(siteDir) {
|
|
668
|
+
const recorded = readRecorded(resolve(siteDir));
|
|
669
|
+
return (sitePath) => recordFor(recorded, sitePath)?.id;
|
|
670
|
+
}
|
|
575
671
|
/** Whether `<siteDir>/customizations.yaml` records `sitePath` — any entry, any path form or glob (the generator's own reading). */
|
|
576
672
|
export function isRecordedRoute(siteDir, sitePath) {
|
|
577
|
-
return
|
|
673
|
+
return customizationsRecord(siteDir)(sitePath) !== undefined;
|
|
674
|
+
}
|
|
675
|
+
// ── Route-family renames — content/_site.mdx's `<family>.path` (#11385) ─────
|
|
676
|
+
const SITE_MDX = "content/_site.mdx";
|
|
677
|
+
const ROUTE_PATH_RE = /^\/[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
678
|
+
/** A `path` key anywhere on a line, block or flow. */
|
|
679
|
+
const PATH_KEY_RE = /(?:^|[\s{,-])["']?path["']?\s*:/;
|
|
680
|
+
const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
681
|
+
const unquoteScalar = (raw) => raw.trim().replace(/^"(.*)"$|^'(.*)'$/, "$1$2");
|
|
682
|
+
/**
|
|
683
|
+
* The route family paths `content/_site.mdx`'s frontmatter sets, read by line
|
|
684
|
+
* (create-ailk carries no YAML parser): a renamable top-level key's `path`,
|
|
685
|
+
* block form (`meet:` then an indented `path: /meetings`, quoted or bare) or
|
|
686
|
+
* one-line flow form (`meet: { path: /meetings }`). Whatever this reader
|
|
687
|
+
* cannot read with certainty is refused with its line, never guessed
|
|
688
|
+
* (SEC-11385-3): a YAML anchor, alias or merge key; a renamable key twice; a
|
|
689
|
+
* multi-line flow mapping on one; a `path` line it cannot attribute to one
|
|
690
|
+
* top-level key; a `path` on a family that is not renamable; and a value that
|
|
691
|
+
* is not one lowercase kebab segment, or is reserved. `services.path` is its
|
|
692
|
+
* own setting and is not read here. No file reads as no rename.
|
|
693
|
+
*/
|
|
694
|
+
function readSiteRouteFamilies(siteDir) {
|
|
695
|
+
const out = { paths: {}, defaultLocale: "en" };
|
|
696
|
+
const file = join(resolve(siteDir), SITE_MDX);
|
|
697
|
+
if (!existsSync(file))
|
|
698
|
+
return out;
|
|
699
|
+
const lines = readFileSync(file, "utf8").split(/\r?\n/);
|
|
700
|
+
if (lines[0]?.trim() !== "---")
|
|
701
|
+
return out;
|
|
702
|
+
const refuse = (i, why) => {
|
|
703
|
+
throw new RoutesRefusedError(`${SITE_MDX} line ${i + 1}: ${why}`);
|
|
704
|
+
};
|
|
705
|
+
const renamable = (key) => hasOwn(RENAMABLE_ROUTE_FAMILIES, key);
|
|
706
|
+
const seen = new Set();
|
|
707
|
+
let top;
|
|
708
|
+
let childIndent;
|
|
709
|
+
let topHasPath = false;
|
|
710
|
+
let scalarIndent;
|
|
711
|
+
const takePath = (i, family, rawValue) => {
|
|
712
|
+
if (family === "services")
|
|
713
|
+
return;
|
|
714
|
+
const value = unquoteScalar(rawValue.replace(/\s+#.*$/, ""));
|
|
715
|
+
if (!renamable(family)) {
|
|
716
|
+
refuse(i, `${family}.path ${value}: ${family} is not a renamable route family (${Object.keys(RENAMABLE_ROUTE_FAMILIES).join(", ")})`);
|
|
717
|
+
}
|
|
718
|
+
if (topHasPath)
|
|
719
|
+
refuse(i, `${family}.path appears twice`);
|
|
720
|
+
topHasPath = true;
|
|
721
|
+
if (!ROUTE_PATH_RE.test(value)) {
|
|
722
|
+
refuse(i, `${family}.path ${value}: a route family's path is one lowercase kebab segment, like /writing-samples`);
|
|
723
|
+
}
|
|
724
|
+
if (RESERVED_ROUTE_SEGMENTS.includes(value.slice(1))) {
|
|
725
|
+
refuse(i, `${family}.path ${value}: reserved — ${value} is a reserved segment (${RESERVED_ROUTE_SEGMENTS.join(", ")})`);
|
|
726
|
+
}
|
|
727
|
+
out.paths[family] = value.slice(1);
|
|
728
|
+
};
|
|
729
|
+
for (let i = 1; i < lines.length; i++) {
|
|
730
|
+
const raw = lines[i];
|
|
731
|
+
if (/^(---|\.\.\.)\s*$/.test(raw))
|
|
732
|
+
break;
|
|
733
|
+
const indent = raw.length - raw.trimStart().length;
|
|
734
|
+
// A block scalar's lines are prose, not structure.
|
|
735
|
+
if (scalarIndent !== undefined) {
|
|
736
|
+
if (raw.trim() === "" || indent > scalarIndent)
|
|
737
|
+
continue;
|
|
738
|
+
scalarIndent = undefined;
|
|
739
|
+
}
|
|
740
|
+
// Quoted text and comments are not structure either.
|
|
741
|
+
const bare = raw
|
|
742
|
+
.replace(/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g, '""')
|
|
743
|
+
.replace(/(^|\s)#.*$/, "")
|
|
744
|
+
.trimEnd();
|
|
745
|
+
if (bare.trim() === "")
|
|
746
|
+
continue;
|
|
747
|
+
// A node starts a line, a list item or a value — or, in a flow collection, follows `[`, `{` or `,`.
|
|
748
|
+
const flow = /(?::|^\s*-)\s+[[{]/.test(bare);
|
|
749
|
+
const node = flow ? /(?:^\s*|^\s*-\s+|:\s+|[[{,]\s*)[&*][^\s,\]}]/ : /(?:^\s*|^\s*-\s+|:\s+)[&*][^\s,\]}]/;
|
|
750
|
+
if (/(?:^|[\s{,])<<\s*:/.test(bare) || node.test(bare)) {
|
|
751
|
+
refuse(i, "an anchor, alias or merge key, which create-ailk cannot read with certainty — write the route family paths out in full");
|
|
752
|
+
}
|
|
753
|
+
if (/(?::|^\s*-)\s+[|>][-+1-9]*$/.test(bare))
|
|
754
|
+
scalarIndent = indent;
|
|
755
|
+
if (indent === 0) {
|
|
756
|
+
const key = /^(["']?)([A-Za-z_$][\w$-]*)\1\s*:(?:\s+(.*))?$/.exec(raw);
|
|
757
|
+
top = key?.[2];
|
|
758
|
+
childIndent = undefined;
|
|
759
|
+
topHasPath = false;
|
|
760
|
+
if (key === null || top === undefined)
|
|
761
|
+
continue;
|
|
762
|
+
if (renamable(top)) {
|
|
763
|
+
if (seen.has(top))
|
|
764
|
+
refuse(i, `${top} appears twice`);
|
|
765
|
+
seen.add(top);
|
|
766
|
+
}
|
|
767
|
+
const value = (key[3] ?? "").replace(/\s+#.*$/, "").trim();
|
|
768
|
+
if (top === "defaultLocale" && value !== "")
|
|
769
|
+
out.defaultLocale = unquoteScalar(value);
|
|
770
|
+
if (!value.startsWith("{"))
|
|
771
|
+
continue;
|
|
772
|
+
if (!value.endsWith("}") || /[{}[\]]/.test(value.slice(1, -1))) {
|
|
773
|
+
if (renamable(top) || PATH_KEY_RE.test(bare))
|
|
774
|
+
refuse(i, `${top}: a flow mapping create-ailk cannot read — write it on one line, or in block form`);
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
for (const pair of value.slice(1, -1).split(",")) {
|
|
778
|
+
const at = pair.indexOf(":");
|
|
779
|
+
if (at !== -1 && unquoteScalar(pair.slice(0, at)) === "path")
|
|
780
|
+
takePath(i, top, pair.slice(at + 1));
|
|
781
|
+
}
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
if (top === undefined) {
|
|
785
|
+
if (PATH_KEY_RE.test(bare))
|
|
786
|
+
refuse(i, "a path line create-ailk cannot attribute to one top-level key");
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
childIndent ??= indent;
|
|
790
|
+
const pathLine = /^\s*(["']?)path\1\s*:(?:\s+(.*))?$/.exec(raw);
|
|
791
|
+
if (indent === childIndent && pathLine !== null)
|
|
792
|
+
takePath(i, top, pathLine[2] ?? "");
|
|
793
|
+
else if (renamable(top) && PATH_KEY_RE.test(bare)) {
|
|
794
|
+
refuse(i, `${top}: a path line create-ailk cannot attribute to the route family — set ${top}.path directly under ${top}`);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return out;
|
|
798
|
+
}
|
|
799
|
+
/** Family-keyed paths → `{ <convention segment>: <served segment> }`. */
|
|
800
|
+
function conventionRenames(paths) {
|
|
801
|
+
const out = {};
|
|
802
|
+
for (const [family, segment] of Object.entries(paths))
|
|
803
|
+
out[RENAMABLE_ROUTE_FAMILIES[family]] = segment;
|
|
804
|
+
return out;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* The site's route renames (#11385 D6): `content/_site.mdx`'s renamable
|
|
808
|
+
* family paths as `{ <convention segment>: <served segment> }` —
|
|
809
|
+
* `{ meet: "meetings" }`, `{ "case-studies": "work" }`. Throws
|
|
810
|
+
* `RoutesRefusedError`, naming the key and the line, for frontmatter it
|
|
811
|
+
* cannot read with certainty; no file is `{}`.
|
|
812
|
+
*/
|
|
813
|
+
export function readSiteRouteRenames(siteDir) {
|
|
814
|
+
return conventionRenames(readSiteRouteFamilies(siteDir).paths);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* A copy of `@working-theory/templates`' `routeRenameRefusals` (#11385 D7),
|
|
818
|
+
* message for message — `tests/routes/route-renames-parity.test.ts` runs both
|
|
819
|
+
* over one table. `renames` is family-keyed; the served set is
|
|
820
|
+
* `ROUTES_FIRST_SEGMENTS` (the routes map's first segments) plus
|
|
821
|
+
* `extraServed`.
|
|
822
|
+
*/
|
|
823
|
+
export function routeRenameRefusals(renames, conventions, reserved, extraServed = []) {
|
|
824
|
+
const served = new Set(extraServed);
|
|
825
|
+
for (const first of ROUTES_FIRST_SEGMENTS)
|
|
826
|
+
served.add(first);
|
|
827
|
+
const entries = Object.entries(renames);
|
|
828
|
+
const refusals = [];
|
|
829
|
+
for (const [family, target] of entries) {
|
|
830
|
+
const head = `${family} → /${target}:`;
|
|
831
|
+
const own = conventions[family];
|
|
832
|
+
if (target === own) {
|
|
833
|
+
refusals.push(`${head} no-op — it is the family's own segment`);
|
|
834
|
+
}
|
|
835
|
+
else if (reserved.includes(target)) {
|
|
836
|
+
refusals.push(`${head} reserved — /${target} is a reserved segment`);
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
const chained = entries.find(([other]) => other !== family && conventions[other] === target);
|
|
840
|
+
if (chained !== undefined) {
|
|
841
|
+
refusals.push(`${head} chain — /${target} is ${chained[0]}'s own segment, which ${chained[0]} renames to /${chained[1]}`);
|
|
842
|
+
}
|
|
843
|
+
else if (served.has(target)) {
|
|
844
|
+
refusals.push(`${head} served route — /${target} is already served`);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
for (const [other, otherTarget] of entries) {
|
|
848
|
+
if (other !== family && otherTarget === target && family < other) {
|
|
849
|
+
refusals.push(`${head} same target — ${family} and ${other} both rename to /${target}`);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
return refusals;
|
|
854
|
+
}
|
|
855
|
+
/** A path under `app/[locale]/` (no leading slash) with a renamed first segment swapped. */
|
|
856
|
+
function renamedEntryPath(path, renames) {
|
|
857
|
+
const [first, ...rest] = path.split("/");
|
|
858
|
+
return first !== undefined && hasOwn(renames, first) ? [renames[first], ...rest].join("/") : path;
|
|
859
|
+
}
|
|
860
|
+
/** Every entry at or under `path`, lstat-read: a link is listed and never followed. */
|
|
861
|
+
function lstatTree(path) {
|
|
862
|
+
let stat;
|
|
863
|
+
try {
|
|
864
|
+
stat = lstatSync(path);
|
|
865
|
+
}
|
|
866
|
+
catch {
|
|
867
|
+
return [];
|
|
868
|
+
}
|
|
869
|
+
if (stat.isSymbolicLink())
|
|
870
|
+
return [{ path, link: true }];
|
|
871
|
+
if (!stat.isDirectory())
|
|
872
|
+
return [{ path, link: false }];
|
|
873
|
+
return readdirSync(path)
|
|
874
|
+
.sort()
|
|
875
|
+
.flatMap((name) => lstatTree(join(path, name)));
|
|
876
|
+
}
|
|
877
|
+
/** The package a generated file's header names, or undefined for a file the generator did not write. */
|
|
878
|
+
function generatedBy(text) {
|
|
879
|
+
if (!isGenerated(text))
|
|
880
|
+
return undefined;
|
|
881
|
+
const lines = text.split("\n", 2);
|
|
882
|
+
const header = lines[0] === OSS_FALSE_MARKER ? lines[1] : lines[0];
|
|
883
|
+
return header.slice(GENERATED_ROUTE_HEADER.length).split(" ")[0];
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Every reason the site's renames cannot be carried out (#11385 D7), each
|
|
887
|
+
* `<family> → /<new>: <reason>`: `routeRenameRefusals` over the installed
|
|
888
|
+
* manifests' first segments that belong to no renamed family and the content
|
|
889
|
+
* slugs `[slug]` would serve at a target; then, per family, a symbolic link
|
|
890
|
+
* at or under the old or new directory, a file under the old directory that
|
|
891
|
+
* is not a generated routing file (it would be stranded), a
|
|
892
|
+
* `customizations.yaml` record under the old directory, and a file under the
|
|
893
|
+
* new one that is not a generated routing file of the family's own packages.
|
|
894
|
+
* Check mode refuses only the collisions and the links: it reports a
|
|
895
|
+
* stranded, recorded or occupying file as the stray, recorded or stale file
|
|
896
|
+
* it is, so `--check` names it rather than stopping.
|
|
897
|
+
*/
|
|
898
|
+
function renameRefusals(root, web, manifests, recorded, families, mode) {
|
|
899
|
+
const renamed = new Set(Object.keys(families.paths).map((family) => RENAMABLE_ROUTE_FAMILIES[family]));
|
|
900
|
+
const extra = new Set();
|
|
901
|
+
const serve = (segment) => {
|
|
902
|
+
if (segment !== undefined && segment !== "" && !renamed.has(segment))
|
|
903
|
+
extra.add(segment);
|
|
904
|
+
};
|
|
905
|
+
for (const manifest of manifests) {
|
|
906
|
+
for (const prefix of manifest.prefix)
|
|
907
|
+
serve(prefix.split("/")[0]);
|
|
908
|
+
for (const entry of manifest.routes)
|
|
909
|
+
if (entry.mount === "locale")
|
|
910
|
+
serve(routeSegments(entry.path)[0]);
|
|
911
|
+
}
|
|
912
|
+
// No page-type registry is vendored here, so a default-locale content file
|
|
913
|
+
// of any type at the target's slug counts as a page `[slug]` serves.
|
|
914
|
+
const contentDir = join(root, "content", families.defaultLocale);
|
|
915
|
+
const types = existsSync(contentDir)
|
|
916
|
+
? readdirSync(contentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name)
|
|
917
|
+
: [];
|
|
918
|
+
for (const target of Object.values(families.paths)) {
|
|
919
|
+
if (types.some((type) => existsSync(join(contentDir, type, `${target}.mdx`))))
|
|
920
|
+
extra.add(target);
|
|
921
|
+
}
|
|
922
|
+
const refusals = routeRenameRefusals(families.paths, RENAMABLE_ROUTE_FAMILIES, RESERVED_ROUTE_SEGMENTS, [...extra]);
|
|
923
|
+
const site = (path) => relative(root, path).split(sep).join("/");
|
|
924
|
+
for (const [family, target] of Object.entries(families.paths)) {
|
|
925
|
+
const head = `${family} → /${target}:`;
|
|
926
|
+
const from = RENAMABLE_ROUTE_FAMILIES[family];
|
|
927
|
+
const owners = new Set(manifests
|
|
928
|
+
.filter((m) => m.prefix.some((p) => p.split("/")[0] === from) || m.routes.some((e) => e.mount === "locale" && e.path.split("/")[0] === from))
|
|
929
|
+
.map((m) => m.package));
|
|
930
|
+
const oldTree = lstatTree(join(web, LOCALE_DIR, from));
|
|
931
|
+
const newTree = lstatTree(join(web, LOCALE_DIR, target));
|
|
932
|
+
for (const { path, link } of [...oldTree, ...newTree]) {
|
|
933
|
+
if (link)
|
|
934
|
+
refusals.push(`${head} link — ${site(path)} is a symbolic link`);
|
|
935
|
+
}
|
|
936
|
+
if (mode === "check")
|
|
937
|
+
continue;
|
|
938
|
+
const generated = (path) => ROUTING_FILES.has(posix.basename(path.split(sep).join("/"))) ? generatedBy(readFileSync(path, "utf8")) : undefined;
|
|
939
|
+
const oldFiles = oldTree.filter((e) => !e.link).map((e) => e.path);
|
|
940
|
+
for (const path of oldFiles) {
|
|
941
|
+
if (generated(path) === undefined) {
|
|
942
|
+
refusals.push(`${head} stranded — ${site(path)} is not a generated route file, and would be left behind under /${from}`);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
const candidates = [
|
|
946
|
+
...oldFiles.map(site),
|
|
947
|
+
...manifests.flatMap((m) => m.routes
|
|
948
|
+
.filter((e) => e.mount === "locale" && e.path.split("/")[0] === from)
|
|
949
|
+
.map((e) => posix.join(ROUTES_APP_DIR, LOCALE_DIR, e.path))),
|
|
950
|
+
];
|
|
951
|
+
for (const record of recorded) {
|
|
952
|
+
const match = candidates.find((path) => record.patterns.some((re) => re.test(path)));
|
|
953
|
+
if (match !== undefined) {
|
|
954
|
+
refusals.push(`${head} recorded route — customizations.yaml "${record.id}" records ${match} under /${from}, which would no longer match the moved file`);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
for (const { path, link } of newTree) {
|
|
958
|
+
if (link)
|
|
959
|
+
continue;
|
|
960
|
+
const by = generated(path);
|
|
961
|
+
if (by === undefined || !owners.has(by)) {
|
|
962
|
+
refusals.push(`${head} occupied target — ${site(path)} is not a generated route file of ${family}`);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return refusals;
|
|
578
967
|
}
|
|
579
968
|
/** Routing files under `<web>/<mount dir>/<prefix>`, as site-relative POSIX paths, sorted. */
|
|
580
969
|
function routingFilesUnder(web, siteDir, prefix, mount = "locale") {
|
|
@@ -596,20 +985,26 @@ function routingFilesUnder(web, siteDir, prefix, mount = "locale") {
|
|
|
596
985
|
walk(root);
|
|
597
986
|
return out.sort();
|
|
598
987
|
}
|
|
599
|
-
function plan(siteDir) {
|
|
988
|
+
function plan(siteDir, mode = "check") {
|
|
600
989
|
const root = resolve(siteDir);
|
|
601
990
|
const web = join(root, ROUTES_APP_DIR);
|
|
991
|
+
const families = readSiteRouteFamilies(root);
|
|
992
|
+
const renames = conventionRenames(families.paths);
|
|
602
993
|
const manifests = readRouteManifests(root);
|
|
603
994
|
const recorded = readRecorded(root);
|
|
604
995
|
// The site's topology (`.ailk-site-manifest.json`): on a spoke, the paths
|
|
605
996
|
// it does not carry are not its routes. A hub, or no manifest, carries all.
|
|
606
997
|
const spoke = readSpokeShape(root);
|
|
607
998
|
const gate = siteGate(root);
|
|
608
|
-
|
|
999
|
+
// An adopted entry is carried only while an installed manifest leaves its path to the site (#11657 D2).
|
|
1000
|
+
const owned = new Set(manifests.flatMap((m) => m.siteOwned));
|
|
1001
|
+
const carries = (manifest, entry, sitePath) => (spoke === undefined || !isSpokeExcluded(sitePath, spoke)) &&
|
|
1002
|
+
(!manifest.siteGated || gate(sitePath)) &&
|
|
1003
|
+
(!manifest.adopts.includes(entry.path) || owned.has(entry.path));
|
|
609
1004
|
const planned = [];
|
|
610
1005
|
const notCarried = [];
|
|
611
1006
|
for (const manifest of manifests) {
|
|
612
|
-
const carried = manifest.routes.filter((entry) => carries(manifest, relative(root, join(web, mountDir(entry.mount), entry.path)).split(sep).join("/")));
|
|
1007
|
+
const carried = manifest.routes.filter((entry) => carries(manifest, entry, relative(root, join(web, mountDir(entry.mount), entry.path)).split(sep).join("/")));
|
|
613
1008
|
if (manifest.config !== undefined && carried.some((entry) => entry.config)) {
|
|
614
1009
|
const configPath = join(web, `${manifest.config}.tsx`);
|
|
615
1010
|
if (!existsSync(configPath)) {
|
|
@@ -617,16 +1012,34 @@ function plan(siteDir) {
|
|
|
617
1012
|
}
|
|
618
1013
|
}
|
|
619
1014
|
for (const entry of manifest.routes) {
|
|
620
|
-
|
|
1015
|
+
// #11385 D5 — a renamed family's entry is planned under the new
|
|
1016
|
+
// segment; the gates read the convention path they are keyed on.
|
|
1017
|
+
const routePath = entry.mount === "locale" ? renamedEntryPath(entry.path, renames) : entry.path;
|
|
1018
|
+
const absPath = join(web, mountDir(entry.mount), routePath);
|
|
621
1019
|
const sitePath = relative(root, absPath).split(sep).join("/");
|
|
622
|
-
|
|
1020
|
+
const conventionSitePath = relative(root, join(web, mountDir(entry.mount), entry.path)).split(sep).join("/");
|
|
1021
|
+
if (!carries(manifest, entry, conventionSitePath)) {
|
|
623
1022
|
notCarried.push(sitePath);
|
|
624
1023
|
continue;
|
|
625
1024
|
}
|
|
626
|
-
planned.push({
|
|
1025
|
+
planned.push({
|
|
1026
|
+
sitePath,
|
|
1027
|
+
absPath,
|
|
1028
|
+
routePath,
|
|
1029
|
+
text: renderRouteFile(manifest, entry),
|
|
1030
|
+
record: recordFor(recorded, sitePath),
|
|
1031
|
+
package: manifest.package,
|
|
1032
|
+
entry,
|
|
1033
|
+
});
|
|
627
1034
|
}
|
|
628
1035
|
}
|
|
629
|
-
|
|
1036
|
+
if (Object.keys(families.paths).length > 0) {
|
|
1037
|
+
const refusals = renameRefusals(root, web, manifests, recorded, families, mode);
|
|
1038
|
+
if (refusals.length > 0) {
|
|
1039
|
+
throw new RoutesRefusedError(`${SITE_MDX}: the route family rename is refused, and nothing was written or removed:\n ${refusals.join("\n ")}`);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return { root, web, manifests, planned, recorded, notCarried, renames };
|
|
630
1043
|
}
|
|
631
1044
|
/**
|
|
632
1045
|
* Whether a `siteGated` manifest's entry at `sitePath` is a route of the site
|
|
@@ -659,13 +1072,15 @@ export function siteGate(siteDir) {
|
|
|
659
1072
|
return surface === undefined || surfaces.has(surface.id);
|
|
660
1073
|
};
|
|
661
1074
|
}
|
|
662
|
-
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides
|
|
1075
|
+
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases, unserved roster routes and undecided pages. */
|
|
663
1076
|
export function routesFailing(drift) {
|
|
664
1077
|
return (drift.missing.length +
|
|
665
1078
|
drift.stale.length +
|
|
666
1079
|
drift.stray.length +
|
|
667
1080
|
drift.orphanedOverrides.length +
|
|
668
|
-
drift.seamAliasMissing.length
|
|
1081
|
+
drift.seamAliasMissing.length +
|
|
1082
|
+
drift.unservedRoster.length +
|
|
1083
|
+
drift.undecidedPages.length);
|
|
669
1084
|
}
|
|
670
1085
|
/**
|
|
671
1086
|
* The two site files that bind a `siteSeam` package's `<package>/site` to
|
|
@@ -693,9 +1108,195 @@ function seamAliasMissing(web, siteDir, manifests) {
|
|
|
693
1108
|
}
|
|
694
1109
|
return out;
|
|
695
1110
|
}
|
|
1111
|
+
// ── The roster's routes — each served by some page file (#11511) ───────────
|
|
1112
|
+
/**
|
|
1113
|
+
* The roster's page routes, or none: no `.ailk-site-manifest.json` nor
|
|
1114
|
+
* legacy `TEMPLATE-MANIFEST.json`, or a JSON object with no `rows` key (a
|
|
1115
|
+
* pre-roster site). Anything else unreadable refuses, naming the file.
|
|
1116
|
+
*/
|
|
1117
|
+
function rosterRoutes(root) {
|
|
1118
|
+
const file = [SITE_ROSTER_PATH, LEGACY_SITE_ROSTER_PATH].find((name) => existsSync(join(root, name)));
|
|
1119
|
+
if (file === undefined)
|
|
1120
|
+
return [];
|
|
1121
|
+
try {
|
|
1122
|
+
const doc = JSON.parse(readFileSync(join(root, file), "utf8"));
|
|
1123
|
+
if (isRecord(doc) && !("rows" in doc))
|
|
1124
|
+
return [];
|
|
1125
|
+
}
|
|
1126
|
+
catch {
|
|
1127
|
+
// Unparseable: readRosterPageRoutes refuses it, naming the file.
|
|
1128
|
+
}
|
|
1129
|
+
try {
|
|
1130
|
+
return readRosterPageRoutes(root) ?? [];
|
|
1131
|
+
}
|
|
1132
|
+
catch (err) {
|
|
1133
|
+
if (err instanceof AddModuleRefusedError)
|
|
1134
|
+
throw new RoutesRefusedError(err.message);
|
|
1135
|
+
throw err;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/** Every `page.tsx` under `<web>/app/[locale]`, as route segments with route groups dropped. */
|
|
1139
|
+
function pageSegments(web) {
|
|
1140
|
+
const out = [];
|
|
1141
|
+
const walk = (dir, segments) => {
|
|
1142
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
1143
|
+
if (entry.isDirectory()) {
|
|
1144
|
+
if (SKIPPED_DIRS.has(entry.name) || entry.name.startsWith("_") || entry.name.startsWith("@"))
|
|
1145
|
+
continue;
|
|
1146
|
+
const group = entry.name.startsWith("(") && entry.name.endsWith(")");
|
|
1147
|
+
walk(join(dir, entry.name), group ? segments : [...segments, entry.name]);
|
|
1148
|
+
}
|
|
1149
|
+
else if (entry.name === "page.tsx") {
|
|
1150
|
+
out.push(segments);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
const root = join(web, LOCALE_DIR);
|
|
1155
|
+
if (existsSync(root))
|
|
1156
|
+
walk(root, []);
|
|
1157
|
+
return out;
|
|
1158
|
+
}
|
|
1159
|
+
const isDynamic = (segment) => segment.startsWith("[") && segment.endsWith("]");
|
|
1160
|
+
/**
|
|
1161
|
+
* How a page file's segments match a roster route's, as Next.js matches them
|
|
1162
|
+
* (precedence aside): `"static"` serves it outright — static segments, or a
|
|
1163
|
+
* catch-all; `"dynamic"` matched through a single `[y]` and serves a fully
|
|
1164
|
+
* static route only with content; `undefined` does not match.
|
|
1165
|
+
*/
|
|
1166
|
+
function matchPage(page, route) {
|
|
1167
|
+
let dynamic = false;
|
|
1168
|
+
for (let i = 0; i < page.length; i++) {
|
|
1169
|
+
const segment = page[i];
|
|
1170
|
+
if (segment.startsWith("[[..."))
|
|
1171
|
+
return "static";
|
|
1172
|
+
if (segment.startsWith("[..."))
|
|
1173
|
+
return route.length > i ? "static" : undefined;
|
|
1174
|
+
if (i >= route.length)
|
|
1175
|
+
return undefined;
|
|
1176
|
+
if (isDynamic(segment))
|
|
1177
|
+
dynamic = true;
|
|
1178
|
+
else if (segment !== route[i])
|
|
1179
|
+
return undefined;
|
|
1180
|
+
}
|
|
1181
|
+
if (page.length !== route.length)
|
|
1182
|
+
return undefined;
|
|
1183
|
+
return dynamic ? "dynamic" : "static";
|
|
1184
|
+
}
|
|
1185
|
+
/** The roster page routes the site carries that no page file serves, each with the page path it expected (D4–D6). */
|
|
1186
|
+
function unservedRoster(root, web, renames) {
|
|
1187
|
+
const routes = rosterRoutes(root);
|
|
1188
|
+
if (routes.length === 0)
|
|
1189
|
+
return [];
|
|
1190
|
+
const spoke = readSpokeShape(root);
|
|
1191
|
+
const gate = siteGate(root);
|
|
1192
|
+
const declined = readDeclinedRoutes(root);
|
|
1193
|
+
const pages = pageSegments(web);
|
|
1194
|
+
const contentDir = join(root, "content", "en");
|
|
1195
|
+
const types = existsSync(contentDir)
|
|
1196
|
+
? readdirSync(contentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name)
|
|
1197
|
+
: [];
|
|
1198
|
+
const hasContent = (slug) => types.some((type) => existsSync(join(contentDir, type, `${slug}.mdx`)));
|
|
1199
|
+
const out = [];
|
|
1200
|
+
for (const route of routes) {
|
|
1201
|
+
const segments = route.split("/").filter((s) => s !== "");
|
|
1202
|
+
const expected = posix.join(ROUTES_APP_DIR, LOCALE_DIR, ...segments, "page.tsx");
|
|
1203
|
+
if (!gate(expected) || (spoke !== undefined && isSpokeExcluded(expected, spoke)))
|
|
1204
|
+
continue;
|
|
1205
|
+
if (declinedRouteOfPath(expected, declined) !== undefined)
|
|
1206
|
+
continue;
|
|
1207
|
+
// #11385 D5 — a renamed family's roster route is served under its new segment.
|
|
1208
|
+
const at = renamedEntryPath(segments.join("/"), renames).split("/").filter((s) => s !== "");
|
|
1209
|
+
const matches = pages.map((page) => matchPage(page, at));
|
|
1210
|
+
const served = matches.includes("static") ||
|
|
1211
|
+
(matches.includes("dynamic") && (segments.some(isDynamic) || hasContent(segments[segments.length - 1])));
|
|
1212
|
+
if (!served)
|
|
1213
|
+
out.push(`${route} → ${posix.join(ROUTES_APP_DIR, LOCALE_DIR, ...at, "page.tsx")}`);
|
|
1214
|
+
}
|
|
1215
|
+
return out;
|
|
1216
|
+
}
|
|
1217
|
+
// ── Site pages — each a package page or a decided one (#11700) ─────────────
|
|
1218
|
+
/** The keys of the site's `.ailk-template-files.json`, or `undefined` with no record; a record that does not parse refuses. */
|
|
1219
|
+
function readTemplateFiles(root) {
|
|
1220
|
+
const path = join(root, TEMPLATE_RECORD_PATH);
|
|
1221
|
+
if (!existsSync(path))
|
|
1222
|
+
return undefined;
|
|
1223
|
+
try {
|
|
1224
|
+
return new Set(Object.keys(parseTemplateRecord(readFileSync(path, "utf8"), { onUnrecordable: () => { } }).files));
|
|
1225
|
+
}
|
|
1226
|
+
catch (err) {
|
|
1227
|
+
if (err instanceof TemplateRecordError)
|
|
1228
|
+
throw new RoutesRefusedError(err.message);
|
|
1229
|
+
throw err;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* `architecture.yaml`'s `customizations.scaffold_paths` globs — the files a
|
|
1234
|
+
* generator or module bundle writes — read by line in the shape
|
|
1235
|
+
* `derive-architecture.ts` emits: a two-space `scaffold_paths:` key under the
|
|
1236
|
+
* top-level `customizations:`, then four-space `- "<glob>"` items.
|
|
1237
|
+
*/
|
|
1238
|
+
function readScaffoldPaths(root) {
|
|
1239
|
+
const path = join(root, "architecture.yaml");
|
|
1240
|
+
if (!existsSync(path))
|
|
1241
|
+
return [];
|
|
1242
|
+
const out = [];
|
|
1243
|
+
let inCustomizations = false;
|
|
1244
|
+
let inList = false;
|
|
1245
|
+
for (const line of readFileSync(path, "utf8").split(/\r?\n/)) {
|
|
1246
|
+
if (/^\S/.test(line)) {
|
|
1247
|
+
inCustomizations = /^customizations:/.test(line);
|
|
1248
|
+
inList = false;
|
|
1249
|
+
}
|
|
1250
|
+
else if (inCustomizations && /^ {2}\S/.test(line)) {
|
|
1251
|
+
inList = /^ {2}scaffold_paths:\s*$/.test(line);
|
|
1252
|
+
}
|
|
1253
|
+
else if (inList) {
|
|
1254
|
+
const item = /^ {4}-\s+(.+?)\s*$/.exec(line);
|
|
1255
|
+
if (item)
|
|
1256
|
+
out.push(globToRegExp(item[1].replace(/^["']|["']$/g, "")));
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return out;
|
|
1260
|
+
}
|
|
1261
|
+
/** A `page.tsx`'s route segments under `app/[locale]/`: route groups and `_` / `@` folders dropped. */
|
|
1262
|
+
function routeSegments(localePath) {
|
|
1263
|
+
return posix
|
|
1264
|
+
.dirname(localePath)
|
|
1265
|
+
.split("/")
|
|
1266
|
+
.filter((s) => s !== "." && !(s.startsWith("(") && s.endsWith(")")) && !s.startsWith("_") && !s.startsWith("@"));
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* What already serves a hand-written `page.tsx` (#11700 D6): the
|
|
1270
|
+
* `add-route magnet` command for a magnet page, else the installed package
|
|
1271
|
+
* page whose route matches its address (a static match before a dynamic
|
|
1272
|
+
* one), else nothing.
|
|
1273
|
+
*/
|
|
1274
|
+
function suggestionFor(sitePath, text, planned) {
|
|
1275
|
+
const localePath = sitePath.slice(`${ROUTES_APP_DIR}/${LOCALE_DIR}/`.length);
|
|
1276
|
+
const segments = routeSegments(localePath);
|
|
1277
|
+
if (text.includes(MAGNET_PAGE_MARKER) || /\bmagnet(?:Landing|Start)\b/.test(text)) {
|
|
1278
|
+
const landing = segments.length > 1 && segments[segments.length - 1] === "start" ? segments.slice(0, -1) : segments;
|
|
1279
|
+
const flow = MAGNET_COMMAND_RE.exec(text.split("\n", 1)[0] ?? "")?.[2] ?? /\bslug:\s*"([^"]+)"/.exec(text)?.[1] ?? "<flow-slug>";
|
|
1280
|
+
return `regenerate it: \`create-ailk add-route magnet --path /${landing.join("/")} --flow ${flow}\``;
|
|
1281
|
+
}
|
|
1282
|
+
let dynamic;
|
|
1283
|
+
for (const p of planned) {
|
|
1284
|
+
if (p.entry.mount !== "locale" || p.entry.kind !== "page")
|
|
1285
|
+
continue;
|
|
1286
|
+
const match = matchPage(routeSegments(p.routePath), segments);
|
|
1287
|
+
if (match === "static")
|
|
1288
|
+
return `${p.package}'s ${p.entry.path} serves this address — delete this file, then run \`create-ailk routes --write\``;
|
|
1289
|
+
if (match === "dynamic")
|
|
1290
|
+
dynamic ??= p;
|
|
1291
|
+
}
|
|
1292
|
+
if (dynamic === undefined)
|
|
1293
|
+
return undefined;
|
|
1294
|
+
return `${dynamic.package}'s ${dynamic.entry.path} serves this address (from a content file) — delete this file, then run \`create-ailk routes --write\``;
|
|
1295
|
+
}
|
|
696
1296
|
/** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
|
|
697
1297
|
export function checkRoutes(siteDir) {
|
|
698
|
-
const { root, web, manifests, planned, recorded, notCarried } = plan(siteDir);
|
|
1298
|
+
const { root, web, manifests, planned, recorded, notCarried, renames } = plan(siteDir);
|
|
1299
|
+
const templateFiles = readTemplateFiles(root);
|
|
699
1300
|
const drift = {
|
|
700
1301
|
missing: [],
|
|
701
1302
|
stale: [],
|
|
@@ -705,14 +1306,27 @@ export function checkRoutes(siteDir) {
|
|
|
705
1306
|
siteKept: [],
|
|
706
1307
|
orphanedOverrides: orphanedOverrides(web, root, manifests),
|
|
707
1308
|
seamAliasMissing: seamAliasMissing(web, root, manifests),
|
|
1309
|
+
unservedRoster: unservedRoster(root, web, renames),
|
|
1310
|
+
undecidedPages: [],
|
|
1311
|
+
decidedPages: [],
|
|
1312
|
+
routeSuggestions: {},
|
|
1313
|
+
sitePagesUnchecked: templateFiles === undefined,
|
|
708
1314
|
generated: planned.length,
|
|
709
1315
|
};
|
|
1316
|
+
const read = (sitePath) => readFileSync(join(root, sitePath), "utf8");
|
|
1317
|
+
// A recorded route needs a decided entry; an undecided one fails (#11700 D3).
|
|
1318
|
+
const claim = (sitePath, record, state) => {
|
|
1319
|
+
if (isDecided(record))
|
|
1320
|
+
drift.recorded.push({ path: sitePath, state, id: record.id });
|
|
1321
|
+
else
|
|
1322
|
+
drift.undecidedPages.push({ path: sitePath, id: record.id });
|
|
1323
|
+
};
|
|
710
1324
|
const known = new Set();
|
|
711
1325
|
for (const p of planned) {
|
|
712
1326
|
known.add(p.sitePath);
|
|
713
1327
|
const exists = existsSync(p.absPath);
|
|
714
1328
|
if (p.record) {
|
|
715
|
-
|
|
1329
|
+
claim(p.sitePath, p.record, exists ? "replaced" : "removed");
|
|
716
1330
|
}
|
|
717
1331
|
else if (!exists) {
|
|
718
1332
|
drift.missing.push(p.sitePath);
|
|
@@ -726,11 +1340,15 @@ export function checkRoutes(siteDir) {
|
|
|
726
1340
|
// contract ahead of its first page): nothing under its prefix is stray.
|
|
727
1341
|
if (manifest.routes.length === 0)
|
|
728
1342
|
continue;
|
|
729
|
-
const kept = new Set(manifest.siteOwned.map((path) => relative(root, join(web, LOCALE_DIR, path)).split(sep).join("/")));
|
|
1343
|
+
const kept = new Set(manifest.siteOwned.map((path) => relative(root, join(web, LOCALE_DIR, renamedEntryPath(path, renames))).split(sep).join("/")));
|
|
730
1344
|
const rootPage = join(web, LOCALE_DIR, ROOT_PAGE);
|
|
731
1345
|
const underPrefixes = [
|
|
732
1346
|
...(manifest.localeRoot && existsSync(rootPage) ? [relative(root, rootPage).split(sep).join("/")] : []),
|
|
733
|
-
|
|
1347
|
+
// #11385 D5 — a renamed prefix's stray scope is its old and its new segment.
|
|
1348
|
+
...manifest.prefix.flatMap((prefix) => {
|
|
1349
|
+
const moved = renamedEntryPath(prefix, renames);
|
|
1350
|
+
return moved === prefix ? routingFilesUnder(web, root, prefix) : [...routingFilesUnder(web, root, prefix), ...routingFilesUnder(web, root, moved)];
|
|
1351
|
+
}),
|
|
734
1352
|
...manifest.appPrefixes.flatMap((prefix) => routingFilesUnder(web, root, prefix, "app")),
|
|
735
1353
|
];
|
|
736
1354
|
for (const sitePath of underPrefixes) {
|
|
@@ -741,13 +1359,47 @@ export function checkRoutes(siteDir) {
|
|
|
741
1359
|
drift.siteKept.push(sitePath);
|
|
742
1360
|
continue;
|
|
743
1361
|
}
|
|
1362
|
+
// A pair `add-route magnet` wrote is never reported (#11700 D5).
|
|
1363
|
+
if (isGeneratedMagnetPage(sitePath, read(sitePath)))
|
|
1364
|
+
continue;
|
|
744
1365
|
const record = recordFor(recorded, sitePath);
|
|
745
1366
|
if (record)
|
|
746
|
-
|
|
1367
|
+
claim(sitePath, record, "replaced");
|
|
747
1368
|
else
|
|
748
1369
|
drift.stray.push(sitePath);
|
|
749
1370
|
}
|
|
750
1371
|
}
|
|
1372
|
+
// Every other routing file under app/[locale]/ the template, a generator or
|
|
1373
|
+
// `add-route magnet` did not write is a site page (#11700 D1).
|
|
1374
|
+
const shipped = readScaffoldPaths(root);
|
|
1375
|
+
for (const sitePath of routingFilesUnder(web, root, "")) {
|
|
1376
|
+
if (known.has(sitePath) || templateFiles?.has(sitePath) || shipped.some((re) => re.test(sitePath)))
|
|
1377
|
+
continue;
|
|
1378
|
+
const text = read(sitePath);
|
|
1379
|
+
if (isGenerated(text) || isGeneratedMagnetPage(sitePath, text))
|
|
1380
|
+
continue;
|
|
1381
|
+
const record = recordFor(recorded, sitePath);
|
|
1382
|
+
if (record !== undefined && isDecided(record))
|
|
1383
|
+
drift.decidedPages.push({ path: sitePath, state: "replaced", id: record.id });
|
|
1384
|
+
else if (record !== undefined)
|
|
1385
|
+
drift.undecidedPages.push({ path: sitePath, id: record.id });
|
|
1386
|
+
else if (templateFiles !== undefined)
|
|
1387
|
+
drift.undecidedPages.push({ path: sitePath });
|
|
1388
|
+
}
|
|
1389
|
+
drift.undecidedPages.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
1390
|
+
const reported = [
|
|
1391
|
+
...drift.stray,
|
|
1392
|
+
...drift.stale.filter((path) => !isGenerated(read(path))),
|
|
1393
|
+
...drift.undecidedPages.map((page) => page.path),
|
|
1394
|
+
...drift.decidedPages.map((page) => page.path),
|
|
1395
|
+
];
|
|
1396
|
+
for (const sitePath of reported) {
|
|
1397
|
+
if (posix.basename(sitePath) !== "page.tsx" || !existsSync(join(root, sitePath)))
|
|
1398
|
+
continue;
|
|
1399
|
+
const suggestion = suggestionFor(sitePath, read(sitePath), planned);
|
|
1400
|
+
if (suggestion !== undefined)
|
|
1401
|
+
drift.routeSuggestions[sitePath] = suggestion;
|
|
1402
|
+
}
|
|
751
1403
|
return drift;
|
|
752
1404
|
}
|
|
753
1405
|
function readCatalog(path) {
|
|
@@ -824,8 +1476,8 @@ function orphanedOverrides(web, siteDir, manifests) {
|
|
|
824
1476
|
}
|
|
825
1477
|
/** Write every generated file that is missing or stale; a recorded route is left exactly as it is. */
|
|
826
1478
|
export function writeRoutes(siteDir) {
|
|
827
|
-
const { planned } = plan(siteDir);
|
|
828
|
-
const result = { written: [], current: [], recorded: [], kept: [] };
|
|
1479
|
+
const { root, web, planned, renames } = plan(siteDir, "write");
|
|
1480
|
+
const result = { written: [], current: [], recorded: [], kept: [], removed: [] };
|
|
829
1481
|
for (const p of planned) {
|
|
830
1482
|
const exists = existsSync(p.absPath);
|
|
831
1483
|
if (p.record) {
|
|
@@ -847,8 +1499,60 @@ export function writeRoutes(siteDir) {
|
|
|
847
1499
|
writeFileSync(p.absPath, p.text);
|
|
848
1500
|
result.written.push(p.sitePath);
|
|
849
1501
|
}
|
|
1502
|
+
for (const from of Object.keys(renames))
|
|
1503
|
+
vacate(join(web, LOCALE_DIR, from), root, result);
|
|
850
1504
|
return result;
|
|
851
1505
|
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Delete the generated routing files under a renamed family's old directory
|
|
1508
|
+
* and the directories that leaves empty (#11385 D5, SEC-11385-5). Entries are
|
|
1509
|
+
* read with lstat and no link is followed; each file is re-checked as it is
|
|
1510
|
+
* deleted — a regular file, its real path inside the directory, still
|
|
1511
|
+
* carrying the generator header — and one that fails is left and reported as
|
|
1512
|
+
* kept. `plan()` has already refused anything else under the directory.
|
|
1513
|
+
*/
|
|
1514
|
+
function vacate(dir, root, result) {
|
|
1515
|
+
let base;
|
|
1516
|
+
try {
|
|
1517
|
+
if (!lstatSync(dir).isDirectory())
|
|
1518
|
+
return;
|
|
1519
|
+
base = realpathSync(dir);
|
|
1520
|
+
}
|
|
1521
|
+
catch {
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
const walk = (current) => {
|
|
1525
|
+
for (const name of readdirSync(current).sort()) {
|
|
1526
|
+
const path = join(current, name);
|
|
1527
|
+
const stat = lstatSync(path);
|
|
1528
|
+
if (stat.isDirectory()) {
|
|
1529
|
+
walk(path);
|
|
1530
|
+
continue;
|
|
1531
|
+
}
|
|
1532
|
+
const sitePath = relative(root, path).split(sep).join("/");
|
|
1533
|
+
const deletable = stat.isFile() &&
|
|
1534
|
+
ROUTING_FILES.has(name) &&
|
|
1535
|
+
realpathSync(path).startsWith(`${base}${sep}`) &&
|
|
1536
|
+
isGenerated(readFileSync(path, "utf8"));
|
|
1537
|
+
if (!deletable) {
|
|
1538
|
+
result.kept.push(sitePath);
|
|
1539
|
+
continue;
|
|
1540
|
+
}
|
|
1541
|
+
unlinkSync(path);
|
|
1542
|
+
result.removed.push(sitePath);
|
|
1543
|
+
}
|
|
1544
|
+
if (readdirSync(current).length === 0)
|
|
1545
|
+
rmdirSync(current);
|
|
1546
|
+
};
|
|
1547
|
+
walk(dir);
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* The order an agent or a person adds a page in (#11700 D8). The same
|
|
1551
|
+
* sentence is in this help, the check's failure header, the scaffold
|
|
1552
|
+
* CLAUDE.md, the `add-page` and `extend-site` skill text and
|
|
1553
|
+
* `template-guard.sh`'s refusal; `routes.test.ts` reads all six.
|
|
1554
|
+
*/
|
|
1555
|
+
export const PAGE_DECISION_GUIDANCE = "Before you add a page, look up its page type and the package route that serves it, and use that package page when it exists. Otherwise record the decision in customizations.yaml (build-in: site — <decider>, <YYYY-MM-DD>, <reason>) before you write the file.";
|
|
852
1556
|
export const ROUTES_HELP = `create-ailk routes — generate the route files for the pages a site's packages ship.
|
|
853
1557
|
|
|
854
1558
|
Usage:
|
|
@@ -871,7 +1575,16 @@ Options:
|
|
|
871
1575
|
leaves to the site). It also names each orphaned
|
|
872
1576
|
override: a key in apps/web/messages/<locale>.json
|
|
873
1577
|
under a namespace a package's catalog ships that
|
|
874
|
-
the catalog no longer has.
|
|
1578
|
+
the catalog no longer has. And it names each roster
|
|
1579
|
+
page route (.ailk-site-manifest.json) that no page
|
|
1580
|
+
file serves — neither a site page nor a generated
|
|
1581
|
+
re-export. And it names each undecided page: a
|
|
1582
|
+
routing file under app/[locale]/ that no package,
|
|
1583
|
+
generator or template wrote, or a recorded package
|
|
1584
|
+
route, with no decided customizations.yaml entry
|
|
1585
|
+
(an undecided entry fails too). A reported
|
|
1586
|
+
page.tsx names the package page or the add-route
|
|
1587
|
+
magnet command that already serves its address.
|
|
875
1588
|
--help, -h Print this message.
|
|
876
1589
|
|
|
877
1590
|
A page package is an installed @working-theory/* dependency of apps/web whose
|
|
@@ -882,12 +1595,19 @@ app root (apps/web/account.config.tsx, say) and passes it in. Replace or remove
|
|
|
882
1595
|
customizations.yaml (an entry whose paths match the route file): a recorded
|
|
883
1596
|
route is reported as replaced or removed, never failed, and --write never
|
|
884
1597
|
touches it. A manifest may list several prefixes, and one manifest with
|
|
885
|
-
"root": true may ship the locale-root page.tsx.
|
|
1598
|
+
"root": true may ship the locale-root page.tsx. No two manifests may claim the
|
|
1599
|
+
same prefix; one may claim a prefix strictly inside another's, which then
|
|
1600
|
+
ships no route under it. A manifest with
|
|
886
1601
|
"siteGated": true ships only the routes the site selected: its public pages
|
|
887
1602
|
are not carried when .ailk-site-manifest.json lists no marketing module, and
|
|
888
1603
|
neither is any page under a surface the architecture.yaml "# Surfaces:" header
|
|
889
1604
|
leaves out. Run --write after \`pnpm install\` (the manifests are read from the
|
|
890
1605
|
installed packages); the scaffold's preflight runs --check as \`pnpm routes:check\`.
|
|
1606
|
+
|
|
1607
|
+
${PAGE_DECISION_GUIDANCE} A decided entry is
|
|
1608
|
+
"build-in: site — <decider>, <YYYY-MM-DD>, <reason>" or "build-in: ailk#<N>";
|
|
1609
|
+
undecided_ok_until does not apply to a page. With no .ailk-template-files.json
|
|
1610
|
+
a page outside every package prefix is not checked, and the report says so.
|
|
891
1611
|
`;
|
|
892
1612
|
/** Parse the argv AFTER the `routes` word. Strict `node:util` parseArgs, like `parseSyncRoutesArgs`. */
|
|
893
1613
|
export function parseRoutesArgs(argv) {
|
|
@@ -920,18 +1640,29 @@ export function formatRoutesReport(result, mode) {
|
|
|
920
1640
|
const lines = [];
|
|
921
1641
|
if (mode === "check") {
|
|
922
1642
|
const drift = result;
|
|
1643
|
+
const hint = (p) => (drift.routeSuggestions[p] === undefined ? "" : ` → ${drift.routeSuggestions[p]}`);
|
|
923
1644
|
const failing = [
|
|
924
1645
|
...drift.missing.map((p) => ` missing: ${p}`),
|
|
925
|
-
...drift.stale.map((p) => ` stale: ${p}`),
|
|
926
|
-
...drift.stray.map((p) => ` stray: ${p}`),
|
|
1646
|
+
...drift.stale.map((p) => ` stale: ${p}${hint(p)}`),
|
|
1647
|
+
...drift.stray.map((p) => ` stray: ${p}${hint(p)}`),
|
|
1648
|
+
...drift.undecidedPages.map(({ path, id }) => ` undecided: ${path} — ${id === undefined ? "no customizations.yaml entry" : `customizations.yaml "${id}" is undecided`}${hint(path)}`),
|
|
927
1649
|
...drift.orphanedOverrides.map((p) => ` orphaned override: ${p}`),
|
|
928
1650
|
...drift.seamAliasMissing.map((p) => ` missing site seam alias: ${p}`),
|
|
1651
|
+
...drift.unservedRoster.map((entry) => {
|
|
1652
|
+
const [route, path] = entry.split(" → ");
|
|
1653
|
+
return ` unserved roster route: ${route} (no page at ${path} — a site page or a generated re-export)`;
|
|
1654
|
+
}),
|
|
929
1655
|
];
|
|
930
1656
|
if (failing.length === 0) {
|
|
931
1657
|
lines.push(`[create-ailk] routes: OK — ${drift.generated} generated route file(s) in sync`);
|
|
932
1658
|
}
|
|
933
1659
|
else {
|
|
934
|
-
lines.push(`[create-ailk] routes: ${failing.length} route file(s) or message override(s) differ from the installed page packages (run \`create-ailk routes --write\` to rewrite a route file; record a replaced or removed route in customizations.yaml; delete an orphaned override, whose key the package no longer has)
|
|
1660
|
+
lines.push(`[create-ailk] routes: ${failing.length} route file(s) or message override(s) differ from the installed page packages (run \`create-ailk routes --write\` to rewrite a route file; record a replaced or removed route in customizations.yaml; delete an orphaned override, whose key the package no longer has; add a page for an unserved roster route, or drop or decline its row):${drift.undecidedPages.length > 0 ? ` ${PAGE_DECISION_GUIDANCE}` : ""}`, ...failing);
|
|
1661
|
+
}
|
|
1662
|
+
for (const r of drift.decidedPages)
|
|
1663
|
+
lines.push(` kept by the site (decided): ${r.path} — customizations.yaml "${r.id}"${hint(r.path)}`);
|
|
1664
|
+
if (drift.sitePagesUnchecked) {
|
|
1665
|
+
lines.push(` site pages not checked: no ${TEMPLATE_RECORD_PATH} (run create-ailk update to write it)`);
|
|
935
1666
|
}
|
|
936
1667
|
}
|
|
937
1668
|
else {
|
|
@@ -941,6 +1672,8 @@ export function formatRoutesReport(result, mode) {
|
|
|
941
1672
|
lines.push(` wrote: ${p}`);
|
|
942
1673
|
for (const p of write.kept)
|
|
943
1674
|
lines.push(` kept (not a generated file, never overwritten): ${p}`);
|
|
1675
|
+
for (const p of write.removed)
|
|
1676
|
+
lines.push(` removed: ${p}`);
|
|
944
1677
|
}
|
|
945
1678
|
for (const r of result.recorded)
|
|
946
1679
|
lines.push(` ${r.state} (recorded): ${r.path} — customizations.yaml "${r.id}"`);
|