Skip to content

Commit b70e2d9

Browse files
committed
fix: Update paths in build scripts and enhance error handling in validators
1 parent 108a061 commit b70e2d9

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

.github/workflows/catalogs-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
node-version: '20'
1717
- run: npm ci
1818
- run: npm run build
19-
- run: node tools/ci-scripts/build-catalogs.js
19+
- run: node scripts/ci-scripts/build-catalogs.js
2020
- uses: stefanzweifel/git-auto-commit-action@v5
2121
with:
2222
commit_message: 'Update catalogs'

.github/workflows/docs-validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
node-version: '20'
1515
- run: npm ci
1616
- run: npm run build
17-
- run: node tools/ci-scripts/build-catalogs.js
17+
- run: node scripts/ci-scripts/build-catalogs.js
1818
- run: npm run cli ref audit

reference/standards/catalogs/registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tech:typescript/frameworks/[email protected]": {
3-
"path": "tech\\typescript\\frameworks\\express@5\\guide.md",
3+
"path": "reference\\tech\\typescript\\frameworks\\express@5\\guide.md",
44
"status": "active",
55
"sha": "placeholder",
66
"aliases": [],

scripts/ci-scripts/build-catalogs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const path = require('path');
55
const yaml = require('js-yaml');
66

77
const ROOT = path.resolve(__dirname, '..', '..');
8-
const STANDARDS_DIR = path.join(ROOT, 'standards');
9-
const TECH_DIR = path.join(ROOT, 'tech');
10-
const TEMPLATES_DIR = path.join(ROOT, 'templates');
8+
const STANDARDS_DIR = path.join(ROOT, 'reference', 'standards');
9+
const TECH_DIR = path.join(ROOT, 'reference', 'tech');
10+
const TEMPLATES_DIR = path.join(ROOT, 'docs', 'templates');
1111
const REGISTRY_PATH = path.join(STANDARDS_DIR, 'catalogs', 'registry.json');
1212
const ALIASES_PATH = path.join(STANDARDS_DIR, 'catalogs', 'aliases.json');
1313

src/validators/ajv.validator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ export class AjvValidator {
2525
* Compiles the validation schema for use in validation.
2626
*/
2727
compile(): void {
28-
const schema = this.loader.load();
29-
this.validateFn = this.ajv.compile(schema as AnySchema);
28+
try {
29+
const schema = this.loader.load();
30+
this.validateFn = this.ajv.compile(schema as AnySchema);
31+
} catch (error) {
32+
const schemaPath = this.loader.getSchemaPath();
33+
const errorMessage = error instanceof Error ? error.message : String(error);
34+
throw new Error(`Failed to compile validator for schema '${schemaPath}': ${errorMessage}`);
35+
}
3036
}
3137

3238
/**

src/validators/schema.loader.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ export class SchemaLoader {
3030
}
3131
return parseJsonFile(this.schemaPath, fileManager);
3232
}
33+
34+
/**
35+
* Gets the path to the schema file.
36+
* @returns The schema file path.
37+
*/
38+
getSchemaPath(): string {
39+
return this.schemaPath;
40+
}
3341
}

src/validators/validator.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ export function validateTasks(tasks: ITask[]): IValidationResult {
2929
const validator = new AjvValidator(loader);
3030
const errors: string[] = [];
3131
for (let i = 0; i < tasks.length; i++) {
32-
// Array access with controlled index is safe
33-
// eslint-disable-next-line security/detect-object-injection
34-
const res = validator.validate(tasks[i]);
32+
const task = tasks.at(i);
33+
if (!task) {
34+
errors.push(`Task[${i}] is undefined`);
35+
continue;
36+
}
37+
const res = validator.validate(task);
3538
if (!res.isValid) {
3639
const msg = (res.errors || [])
3740
.map((e: unknown) => {

0 commit comments

Comments
 (0)