@@ -62,7 +62,10 @@ const SchemaValidation = /** @type {SchemaValidationJson} */ (
6262const SchemaDir = './src/schemas/json'
6363const TestPositiveDir = './src/test'
6464const TestNegativeDir = './src/negative_test'
65- const UrlSchemaStore = 'https://json.schemastore.org/'
65+ const SchemaStoreUrls = /** @type {const } */ ( [
66+ 'https://json.schemastore.org/' ,
67+ 'https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/' ,
68+ ] )
6669const [ SchemasToBeTested , FoldersPositiveTest , FoldersNegativeTest ] = (
6770 await Promise . all ( [
6871 fs . readdir ( SchemaDir ) ,
@@ -230,9 +233,11 @@ async function forEachFile(/** @type {ForEachTestFile} */ obj) {
230233 const schemaFile = await toFile ( schemaPath )
231234 if ( obj . actionName ) {
232235 if ( process . env . CI ) {
233- console . info ( `Running "${ obj . actionName } " on file "${ schemaFile . path } "` )
236+ console . info (
237+ `Running "${ obj . actionName } " on file "./${ schemaFile . path } "` ,
238+ )
234239 } else {
235- spinner . text = `Running "${ obj . actionName } " on file "${ schemaFile . path } "`
240+ spinner . text = `Running "${ obj . actionName } " on file "./ ${ schemaFile . path } "`
236241 }
237242 }
238243 const data = await obj ?. onSchemaFile ?. ( schemaFile , { spinner } )
@@ -832,7 +837,12 @@ async function taskMaintenance() {
832837 {
833838 console . info ( `===== BROKEN SCHEMAS =====` )
834839 forEachCatalogUrl ( ( url ) => {
835- if ( url . startsWith ( UrlSchemaStore ) ) return
840+ if (
841+ url . startsWith ( SchemaStoreUrls [ 0 ] ) ||
842+ url . startsWith ( SchemaStoreUrls [ 1 ] )
843+ ) {
844+ return
845+ }
836846
837847 fetch ( url )
838848 . then ( async ( res ) => {
@@ -1105,11 +1115,14 @@ async function assertCatalogJsonLocalURLsAreOneToOne() {
11051115 {
11061116 await forEachCatalogUrl ( ( /** @type {string } */ catalogUrl ) => {
11071117 // Skip external schemas.
1108- if ( ! catalogUrl . startsWith ( UrlSchemaStore ) ) {
1118+ if (
1119+ ! catalogUrl . startsWith ( SchemaStoreUrls [ 0 ] ) &&
1120+ ! catalogUrl . startsWith ( SchemaStoreUrls [ 1 ] )
1121+ ) {
11091122 return
11101123 }
11111124
1112- const filename = new URL ( catalogUrl ) . pathname . slice ( 1 )
1125+ const filename = path . basename ( new URL ( catalogUrl ) . pathname )
11131126
11141127 // Check that local URLs end in .json
11151128 if ( ! filename . endsWith ( '.json' ) ) {
@@ -1136,8 +1149,11 @@ async function assertCatalogJsonLocalURLsAreOneToOne() {
11361149 const /** @type {string[] } */ allCatalogLocalJsonFiles = [ ]
11371150
11381151 await forEachCatalogUrl ( ( catalogUrl ) => {
1139- if ( catalogUrl . startsWith ( UrlSchemaStore ) ) {
1140- const filename = new URL ( catalogUrl ) . pathname . slice ( 1 )
1152+ if (
1153+ catalogUrl . startsWith ( SchemaStoreUrls [ 0 ] ) ||
1154+ catalogUrl . startsWith ( SchemaStoreUrls [ 1 ] )
1155+ ) {
1156+ const filename = path . basename ( new URL ( catalogUrl ) . pathname )
11411157 allCatalogLocalJsonFiles . push ( filename )
11421158 }
11431159 } )
@@ -1154,7 +1170,9 @@ async function assertCatalogJsonLocalURLsAreOneToOne() {
11541170 if ( ! allCatalogLocalJsonFiles . includes ( schemaName ) ) {
11551171 printErrorAndExit ( new Error ( ) , [
11561172 `Expected schema file "${ schemaName } " to have a corresponding entry in the catalog file "${ CatalogFile } "` ,
1157- `Expected to find entry with "url" of "${ UrlSchemaStore } ${ schemaName } "` ,
1173+ `Expected to find entry with "url" that is one of:` ,
1174+ ` - "${ SchemaStoreUrls [ 0 ] } ${ schemaName } "` ,
1175+ ` - "${ SchemaStoreUrls [ 1 ] } ${ schemaName } "` ,
11581176 `If this is intentional, ignore this error by appending to the property "missingCatalogUrl" in file "${ SchemaValidationFile } "` ,
11591177 ] )
11601178 }
@@ -1641,7 +1659,8 @@ async function printSimpleStatistics() {
16411659 let countScanURLInternal = 0
16421660
16431661 await forEachCatalogUrl ( ( catalogUrl ) => {
1644- catalogUrl . startsWith ( UrlSchemaStore )
1662+ catalogUrl . startsWith ( SchemaStoreUrls [ 0 ] ) ||
1663+ catalogUrl . startsWith ( SchemaStoreUrls [ 1 ] )
16451664 ? countScanURLInternal ++
16461665 : countScanURLExternal ++
16471666 } )
0 commit comments