11"use strict" ;
22
3+ import assert from 'assert'
34import { readFile } from 'fs/promises'
45import { dirname , basename , join } from 'path'
56import { fileURLToPath } from 'url'
@@ -9,15 +10,19 @@ import addFormats from 'ajv-formats'
910import addFormats2019 from 'ajv-formats-draft2019'
1011import { glob } from 'glob'
1112
13+ // region config
1214
13- const __dirname = dirname ( fileURLToPath ( import . meta . url ) )
14- const schemaDir = join ( __dirname , '..' , '..' , '..' , '..' , 'schema' )
15+ const bomSchemasGlob = 'bom-*.schema.json'
16+ const schemaDir = join ( dirname ( fileURLToPath ( import . meta . url ) ) , '..' , '..' , '..' , '..' , 'schema' )
1517
16- const [ spdxSchema , jsfSchema ] = await Promise . all ( [
18+ // endregion config
19+
20+ const [ spdxSchema , jsfSchema , bomSchemas ] = await Promise . all ( [
1721 readFile ( join ( schemaDir , 'spdx.schema.json' ) , 'utf-8' ) . then ( JSON . parse ) ,
18- readFile ( join ( schemaDir , 'jsf-0.82.schema.json' ) , 'utf-8' ) . then ( JSON . parse )
22+ readFile ( join ( schemaDir , 'jsf-0.82.schema.json' ) , 'utf-8' ) . then ( JSON . parse ) ,
23+ glob ( join ( schemaDir , bomSchemasGlob ) ) . then ( l => l . sort ( ) )
1924] )
20- const bomSchemas = ( await glob ( join ( schemaDir , 'bom-*.schema.json' ) ) ) . sort ( )
25+ assert . notStrictEqual ( bomSchemas . length , 0 )
2126
2227/**
2328 * @return {Ajv }
@@ -28,8 +33,10 @@ function getAjv() {
2833 useDefaults : false ,
2934 // main idea is to be as strict as possible
3035 strict : true ,
31- // this parser has issues with the oneOf-required in `{oneOf:[{reqiored:['a']},{required:['b']}], properties:{a:{},b:{}}}`
32- strictRequired : false ,
36+ // this parser has issues with the oneOf-required in
37+ // `{ type: 'object', oneOf:[{required:['a']},{required:['b']}], properties:{a:{...},b:{...}} }`
38+ // so lets simply log them, do not throw errors on them.
39+ strictRequired : 'log' ,
3340 strictSchema : true ,
3441 addUsedSchema : false ,
3542 schemas : {
@@ -39,7 +46,8 @@ function getAjv() {
3946 } ) ;
4047 addFormats ( ajv )
4148 addFormats2019 ( ajv , { formats : [ 'idn-email' ] } )
42- // there is just no working implementation for format "iri-reference": see https://github.com/luzlab/ajv-formats-draft2019/issues/22
49+ // there is just no working implementation for format "iri-reference"
50+ // see https://github.com/luzlab/ajv-formats-draft2019/issues/22
4351 ajv . addFormat ( 'iri-reference' , true )
4452 return ajv
4553}
0 commit comments