frontend-quality-gates / merge / static checks (pull_request) Successful in 1m15s
frontend-quality-gates / merge / tests (pull_request) Successful in 13m20s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m16s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
스크립트 22곳이 argv[1]로 직접 실행을 판정해서, checkout 경로에 공백·한글이 있거나 symlink 절대 경로로 부르면 18곳이 검사 없이 rc=0으로 끝날 수 있다. merge 게이트 명령 셋이 여기 걸린다. isEntryModule(import.meta) 하나로 바꾸고, process.argv 둘째 값 읽기와 helper 밖 판정은 시험으로 막는다. 맨 import.meta.main은 그 값이 없는 Node에서 같은 거짓 통과가 나서 버렸다. realpath 비교는 같은 판정의 사본 22개가 남고, argv 값의 쓰임을 따라가는 시험은 return·대입으로 피할 수 있어 버렸다. 위험·한계: 건너뛰던 검사가 실패하기 시작할 수 있고, 실행 판정이 아닌 process.argv[1] 읽기도 실패한다. import.meta.main이 없는 Node에서 직접 실행하거나 import하면 실패한다. verify-extreme-scale도 그 Node에서는 rc=2보다 먼저 rc=1로 끝나고, 이전 기록(passed일 수 있다)이 그대로 남아 종료 code로 본다. 코드로 읽은 것이고 그 Node로 돌려 보지 않았다. 막는 시험은 process·argv 별칭과 계산한 index를 따라가지 않는다. 검증(노트북, main으로 옮기기 전 트리 a806088b): 새 시험 고치기 전 실패, 고친 뒤 통과. test:unit 3707개, types, lint, check:ci, verify:documentation rc=0. desktop merge 단계는 따로 확인한다. Refs: REV-FE-0040
463 lines
18 KiB
TypeScript
463 lines
18 KiB
TypeScript
import { randomUUID } from "node:crypto";
|
|
import { mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { selectCompiledProductFeatures } from "../src/contracts/product-features.ts";
|
|
import { isEntryModule } from "./lib/entry-module.ts";
|
|
|
|
export type FeatureImportEntry = Readonly<{
|
|
id: string;
|
|
importPath: string;
|
|
}>;
|
|
|
|
export type FeatureIndexEntry = FeatureImportEntry & Readonly<{
|
|
directory: string;
|
|
contextId: string;
|
|
contextRoutePath: string;
|
|
contextMaxFeatures: number;
|
|
/** 09-03. Present when the context has a `context-layout.tsx`. */
|
|
contextLayoutImportPath?: string;
|
|
}>;
|
|
|
|
/**
|
|
* `declaredIds` is every feature the app declares, selected or not, so a build
|
|
* that left one out still reports it as `NOT_INSTALLED` without importing it.
|
|
*/
|
|
export function renderFeatureIndex(
|
|
entries: readonly FeatureImportEntry[],
|
|
declaredIds: readonly string[] = entries.map((entry) => entry.id),
|
|
): string {
|
|
const sorted = [...entries].sort((left, right) => left.id.localeCompare(right.id));
|
|
const declared = [...declaredIds]
|
|
.sort((left, right) => left.localeCompare(right))
|
|
.map((id) => JSON.stringify(id))
|
|
.join(", ");
|
|
const imports = sorted
|
|
.map(
|
|
(entry, index) =>
|
|
`import { FEATURE_MODULE as featureModule${index} } from ${JSON.stringify(entry.importPath)};`,
|
|
)
|
|
.join("\n");
|
|
const modules = sorted.map((_, index) => ` featureModule${index},`).join("\n");
|
|
const featureImports = imports.length > 0 ? `${imports}\n` : "";
|
|
return `// Generated by scripts/generate-product-feature-index.ts. Do not edit by hand.\nimport type { FeatureModule } from "../features/feature-module.ts";\n${featureImports}\nexport const DECLARED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze([${declared}]);\n\nexport const PRODUCT_FEATURE_MODULES = Object.freeze([\n${modules}\n] as const);\n\ntype GeneratedProductFeatureModule = (typeof PRODUCT_FEATURE_MODULES)[number];\nexport type ProductFeatureModule =\n [GeneratedProductFeatureModule] extends [never]\n ? FeatureModule\n : GeneratedProductFeatureModule;\n`;
|
|
}
|
|
|
|
export function renderContextIndex(entries: readonly FeatureIndexEntry[]): string {
|
|
if (entries.length === 0) {
|
|
return `// Generated by scripts/generate-product-feature-index.ts. Do not edit by hand.\nexport const PRODUCT_CONTEXT_MODULES = Object.freeze([] as const);\n`;
|
|
}
|
|
const sorted = [...entries].sort((left, right) => left.id.localeCompare(right.id));
|
|
const imports = sorted
|
|
.map(
|
|
(entry, index) =>
|
|
`import { FEATURE_MODULE as featureModule${index} } from ${JSON.stringify(entry.importPath)};`,
|
|
)
|
|
.join("\n");
|
|
const indexById = new Map(sorted.map((entry, index) => [entry.id, index] as const));
|
|
const grouped = new Map<string, FeatureIndexEntry[]>();
|
|
for (const entry of sorted) {
|
|
const group = grouped.get(entry.contextId) ?? [];
|
|
group.push(entry);
|
|
grouped.set(entry.contextId, group);
|
|
}
|
|
|
|
const contexts = [...grouped.entries()]
|
|
.sort(([left], [right]) => left.localeCompare(right))
|
|
.map(([contextId, features]) => {
|
|
const first = features[0];
|
|
if (!first) throw new Error(`Context ${contextId} has no features`);
|
|
for (const feature of features) {
|
|
if (feature.contextRoutePath !== first.contextRoutePath) {
|
|
throw new Error(
|
|
`Context ${contextId} has conflicting route paths: ${first.contextRoutePath}, ${feature.contextRoutePath}`,
|
|
);
|
|
}
|
|
if (feature.contextMaxFeatures !== first.contextMaxFeatures) {
|
|
throw new Error(
|
|
`Context ${contextId} has conflicting maxFeatures budgets: ${first.contextMaxFeatures}, ${feature.contextMaxFeatures}`,
|
|
);
|
|
}
|
|
}
|
|
if (features.length > first.contextMaxFeatures) {
|
|
throw new Error(
|
|
`Context ${contextId} feature cardinality ${features.length} exceeds budget ${first.contextMaxFeatures}`,
|
|
);
|
|
}
|
|
const featureRefs = features
|
|
.map((feature) => `featureModule${indexById.get(feature.id)}`)
|
|
.join(", ");
|
|
const routeImports = features
|
|
.map(
|
|
(feature, index) =>
|
|
` import(${JSON.stringify(`../features/${feature.directory}/context-routes.ts`)})${index < features.length - 1 ? "," : ""}`,
|
|
)
|
|
.join("\n");
|
|
const routeSpreads = features
|
|
.map((_, index) => ` ...routeModule${index}.FEATURE_CONTEXT_ROUTES,`)
|
|
.join("\n");
|
|
const routeBindings = features
|
|
.map((_, index) => `routeModule${index}`)
|
|
.join(", ");
|
|
const layout = first.contextLayoutImportPath
|
|
? ` loadLayout: async () => (await import(${JSON.stringify(first.contextLayoutImportPath)})).CONTEXT_LAYOUT,\n`
|
|
: "";
|
|
return ` defineBoundedContextModule({\n id: ${JSON.stringify(contextId)},\n features: Object.freeze([${featureRefs}]),\n budget: Object.freeze({ maxFeatures: ${first.contextMaxFeatures} }),\n route: Object.freeze({\n path: ${JSON.stringify(first.contextRoutePath)},\n${layout} async loadRoutes() {\n const [${routeBindings}] = await Promise.all([\n${routeImports}\n ]);\n return Object.freeze([\n${routeSpreads}\n ]);\n },\n }),\n }),`;
|
|
})
|
|
.join("\n");
|
|
|
|
const featureImports = imports.length > 0 ? `${imports}\n` : "";
|
|
return `// Generated by scripts/generate-product-feature-index.ts. Do not edit by hand.\nimport { defineBoundedContextModule } from "../contexts/bounded-context-module.ts";\n${featureImports}\nexport const PRODUCT_CONTEXT_MODULES = Object.freeze([\n${contexts}\n] as const);\n`;
|
|
}
|
|
|
|
/**
|
|
* Ownership declarations the generator reads, documented in
|
|
* docs/architecture/starter-experience.md ("소유 선언"). Each boundary
|
|
* declares only its parent:
|
|
*
|
|
* src/apps/<app>/app-module.ts APP_MODULE_ID, APP_MAX_CONTEXTS
|
|
* src/contexts/<context>/context-module.ts CONTEXT_MODULE_ID, CONTEXT_APP_ID,
|
|
* CONTEXT_ROUTE_PATH, CONTEXT_MAX_FEATURES
|
|
* src/contexts/<context>/context-layout.tsx CONTEXT_LAYOUT (optional, 09-03:
|
|
* the context's own layout)
|
|
* src/features/<feature>/feature-module.ts FEATURE_MODULE_ID, FEATURE_CONTEXT_ID
|
|
*
|
|
* The generated indexes describe exactly one deployable app: the contexts it
|
|
* owns and the features those contexts own. Features of other apps are never
|
|
* imported, so global growth elsewhere cannot enter this app's compile or
|
|
* boot graph.
|
|
*/
|
|
export type AppDeclaration = Readonly<{ id: string; maxContexts: number }>;
|
|
export type ContextDeclaration = Readonly<{
|
|
id: string;
|
|
appId: string;
|
|
routePath: string;
|
|
maxFeatures: number;
|
|
layoutImportPath?: string;
|
|
}>;
|
|
export type FeatureDeclaration = Readonly<{
|
|
id: string;
|
|
contextId: string;
|
|
directory: string;
|
|
}>;
|
|
|
|
/**
|
|
* Ownership-indexed view of the declarations. The generator only asks for one
|
|
* app, that app's contexts and those contexts' features, so its work and its
|
|
* output are local to the selected app.
|
|
*/
|
|
export interface TopologyDeclarationSource {
|
|
appIds(): readonly string[];
|
|
app(appId: string): AppDeclaration | undefined;
|
|
contextsOf(appId: string): readonly ContextDeclaration[];
|
|
featuresOf(contextId: string): readonly FeatureDeclaration[];
|
|
}
|
|
|
|
export type SelectedAppIndexes = Readonly<{
|
|
app: AppDeclaration;
|
|
entries: readonly FeatureIndexEntry[];
|
|
featureIndex: string;
|
|
contextIndex: string;
|
|
appIndex: string;
|
|
}>;
|
|
|
|
export function renderAppIndex(app: AppDeclaration): string {
|
|
return `// Generated by scripts/generate-product-feature-index.ts. Do not edit by hand.
|
|
export const PRODUCT_APP = Object.freeze({
|
|
id: ${JSON.stringify(app.id)},
|
|
maxContexts: ${app.maxContexts},
|
|
} as const);
|
|
`;
|
|
}
|
|
|
|
export function resolveSelectedApp(
|
|
source: TopologyDeclarationSource,
|
|
requested: string | undefined,
|
|
): string {
|
|
if (requested) {
|
|
if (!source.app(requested)) throw new Error(`Unknown deployable app: ${requested}`);
|
|
return requested;
|
|
}
|
|
const ids = source.appIds();
|
|
if (ids.length !== 1) {
|
|
throw new Error(
|
|
`Select a deployable app with --app=<id> or PRODUCT_APP_ID (declared: ${ids.join(", ") || "none"})`,
|
|
);
|
|
}
|
|
return ids[0] as string;
|
|
}
|
|
|
|
/**
|
|
* The production selection: one app -> its direct contexts -> their features,
|
|
* narrowed by `VITE_PRODUCT_FEATURES` (09-02, D-9). The narrowing happens here
|
|
* so the bundle, the Node build scripts and the context router all import the
|
|
* same set, and a misspelt id fails the first build step.
|
|
*/
|
|
export function selectAppIndexes(
|
|
source: TopologyDeclarationSource,
|
|
appId: string,
|
|
productFeatures?: string,
|
|
): SelectedAppIndexes {
|
|
const app = source.app(appId);
|
|
if (!app) throw new Error(`Unknown deployable app: ${appId}`);
|
|
const contexts = [...source.contextsOf(appId)].sort((left, right) =>
|
|
left.id.localeCompare(right.id),
|
|
);
|
|
const entries: FeatureIndexEntry[] = [];
|
|
let populatedContexts = 0;
|
|
for (const context of contexts) {
|
|
const features = source.featuresOf(context.id);
|
|
if (features.length === 0) continue;
|
|
populatedContexts += 1;
|
|
if (features.length > context.maxFeatures) {
|
|
throw new Error(
|
|
`Context ${context.id} feature cardinality ${features.length} exceeds budget ${context.maxFeatures}`,
|
|
);
|
|
}
|
|
for (const feature of features) {
|
|
entries.push({
|
|
id: feature.id,
|
|
importPath: `../features/${feature.directory}/feature-module.ts`,
|
|
directory: feature.directory,
|
|
contextId: context.id,
|
|
contextRoutePath: context.routePath,
|
|
contextMaxFeatures: context.maxFeatures,
|
|
...(context.layoutImportPath
|
|
? { contextLayoutImportPath: context.layoutImportPath }
|
|
: {}),
|
|
});
|
|
}
|
|
}
|
|
if (populatedContexts > app.maxContexts) {
|
|
throw new Error(
|
|
`App ${app.id} context cardinality ${populatedContexts} exceeds budget ${app.maxContexts}`,
|
|
);
|
|
}
|
|
const ids = entries.map((entry) => entry.id);
|
|
if (new Set(ids).size !== ids.length) {
|
|
throw new Error(`Duplicate generated feature ids: ${ids.join(", ")}`);
|
|
}
|
|
const selected = selectCompiledProductFeatures(
|
|
entries.map((entry) => Object.freeze({ featureId: entry.id, entry })),
|
|
productFeatures,
|
|
).map(({ entry }) => entry);
|
|
return Object.freeze({
|
|
app,
|
|
entries: Object.freeze(selected),
|
|
featureIndex: renderFeatureIndex(selected, ids),
|
|
contextIndex: renderContextIndex(selected),
|
|
appIndex: renderAppIndex(app),
|
|
});
|
|
}
|
|
|
|
function requiredLiteral(source: string, name: string, file: string): string {
|
|
const match = source.match(
|
|
new RegExp(`export\\s+const\\s+${name}\\s*=\\s*["']([^"']+)["']`),
|
|
);
|
|
if (!match?.[1]) {
|
|
throw new Error(`${file} must export a literal ${name}`);
|
|
}
|
|
return match[1];
|
|
}
|
|
|
|
function requiredInteger(source: string, name: string, file: string): number {
|
|
const match = source.match(
|
|
new RegExp(`export\\s+const\\s+${name}\\s*=\\s*(\\d+)`),
|
|
);
|
|
const parsed = match?.[1] ? Number.parseInt(match[1], 10) : Number.NaN;
|
|
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
throw new Error(`${file} must export a positive integer ${name}`);
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
/**
|
|
* 09-07 (D-10). A feature directory must declare itself. A missing or
|
|
* misspelt `feature-module.ts` used to drop the feature from the product
|
|
* without a word. Code that is no feature (a test's consumer fixture) lives
|
|
* outside src/features.
|
|
*/
|
|
async function readDeclarations(
|
|
directory: string,
|
|
fileName: string,
|
|
required = false,
|
|
): Promise<readonly Readonly<{ directory: string; file: string; source: string }>[]> {
|
|
const found: { directory: string; file: string; source: string }[] = [];
|
|
let items;
|
|
try {
|
|
items = await readdir(directory, { withFileTypes: true });
|
|
} catch {
|
|
return found;
|
|
}
|
|
for (const item of items) {
|
|
if (!item.isDirectory()) continue;
|
|
const file = resolve(directory, item.name, fileName);
|
|
let source: string;
|
|
try {
|
|
source = await readFile(file, "utf8");
|
|
} catch {
|
|
if (!required) continue;
|
|
throw new Error(
|
|
`src/features/${item.name} has no ${fileName}; add one, or keep code that is no feature outside src/features`,
|
|
);
|
|
}
|
|
found.push({ directory: item.name, file, source });
|
|
}
|
|
return found;
|
|
}
|
|
|
|
/**
|
|
* Filesystem declaration source. Declarations are small literal headers, so
|
|
* reading them is a metadata scan; only the selected app's features are ever
|
|
* imported by the generated output.
|
|
*/
|
|
export async function createFileSystemDeclarationSource(
|
|
root: string,
|
|
): Promise<TopologyDeclarationSource> {
|
|
const apps = new Map<string, AppDeclaration>();
|
|
for (const declaration of await readDeclarations(resolve(root, "src/apps"), "app-module.ts")) {
|
|
const id = requiredLiteral(declaration.source, "APP_MODULE_ID", declaration.file);
|
|
if (apps.has(id)) throw new Error(`Duplicate app id: ${id}`);
|
|
apps.set(id, {
|
|
id,
|
|
maxContexts: requiredInteger(declaration.source, "APP_MAX_CONTEXTS", declaration.file),
|
|
});
|
|
}
|
|
const contextsByApp = new Map<string, ContextDeclaration[]>();
|
|
const contextIds = new Set<string>();
|
|
for (const declaration of await readDeclarations(resolve(root, "src/contexts"), "context-module.ts")) {
|
|
let context: ContextDeclaration = {
|
|
id: requiredLiteral(declaration.source, "CONTEXT_MODULE_ID", declaration.file),
|
|
appId: requiredLiteral(declaration.source, "CONTEXT_APP_ID", declaration.file),
|
|
routePath: requiredLiteral(declaration.source, "CONTEXT_ROUTE_PATH", declaration.file),
|
|
maxFeatures: requiredInteger(declaration.source, "CONTEXT_MAX_FEATURES", declaration.file),
|
|
};
|
|
const layout = `${declaration.directory}/context-layout.tsx`;
|
|
if (await readFile(resolve(root, "src/contexts", layout)).then(() => true, () => false)) {
|
|
context = { ...context, layoutImportPath: `../contexts/${layout}` };
|
|
}
|
|
if (contextIds.has(context.id)) throw new Error(`Duplicate context id: ${context.id}`);
|
|
if (!apps.has(context.appId)) {
|
|
throw new Error(`Context ${context.id} belongs to undeclared app ${context.appId}`);
|
|
}
|
|
contextIds.add(context.id);
|
|
const owned = contextsByApp.get(context.appId) ?? [];
|
|
owned.push(context);
|
|
contextsByApp.set(context.appId, owned);
|
|
}
|
|
const featuresByContext = new Map<string, FeatureDeclaration[]>();
|
|
const featureIds = new Set<string>();
|
|
for (const declaration of await readDeclarations(
|
|
resolve(root, "src/features"),
|
|
"feature-module.ts",
|
|
true,
|
|
)) {
|
|
const feature: FeatureDeclaration = {
|
|
id: requiredLiteral(declaration.source, "FEATURE_MODULE_ID", declaration.file),
|
|
contextId: requiredLiteral(declaration.source, "FEATURE_CONTEXT_ID", declaration.file),
|
|
directory: declaration.directory,
|
|
};
|
|
if (featureIds.has(feature.id)) throw new Error(`Duplicate generated feature ids: ${feature.id}`);
|
|
if (!contextIds.has(feature.contextId)) {
|
|
throw new Error(`Feature ${feature.id} belongs to undeclared context ${feature.contextId}`);
|
|
}
|
|
featureIds.add(feature.id);
|
|
const owned = featuresByContext.get(feature.contextId) ?? [];
|
|
owned.push(feature);
|
|
featuresByContext.set(feature.contextId, owned);
|
|
}
|
|
return Object.freeze({
|
|
appIds: () => [...apps.keys()].sort(),
|
|
app: (appId: string) => apps.get(appId),
|
|
contextsOf: (appId: string) => contextsByApp.get(appId) ?? [],
|
|
featuresOf: (contextId: string) => featuresByContext.get(contextId) ?? [],
|
|
});
|
|
}
|
|
|
|
export async function generateAppIndexes(
|
|
root: string,
|
|
requestedApp: string | undefined,
|
|
productFeatures?: string,
|
|
): Promise<SelectedAppIndexes> {
|
|
const source = await createFileSystemDeclarationSource(root);
|
|
return selectAppIndexes(
|
|
source,
|
|
resolveSelectedApp(source, requestedApp),
|
|
productFeatures,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 1105/12-04. Every build, dev server, type check and test run renders these
|
|
* files first, so two runs in one checkout render them at the same time while
|
|
* the other run's Vite or tsc reads them. `writeFile` truncated the file in
|
|
* place, and a reader could see it empty or half written. An index that has
|
|
* not changed is left alone; a changed one replaces the old file with one
|
|
* rename, so a reader sees the old file or the new one, never a part.
|
|
*/
|
|
export async function writeIndexIfChanged(file: string, content: string): Promise<void> {
|
|
if ((await readFile(file, "utf8").catch(() => null)) === content) return;
|
|
const temporary = join(dirname(file), `.${basename(file)}.${randomUUID()}.tmp`);
|
|
try {
|
|
await writeFile(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
await rename(temporary, file);
|
|
} catch (error) {
|
|
await rm(temporary, { force: true });
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
// `--root=` points the same production command at another checkout (used by
|
|
// the multi-app topology evidence); the default is this repository.
|
|
const rootArgument = process.argv
|
|
.find((argument) => argument.startsWith("--root="))
|
|
?.slice("--root=".length);
|
|
const root = rootArgument ? resolve(rootArgument) : resolve(scriptDir, "..");
|
|
const outputRoot = resolve(root, "src/.generated");
|
|
const outputs = {
|
|
feature: resolve(outputRoot, "product-feature-index.ts"),
|
|
context: resolve(outputRoot, "product-context-index.ts"),
|
|
app: resolve(outputRoot, "product-app.ts"),
|
|
};
|
|
const requestedApp =
|
|
process.argv.find((argument) => argument.startsWith("--app="))?.slice("--app=".length) ||
|
|
process.env["PRODUCT_APP_ID"] ||
|
|
undefined;
|
|
const selected = await generateAppIndexes(
|
|
root,
|
|
requestedApp,
|
|
process.env["VITE_PRODUCT_FEATURES"],
|
|
);
|
|
const rendered = {
|
|
feature: selected.featureIndex,
|
|
context: selected.contextIndex,
|
|
app: selected.appIndex,
|
|
};
|
|
await mkdir(outputRoot, { recursive: true });
|
|
|
|
if (process.argv.includes("--check")) {
|
|
const stale: string[] = [];
|
|
for (const key of ["feature", "context", "app"] as const) {
|
|
const current = await readFile(outputs[key], "utf8").catch(() => "");
|
|
if (current !== rendered[key]) stale.push(relative(root, outputs[key]));
|
|
}
|
|
if (stale.length > 0) {
|
|
throw new Error(`Generated topology index is stale: ${stale.join(", ")}`);
|
|
}
|
|
return;
|
|
}
|
|
|
|
await Promise.all(
|
|
(["feature", "context", "app"] as const).map((key) =>
|
|
writeIndexIfChanged(outputs[key], rendered[key]),
|
|
),
|
|
);
|
|
}
|
|
|
|
if (isEntryModule(import.meta)) {
|
|
await main();
|
|
}
|