everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
63 lines (61 loc) • 2.6 kB
JavaScript
import { Finding } from "../domain.mjs";
import { fileExists, readText } from "../fs.mjs";
import { Effect } from "effect";
//#region src/services/scaffold/upgrade-audit/checks/ui-seam.ts
const ROUTER_PATH = "ui/src/router.tsx";
const APP_PATH = "ui/src/app.ts";
const AUTHORED_SEAM_RE = /everything-dev\/ui\/router-client/;
const MONOLITHIC_RE = /createTanStackRouter\s*\(/;
const detectRouterSeam = (source) => {
if (AUTHORED_SEAM_RE.test(source)) return "authored-seam";
if (MONOLITHIC_RE.test(source)) return "monolithic";
return "unknown";
};
const readRouterSeam = (projectDir) => Effect.gen(function* () {
if (!(yield* fileExists(projectDir, ROUTER_PATH))) return "absent";
return detectRouterSeam(yield* readText(projectDir, ROUTER_PATH));
});
const hasExport = (source, name) => new RegExp(`export\\s+(?:const|function)\\s+${name}\\b`).test(source);
const checkUiSeam = (projectDir) => Effect.gen(function* () {
const findings = [];
const routerSeam = yield* readRouterSeam(projectDir);
if (routerSeam === "absent") findings.push(new Finding({
check: "ui-seam",
path: ROUTER_PATH,
severity: "warn",
message: "ui/src/router.tsx not found — the authored router seam (ADR 0023) is required by the generated hydrate/SSR stubs"
}));
if (routerSeam === "monolithic") findings.push(new Finding({
check: "ui-seam",
path: ROUTER_PATH,
severity: "warn",
message: "pre-ADR-0023 monolithic router factory — drops the composed manifest tree (opts.routeTree); apply migrates it to the createCoreRouter authored seam"
}));
if (routerSeam === "unknown") findings.push(new Finding({
check: "ui-seam",
path: ROUTER_PATH,
severity: "warn",
message: "ui/src/router.tsx is neither the authored seam nor the known monolithic factory — inspect manually; apply will not touch it"
}));
if (!(yield* fileExists(projectDir, APP_PATH))) {
findings.push(new Finding({
check: "ui-seam",
path: APP_PATH,
severity: "warn",
message: "ui/src/app.ts not found — the @/app public surface is required by the generated stubs"
}));
return findings;
}
const appSource = yield* readText(projectDir, APP_PATH);
const missing = ["appLocale", "apiConnectionError"].filter((name) => !hasExport(appSource, name));
if (missing.length > 0) findings.push(new Finding({
check: "ui-seam",
path: APP_PATH,
severity: "warn",
message: `app surface is missing bootstrap overrides the generated stubs read: ${missing.join(", ")}`
}));
return findings;
});
//#endregion
export { checkUiSeam, detectRouterSeam, readRouterSeam };
//# sourceMappingURL=ui-seam.mjs.map