-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalidate-schemas.js
More file actions
46 lines (38 loc) · 1.19 KB
/
validate-schemas.js
File metadata and controls
46 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
const Ajv = require('ajv');
const addFormats = require('ajv-formats');
const fs = require('fs');
const path = require('path');
// Create AJV instance with formats support
const ajv = new Ajv({ allErrors: true, strict: false });
addFormats(ajv);
const schemasDir = path.join(__dirname, 'work/schemas');
const schemaFiles = fs.readdirSync(schemasDir)
.filter(f => f.endsWith('.schema.json'))
.sort();
console.log('=== Validating All Schemas ===\n');
let passedCount = 0;
let failedCount = 0;
const results = [];
for (const file of schemaFiles) {
const schemaPath = path.join(schemasDir, file);
try {
const schemaData = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
ajv.compile(schemaData);
console.log(`✅ ${file}`);
passedCount++;
results.push({ file, status: 'PASS' });
} catch (error) {
console.log(`❌ ${file}`);
console.log(` Error: ${error.message}\n`);
failedCount++;
results.push({ file, status: 'FAIL', error: error.message });
}
}
console.log(`\n=== Summary ===`);
console.log(`Total: ${schemaFiles.length}`);
console.log(`Passed: ${passedCount}`);
console.log(`Failed: ${failedCount}`);
if (failedCount > 0) {
process.exit(1);
}