feat: add domain core and verification harness
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import path from "node:path";
|
||||
import {
|
||||
readTextFileIfSmall,
|
||||
relative,
|
||||
repositoryRoot,
|
||||
walkFiles,
|
||||
} from "./repository-files.mjs";
|
||||
|
||||
const domainRoot = path.join(repositoryRoot, "app", "src", "main", "java", "brainwave", "domain");
|
||||
const forbiddenImports = [
|
||||
/^android\./u,
|
||||
/^androidx\./u,
|
||||
/^com\.google\.dagger\./u,
|
||||
/^dagger\./u,
|
||||
/^okhttp3\./u,
|
||||
/^retrofit2\./u,
|
||||
/^io\.ktor\./u,
|
||||
/^androidx\.room\./u,
|
||||
];
|
||||
|
||||
const failures = [];
|
||||
let kotlinFiles = [];
|
||||
try {
|
||||
kotlinFiles = (await walkFiles(domainRoot)).filter((file) => file.endsWith(".kt"));
|
||||
} catch {
|
||||
failures.push(`domain source directory is missing: ${relative(domainRoot)}`);
|
||||
}
|
||||
|
||||
for (const file of kotlinFiles) {
|
||||
const content = await readTextFileIfSmall(file);
|
||||
if (content === null) continue;
|
||||
for (const [index, line] of content.split(/\r?\n/u).entries()) {
|
||||
const match = /^\s*import\s+([^\s]+)/u.exec(line);
|
||||
if (!match) continue;
|
||||
if (forbiddenImports.some((pattern) => pattern.test(match[1]))) {
|
||||
failures.push(`${relative(file)}:${index + 1} forbidden import ${match[1]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
console.error("Domain boundary verification failed:");
|
||||
for (const failure of failures) console.error(`- ${failure}`);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`Domain boundary verification passed (${kotlinFiles.length} Kotlin files).`);
|
||||
}
|
||||
Reference in New Issue
Block a user