Files
itworx-knowledge-hub-Public/scripts/validate-public-source.mjs
T

32 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
import process from "node:process";
const required = [
"README.md", "SECURITY.md", "CONTRIBUTING.md", "LICENSE", "PUBLIC_SOURCE_EXPORT.md",
"PUBLIC_SOURCE_MANIFEST.json", "MANIFEST.json", "ItWorx.KnowledgeHub.slnx", "docker-compose.yml",
"deploy/docker/Dockerfile", "docs/api/openapi.yaml", "src/frontend/package.json"
];
const missing = required.filter((entry) => !fs.existsSync(path.join(process.cwd(), entry)));
if (missing.length > 0) {
console.error(`Missing public source files: ${missing.join(", ")}`);
process.exit(1);
}
for (const privatePath of [".claude", ".agents", ".codex", "artifacts", "docs/deployments", "docs/v2", "n8n"]) {
if (fs.existsSync(path.join(process.cwd(), privatePath))) {
console.error(`Private-only path present in public export: ${privatePath}`);
process.exit(1);
}
}
const manifest = JSON.parse(fs.readFileSync("PUBLIC_SOURCE_MANIFEST.json", "utf8"));
if (!Array.isArray(manifest.files) || manifest.files.length === 0) {
console.error("PUBLIC_SOURCE_MANIFEST.json contains no files.");
process.exit(1);
}
console.log(`Public source structure passed (${manifest.files.length} allowlisted files).`);