create-ailk 0.40.3 → 0.41.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/dist/lib/env-catalog.js +1 -1
- package/dist/module-architecture.js +14 -48
- package/dist/routes.d.ts +8 -2
- package/dist/routes.js +189 -15
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.js +49 -21
- package/dist/topology.js +0 -1
- package/dist/update.d.ts +16 -1
- package/dist/update.js +250 -6
- package/package.json +3 -3
- package/templates/apps/api/.env.example +2 -1
- package/templates/apps/web/.env.example +5 -6
- package/templates/apps/web/CLAUDE.md +29 -7
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +9 -1
- 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 +18 -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/page-chrome.ts +3 -0
- package/templates/apps/web/messages/en.json +0 -9
- package/versions.json +50 -50
- package/templates/apps/web/lib/deliverable-grant.ts +0 -18
package/dist/lib/env-catalog.js
CHANGED
|
@@ -232,7 +232,7 @@ export const ENV_CATALOG = {
|
|
|
232
232
|
secret: false,
|
|
233
233
|
},
|
|
234
234
|
OSS_API_INTERNAL_SECRET: {
|
|
235
|
-
description: "Shared secret the /
|
|
235
|
+
description: "Shared secret the Offerings buy route (/api/offerings/checkout/<lookupKey>) sends to the API's checkout route; must equal the API's value. Server-only.",
|
|
236
236
|
secret: true,
|
|
237
237
|
},
|
|
238
238
|
SENTRY_AUTH_TOKEN: {
|
|
@@ -1231,7 +1231,8 @@ export const MODULE_SLICES = {
|
|
|
1231
1231
|
//
|
|
1232
1232
|
// the flows route files (generated, #11251) written by `routes --write`;
|
|
1233
1233
|
// the spoke's `results` entries not carried
|
|
1234
|
-
//
|
|
1234
|
+
// the package's `reports` route files (generated, #11657), the ReportPage
|
|
1235
|
+
// + ReportsList seeds
|
|
1235
1236
|
// dropped (`SPOKE_EXCLUDED_MODULE_PATHS`,
|
|
1236
1237
|
// 2026-10-09): the reader links a report's
|
|
1237
1238
|
// bytes on the hub through
|
|
@@ -1294,49 +1295,18 @@ export const MODULE_SLICES = {
|
|
|
1294
1295
|
// `sync-routes.ts`'s `NESTED_FOREIGN_MODULE_ENTRIES` for the companion
|
|
1295
1296
|
// fix that keeps its presence from falsely reading as "projects carried".
|
|
1296
1297
|
"apps/web/app/[locale]/projects/apply/ListingApplicationClient.tsx",
|
|
1297
|
-
// #
|
|
1298
|
-
//
|
|
1299
|
-
//
|
|
1300
|
-
//
|
|
1301
|
-
//
|
|
1302
|
-
//
|
|
1303
|
-
// package's `@working-theory/ui-signal-collectors/pages/flows/[slug]/magnet-page`
|
|
1304
|
-
// (#11251 D7).
|
|
1305
|
-
"apps/web/app/[locale]/careers/apply/page.tsx",
|
|
1306
|
-
"apps/web/app/[locale]/careers/[slug]/apply/page.tsx",
|
|
1307
|
-
// #9287 DD10 — the trial magnet pair. Its own `trial` route segment,
|
|
1308
|
-
// which no surface gates, so `ownedFiles` keeps both pages out of a
|
|
1309
|
-
// keyless scaffold, beside the careers walks.
|
|
1310
|
-
"apps/web/app/[locale]/trial/page.tsx",
|
|
1311
|
-
"apps/web/app/[locale]/trial/request/page.tsx",
|
|
1298
|
+
// #11657 — the magnet pages (the Job application walks, the trial
|
|
1299
|
+
// pair, the reports hub, the report reader, its walk and file proxy and
|
|
1300
|
+
// the deliverable renderer) ship in `@working-theory/ui-signal-collectors`;
|
|
1301
|
+
// a site holds only the route files `routes --write` generates from its
|
|
1302
|
+
// manifest, so none is an `ownedFiles` entry. `/downloads` is retired
|
|
1303
|
+
// into routes-map `legacyRoutes` redirects.
|
|
1312
1304
|
// #5581 U4 — the eleven signal-collectors components + the slice's own
|
|
1313
1305
|
// re-export entry point moved to packages-paid/ui-signal-collectors;
|
|
1314
1306
|
// the package is delivered to a keyed scaffold via `patches` below,
|
|
1315
1307
|
// not via `ownedFiles`/`installMap` (D5).
|
|
1316
|
-
// #5562 — the report reader at `/reports/<slug>`. UNLIKE the flow routes
|
|
1317
|
-
// above, this one DOES belong in `ownedFiles`, and for the same reason
|
|
1318
|
-
// `projects/apply/ListingApplicationClient.tsx` does: `/reports` is a URL
|
|
1319
|
-
// segment `MODULE_SURFACES["signal-collectors"] = ["flows"]` does not gate,
|
|
1320
|
-
// so `excludedRoutePaths()` would leave it in a keyless scaffold. It has no
|
|
1321
|
-
// upgrade-path fixture to protect either — it is net-new here, so nothing
|
|
1322
|
-
// in `templates/` can regress by its absence.
|
|
1323
|
-
"apps/web/app/[locale]/reports/[slug]/page.tsx",
|
|
1324
|
-
// spec 6892 D2 — the /reports hub, alongside its reader above: also a
|
|
1325
|
-
// URL segment MODULE_SURFACES["signal-collectors"] does not gate.
|
|
1326
|
-
"apps/web/app/[locale]/reports/page.tsx",
|
|
1327
|
-
// #8848 D6, D7 — the hub deliverable at `/reports/<slug>`: its renderer,
|
|
1328
|
-
// the gated walk and the ungated file's byte proxy. Same segment, same
|
|
1329
|
-
// reason as the reader above.
|
|
1330
|
-
"apps/web/app/[locale]/reports/deliverable-page.tsx",
|
|
1331
|
-
"apps/web/app/[locale]/reports/[slug]/start/page.tsx",
|
|
1332
|
-
"apps/web/app/[locale]/reports/[slug]/file/route.ts",
|
|
1333
|
-
// #8848 D12 — `/downloads` redirects into `/reports`, so a scaffold
|
|
1334
|
-
// without this module ships no `/downloads` at all (the redirect target
|
|
1335
|
-
// is this module's) rather than the old broken list.
|
|
1336
|
-
"apps/web/app/[locale]/downloads/page.tsx",
|
|
1337
|
-
"apps/web/app/[locale]/downloads/[slug]/page.tsx",
|
|
1338
1308
|
//
|
|
1339
|
-
// The two sections
|
|
1309
|
+
// The two sections the reports route composes — `report-header` and
|
|
1340
1310
|
// `reports-list` — are deliberately NOT owned here. They are
|
|
1341
1311
|
// `SectionRenderer` DISPATCH entries with static imports, so stripping
|
|
1342
1312
|
// them would leave the renderer with dangling imports in a keyless
|
|
@@ -1358,9 +1328,8 @@ export const MODULE_SLICES = {
|
|
|
1358
1328
|
{ route: "/flows/[slug]" },
|
|
1359
1329
|
{ route: "/flows/[slug]/start" },
|
|
1360
1330
|
{ route: "/flows/[slug]/results/[payload]" },
|
|
1361
|
-
// #5562 — the report reader.
|
|
1362
|
-
//
|
|
1363
|
-
// the contribution and the delivery shape carrying it agree here. Its
|
|
1331
|
+
// #5562 — the report reader. Like the three rows above, its code ships
|
|
1332
|
+
// in the package and its route file is generated (#11657). Its
|
|
1364
1333
|
// seeds are SELF-SEEDING (spec 6892 D3): this module's own `installMap`
|
|
1365
1334
|
// lands the four `ReportPage` samples below, so every template taking
|
|
1366
1335
|
// the module gets them — `moduleRosterRows` derives the code-route form
|
|
@@ -1368,7 +1337,7 @@ export const MODULE_SLICES = {
|
|
|
1368
1337
|
{ route: "/reports/[slug]", contentDir: "content/en/ReportPage" },
|
|
1369
1338
|
// #8848 D7's walk (`/reports/[slug]/start`) is NOT a contribution: a
|
|
1370
1339
|
// contribution needs a shipped template manifest to carry its row, and
|
|
1371
|
-
// none does yet. Its code ships
|
|
1340
|
+
// none does yet. Its code ships in the package (#11657).
|
|
1372
1341
|
],
|
|
1373
1342
|
// installMap (#5618 D6.3) — the module's sample files, moved here out
|
|
1374
1343
|
// of `site-templates/marketing-site/` so the module OWNS its samples
|
|
@@ -1499,8 +1468,8 @@ export const MODULE_SLICES = {
|
|
|
1499
1468
|
// filter (`isSpokeExcluded`), which drops every destination under
|
|
1500
1469
|
// apps/api or database and the web files that call the hub's own
|
|
1501
1470
|
// checkout (`SPOKE_HUB_CHECKOUT_SEEDS`: flows/[slug]/checkout.actions.ts,
|
|
1502
|
-
// the flow results directory — the results layout among it —
|
|
1503
|
-
// dev/purchase
|
|
1471
|
+
// the flow results directory — the results layout among it — spoke-intake
|
|
1472
|
+
// Rule 3; `/dev/purchase` is retired, #11657). What lands
|
|
1504
1473
|
// is the scaffold-commerce skill, the commerce-boundary rule and the
|
|
1505
1474
|
// @working-theory/ui-commerce dependency (`patches` below). A spoke sells
|
|
1506
1475
|
// through its hub's Offerings buy route (#9142). The checkout and
|
|
@@ -1592,9 +1561,6 @@ export const MODULE_SLICES = {
|
|
|
1592
1561
|
// `FlowResultsPriceCard` in `@working-theory/ui-commerce`, which the
|
|
1593
1562
|
// slot loads through the paid-sections registry. Without commerce the
|
|
1594
1563
|
// page renders, offering Book a Call for every fit.
|
|
1595
|
-
"apps/web/app/[locale]/dev/purchase/page.tsx",
|
|
1596
|
-
"apps/web/app/[locale]/dev/purchase/error.tsx",
|
|
1597
|
-
"apps/web/app/[locale]/dev/purchase/purchase.actions.ts",
|
|
1598
1564
|
// #11253 D3, D6 — the checkout and purchase pages' typed config
|
|
1599
1565
|
// (`defineCommerceConfig`), the host seam the generated route files pass
|
|
1600
1566
|
// in, and the checkout stamp it reads, which every commerce site now
|
package/dist/routes.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface RouteManifest {
|
|
|
46
46
|
config: string | undefined;
|
|
47
47
|
/** Routing files under the prefix that stay the site's own pages, never generated. */
|
|
48
48
|
siteOwned: string[];
|
|
49
|
+
/** Entry paths outside the prefixes that another installed manifest's `siteOwned` names (#11657 D2). */
|
|
50
|
+
adopts: string[];
|
|
49
51
|
/** The package's message catalog, when it ships one. */
|
|
50
52
|
messages: ManifestMessages | undefined;
|
|
51
53
|
/** `false` when each generated file carries the `// oss: false` marker; unset otherwise. */
|
|
@@ -81,6 +83,8 @@ export declare const OSS_FALSE_MARKER = "// oss: false";
|
|
|
81
83
|
export declare function renderRouteFile(manifest: RouteManifest, entry: RouteEntry): string;
|
|
82
84
|
/** Whether `text` is a file this generator wrote: its first line (after an `oss: false` marker) is the header. */
|
|
83
85
|
export declare function isGenerated(text: string): boolean;
|
|
86
|
+
/** The id of the first `customizations:` entry whose paths match, per path; reads the file once (#11511). */
|
|
87
|
+
export declare function customizationsRecord(siteDir: string): (sitePath: string) => string | undefined;
|
|
84
88
|
/** Whether `<siteDir>/customizations.yaml` records `sitePath` — any entry, any path form or glob (the generator's own reading). */
|
|
85
89
|
export declare function isRecordedRoute(siteDir: string, sitePath: string): boolean;
|
|
86
90
|
export interface RecordedRoute {
|
|
@@ -101,6 +105,8 @@ export interface RoutesDrift {
|
|
|
101
105
|
orphanedOverrides: string[];
|
|
102
106
|
/** A site file missing the alias line a `siteSeam` package needs: `<file>: <alias>` (#11257 D4). */
|
|
103
107
|
seamAliasMissing: string[];
|
|
108
|
+
/** A roster page route the site carries that no page file serves: `<route> → <expected page path>` (#11511). */
|
|
109
|
+
unservedRoster: string[];
|
|
104
110
|
/** The manifest entries in force — recorded ones included, not-carried ones not. */
|
|
105
111
|
generated: number;
|
|
106
112
|
}
|
|
@@ -111,7 +117,7 @@ export interface RoutesDrift {
|
|
|
111
117
|
* site with no readable header carries every surface.
|
|
112
118
|
*/
|
|
113
119
|
export declare function siteGate(siteDir: string): (sitePath: string) => boolean;
|
|
114
|
-
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides
|
|
120
|
+
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases and unserved roster routes. */
|
|
115
121
|
export declare function routesFailing(drift: RoutesDrift): number;
|
|
116
122
|
/** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
|
|
117
123
|
export declare function checkRoutes(siteDir: string): RoutesDrift;
|
|
@@ -130,7 +136,7 @@ export interface RoutesArgs {
|
|
|
130
136
|
check: boolean;
|
|
131
137
|
help: boolean;
|
|
132
138
|
}
|
|
133
|
-
export declare const ROUTES_HELP = "create-ailk routes \u2014 generate the route files for the pages a site's packages ship.\n\nUsage:\n create-ailk routes --write [<target-dir>]\n create-ailk routes --check [<target-dir>]\n\nArguments:\n <target-dir> The site root (holds apps/web). Defaults to the\n current dir.\n\nOptions:\n --write Write one generated file per route the installed\n page packages declare, under apps/web/app/[locale]/.\n A file already current is left alone.\n --check Write nothing; exit 1 naming each generated file\n that is missing, stale (differs from what --write\n would write) or stray (a page.tsx, layout.tsx or\n route.ts under a package's route prefix that is\n neither generated, recorded, nor one the package\n leaves to the site). It also names each orphaned\n override: a key in apps/web/messages/<locale>.json\n under a namespace a package's catalog ships that\n the catalog no longer has.\n --help, -h Print this message.\n\nA page package is an installed @working-theory/* dependency of apps/web whose\npackage.json declares \"ailk\": { \"routes\": \"<manifest>\" }. A generated file\nre-exports the package's page and copies its route-segment config; when the\npage takes the site's config it imports the manifest's config file from the\napp root (apps/web/account.config.tsx, say) and passes it in. Replace or remove a shipped route by recording it in\ncustomizations.yaml (an entry whose paths match the route file): a recorded\nroute is reported as replaced or removed, never failed, and --write never\ntouches it. A manifest may list several prefixes, and one manifest with\n\"root\": true may ship the locale-root page.tsx. A manifest with\n\"siteGated\": true ships only the routes the site selected: its public pages\nare not carried when .ailk-site-manifest.json lists no marketing module, and\nneither is any page under a surface the architecture.yaml \"# Surfaces:\" header\nleaves out. Run --write after `pnpm install` (the manifests are read from the\ninstalled packages); the scaffold's preflight runs --check as `pnpm routes:check`.\n";
|
|
139
|
+
export declare const ROUTES_HELP = "create-ailk routes \u2014 generate the route files for the pages a site's packages ship.\n\nUsage:\n create-ailk routes --write [<target-dir>]\n create-ailk routes --check [<target-dir>]\n\nArguments:\n <target-dir> The site root (holds apps/web). Defaults to the\n current dir.\n\nOptions:\n --write Write one generated file per route the installed\n page packages declare, under apps/web/app/[locale]/.\n A file already current is left alone.\n --check Write nothing; exit 1 naming each generated file\n that is missing, stale (differs from what --write\n would write) or stray (a page.tsx, layout.tsx or\n route.ts under a package's route prefix that is\n neither generated, recorded, nor one the package\n leaves to the site). It also names each orphaned\n override: a key in apps/web/messages/<locale>.json\n under a namespace a package's catalog ships that\n the catalog no longer has. And it names each roster\n page route (.ailk-site-manifest.json) that no page\n file serves \u2014 neither a site page nor a generated\n re-export.\n --help, -h Print this message.\n\nA page package is an installed @working-theory/* dependency of apps/web whose\npackage.json declares \"ailk\": { \"routes\": \"<manifest>\" }. A generated file\nre-exports the package's page and copies its route-segment config; when the\npage takes the site's config it imports the manifest's config file from the\napp root (apps/web/account.config.tsx, say) and passes it in. Replace or remove a shipped route by recording it in\ncustomizations.yaml (an entry whose paths match the route file): a recorded\nroute is reported as replaced or removed, never failed, and --write never\ntouches it. A manifest may list several prefixes, and one manifest with\n\"root\": true may ship the locale-root page.tsx. No two manifests may claim the\nsame prefix; one may claim a prefix strictly inside another's, which then\nships no route under it. A manifest with\n\"siteGated\": true ships only the routes the site selected: its public pages\nare not carried when .ailk-site-manifest.json lists no marketing module, and\nneither is any page under a surface the architecture.yaml \"# Surfaces:\" header\nleaves out. Run --write after `pnpm install` (the manifests are read from the\ninstalled packages); the scaffold's preflight runs --check as `pnpm routes:check`.\n";
|
|
134
140
|
/** Parse the argv AFTER the `routes` word. Strict `node:util` parseArgs, like `parseSyncRoutesArgs`. */
|
|
135
141
|
export declare function parseRoutesArgs(argv: string[]): RoutesArgs;
|
|
136
142
|
/** The printed report: one line per file, grouped by state; the recorded routes last, under their decision. */
|
package/dist/routes.js
CHANGED
|
@@ -48,6 +48,14 @@
|
|
|
48
48
|
* later slice): it is REPORTED as kept by the site, never stray, and
|
|
49
49
|
* `--write` never touches it.
|
|
50
50
|
*
|
|
51
|
+
* Adoption (#11657 D2). A manifest may list `adopts` — routing files OUTSIDE
|
|
52
|
+
* its own prefixes, each one of its entries, that another installed
|
|
53
|
+
* manifest names in its `siteOwned` list (the signal-collectors package's
|
|
54
|
+
* two careers walks, under site-pages' `careers` prefix). An adopted entry is
|
|
55
|
+
* carried only while some installed manifest lists its path as `siteOwned`;
|
|
56
|
+
* with no such owner it is not carried — neither written, missing nor stray.
|
|
57
|
+
* Two installed manifests adopting one path are refused, naming both.
|
|
58
|
+
*
|
|
51
59
|
* A page package's strings ship in its own catalog (ADR 0040 rule 5), named
|
|
52
60
|
* by the manifest's `messages.catalog` (one `<locale>.json` per locale); a
|
|
53
61
|
* site's `messages/<locale>.json` holds overrides only. Check mode also
|
|
@@ -89,8 +97,11 @@
|
|
|
89
97
|
* The locale root (#11259 D5). A manifest that sets `"root": true` may list
|
|
90
98
|
* the entry `page.tsx` — the home page at `app/[locale]/page.tsx`; its stray
|
|
91
99
|
* 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
|
-
*
|
|
100
|
+
* manifest at most may claim the root, and no two may claim the same
|
|
101
|
+
* prefix. One package's prefix may sit strictly inside another's (#11659 D9:
|
|
102
|
+
* site-pages' `private/[slug]` under ui-scheduling's `private`); the inner
|
|
103
|
+
* prefix then owns its subtree, and an outer route inside it is refused.
|
|
104
|
+
* Each refusal names both packages.
|
|
94
105
|
*
|
|
95
106
|
* The site's surfaces (#11259 D5). A manifest that sets `"siteGated": true`
|
|
96
107
|
* ships routes a site carries only when it selected them. On a site whose
|
|
@@ -107,7 +118,9 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
|
|
|
107
118
|
import { dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
108
119
|
import { parseArgs } from "node:util";
|
|
109
120
|
import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
|
|
121
|
+
import { declinedRouteOfPath, readDeclinedRoutes } from "./declined-routes.js";
|
|
110
122
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
123
|
+
import { LEGACY_SITE_ROSTER_PATH, SITE_ROSTER_PATH, readRosterPageRoutes } from "./site-roster.js";
|
|
111
124
|
import { GATEABLE_SURFACES, ROUTE_ROOT, canonicalizeSurface, isRemovedPublicRoutePath } from "./surfaces.js";
|
|
112
125
|
import { isSpokeExcluded, readSpokeShape } from "./topology.js";
|
|
113
126
|
/** The app a page package's routes mount in, relative to the site root. */
|
|
@@ -232,6 +245,16 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
232
245
|
throw new RoutesRefusedError(`${at}: siteOwned ${JSON.stringify(path)} must be a routing file under ${prefix.map((p) => `${p}/`).join(" or ")}`);
|
|
233
246
|
}
|
|
234
247
|
}
|
|
248
|
+
const adopts = stringList(raw.adopts, `${at}: adopts`);
|
|
249
|
+
for (const path of adopts) {
|
|
250
|
+
if (!isPlainPath(path) || !ROUTING_FILES.has(posix.basename(path))) {
|
|
251
|
+
throw new RoutesRefusedError(`${at}: adopts ${JSON.stringify(path)} must be a plain path ending in page.tsx, layout.tsx or route.ts`);
|
|
252
|
+
}
|
|
253
|
+
if (underPrefix(path))
|
|
254
|
+
throw new RoutesRefusedError(`${at}: adopts ${path} is under the manifest's own ${prefixNamed}`);
|
|
255
|
+
}
|
|
256
|
+
if (new Set(adopts).size !== adopts.length)
|
|
257
|
+
throw new RoutesRefusedError(`${at}: adopts must be distinct`);
|
|
235
258
|
let messages;
|
|
236
259
|
if (raw.messages !== undefined) {
|
|
237
260
|
if (!isRecord(raw.messages) || !isPlainPath(raw.messages.catalog)) {
|
|
@@ -273,7 +296,7 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
273
296
|
if (!root)
|
|
274
297
|
throw new RoutesRefusedError(`${where}: ${path} is the locale root, which only a manifest with "root": true ships`);
|
|
275
298
|
}
|
|
276
|
-
else if (!underPrefix(path)) {
|
|
299
|
+
else if (!underPrefix(path) && !adopts.includes(path)) {
|
|
277
300
|
throw new RoutesRefusedError(`${where}: ${path} is outside the manifest's ${prefixNamed}`);
|
|
278
301
|
}
|
|
279
302
|
if (seen.has(path) || siteOwned.includes(path)) {
|
|
@@ -334,6 +357,13 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
334
357
|
}
|
|
335
358
|
return { path, kind, module: entry.module, exports, segmentConfig, config, metadataConfig, mount, waiver };
|
|
336
359
|
});
|
|
360
|
+
for (const path of adopts) {
|
|
361
|
+
const adopted = routes.find((entry) => entry.path === path);
|
|
362
|
+
if (adopted === undefined)
|
|
363
|
+
throw new RoutesRefusedError(`${at}: adopts ${path}, which none of its routes is`);
|
|
364
|
+
if (adopted.mount === "app")
|
|
365
|
+
throw new RoutesRefusedError(`${at}: adopts ${path}, which is mounted under app/`);
|
|
366
|
+
}
|
|
337
367
|
const oss = raw.oss === false ? false : undefined;
|
|
338
368
|
return {
|
|
339
369
|
package: pkg,
|
|
@@ -345,6 +375,7 @@ export function parseRouteManifest(pkg, version, raw) {
|
|
|
345
375
|
siteSeam: raw.siteSeam === true,
|
|
346
376
|
config: raw.config,
|
|
347
377
|
siteOwned,
|
|
378
|
+
adopts,
|
|
348
379
|
messages,
|
|
349
380
|
oss,
|
|
350
381
|
routes,
|
|
@@ -412,9 +443,20 @@ export function readRouteManifests(siteDir) {
|
|
|
412
443
|
throw new RoutesRefusedError(`${name}'s route manifest claims the locale root, which ${other.package}'s already does`);
|
|
413
444
|
}
|
|
414
445
|
for (const mine of manifest.prefix) {
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
446
|
+
for (const theirs of other.prefix) {
|
|
447
|
+
if (!overlaps(mine, theirs))
|
|
448
|
+
continue;
|
|
449
|
+
if (mine === theirs) {
|
|
450
|
+
throw new RoutesRefusedError(`${name}'s route manifest: prefix ${JSON.stringify(mine)} overlaps ${other.package}'s ${JSON.stringify(theirs)}`);
|
|
451
|
+
}
|
|
452
|
+
// #11659 D9 — a prefix strictly nested in another package's is
|
|
453
|
+
// allowed; the inner prefix owns its subtree, so the outer package
|
|
454
|
+
// may ship no route inside it.
|
|
455
|
+
const [outer, inner, innerPrefix] = mine.startsWith(`${theirs}/`) ? [other, manifest, mine] : [manifest, other, theirs];
|
|
456
|
+
const intruder = outer.routes.find((entry) => entry.mount === "locale" && entry.path.startsWith(`${innerPrefix}/`));
|
|
457
|
+
if (intruder !== undefined) {
|
|
458
|
+
throw new RoutesRefusedError(`${outer.package}'s route manifest: route ${JSON.stringify(intruder.path)} sits under ${inner.package}'s prefix ${JSON.stringify(innerPrefix)}`);
|
|
459
|
+
}
|
|
418
460
|
}
|
|
419
461
|
}
|
|
420
462
|
for (const mine of manifest.appPrefixes) {
|
|
@@ -426,6 +468,14 @@ export function readRouteManifests(siteDir) {
|
|
|
426
468
|
}
|
|
427
469
|
manifests.push({ ...manifest, root: dirname(installed) });
|
|
428
470
|
}
|
|
471
|
+
for (const [i, manifest] of manifests.entries()) {
|
|
472
|
+
for (const other of manifests.slice(i + 1)) {
|
|
473
|
+
const both = manifest.adopts.find((path) => other.adopts.includes(path));
|
|
474
|
+
if (both !== undefined) {
|
|
475
|
+
throw new RoutesRefusedError(`${both} is adopted by both ${manifest.package}'s and ${other.package}'s route manifests`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
429
479
|
return manifests;
|
|
430
480
|
}
|
|
431
481
|
/** The header line of every generated route file begins with this; `remove-module` reads it as module code. */
|
|
@@ -572,9 +622,14 @@ function readRecorded(siteDir) {
|
|
|
572
622
|
function recordFor(recorded, sitePath) {
|
|
573
623
|
return recorded.find((entry) => entry.patterns.some((re) => re.test(sitePath)));
|
|
574
624
|
}
|
|
625
|
+
/** The id of the first `customizations:` entry whose paths match, per path; reads the file once (#11511). */
|
|
626
|
+
export function customizationsRecord(siteDir) {
|
|
627
|
+
const recorded = readRecorded(resolve(siteDir));
|
|
628
|
+
return (sitePath) => recordFor(recorded, sitePath)?.id;
|
|
629
|
+
}
|
|
575
630
|
/** Whether `<siteDir>/customizations.yaml` records `sitePath` — any entry, any path form or glob (the generator's own reading). */
|
|
576
631
|
export function isRecordedRoute(siteDir, sitePath) {
|
|
577
|
-
return
|
|
632
|
+
return customizationsRecord(siteDir)(sitePath) !== undefined;
|
|
578
633
|
}
|
|
579
634
|
/** Routing files under `<web>/<mount dir>/<prefix>`, as site-relative POSIX paths, sorted. */
|
|
580
635
|
function routingFilesUnder(web, siteDir, prefix, mount = "locale") {
|
|
@@ -605,11 +660,15 @@ function plan(siteDir) {
|
|
|
605
660
|
// it does not carry are not its routes. A hub, or no manifest, carries all.
|
|
606
661
|
const spoke = readSpokeShape(root);
|
|
607
662
|
const gate = siteGate(root);
|
|
608
|
-
|
|
663
|
+
// An adopted entry is carried only while an installed manifest leaves its path to the site (#11657 D2).
|
|
664
|
+
const owned = new Set(manifests.flatMap((m) => m.siteOwned));
|
|
665
|
+
const carries = (manifest, entry, sitePath) => (spoke === undefined || !isSpokeExcluded(sitePath, spoke)) &&
|
|
666
|
+
(!manifest.siteGated || gate(sitePath)) &&
|
|
667
|
+
(!manifest.adopts.includes(entry.path) || owned.has(entry.path));
|
|
609
668
|
const planned = [];
|
|
610
669
|
const notCarried = [];
|
|
611
670
|
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("/")));
|
|
671
|
+
const carried = manifest.routes.filter((entry) => carries(manifest, entry, relative(root, join(web, mountDir(entry.mount), entry.path)).split(sep).join("/")));
|
|
613
672
|
if (manifest.config !== undefined && carried.some((entry) => entry.config)) {
|
|
614
673
|
const configPath = join(web, `${manifest.config}.tsx`);
|
|
615
674
|
if (!existsSync(configPath)) {
|
|
@@ -619,7 +678,7 @@ function plan(siteDir) {
|
|
|
619
678
|
for (const entry of manifest.routes) {
|
|
620
679
|
const absPath = join(web, mountDir(entry.mount), entry.path);
|
|
621
680
|
const sitePath = relative(root, absPath).split(sep).join("/");
|
|
622
|
-
if (!carries(manifest, sitePath)) {
|
|
681
|
+
if (!carries(manifest, entry, sitePath)) {
|
|
623
682
|
notCarried.push(sitePath);
|
|
624
683
|
continue;
|
|
625
684
|
}
|
|
@@ -659,13 +718,14 @@ export function siteGate(siteDir) {
|
|
|
659
718
|
return surface === undefined || surfaces.has(surface.id);
|
|
660
719
|
};
|
|
661
720
|
}
|
|
662
|
-
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides
|
|
721
|
+
/** The count check mode fails on: missing, stale and stray route files, orphaned overrides, missing seam aliases and unserved roster routes. */
|
|
663
722
|
export function routesFailing(drift) {
|
|
664
723
|
return (drift.missing.length +
|
|
665
724
|
drift.stale.length +
|
|
666
725
|
drift.stray.length +
|
|
667
726
|
drift.orphanedOverrides.length +
|
|
668
|
-
drift.seamAliasMissing.length
|
|
727
|
+
drift.seamAliasMissing.length +
|
|
728
|
+
drift.unservedRoster.length);
|
|
669
729
|
}
|
|
670
730
|
/**
|
|
671
731
|
* The two site files that bind a `siteSeam` package's `<package>/site` to
|
|
@@ -693,6 +753,110 @@ function seamAliasMissing(web, siteDir, manifests) {
|
|
|
693
753
|
}
|
|
694
754
|
return out;
|
|
695
755
|
}
|
|
756
|
+
// ── The roster's routes — each served by some page file (#11511) ───────────
|
|
757
|
+
/**
|
|
758
|
+
* The roster's page routes, or none: no `.ailk-site-manifest.json` nor
|
|
759
|
+
* legacy `TEMPLATE-MANIFEST.json`, or a JSON object with no `rows` key (a
|
|
760
|
+
* pre-roster site). Anything else unreadable refuses, naming the file.
|
|
761
|
+
*/
|
|
762
|
+
function rosterRoutes(root) {
|
|
763
|
+
const file = [SITE_ROSTER_PATH, LEGACY_SITE_ROSTER_PATH].find((name) => existsSync(join(root, name)));
|
|
764
|
+
if (file === undefined)
|
|
765
|
+
return [];
|
|
766
|
+
try {
|
|
767
|
+
const doc = JSON.parse(readFileSync(join(root, file), "utf8"));
|
|
768
|
+
if (isRecord(doc) && !("rows" in doc))
|
|
769
|
+
return [];
|
|
770
|
+
}
|
|
771
|
+
catch {
|
|
772
|
+
// Unparseable: readRosterPageRoutes refuses it, naming the file.
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
return readRosterPageRoutes(root) ?? [];
|
|
776
|
+
}
|
|
777
|
+
catch (err) {
|
|
778
|
+
if (err instanceof AddModuleRefusedError)
|
|
779
|
+
throw new RoutesRefusedError(err.message);
|
|
780
|
+
throw err;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
/** Every `page.tsx` under `<web>/app/[locale]`, as route segments with route groups dropped. */
|
|
784
|
+
function pageSegments(web) {
|
|
785
|
+
const out = [];
|
|
786
|
+
const walk = (dir, segments) => {
|
|
787
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
788
|
+
if (entry.isDirectory()) {
|
|
789
|
+
if (SKIPPED_DIRS.has(entry.name) || entry.name.startsWith("_") || entry.name.startsWith("@"))
|
|
790
|
+
continue;
|
|
791
|
+
const group = entry.name.startsWith("(") && entry.name.endsWith(")");
|
|
792
|
+
walk(join(dir, entry.name), group ? segments : [...segments, entry.name]);
|
|
793
|
+
}
|
|
794
|
+
else if (entry.name === "page.tsx") {
|
|
795
|
+
out.push(segments);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
const root = join(web, LOCALE_DIR);
|
|
800
|
+
if (existsSync(root))
|
|
801
|
+
walk(root, []);
|
|
802
|
+
return out;
|
|
803
|
+
}
|
|
804
|
+
const isDynamic = (segment) => segment.startsWith("[") && segment.endsWith("]");
|
|
805
|
+
/**
|
|
806
|
+
* How a page file's segments match a roster route's, as Next.js matches them
|
|
807
|
+
* (precedence aside): `"static"` serves it outright — static segments, or a
|
|
808
|
+
* catch-all; `"dynamic"` matched through a single `[y]` and serves a fully
|
|
809
|
+
* static route only with content; `undefined` does not match.
|
|
810
|
+
*/
|
|
811
|
+
function matchPage(page, route) {
|
|
812
|
+
let dynamic = false;
|
|
813
|
+
for (let i = 0; i < page.length; i++) {
|
|
814
|
+
const segment = page[i];
|
|
815
|
+
if (segment.startsWith("[[..."))
|
|
816
|
+
return "static";
|
|
817
|
+
if (segment.startsWith("[..."))
|
|
818
|
+
return route.length > i ? "static" : undefined;
|
|
819
|
+
if (i >= route.length)
|
|
820
|
+
return undefined;
|
|
821
|
+
if (isDynamic(segment))
|
|
822
|
+
dynamic = true;
|
|
823
|
+
else if (segment !== route[i])
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
if (page.length !== route.length)
|
|
827
|
+
return undefined;
|
|
828
|
+
return dynamic ? "dynamic" : "static";
|
|
829
|
+
}
|
|
830
|
+
/** The roster page routes the site carries that no page file serves, each with the page path it expected (D4–D6). */
|
|
831
|
+
function unservedRoster(root, web) {
|
|
832
|
+
const routes = rosterRoutes(root);
|
|
833
|
+
if (routes.length === 0)
|
|
834
|
+
return [];
|
|
835
|
+
const spoke = readSpokeShape(root);
|
|
836
|
+
const gate = siteGate(root);
|
|
837
|
+
const declined = readDeclinedRoutes(root);
|
|
838
|
+
const pages = pageSegments(web);
|
|
839
|
+
const contentDir = join(root, "content", "en");
|
|
840
|
+
const types = existsSync(contentDir)
|
|
841
|
+
? readdirSync(contentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name)
|
|
842
|
+
: [];
|
|
843
|
+
const hasContent = (slug) => types.some((type) => existsSync(join(contentDir, type, `${slug}.mdx`)));
|
|
844
|
+
const out = [];
|
|
845
|
+
for (const route of routes) {
|
|
846
|
+
const segments = route.split("/").filter((s) => s !== "");
|
|
847
|
+
const expected = posix.join(ROUTES_APP_DIR, LOCALE_DIR, ...segments, "page.tsx");
|
|
848
|
+
if (!gate(expected) || (spoke !== undefined && isSpokeExcluded(expected, spoke)))
|
|
849
|
+
continue;
|
|
850
|
+
if (declinedRouteOfPath(expected, declined) !== undefined)
|
|
851
|
+
continue;
|
|
852
|
+
const matches = pages.map((page) => matchPage(page, segments));
|
|
853
|
+
const served = matches.includes("static") ||
|
|
854
|
+
(matches.includes("dynamic") && (segments.some(isDynamic) || hasContent(segments[segments.length - 1])));
|
|
855
|
+
if (!served)
|
|
856
|
+
out.push(`${route} → ${expected}`);
|
|
857
|
+
}
|
|
858
|
+
return out;
|
|
859
|
+
}
|
|
696
860
|
/** How the site's route files and message overrides differ from the installed page packages. `routesFailing` zero means in sync. */
|
|
697
861
|
export function checkRoutes(siteDir) {
|
|
698
862
|
const { root, web, manifests, planned, recorded, notCarried } = plan(siteDir);
|
|
@@ -705,6 +869,7 @@ export function checkRoutes(siteDir) {
|
|
|
705
869
|
siteKept: [],
|
|
706
870
|
orphanedOverrides: orphanedOverrides(web, root, manifests),
|
|
707
871
|
seamAliasMissing: seamAliasMissing(web, root, manifests),
|
|
872
|
+
unservedRoster: unservedRoster(root, web),
|
|
708
873
|
generated: planned.length,
|
|
709
874
|
};
|
|
710
875
|
const known = new Set();
|
|
@@ -871,7 +1036,10 @@ Options:
|
|
|
871
1036
|
leaves to the site). It also names each orphaned
|
|
872
1037
|
override: a key in apps/web/messages/<locale>.json
|
|
873
1038
|
under a namespace a package's catalog ships that
|
|
874
|
-
the catalog no longer has.
|
|
1039
|
+
the catalog no longer has. And it names each roster
|
|
1040
|
+
page route (.ailk-site-manifest.json) that no page
|
|
1041
|
+
file serves — neither a site page nor a generated
|
|
1042
|
+
re-export.
|
|
875
1043
|
--help, -h Print this message.
|
|
876
1044
|
|
|
877
1045
|
A page package is an installed @working-theory/* dependency of apps/web whose
|
|
@@ -882,7 +1050,9 @@ app root (apps/web/account.config.tsx, say) and passes it in. Replace or remove
|
|
|
882
1050
|
customizations.yaml (an entry whose paths match the route file): a recorded
|
|
883
1051
|
route is reported as replaced or removed, never failed, and --write never
|
|
884
1052
|
touches it. A manifest may list several prefixes, and one manifest with
|
|
885
|
-
"root": true may ship the locale-root page.tsx.
|
|
1053
|
+
"root": true may ship the locale-root page.tsx. No two manifests may claim the
|
|
1054
|
+
same prefix; one may claim a prefix strictly inside another's, which then
|
|
1055
|
+
ships no route under it. A manifest with
|
|
886
1056
|
"siteGated": true ships only the routes the site selected: its public pages
|
|
887
1057
|
are not carried when .ailk-site-manifest.json lists no marketing module, and
|
|
888
1058
|
neither is any page under a surface the architecture.yaml "# Surfaces:" header
|
|
@@ -926,12 +1096,16 @@ export function formatRoutesReport(result, mode) {
|
|
|
926
1096
|
...drift.stray.map((p) => ` stray: ${p}`),
|
|
927
1097
|
...drift.orphanedOverrides.map((p) => ` orphaned override: ${p}`),
|
|
928
1098
|
...drift.seamAliasMissing.map((p) => ` missing site seam alias: ${p}`),
|
|
1099
|
+
...drift.unservedRoster.map((entry) => {
|
|
1100
|
+
const [route, path] = entry.split(" → ");
|
|
1101
|
+
return ` unserved roster route: ${route} (no page at ${path} — a site page or a generated re-export)`;
|
|
1102
|
+
}),
|
|
929
1103
|
];
|
|
930
1104
|
if (failing.length === 0) {
|
|
931
1105
|
lines.push(`[create-ailk] routes: OK — ${drift.generated} generated route file(s) in sync`);
|
|
932
1106
|
}
|
|
933
1107
|
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):`, ...failing);
|
|
1108
|
+
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):`, ...failing);
|
|
935
1109
|
}
|
|
936
1110
|
}
|
|
937
1111
|
else {
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -212,8 +212,8 @@ export declare function isUnservedSurfaceContent(path: string, enabled: readonly
|
|
|
212
212
|
* so without it nothing can host a foreign file there. A module-less
|
|
213
213
|
* surface's segment hosts other modules' companion routes by design —
|
|
214
214
|
* signal-collectors' `projects/apply` and `careers/apply` walks
|
|
215
|
-
* (`NESTED_FOREIGN_MODULE_ENTRIES` in `sync-routes.ts`, #8840 D13) and
|
|
216
|
-
*
|
|
215
|
+
* (`NESTED_FOREIGN_MODULE_ENTRIES` in `sync-routes.ts`, #8840 D13) — and
|
|
216
|
+
* those keep landing.
|
|
217
217
|
*/
|
|
218
218
|
export declare function isUnservedSurfaceRoute(path: string, enabled: readonly string[]): boolean;
|
|
219
219
|
/**
|