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

Function assertCatalogJsonHasNoFileMatchConflict

cli.js:1373–1404  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1371}
1372
1373function assertCatalogJsonHasNoFileMatchConflict() {
1374 const /** @type {string[]} */ allFileMatches = []
1375
1376 for (const catalogEntry of Catalog.schemas) {
1377 for (const fileGlob of catalogEntry.fileMatch ?? []) {
1378 // Ignore globs that are OK to conflict for backwards compatibility.
1379 if (SchemaValidation.fileMatchConflict.includes(fileGlob)) {
1380 continue
1381 }
1382
1383 if (allFileMatches.includes(fileGlob)) {
1384 const firstEntry = Catalog.schemas.find((entry) =>
1385 entry.fileMatch?.includes(fileGlob),
1386 )
1387 // @ts-expect-error Node v18 supports "Array.prototype.findLast".
1388 const lastEntry = Catalog.schemas.findLast((entry) =>
1389 entry.fileMatch?.includes(fileGlob),
1390 )
1391 printErrorAndExit(new Error(), [
1392 `Found two schema entries with duplicate "fileMatch" entry of "${fileGlob}" in file "${CatalogFile}"`,
1393 `The first entry has url "${firstEntry?.url}"`,
1394 `The second entry has url "${lastEntry?.url}"`,
1395 `Expected all values in "fileMatch" entries to be unique`,
1396 ])
1397 }
1398
1399 allFileMatches.push(fileGlob)
1400 }
1401 }
1402
1403 console.info('✔️ catalog.json has no duplicate "fileMatch" values')
1404}
1405
1406async function assertCatalogJsonLocalURLsAreOneToOne() {
1407 // Check that each local URL in the catalog has a corresponding JSON Schema file.

Callers 1

taskCheckFunction · 0.85

Calls 1

printErrorAndExitFunction · 0.85

Tested by

no test coverage detected