import { readdirSync, readFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; // components/ui/README.md is how the platform layer is found: "reuse before build" only works if a // primitive is listed where the next author looks. A dozen files had slipped in unlisted, so every // source file in the directory must be named there, in backticks, by its file name. const UI = resolve(dirname(fileURLToPath(import.meta.url)), "../components/ui"); describe("the platform layer's README", () => { it("names every file in components/ui", () => { const readme = readFileSync(resolve(UI, "README.md"), "utf8"); const unlisted = readdirSync(UI) .filter((f) => /\.tsx?$/.test(f) && !/\.test\.tsx?$/.test(f) && !f.endsWith(".testkit.ts")) .map((f) => f.replace(/\.tsx?$/, "")) .filter((name) => !readme.includes("`" + name + "`")); expect(unlisted).toEqual([]); }); });