diff --git a/lib/data/changelog-urls.json b/lib/data/changelog-urls.json index cf5f0d219bfd7f..d0100044ff8bc1 100644 --- a/lib/data/changelog-urls.json +++ b/lib/data/changelog-urls.json @@ -1,4 +1,5 @@ { + "$schema": "../../tools/schemas/changelog-urls-schema.json", "npm": { "babel-preset-react-app": "https://github.com/facebook/create-react-app/releases", "firebase": "https://firebase.google.com/support/release-notes/js", diff --git a/lib/data/source-urls.json b/lib/data/source-urls.json index d4e68ccb50101f..9ec7c57129baac 100644 --- a/lib/data/source-urls.json +++ b/lib/data/source-urls.json @@ -1,4 +1,5 @@ { + "$schema": "../../tools/schemas/source-urls-schema.json", "orb": { "cypress-io/cypress": "https://github.com/cypress-io/circleci-orb", "hutson/library-release-workflows": "https://github.com/hyper-expanse/library-release-workflows" diff --git a/lib/modules/datasource/metadata-manual.ts b/lib/modules/datasource/metadata-manual.ts index e1b8be133770eb..064453499c0fbd 100644 --- a/lib/modules/datasource/metadata-manual.ts +++ b/lib/modules/datasource/metadata-manual.ts @@ -1,13 +1,15 @@ -import changelogUrls from '../../data/changelog-urls.json'; -import sourceUrls from '../../data/source-urls.json'; +import changelogUrlsJson from '../../data/changelog-urls.json'; +import sourceUrlsJson from '../../data/source-urls.json'; +const { $schema: changelogSchema, ...changelogUrls } = changelogUrlsJson; // Only necessary when the changelog data cannot be found in the package's source repository export const manualChangelogUrls: Record< string, Record > = changelogUrls; -// Only necessary if the datasource is unable to locate the source URL itself +const { $schema: sourceUrlSchema, ...sourceUrls } = sourceUrlsJson; +// Only necessary when the changelog data cannot be found in the package's source repository export const manualSourceUrls: Record< string, Record diff --git a/test/validate-schemas.spec.ts b/test/validate-schemas.spec.ts index e7f424570b6f91..e023e476b6123b 100644 --- a/test/validate-schemas.spec.ts +++ b/test/validate-schemas.spec.ts @@ -18,7 +18,7 @@ describe('validate-schemas', () => { ); for (const schemaFile of schemaFiles) { - const correspondingDatFileName = schemaFile.replace('-schema', ''); + const correspondingDataFileName = schemaFile.replace('-schema', ''); const schemaName = `${schemaFile .replace('.json', '') .split('-') @@ -26,7 +26,7 @@ describe('validate-schemas', () => { .join('')}` as keyof typeof Schemas; schemasAndJsonFiles.push({ schemaName, - dataFileName: correspondingDatFileName, + dataFileName: correspondingDataFileName, }); } diff --git a/tools/schemas/changelog-urls-schema.json b/tools/schemas/changelog-urls-schema.json new file mode 100644 index 00000000000000..eb9c912a3b69a3 --- /dev/null +++ b/tools/schemas/changelog-urls-schema.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json-schema.org/draft-04/schema#", + "type": "object", + "patternProperties": { + "^[a-zA-Z-]+$": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9. -/:@]+$": { + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/tools/schemas/schema.ts b/tools/schemas/schema.ts index 8609e3582e81dc..a37f6ea8f07329 100644 --- a/tools/schemas/schema.ts +++ b/tools/schemas/schema.ts @@ -52,3 +52,15 @@ export const ReplacementsSchema = z all: AllSchema, }) .catchall(RuleSetSchema); + +export const ChangelogUrlsSchema = z + .object({ + $schema: z.string(), + }) + .catchall(z.record(z.string(), z.string().url())); + +export const SourceUrlsSchema = z + .object({ + $schema: z.string(), + }) + .catchall(z.record(z.string(), z.string().url())); diff --git a/tools/schemas/source-urls-schema.json b/tools/schemas/source-urls-schema.json new file mode 100644 index 00000000000000..eb9c912a3b69a3 --- /dev/null +++ b/tools/schemas/source-urls-schema.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json-schema.org/draft-04/schema#", + "type": "object", + "patternProperties": { + "^[a-zA-Z-]+$": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9. -/:@]+$": { + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +}