46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const packageJson = JSON.parse(readFileSync("package.json", "utf8"));
|
|
const licenseText = readFileSync("LICENSE", "utf8");
|
|
const violations = [];
|
|
|
|
const expectEqual = (path, actual, expected) => {
|
|
if (actual !== expected) {
|
|
violations.push(`package.json ${path}: expected "${expected}", received "${actual ?? "<missing>"}"`);
|
|
}
|
|
};
|
|
|
|
const expectNonEmpty = (path, actual) => {
|
|
if (typeof actual !== "string" || actual.trim().length === 0) {
|
|
violations.push(`package.json ${path}: expected a non-empty string`);
|
|
}
|
|
};
|
|
|
|
expectEqual("name", packageJson.name, "yedir-ai");
|
|
expectNonEmpty("description", packageJson.description);
|
|
expectEqual("private", packageJson.private, true);
|
|
expectEqual("license", packageJson.license, "Apache-2.0");
|
|
expectEqual("packageManager", packageJson.packageManager, "pnpm@9.12.3");
|
|
expectEqual("engines.node", packageJson.engines?.node, ">=20");
|
|
expectEqual("engines.pnpm", packageJson.engines?.pnpm, "9.12.3");
|
|
|
|
if (!licenseText.includes("Apache License, Version 2.0")) {
|
|
violations.push("LICENSE: expected Apache License, Version 2.0 text");
|
|
}
|
|
|
|
if (packageJson.repository || packageJson.homepage || packageJson.bugs) {
|
|
violations.push(
|
|
"package.json: repository/homepage/bugs metadata should be added only after the canonical remote repository is renamed and verified"
|
|
);
|
|
}
|
|
|
|
if (violations.length > 0) {
|
|
console.error("Package metadata check failed.");
|
|
console.error(violations.join("\n"));
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log("Package metadata check passed.");
|