()
| 1404 | } |
| 1405 | |
| 1406 | async function assertCatalogJsonLocalURLsAreOneToOne() { |
| 1407 | // Check that each local URL in the catalog has a corresponding JSON Schema file. |
| 1408 | { |
| 1409 | await forEachCatalogUrl((/** @type {string} */ catalogUrl) => { |
| 1410 | // Skip external schemas. |
| 1411 | if ( |
| 1412 | !catalogUrl.startsWith(SchemaStoreUrls[0]) && |
| 1413 | !catalogUrl.startsWith(SchemaStoreUrls[1]) |
| 1414 | ) { |
| 1415 | return |
| 1416 | } |
| 1417 | |
| 1418 | const filename = path.basename(new URL(catalogUrl).pathname) |
| 1419 | |
| 1420 | // Check that local URLs end in .json |
| 1421 | if (!filename.endsWith('.json')) { |
| 1422 | printErrorAndExit(new Error(), [ |
| 1423 | `Expected catalog entries for local files to have a "url" that ends in ".json"`, |
| 1424 | `The invalid entry has a "url" of "${catalogUrl}" in file "${CatalogFile}"`, |
| 1425 | ]) |
| 1426 | } |
| 1427 | |
| 1428 | // Check if schema file exist or not. |
| 1429 | if (!exists(path.join(SchemaDir, filename))) { |
| 1430 | printErrorAndExit(new Error(), [ |
| 1431 | `Expected schema file to exist at "./${path.join(SchemaDir, filename)}", but no file found`, |
| 1432 | `Schema file path inferred from catalog entry with a "url" of "${catalogUrl}" in file "${CatalogFile}"`, |
| 1433 | ]) |
| 1434 | } |
| 1435 | }) |
| 1436 | |
| 1437 | console.info(`✔️ catalog.json has no invalid schema URLs`) |
| 1438 | } |
| 1439 | |
| 1440 | // Check that each JSON Schema file has a corresponding local entry in the catalog. |
| 1441 | { |
| 1442 | const /** @type {string[]} */ allCatalogLocalJsonFiles = [] |
| 1443 | |
| 1444 | await forEachCatalogUrl((catalogUrl) => { |
| 1445 | if ( |
| 1446 | catalogUrl.startsWith(SchemaStoreUrls[0]) || |
| 1447 | catalogUrl.startsWith(SchemaStoreUrls[1]) |
| 1448 | ) { |
| 1449 | const filename = path.basename(new URL(catalogUrl).pathname) |
| 1450 | allCatalogLocalJsonFiles.push(filename) |
| 1451 | } |
| 1452 | }) |
| 1453 | |
| 1454 | for (const schemaName of await fs.readdir(SchemaDir)) { |
| 1455 | if (isIgnoredFile(schemaName)) continue |
| 1456 | if ( |
| 1457 | SchemaValidation.missingCatalogUrl.includes(schemaName) || |
| 1458 | SchemaValidation.skiptest.includes(schemaName) |
| 1459 | ) { |
| 1460 | continue |
| 1461 | } |
| 1462 | |
| 1463 | if (!allCatalogLocalJsonFiles.includes(schemaName)) { |
no test coverage detected