feat: add domain core and verification harness
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import path from "node:path";
|
||||
import {
|
||||
readTextFileIfSmall,
|
||||
relative,
|
||||
walkFiles,
|
||||
} from "./repository-files.mjs";
|
||||
|
||||
const checkedExtensions = new Set([
|
||||
".css",
|
||||
".html",
|
||||
".js",
|
||||
".json",
|
||||
".kt",
|
||||
".kts",
|
||||
".md",
|
||||
".mjs",
|
||||
".properties",
|
||||
".toml",
|
||||
".xml",
|
||||
".yaml",
|
||||
".yml",
|
||||
]);
|
||||
|
||||
const failures = [];
|
||||
let checked = 0;
|
||||
for (const file of await walkFiles()) {
|
||||
if (!checkedExtensions.has(path.extname(file).toLowerCase())) continue;
|
||||
const content = await readTextFileIfSmall(file);
|
||||
if (content === null) continue;
|
||||
checked += 1;
|
||||
|
||||
if (content.length > 0 && !content.endsWith("\n")) {
|
||||
failures.push(`${relative(file)} must end with a newline`);
|
||||
}
|
||||
content.split(/\r?\n/u).forEach((line, index) => {
|
||||
if (/[ \t]+$/u.test(line)) failures.push(`${relative(file)}:${index + 1} has trailing whitespace`);
|
||||
});
|
||||
|
||||
if (file.endsWith(".json")) {
|
||||
try {
|
||||
JSON.parse(content);
|
||||
} catch (error) {
|
||||
failures.push(`${relative(file)} is invalid JSON: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
console.error("Formatting verification failed:");
|
||||
for (const failure of failures) console.error(`- ${failure}`);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`Formatting verification passed (${checked} text files).`);
|
||||
}
|
||||
Reference in New Issue
Block a user