Files
John SmithandClaude Opus 5.5 56fad94c34 feat(schema): add kind, topics, compat, npm and path; reject unknown fields and non-root repo URLs
Entries gain a fixed kind and 1-3 topics (replacing 374 one-off tags as the categorization axis), an OpenCode API compat field (required for plugins), and npm/path for packages and monorepo folders. repo must be a repository root; unknown fields such as install: or repository: are rejected. Cross-entry rules (one entry per repo+path, kind must fit the category, no placeholder owners or mojibake) live in scripts/utils/catalog.js, and validate.js now always loads the whole catalog and fails on unparseable YAML. Adds npm run fmt for canonical formatting and drops the unused glob dependency.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:00:22 -04:00

34 lines
1.1 KiB
JavaScript

#!/usr/bin/env node
/**
* Validate catalog entries.
* Usage: node scripts/validate.js [file1.yaml] [file2.yaml] ...
*
* Always loads the whole catalog so cross-entry rules (duplicate repos) are enforced; when files are
* given, only problems in those files are reported. Exits 1 on any problem, including unparseable YAML.
*/
const path = require('path');
const { checkCatalog, formatProblems, loadCatalog } = require('./utils/catalog');
const ROOT = path.join(__dirname, '..');
function main() {
const only = process.argv.slice(2)
.filter(f => f.endsWith('.yaml'))
.map(f => path.relative(ROOT, path.resolve(f)));
const { entries, errors } = loadCatalog();
const problems = [...errors, ...checkCatalog(entries)]
.filter(p => only.length === 0 || only.includes(p.file));
const checked = only.length || entries.length + errors.length;
if (problems.length > 0) {
console.error(formatProblems(problems));
console.error(`\n✗ ${new Set(problems.map(p => p.file)).size} of ${checked} file(s) failed validation.`);
process.exit(1);
}
console.log(`✓ All ${checked} file(s) passed validation.`);
}
main();