From 851a8e284960379ed7b8ecf2b586134253218939 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Sat, 26 Oct 2024 07:40:10 +0530 Subject: [PATCH 1/5] url schemas --- lib/data/changelog-urls.json | 1 + lib/data/source-urls.json | 1 + test/validate-schemas.spec.ts | 4 ++-- tools/schemas/changelog-urls-schema.json | 17 +++++++++++++++++ tools/schemas/schema.ts | 12 ++++++++++++ tools/schemas/source-urls-schema.json | 17 +++++++++++++++++ 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tools/schemas/changelog-urls-schema.json create mode 100644 tools/schemas/source-urls-schema.json 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/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..52078499001ffc --- /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..52078499001ffc --- /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 +} From 140af5dd03b51e3f9aaf2f9326c81f07712b88e2 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Sat, 26 Oct 2024 08:12:30 +0530 Subject: [PATCH 2/5] fxi lint issue --- lib/modules/datasource/metadata-manual.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 From 3de75151f48f0645d63ca822099c47d5c73fffd7 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Mon, 28 Oct 2024 22:05:28 +0530 Subject: [PATCH 3/5] allow @ in dep names --- tools/schemas/changelog-urls-schema.json | 2 +- tools/schemas/source-urls-schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/schemas/changelog-urls-schema.json b/tools/schemas/changelog-urls-schema.json index 52078499001ffc..bfb1854dc4cfea 100644 --- a/tools/schemas/changelog-urls-schema.json +++ b/tools/schemas/changelog-urls-schema.json @@ -5,7 +5,7 @@ "^[a-zA-Z]+$": { "type": "object", "patternProperties": { - "^[a-zA-Z0-9. -/:]+$": { + "^[a-zA-Z0-9. -/:@]+$": { "type": "string", "format": "uri" } diff --git a/tools/schemas/source-urls-schema.json b/tools/schemas/source-urls-schema.json index 52078499001ffc..bfb1854dc4cfea 100644 --- a/tools/schemas/source-urls-schema.json +++ b/tools/schemas/source-urls-schema.json @@ -5,7 +5,7 @@ "^[a-zA-Z]+$": { "type": "object", "patternProperties": { - "^[a-zA-Z0-9. -/:]+$": { + "^[a-zA-Z0-9. -/:@]+$": { "type": "string", "format": "uri" } From ee59b6a0bc8b9af44bfe784a9dd73623136c81fe Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Mon, 28 Oct 2024 23:41:07 +0530 Subject: [PATCH 4/5] Update tools/schemas/source-urls-schema.json Co-authored-by: Michael Kriese --- tools/schemas/source-urls-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/schemas/source-urls-schema.json b/tools/schemas/source-urls-schema.json index bfb1854dc4cfea..eb9c912a3b69a3 100644 --- a/tools/schemas/source-urls-schema.json +++ b/tools/schemas/source-urls-schema.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/draft-04/schema#", "type": "object", "patternProperties": { - "^[a-zA-Z]+$": { + "^[a-zA-Z-]+$": { "type": "object", "patternProperties": { "^[a-zA-Z0-9. -/:@]+$": { From fcdbe84585d9c8f53c6591b121b1f2b87a112f3e Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Mon, 28 Oct 2024 23:41:37 +0530 Subject: [PATCH 5/5] Update tools/schemas/changelog-urls-schema.json --- tools/schemas/changelog-urls-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/schemas/changelog-urls-schema.json b/tools/schemas/changelog-urls-schema.json index bfb1854dc4cfea..eb9c912a3b69a3 100644 --- a/tools/schemas/changelog-urls-schema.json +++ b/tools/schemas/changelog-urls-schema.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/draft-04/schema#", "type": "object", "patternProperties": { - "^[a-zA-Z]+$": { + "^[a-zA-Z-]+$": { "type": "object", "patternProperties": { "^[a-zA-Z0-9. -/:@]+$": {