From 684730c706b865be89f85162ee9055006a34dc7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 13:43:14 +0000 Subject: [PATCH 1/2] Bump ajv from 6.11.0 to 8.6.3 Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.11.0 to 8.6.3. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](https://github.com/ajv-validator/ajv/compare/v6.11.0...v8.6.3) --- updated-dependencies: - dependency-name: ajv dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 46 ++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3063f16b..bae487d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -512,14 +512,14 @@ } }, "ajv": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", - "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", + "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", "uri-js": "^4.2.2" } }, @@ -1222,9 +1222,9 @@ } }, "fast-deep-equal": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", - "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "fast-glob": { @@ -1240,12 +1240,6 @@ "micromatch": "^4.0.4" } }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -1937,9 +1931,9 @@ "dev": true }, "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, "keyv": { @@ -2797,12 +2791,6 @@ "resolve": "^1.1.6" } }, - "regenerator-runtime": { - "version": "0.13.5", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", - "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", - "dev": true - }, "registry-auth-token": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", @@ -2899,6 +2887,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "resolve": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", @@ -3331,9 +3325,9 @@ } }, "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "requires": { "punycode": "^2.1.0" diff --git a/package.json b/package.json index 666bc866..ce7968e1 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@actions/core": "^1.6.0", "@octokit/rest": "^18.12.0", - "ajv": "^6.11.0", + "ajv": "^8.6.3", "auto-changelog": "^2.3.0", "jsdom": "^17.0.0", "mocha": "^9.1.2", From 8b51e69e94818762bc57fd25cce98ed91cb436bf Mon Sep 17 00:00:00 2001 From: Francois Daoust Date: Fri, 8 Oct 2021 16:21:40 +0200 Subject: [PATCH 2/2] Adjust tests to run with latest version of Ajv Latest version is stricter on schema constraints: 1. It requires definitions to be in a `$defs` property 2. It loads regular expression with the `u` flag, which does not like it when the `-` character is escaped when it does not need to 3. It is more assertive in reported failures: "should" => "must" Support for JSON Schema formats (`uri`) requires loading another package as well. --- package-lock.json | 9 +++++++++ package.json | 1 + schema/data.json | 2 +- schema/definitions.json | 34 +++++++++++++++++----------------- schema/index.json | 30 +++++++++++++++--------------- schema/specs.json | 20 ++++++++++---------- test/data.js | 2 ++ test/index.js | 3 +++ test/specs.js | 22 ++++++++++++---------- 9 files changed, 70 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index bae487d8..ec23b49c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -523,6 +523,15 @@ "uri-js": "^4.2.2" } }, + "ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "requires": { + "ajv": "^8.0.0" + } + }, "ansi-align": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", diff --git a/package.json b/package.json index ce7968e1..bf1eec47 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@actions/core": "^1.6.0", "@octokit/rest": "^18.12.0", "ajv": "^8.6.3", + "ajv-formats": "^2.1.1", "auto-changelog": "^2.3.0", "jsdom": "^17.0.0", "mocha": "^9.1.2", diff --git a/schema/data.json b/schema/data.json index 7c9100c0..695fadec 100644 --- a/schema/data.json +++ b/schema/data.json @@ -43,7 +43,7 @@ "specs": { "type": "object", "propertyNames": { - "$ref": "definitions.json#/proptype/url" + "$ref": "definitions.json#/$defs/url" }, "additionalProperties": { "type": "object", diff --git a/schema/definitions.json b/schema/definitions.json index 6b0390d4..4524ff56 100644 --- a/schema/definitions.json +++ b/schema/definitions.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/schema#", "$id": "https://w3c.github.io/browser-specs/schema/definitions.json", - "proptype": { + "$defs": { "url": { "type": "string", "format": "uri" @@ -20,7 +20,7 @@ "shortname": { "type": "string", - "pattern": "^[\\w\\-]+((?<=\\-\\d+)\\.\\d+)?$" + "pattern": "^[\\w\\-]+((?<=-\\d+)\\.\\d+)?$" }, "series": { @@ -30,9 +30,9 @@ "type": "string", "pattern": "^[\\w\\-]+$" }, - "currentSpecification": { "$ref": "#/proptype/shortname" }, - "releaseUrl": { "$ref": "#/proptype/url" }, - "nightlyUrl": { "$ref": "#/proptype/url" } + "currentSpecification": { "$ref": "#/$defs/shortname" }, + "releaseUrl": { "$ref": "#/$defs/url" }, + "nightlyUrl": { "$ref": "#/$defs/url" } }, "required": ["shortname"], "additionalProperties": false @@ -64,11 +64,11 @@ "release": { "type": "object", "properties": { - "url": { "$ref": "#/proptype/url" }, - "filename": { "$ref": "#/proptype/filename" }, + "url": { "$ref": "#/$defs/url" }, + "filename": { "$ref": "#/$defs/filename" }, "pages": { "type": "array", - "items": { "$ref": "#/proptype/url" } + "items": { "$ref": "#/$defs/url" } } }, "required": ["url"], @@ -78,14 +78,14 @@ "nightly": { "type": "object", "properties": { - "url": { "$ref": "#/proptype/url" }, - "filename": { "$ref": "#/proptype/filename" }, - "sourcePath": { "$ref": "#/proptype/relativePath" }, + "url": { "$ref": "#/$defs/url" }, + "filename": { "$ref": "#/$defs/filename" }, + "sourcePath": { "$ref": "#/$defs/relativePath" }, "pages": { "type": "array", - "items": { "$ref": "#/proptype/url" } + "items": { "$ref": "#/$defs/url" } }, - "repository": { "$ref": "#/proptype/url" } + "repository": { "$ref": "#/$defs/url" } }, "additionalProperties": false }, @@ -93,15 +93,15 @@ "tests": { "type": "object", "properties": { - "repository": { "$ref": "#/proptype/url" }, + "repository": { "$ref": "#/$defs/url" }, "testPaths": { "type": "array", - "items": { "$ref": "#/proptype/relativePath" }, + "items": { "$ref": "#/$defs/relativePath" }, "minItems": 1 }, "excludePaths": { "type": "array", - "items": { "$ref": "#/proptype/relativePath" }, + "items": { "$ref": "#/$defs/relativePath" }, "minItems": 1 } }, @@ -115,7 +115,7 @@ "type": "object", "properties": { "name": { "type": "string" }, - "url": { "$ref": "#/proptype/url" } + "url": { "$ref": "#/$defs/url" } }, "required": ["name", "url"], "additionalProperties": false diff --git a/schema/index.json b/schema/index.json index 6add6b7a..1ed2b408 100644 --- a/schema/index.json +++ b/schema/index.json @@ -6,21 +6,21 @@ "items": { "type": "object", "properties": { - "url": { "$ref": "definitions.json#/proptype/url" }, - "shortname": { "$ref": "definitions.json#/proptype/shortname" }, - "series": { "$ref": "definitions.json#/proptype/series" }, - "seriesVersion": { "$ref": "definitions.json#/proptype/seriesVersion" }, - "seriesComposition": { "$ref": "definitions.json#/proptype/seriesComposition" }, - "seriesPrevious": { "$ref": "definitions.json#/proptype/shortname" }, - "seriesNext": { "$ref": "definitions.json#/proptype/shortname" }, - "nightly": { "$ref": "definitions.json#/proptype/nightly" }, - "tests": { "$ref": "definitions.json#/proptype/tests" }, - "release": { "$ref": "definitions.json#/proptype/release" }, - "title": { "$ref": "definitions.json#/proptype/title" }, - "shortTitle": { "$ref": "definitions.json#/proptype/title" }, - "source": { "$ref": "definitions.json#/proptype/source" }, - "organization": { "$ref": "definitions.json#/proptype/organization" }, - "groups": { "$ref": "definitions.json#/proptype/groups" } + "url": { "$ref": "definitions.json#/$defs/url" }, + "shortname": { "$ref": "definitions.json#/$defs/shortname" }, + "series": { "$ref": "definitions.json#/$defs/series" }, + "seriesVersion": { "$ref": "definitions.json#/$defs/seriesVersion" }, + "seriesComposition": { "$ref": "definitions.json#/$defs/seriesComposition" }, + "seriesPrevious": { "$ref": "definitions.json#/$defs/shortname" }, + "seriesNext": { "$ref": "definitions.json#/$defs/shortname" }, + "nightly": { "$ref": "definitions.json#/$defs/nightly" }, + "tests": { "$ref": "definitions.json#/$defs/tests" }, + "release": { "$ref": "definitions.json#/$defs/release" }, + "title": { "$ref": "definitions.json#/$defs/title" }, + "shortTitle": { "$ref": "definitions.json#/$defs/title" }, + "source": { "$ref": "definitions.json#/$defs/source" }, + "organization": { "$ref": "definitions.json#/$defs/organization" }, + "groups": { "$ref": "definitions.json#/$defs/groups" } }, "required": [ "url", "shortname", "series", "seriesComposition", "nightly", diff --git a/schema/specs.json b/schema/specs.json index 5af49749..50bd20bb 100644 --- a/schema/specs.json +++ b/schema/specs.json @@ -12,16 +12,16 @@ { "type": "object", "properties": { - "url": { "$ref": "definitions.json#/proptype/url" }, - "shortname": { "$ref": "definitions.json#/proptype/shortname" }, - "series": { "$ref": "definitions.json#/proptype/series" }, - "seriesVersion": { "$ref": "definitions.json#/proptype/seriesVersion" }, - "seriesComposition": { "$ref": "definitions.json#/proptype/seriesComposition" }, - "nightly": { "$ref": "definitions.json#/proptype/nightly" }, - "tests": { "$ref": "definitions.json#/proptype/tests" }, - "shortTitle": { "$ref": "definitions.json#/proptype/title" }, - "organization": { "$ref": "definitions.json#/proptype/organization" }, - "groups": { "$ref": "definitions.json#/proptype/groups" }, + "url": { "$ref": "definitions.json#/$defs/url" }, + "shortname": { "$ref": "definitions.json#/$defs/shortname" }, + "series": { "$ref": "definitions.json#/$defs/series" }, + "seriesVersion": { "$ref": "definitions.json#/$defs/seriesVersion" }, + "seriesComposition": { "$ref": "definitions.json#/$defs/seriesComposition" }, + "nightly": { "$ref": "definitions.json#/$defs/nightly" }, + "tests": { "$ref": "definitions.json#/$defs/tests" }, + "shortTitle": { "$ref": "definitions.json#/$defs/title" }, + "organization": { "$ref": "definitions.json#/$defs/organization" }, + "groups": { "$ref": "definitions.json#/$defs/groups" }, "forceCurrent": { "type": "boolean" }, "multipage": { "type": "boolean" } }, diff --git a/test/data.js b/test/data.js index e07734b5..3fd16046 100644 --- a/test/data.js +++ b/test/data.js @@ -6,7 +6,9 @@ const assert = require("assert"); const schema = require("../schema/data.json"); const dfnsSchema = require("../schema/definitions.json"); const Ajv = require("ajv"); +const addFormats = require("ajv-formats") const ajv = (new Ajv()).addSchema(dfnsSchema); +addFormats(ajv); describe("Ignore/Monitor lists", () => { describe("The JSON schema", () => { diff --git a/test/index.js b/test/index.js index 840f86fa..71042410 100644 --- a/test/index.js +++ b/test/index.js @@ -8,7 +8,10 @@ const specs = require("../index.json"); const schema = require("../schema/index.json"); const dfnsSchema = require("../schema/definitions.json"); const Ajv = require("ajv"); +const addFormats = require("ajv-formats") const ajv = new Ajv(); +addFormats(ajv); + describe("List of specs", () => { it("has a valid JSON schema", () => { diff --git a/test/specs.js b/test/specs.js index b3c3e582..51a148e7 100644 --- a/test/specs.js +++ b/test/specs.js @@ -12,7 +12,9 @@ const dfnsSchema = require("../schema/definitions.json"); const computeInfo = require("../src/compute-shortname.js"); const computePrevNext = require("../src/compute-prevnext.js"); const Ajv = require("ajv"); +const addFormats = require("ajv-formats") const ajv = (new Ajv()).addSchema(dfnsSchema); +addFormats(ajv); // When an entry is invalid, the schema validator returns one error for each // "oneOf" option and one error on overall "oneOf" problem. This is confusing @@ -22,9 +24,9 @@ function clarifyErrors(errors) { return errors; } - // Update dataPath to drop misleading "[object Object]" + // Update instancePath to drop misleading "[object Object]" errors.forEach(err => - err.dataPath = err.dataPath.replace(/^\[object Object\]/, '')); + err.instancePath = err.instancePath.replace(/^\[object Object\]/, '')); if (errors.length < 2) { return errors; @@ -35,7 +37,7 @@ function clarifyErrors(errors) { if ((errors[0].schemaPath === "#/items/oneOf/0/type") && (errors[1].schemaPath === "#/items/oneOf/1/type")) { return [ - Object.assign(errors[0], { "message": "should be a string or an object" }) + Object.assign(errors[0], { "message": "must be a string or an object" }) ]; } @@ -59,7 +61,7 @@ function clarifyErrors(errors) { clearerErrors.forEach(error => { if ((error.keyword === "additionalProperties") && error.params && error.params.additionalProperty) { - error.message = "should not have additional property '" + + error.message = "must not have additional property '" + error.params.additionalProperty + "'"; } }); @@ -113,32 +115,32 @@ describe("Input list", () => { it("rejects list if it is not an array", () => { const specs = 0; - assert.strictEqual(check(specs), "specs should be array"); + assert.strictEqual(check(specs), "specs must be array"); }); it("rejects an empty list", () => { const specs = []; - assert.strictEqual(check(specs), "specs should NOT have fewer than 1 items"); + assert.strictEqual(check(specs), "specs must NOT have fewer than 1 items"); }); it("rejects items that have a wrong type", () => { const specs = [0]; - assert.strictEqual(check(specs), "specs[0] should be a string or an object"); + assert.strictEqual(check(specs), "specs/0 must be a string or an object"); }); it("rejects spec objects without URL", () => { const specs = [{}]; - assert.strictEqual(check(specs), "specs[0] should have required property 'url'"); + assert.strictEqual(check(specs), "specs/0 must have required property 'url'"); }); it("rejects spec objects with an invalid URL", () => { const specs = [{ url: "invalid" }]; - assert.strictEqual(check(specs), "specs[0].url should match format \"uri\""); + assert.strictEqual(check(specs), "specs/0/url must match format \"uri\""); }); it("rejects spec objects with additional properties", () => { const specs = [{ url: "https://example.org/", invalid: "test" }]; - assert.strictEqual(check(specs), "specs[0] should not have additional property 'invalid'"); + assert.strictEqual(check(specs), "specs/0 must not have additional property 'invalid'"); }); });