47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
const presentationRoots = [
|
|
join(process.cwd(), "src", "lib", "ui"),
|
|
join(process.cwd(), "src", "routes"),
|
|
];
|
|
|
|
const forbiddenTerms = [
|
|
"dimensionlab",
|
|
"dimension lab",
|
|
"vaultwarden",
|
|
"forgejo",
|
|
"grafana",
|
|
"uptime kuma",
|
|
"prometheus",
|
|
"backrest",
|
|
"open webui",
|
|
"comfyui",
|
|
"adminer",
|
|
"cockpit",
|
|
"ollama",
|
|
"dimensionlab.net",
|
|
];
|
|
|
|
describe("presentation content boundary", () => {
|
|
test("keeps environment-specific content out of route and UI implementation", () => {
|
|
const source = presentationRoots.map(readPresentationSource).join("\n").toLowerCase();
|
|
|
|
expect(forbiddenTerms.filter((term) => source.includes(term))).toEqual([]);
|
|
});
|
|
});
|
|
|
|
function readPresentationSource(path: string): string {
|
|
const stats = statSync(path);
|
|
if (stats.isFile()) {
|
|
if (path.endsWith(".test.ts")) return "";
|
|
if (path.includes(`${join("src", "lib", "ui", "stories")}${"/"}`)) return "";
|
|
if (!/\.(svelte|svelte\.js|ts|js|mjs|css|json)$/.test(path)) return "";
|
|
return readFileSync(path, "utf8");
|
|
}
|
|
|
|
return readdirSync(path)
|
|
.map((entry) => readPresentationSource(join(path, entry)))
|
|
.join("\n");
|
|
}
|