refactor(evidence): extract TypeScript lifecycle (#32)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { readdirSync, readFileSync } from "node:fs";
|
||||
import { basename, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import ts from "typescript";
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
const evidenceRoot = fileURLToPath(new URL("../../../src/workspaces/evidence/", import.meta.url));
|
||||
const coreInfrastructure = new Set([
|
||||
"preprocessing-service",
|
||||
"qdrant-collection",
|
||||
"registry",
|
||||
]);
|
||||
|
||||
test("Evidence modules do not import core-owned registry or Qdrant lifecycle", () => {
|
||||
const violations: Array<{ file: string; dependency: string }> = [];
|
||||
for (const file of readdirSync(evidenceRoot).filter((name) => name.endsWith(".ts"))) {
|
||||
const source = ts.createSourceFile(
|
||||
file,
|
||||
readFileSync(join(evidenceRoot, file), "utf8"),
|
||||
ts.ScriptTarget.Latest,
|
||||
true,
|
||||
ts.ScriptKind.TS,
|
||||
);
|
||||
for (const statement of source.statements) {
|
||||
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
|
||||
continue;
|
||||
}
|
||||
const dependency = basename(statement.moduleSpecifier.text).replace(/\.js$/, "");
|
||||
if (coreInfrastructure.has(dependency)) violations.push({ file, dependency });
|
||||
}
|
||||
}
|
||||
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user