MCPcopy Index your code
hub / github.com/SchemaStore/schemastore / assertSchemaValidationJsonReferencesNoNonexistentFiles

Function assertSchemaValidationJsonReferencesNoNonexistentFiles

cli.js:1480–1536  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1478}
1479
1480async function assertSchemaValidationJsonReferencesNoNonexistentFiles() {
1481 const schemaNamesMustExist = (
1482 /** @type {string[]} */ schemaNames,
1483 /** @type {string} */ propertyName,
1484 ) => {
1485 for (const schemaName of schemaNames) {
1486 if (!SchemasToBeTested.includes(`${schemaName}`)) {
1487 printErrorAndExit(new Error(), [
1488 `Expected to find file at path "${SchemaDir}/${schemaName}"`,
1489 `Filename "${schemaName}" declared in file "${SchemaValidationFile}" under property "${propertyName}[]"`,
1490 ])
1491 }
1492 }
1493 }
1494
1495 schemaNamesMustExist(SchemaValidation.ajvNotStrictMode, 'ajvNotStrictMode')
1496 schemaNamesMustExist(SchemaValidation.skiptest, 'skiptest')
1497 schemaNamesMustExist(SchemaValidation.missingCatalogUrl, 'missingCatalogUrl')
1498 schemaNamesMustExist(SchemaValidation.highSchemaVersion, 'highSchemaVersion')
1499 schemaNamesMustExist(
1500 (SchemaValidation.coverage ?? []).map((c) => c.schema),
1501 'coverage',
1502 )
1503 for (const schemaName in SchemaValidation.options) {
1504 if (!SchemasToBeTested.includes(schemaName)) {
1505 printErrorAndExit(new Error(), [
1506 `Expected to find file at path "${SchemaDir}/${schemaName}"`,
1507 `Filename "${schemaName}" declared in file "${SchemaValidationFile}" under property "options"`,
1508 ])
1509 }
1510 }
1511 console.info('✔️ schema-validation.jsonc has no invalid schema names')
1512
1513 const schemaUrlsMustExist = async (
1514 /** @type {string[]} */ schemaUrls,
1515 /** @type {string} */ propertyName,
1516 ) => {
1517 const /** @type {string[]} */ catalogUrls = []
1518 await forEachCatalogUrl((catalogUrl) => {
1519 catalogUrls.push(catalogUrl)
1520 })
1521 for (const schemaUrl of schemaUrls) {
1522 if (!catalogUrls.includes(schemaUrl)) {
1523 printErrorAndExit(new Error(), [
1524 `Failed to find a "url" with value of "${schemaUrl}" in file "${CatalogFile}" under property "${propertyName}[]"`,
1525 ])
1526 }
1527 }
1528 }
1529
1530 await schemaUrlsMustExist(
1531 SchemaValidation.catalogEntryNoLintNameOrDescription,
1532 'catalogEntryNoLintNameOrDescription',
1533 )
1534
1535 console.info(`✔️ schema-validation.jsonc has no invalid schema URLs`)
1536}
1537

Callers 1

taskCheckFunction · 0.85

Calls 3

schemaNamesMustExistFunction · 0.85
printErrorAndExitFunction · 0.85
schemaUrlsMustExistFunction · 0.85

Tested by

no test coverage detected