Setting the file. One moment. Domain Knowledge Validate · Rp Target Wix · wix/skills · Skills DocsPost
(opens in a new tab)
scripts/domain-knowledge-validate.js
JavaScript·69 lines·3 KB
argv
=
process.argv.
slice
(
2
);
9 const args = new Set(argv);
10 const domainsDir = knowledgeRoot(path.resolve(__dirname, '..'));
11
12 if (args.has('--list-missing-deps')) {
13 // Spec 0041's live backlog — entities that have never had dependsOn authored at all.
14 // Non-blocking report, not a validation error; this is the thing to run instead of
15 // trusting a hand-maintained list to stay accurate.
16 const missing = listMissingDependsOn(domainsDir);
17 process.stdout.write(`${missing.length} entit${missing.length === 1 ? 'y has' : 'ies have'} no dependsOn yet:\n`);
18 for (const ref of missing) process.stdout.write(` ${ref}\n`);
19 return;
20 }
21
22 const checkScopeIndex = argv.indexOf('--check-scope');
23 if (checkScopeIndex !== -1) {
24 // Spec 0041's rp-mapper review-gate check: pass only the plan's own selected scope — checkScope
25 // walks the transitive closure itself. --check-scope stores/product,gift-cards/gift-card,ecom/order
26 const inScopeRefs = (argv[checkScopeIndex + 1] || '').split(',').map((s) => s.trim()).filter(Boolean);
27 if (inScopeRefs.length === 0) {
28 process.stderr.write('ERROR: --check-scope requires a comma-separated list of domain/entity refs\n');
29 process.exit(1);
30 }
31 const result = checkScope(domainsDir, inScopeRefs);
32 if (result.ok) {
33 process.stdout.write('OK: every selected ref resolves, every reachable dependency is in scope, and every reachable entity has been reviewed\n');
34 return;
35 }
36 for (const ref of result.unknownRefs) {
37 process.stdout.write(`UNKNOWN: ${ref} does not resolve to a real domain/entity file\n`);
38 }
39 for (const { ref, missing } of result.missingDependencies) {
40 process.stdout.write(`MISSING: ${ref} depends on ${missing.join(', ')}, not in scope for this plan\n`);
41 }
42 for (const ref of result.unreviewedRefs) {
43 process.stdout.write(`UNREVIEWED: ${ref} is reachable from this scope but has never had dependsOn authored\n`);
44 }
45 process.exit(1);
46 }
47
48 const result = validateKnowledge(domainsDir);
49
50 if (args.has('--write-index')) {
51 writeJson(path.join(domainsDir, 'index.json'), result.generatedIndex);
52 const afterWrite = validateKnowledge(domainsDir);
53 if (!afterWrite.ok) {
54 for (const error of afterWrite.errors) process.stderr.write(`ERROR: ${error}\n`);
55 process.exit(1);
56 }
57 process.stdout.write('OK: domain knowledge index regenerated and valid\n');
58 return;
59 }
60
61 if (!result.ok) {
62 for (const error of result.errors) process.stderr.write(`ERROR: ${error}\n`);
63 process.exit(1);
64 }
65
66 process.stdout.write('OK: domain knowledge valid\n');
67}
68
69main();