diff --git a/lib/specifications/SpecificationVersion.js b/lib/specifications/SpecificationVersion.js index ae48edee3..2634fe944 100644 --- a/lib/specifications/SpecificationVersion.js +++ b/lib/specifications/SpecificationVersion.js @@ -4,7 +4,7 @@ const SPEC_VERSION_PATTERN = /^\d+\.\d+$/; const SUPPORTED_VERSIONS = [ "0.1", "1.0", "1.1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", - "3.0" + "3.0", "3.1" ]; /** @@ -63,8 +63,8 @@ class SpecificationVersion { * Test whether the instance's Specification Version falls into the provided range * * @public -@param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range, -for example 2.2 - 2.4 + * @param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range, + * for example 2.2 - 2.4 or =3.0 * @returns {boolean} True if the instance's Specification Version falls into the provided range */ satisfies(range) { @@ -263,6 +263,22 @@ for example 2.2 - 2.4 const comparator = new SpecificationVersion(specVersion); return comparator.neq(testVersion); } + + /** + * Creates an array of Specification Versions that match with the provided range. This is mainly used + * for testing purposes. I.e. to execute identical tests for a range of specification versions. + * + * @public + * @param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range, + * for example 2.2 - 2.4 or =3.0 + * @returns {string[]} Array of versions that match the specified range + */ + static getVersionsForRange(range) { + return SUPPORTED_VERSIONS.filter((specVersion) => { + const comparator = new SpecificationVersion(specVersion); + return comparator.satisfies(range); + }); + } } function getUnsupportedSpecVersionMessage(specVersion) { diff --git a/lib/specifications/types/Application.js b/lib/specifications/types/Application.js index 05303eb92..9506c74b9 100644 --- a/lib/specifications/types/Application.js +++ b/lib/specifications/types/Application.js @@ -66,11 +66,17 @@ class Application extends ComponentProject { return null; // Applications do not have a dedicated test directory } + /** + * Get a resource reader for the sources of the project (excluding any test resources) + * without a virtual base path + * + * @returns {@ui5/fs/ReaderCollection} Reader collection + */ _getRawSourceReader() { return createReader({ fsBasePath: this.getSourcePath(), virBasePath: "/", - name: `Source reader for application project ${this.getName()}`, + name: `Raw source reader for application project ${this.getName()}`, project: this }); } diff --git a/lib/specifications/types/Library.js b/lib/specifications/types/Library.js index 064568570..d3d2059a0 100644 --- a/lib/specifications/types/Library.js +++ b/lib/specifications/types/Library.js @@ -107,9 +107,10 @@ class Library extends ComponentProject { } /** - * * Get a resource reader for the sources of the project (excluding any test resources) + * without a virtual base path. * In the future the path structure can be flat or namespaced depending on the project + * setup * * @returns {@ui5/fs/ReaderCollection} Reader collection */ @@ -117,7 +118,7 @@ class Library extends ComponentProject { return resourceFactory.createReader({ fsBasePath: this.getSourcePath(), virBasePath: "/", - name: `Source reader for library project ${this.getName()}`, + name: `Raw source reader for library project ${this.getName()}`, project: this }); } diff --git a/lib/validation/schema/specVersion/kind/extension.json b/lib/validation/schema/specVersion/kind/extension.json index 27bf6005c..633aaea6b 100644 --- a/lib/validation/schema/specVersion/kind/extension.json +++ b/lib/validation/schema/specVersion/kind/extension.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion", "kind", "type", "metadata"], "properties": { - "specVersion": { "enum": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/kind/extension/project-shim.json b/lib/validation/schema/specVersion/kind/extension/project-shim.json index 415785f1d..cb5a4dbfa 100644 --- a/lib/validation/schema/specVersion/kind/extension/project-shim.json +++ b/lib/validation/schema/specVersion/kind/extension/project-shim.json @@ -6,14 +6,14 @@ "required": ["specVersion", "kind", "type", "metadata", "shims"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { "specVersion": { - "enum": ["3.0"] + "enum": ["3.0", "3.1"] }, "kind": { "enum": ["extension"] diff --git a/lib/validation/schema/specVersion/kind/extension/server-middleware.json b/lib/validation/schema/specVersion/kind/extension/server-middleware.json index a65db5b56..1b46323be 100644 --- a/lib/validation/schema/specVersion/kind/extension/server-middleware.json +++ b/lib/validation/schema/specVersion/kind/extension/server-middleware.json @@ -7,13 +7,13 @@ "required": ["specVersion", "kind", "type", "metadata", "middleware"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.0", "3.1"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/kind/extension/task.json b/lib/validation/schema/specVersion/kind/extension/task.json index f19291e0c..7e02c82eb 100644 --- a/lib/validation/schema/specVersion/kind/extension/task.json +++ b/lib/validation/schema/specVersion/kind/extension/task.json @@ -6,13 +6,13 @@ "required": ["specVersion", "kind", "type", "metadata", "task"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.0", "3.1"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/kind/project.json b/lib/validation/schema/specVersion/kind/project.json index f42fa8a2b..65191e05f 100644 --- a/lib/validation/schema/specVersion/kind/project.json +++ b/lib/validation/schema/specVersion/kind/project.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion", "type"], "properties": { - "specVersion": { "enum": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, "kind": { "enum": ["project", null], "$comment": "Using null to allow not defining 'kind' which defaults to project" @@ -19,6 +19,7 @@ ] } }, + "if": { "properties": { "type": {"const": null} diff --git a/lib/validation/schema/specVersion/kind/project/application.json b/lib/validation/schema/specVersion/kind/project/application.json index 81073634a..1091be04e 100644 --- a/lib/validation/schema/specVersion/kind/project/application.json +++ b/lib/validation/schema/specVersion/kind/project/application.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.0", "3.1"] }, "kind": { "enum": ["project", null] }, diff --git a/lib/validation/schema/specVersion/kind/project/library.json b/lib/validation/schema/specVersion/kind/project/library.json index d36a1f83e..d5114b633 100644 --- a/lib/validation/schema/specVersion/kind/project/library.json +++ b/lib/validation/schema/specVersion/kind/project/library.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.0", "3.1"] }, "kind": { "enum": ["project", null] }, diff --git a/lib/validation/schema/specVersion/kind/project/module.json b/lib/validation/schema/specVersion/kind/project/module.json index 9684f27d1..e6fe250b8 100644 --- a/lib/validation/schema/specVersion/kind/project/module.json +++ b/lib/validation/schema/specVersion/kind/project/module.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.1"] }, "kind": { "enum": ["project", null] }, @@ -26,7 +26,7 @@ "$ref": "#/definitions/resources" }, "builder": { - "$ref": "#/definitions/builder-specVersion-2.5" + "$ref": "#/definitions/builder-specVersion-3.1" }, "server": { "$ref": "../project.json#/definitions/server" @@ -40,13 +40,13 @@ "else": { "if": { "properties": { - "specVersion": { "enum": ["2.5", "2.6"] } + "specVersion": { "enum": ["3.0"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.5", "2.6"] }, + "specVersion": { "enum": ["3.0"] }, "kind": { "enum": ["project", null] }, @@ -54,7 +54,7 @@ "enum": ["module"] }, "metadata": { - "$ref": "../project.json#/definitions/metadata" + "$ref": "../project.json#/definitions/metadata-3.0" }, "resources": { "$ref": "#/definitions/resources" @@ -74,13 +74,13 @@ "else": { "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] } + "specVersion": { "enum": ["2.5", "2.6"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] }, + "specVersion": { "enum": ["2.5", "2.6"] }, "kind": { "enum": ["project", null] }, @@ -93,6 +93,12 @@ "resources": { "$ref": "#/definitions/resources" }, + "builder": { + "$ref": "#/definitions/builder-specVersion-2.5" + }, + "server": { + "$ref": "../project.json#/definitions/server" + }, "customConfiguration": { "type": "object", "additionalProperties": true @@ -100,20 +106,49 @@ } }, "else": { - "additionalProperties": false, - "properties": { - "specVersion": { "enum": ["2.0"] }, - "kind": { - "enum": ["project", null] - }, - "type": { - "enum": ["module"] - }, - "metadata": { - "$ref": "../project.json#/definitions/metadata" - }, - "resources": { - "$ref": "#/definitions/resources" + "if": { + "properties": { + "specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] } + } + }, + "then": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["module"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "resources": { + "$ref": "#/definitions/resources" + }, + "customConfiguration": { + "type": "object", + "additionalProperties": true + } + } + }, + "else": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.0"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["module"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "resources": { + "$ref": "#/definitions/resources" + } } } } @@ -149,6 +184,18 @@ "$ref": "../project.json#/definitions/builder-settings" } } + }, + "builder-specVersion-3.1": { + "type": "object", + "additionalProperties": false, + "properties": { + "resources": { + "$ref": "../project.json#/definitions/builder-resources" + }, + "settings": { + "$ref": "../project.json#/definitions/builder-settings" + } + } } } } diff --git a/lib/validation/schema/specVersion/kind/project/theme-library.json b/lib/validation/schema/specVersion/kind/project/theme-library.json index 522b7064a..44f3f2aa5 100644 --- a/lib/validation/schema/specVersion/kind/project/theme-library.json +++ b/lib/validation/schema/specVersion/kind/project/theme-library.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["3.0"] } + "specVersion": { "enum": ["3.0", "3.1"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["3.0"] }, + "specVersion": { "enum": ["3.0", "3.1"] }, "kind": { "enum": ["project", null] }, diff --git a/lib/validation/schema/specVersion/specVersion.json b/lib/validation/schema/specVersion/specVersion.json index 16458d467..6debcbd3e 100644 --- a/lib/validation/schema/specVersion/specVersion.json +++ b/lib/validation/schema/specVersion/specVersion.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion"], "properties": { - "specVersion": { "enum": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }, "kind": { "enum": ["project", "extension", null], "$comment": "Using null to allow not defining 'kind' which defaults to project" diff --git a/lib/validation/schema/ui5.json b/lib/validation/schema/ui5.json index 59af95301..61795c909 100644 --- a/lib/validation/schema/ui5.json +++ b/lib/validation/schema/ui5.json @@ -10,17 +10,17 @@ "properties": { "specVersion": { "enum": [ - "3.0", + "3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0", "1.1", "1.0", "0.1" ], - "errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"3.0\", \"2.6\", \"2.5\", \"2.4\", \"2.3\", \"2.2\", \"2.1\", \"2.0\", \"1.1\", \"1.0\", \"0.1\"\nFor details, see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions" + "errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"3.1\", \"3.0\", \"2.6\", \"2.5\", \"2.4\", \"2.3\", \"2.2\", \"2.1\", \"2.0\", \"1.1\", \"1.0\", \"0.1\"\nFor details, see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions" } }, "if": { "properties": { - "specVersion": { "enum": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] } + "specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] } } }, "then": { diff --git a/test/lib/specifications/SpecificationVersion.js b/test/lib/specifications/SpecificationVersion.js index b50aa010d..64efc696f 100644 --- a/test/lib/specifications/SpecificationVersion.js +++ b/test/lib/specifications/SpecificationVersion.js @@ -67,6 +67,12 @@ test("(instance) satisfies", (t) => { t.is(new SpecificationVersion("2.2").satisfies("^2.2"), true); t.is(new SpecificationVersion("2.3").satisfies("^2.2"), true); + // range: >=2.2 + t.is(new SpecificationVersion("2.1").satisfies(">=2.2"), false); + t.is(new SpecificationVersion("2.2").satisfies(">=2.2"), true); + t.is(new SpecificationVersion("2.3").satisfies(">=2.2"), true); + t.is(new SpecificationVersion("3.1").satisfies(">=2.2"), true); + // range: > 1.0 t.is(new SpecificationVersion("1.0").satisfies("> 1.0"), false); t.is(new SpecificationVersion("1.1").satisfies("> 1.0"), true); @@ -162,6 +168,12 @@ test("(static) satisfies", (t) => { t.is(SpecificationVersion.satisfies("2.2", "^2.2"), true); t.is(SpecificationVersion.satisfies("2.3", "^2.2"), true); + // range: >=2.2 + t.is(SpecificationVersion.satisfies("2.1", ">=2.2"), false); + t.is(SpecificationVersion.satisfies("2.2", ">=2.2"), true); + t.is(SpecificationVersion.satisfies("2.3", ">=2.2"), true); + t.is(SpecificationVersion.satisfies("3.1", ">=2.2"), true); + // range: > 1.0 t.is(SpecificationVersion.satisfies("1.0", "> 1.0"), false); t.is(SpecificationVersion.satisfies("1.1", "> 1.0"), true); @@ -212,6 +224,45 @@ test("(static) low level comparator", (t) => { t.is(SpecificationVersion.neq("2.2", "2.2"), false); }); +test("(static) getVersionsForRange", (t) => { + // range: 1.x + t.deepEqual(SpecificationVersion.getVersionsForRange("1.x"), [ + "1.0", "1.1" + ]); + + // range: ^2.2 + t.deepEqual(SpecificationVersion.getVersionsForRange("^2.2"), [ + "2.2", "2.3", "2.4", "2.5", "2.6" + ]); + + // range: >=2.2 + t.deepEqual(SpecificationVersion.getVersionsForRange(">=2.2"), [ + "2.2", "2.3", "2.4", "2.5", "2.6", + "3.0", "3.1", + ]); + + // range: > 1.0 + t.deepEqual(SpecificationVersion.getVersionsForRange("> 1.0"), [ + "1.1", + "2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", + "3.0", "3.1", + ]); + + // range: 2.2 - 2.4 + t.deepEqual(SpecificationVersion.getVersionsForRange("2.2 - 2.4"), [ + "2.2", "2.3", "2.4" + ]); + + // range: 0.1 || 1.0 - 1.1 || ^2.5 + t.deepEqual(SpecificationVersion.getVersionsForRange("0.1 || 1.0 - 1.1 || ^2.5"), [ + "0.1", "1.0", "1.1", + "2.5", "2.6" + ]); + + // Incorrect range returns empty array + t.deepEqual(SpecificationVersion.getVersionsForRange("not a range"), []); +}); + test("getSemverCompatibleVersion", (t) => { t.is(__localFunctions__.getSemverCompatibleVersion("0.1"), "0.1.0"); t.is(__localFunctions__.getSemverCompatibleVersion("1.1"), "1.1.0"); diff --git a/test/lib/validation/schema/__helper__/builder-bundleOptions.js b/test/lib/validation/schema/__helper__/builder-bundleOptions.js index 1ba0be8da..b87e12813 100644 --- a/test/lib/validation/schema/__helper__/builder-bundleOptions.js +++ b/test/lib/validation/schema/__helper__/builder-bundleOptions.js @@ -1,3 +1,5 @@ +import SpecificationVersion from "../../../../../lib/specifications/SpecificationVersion.js"; + /** * Common test functionality for builder/bundles/bundleOptions section in config */ @@ -7,11 +9,11 @@ export default { * * @param {Function} test ava test * @param {Function} assertValidation assertion function - * @param {string} type one of "application" and "library" + * @param {string} type one of "application", "library" */ defineTests: function(test, assertValidation, type) { // Version specific tests - ["3.0"].forEach(function(specVersion) { + SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`${type} (specVersion ${specVersion}): builder/bundles/bundleOptions`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/__helper__/customConfiguration.js b/test/lib/validation/schema/__helper__/customConfiguration.js index 356cce67b..34db358c9 100644 --- a/test/lib/validation/schema/__helper__/customConfiguration.js +++ b/test/lib/validation/schema/__helper__/customConfiguration.js @@ -1,9 +1,12 @@ +import SpecificationVersion from "../../../../../lib/specifications/SpecificationVersion.js"; + /** * Common test functionality for customConfiguration section in config */ export default { /** - * Executes the tests for different kind of projects, e.g. "application", "library", "theme-library" and "module" + * Executes the tests for different kind of projects, + * e.g. "application", "library", "theme-library" and "module" * * @param {Function} test ava test * @param {Function} assertValidation assertion function @@ -13,7 +16,6 @@ export default { */ defineTests: function(test, assertValidation, type, additionalConfiguration) { additionalConfiguration = additionalConfiguration || {}; - // version specific tests for customConfiguration test(`${type}: Invalid customConfiguration (specVersion 2.0)`, async (t) => { await assertValidation(t, Object.assign({ @@ -35,7 +37,7 @@ export default { ]); }); - ["2.6", "2.5", "2.4", "2.3", "2.2", "2.1"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=2.1").forEach((specVersion) => { test(`${type}: Valid customConfiguration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, Object.assign( { "specVersion": specVersion, diff --git a/test/lib/validation/schema/__helper__/extension.js b/test/lib/validation/schema/__helper__/extension.js index 69eb7d155..516bc889c 100644 --- a/test/lib/validation/schema/__helper__/extension.js +++ b/test/lib/validation/schema/__helper__/extension.js @@ -1,3 +1,4 @@ +import SpecificationVersion from "../../../../../lib/specifications/SpecificationVersion.js"; import customConfiguration from "./customConfiguration.js"; /** @@ -18,7 +19,7 @@ export default { customConfiguration.defineTests(test, assertValidation, type, additionalConfiguration); - ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { test(`kind: extension / type: ${type} basic (${specVersion})`, async (t) => { await assertValidation(t, Object.assign({ "specVersion": specVersion, @@ -67,7 +68,7 @@ export default { }); }); - ["2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange("2.0 - 2.6").forEach((specVersion) => { test(`kind: extension / type: ${type}: Invalid metadata.name (${specVersion})`, async (t) => { await assertValidation(t, Object.assign({ "specVersion": specVersion, @@ -86,7 +87,7 @@ export default { }); }); - ["3.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=3.0").forEach((specVersion) => { test(`kind: extension / type: ${type}: Invalid metadata.name (${specVersion})`, async (t) => { await assertValidation(t, Object.assign({ "specVersion": specVersion, diff --git a/test/lib/validation/schema/__helper__/framework.js b/test/lib/validation/schema/__helper__/framework.js index d8d5ffd22..841ce8fc7 100644 --- a/test/lib/validation/schema/__helper__/framework.js +++ b/test/lib/validation/schema/__helper__/framework.js @@ -1,16 +1,19 @@ +import SpecificationVersion from "../../../../../lib/specifications/SpecificationVersion.js"; + /** * Common test functionality for framework section in config */ export default { /** - * Executes the tests for different types of kind project, e.g. "application", "library" and "theme-library" + * Executes the tests for different types of kind project, + * e.g. "application", library" and "theme-library" * * @param {Function} test ava test * @param {Function} assertValidation assertion function - * @param {string} type one of "application", "library" and "theme-library" + * @param {string} type one of "application", library" and "theme-library" */ defineTests: function(test, assertValidation, type) { - ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { test(`${type} (specVersion ${specVersion}): framework configuration: OpenUI5`, async (t) => { const config = { "specVersion": specVersion, diff --git a/test/lib/validation/schema/__helper__/project.js b/test/lib/validation/schema/__helper__/project.js index 8d58ada78..baddd13c6 100644 --- a/test/lib/validation/schema/__helper__/project.js +++ b/test/lib/validation/schema/__helper__/project.js @@ -1,3 +1,4 @@ +import SpecificationVersion from "../../../../../lib/specifications/SpecificationVersion.js"; import framework from "./framework.js"; import customConfiguration from "./customConfiguration.js"; import bundleOptions from "./builder-bundleOptions.js"; @@ -29,7 +30,7 @@ export default { } // version specific tests - ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { // tests for all kinds and version 2.0 and above test(`${type} (specVersion ${specVersion}): No metadata`, async (t) => { await assertValidation(t, { @@ -281,7 +282,7 @@ export default { }); }); - ["3.0"].forEach((specVersion) => { + SpecificationVersion.getVersionsForRange(">=3.0").forEach((specVersion) => { test(`${type} (specVersion ${specVersion}): Invalid metadata.name`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/extension.js b/test/lib/validation/schema/specVersion/kind/extension.js index 8fefe5bbe..54fbb1fdc 100644 --- a/test/lib/validation/schema/specVersion/kind/extension.js +++ b/test/lib/validation/schema/specVersion/kind/extension.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../lib/validation/ValidationError.js"; @@ -38,7 +39,8 @@ test.after.always((t) => { }; t.context.ajvCoverage.verify(thresholds); }); -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { + +SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { test(`Type project-shim (${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/extension/project-shim.js b/test/lib/validation/schema/specVersion/kind/extension/project-shim.js index daff1b0bb..dfad329fe 100644 --- a/test/lib/validation/schema/specVersion/kind/extension/project-shim.js +++ b/test/lib/validation/schema/specVersion/kind/extension/project-shim.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { +SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { test(`kind: extension / type: project-shim (${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -127,7 +128,7 @@ test.after.always((t) => { }); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid extension name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/extension/server-middleware.js b/test/lib/validation/schema/specVersion/kind/extension/server-middleware.js index f887078eb..39b5efe6f 100644 --- a/test/lib/validation/schema/specVersion/kind/extension/server-middleware.js +++ b/test/lib/validation/schema/specVersion/kind/extension/server-middleware.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid extension name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/extension/task.js b/test/lib/validation/schema/specVersion/kind/extension/task.js index a9dfe9452..f2a6a1017 100644 --- a/test/lib/validation/schema/specVersion/kind/extension/task.js +++ b/test/lib/validation/schema/specVersion/kind/extension/task.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid extension name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/project/application.js b/test/lib/validation/schema/specVersion/kind/project/application.js index 54cf855f5..ca005d415 100644 --- a/test/lib/validation/schema/specVersion/kind/project/application.js +++ b/test/lib/validation/schema/specVersion/kind/project/application.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.0").forEach(function(specVersion) { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -435,7 +436,7 @@ test.after.always((t) => { keyword: "enum", message: "should be equal to one of the allowed values", params: { - allowedValues: ["3.0", "2.6", "2.5", "2.4"].includes(specVersion) ? [ + allowedValues: ["3.1", "3.0", "2.6", "2.5", "2.4"].includes(specVersion) ? [ "raw", "preload", "require", @@ -509,7 +510,7 @@ test.after.always((t) => { }); }); -["2.2", "2.1", "2.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange("2.0 - 2.2").forEach(function(specVersion) { test(`Unsupported builder/componentPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -539,7 +540,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5", "2.4", "2.3"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.3").forEach(function(specVersion) { test(`application (specVersion ${specVersion}): builder/componentPreload/excludes`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -636,7 +637,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5", "2.4"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.4").forEach(function(specVersion) { // Unsupported cases for older spec-versions already tested via "allowedValues" comparison above test(`application (specVersion ${specVersion}): builder/bundles/bundleDefinition/sections/mode: bundleInfo`, async (t) => { @@ -664,7 +665,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.5").forEach(function(specVersion) { test(`application (specVersion ${specVersion}): builder/settings/includeDependency*`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -845,7 +846,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.6").forEach(function(specVersion) { test(`application (specVersion ${specVersion}): builder/minification/excludes`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -942,7 +943,7 @@ test.after.always((t) => { }); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid project name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/project/library.js b/test/lib/validation/schema/specVersion/kind/project/library.js index 59c3a9649..baf248fa1 100644 --- a/test/lib/validation/schema/specVersion/kind/project/library.js +++ b/test/lib/validation/schema/specVersion/kind/project/library.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.0").forEach(function(specVersion) { test(`library (specVersion ${specVersion}): Valid configuration`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -401,7 +402,7 @@ test.after.always((t) => { keyword: "enum", message: "should be equal to one of the allowed values", params: { - allowedValues: ["3.0", "2.6", "2.5", "2.4"].includes(specVersion) ? [ + allowedValues: ["3.1", "3.0", "2.6", "2.5", "2.4"].includes(specVersion) ? [ "raw", "preload", "require", @@ -564,7 +565,7 @@ test.after.always((t) => { }); }); -["2.2", "2.1", "2.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange("2.0 - 2.2").forEach(function(specVersion) { test(`Unsupported builder/libraryPreload configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -616,7 +617,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5", "2.4", "2.3"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.3").forEach(function(specVersion) { test(`library (specVersion ${specVersion}): builder/libraryPreload/excludes`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -809,7 +810,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5", "2.4"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.4").forEach(function(specVersion) { // Unsupported cases for older spec-versions already tested via "allowedValues" comparison above test(`library (specVersion ${specVersion}): builder/bundles/bundleDefinition/sections/mode: bundleInfo`, async (t) => { @@ -837,7 +838,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.5").forEach(function(specVersion) { test(`library (specVersion ${specVersion}): builder/settings/includeDependency*`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -1018,7 +1019,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.6").forEach(function(specVersion) { test(`library (specVersion ${specVersion}): builder/minification/excludes`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -1115,7 +1116,7 @@ test.after.always((t) => { }); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid project name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/specVersion/kind/project/module.js b/test/lib/validation/schema/specVersion/kind/project/module.js index 4c3b4715c..e49b4769c 100644 --- a/test/lib/validation/schema/specVersion/kind/project/module.js +++ b/test/lib/validation/schema/specVersion/kind/project/module.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,7 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { +SpecificationVersion.getVersionsForRange(">=2.0").forEach((specVersion) => { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -106,7 +107,7 @@ test.after.always((t) => { }); }); -["2.4", "2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { +SpecificationVersion.getVersionsForRange("2.0 - 2.4").forEach((specVersion) => { test(`No server configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -144,7 +145,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.5").forEach(function(specVersion) { test(`Server configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -349,7 +350,7 @@ test.after.always((t) => { }); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid project name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -417,4 +418,25 @@ test.after.always((t) => { }); }); +SpecificationVersion.getVersionsForRange(">=3.1").forEach(function(specVersion) { + test(`Builder resource excludes (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "kind": "project", + "type": "module", + "metadata": { + "name": "my-module" + }, + "builder": { + "resources": { + "excludes": [ + "/resources/some/project/name/test_results/**", + "!/test-resources/some/project/name/demo-app/**" + ] + } + } + }); + }); +}); + project.defineTests(test, assertValidation, "module"); diff --git a/test/lib/validation/schema/specVersion/kind/project/theme-library.js b/test/lib/validation/schema/specVersion/kind/project/theme-library.js index fb0273e1c..eff5bdbf0 100644 --- a/test/lib/validation/schema/specVersion/kind/project/theme-library.js +++ b/test/lib/validation/schema/specVersion/kind/project/theme-library.js @@ -1,6 +1,7 @@ import test from "ava"; import Ajv from "ajv"; import ajvErrors from "ajv-errors"; +import SpecificationVersion from "../../../../../../../lib/specifications/SpecificationVersion.js"; import AjvCoverage from "../../../../../../utils/AjvCoverage.js"; import {_Validator as Validator} from "../../../../../../../lib/validation/validator.js"; import ValidationError from "../../../../../../../lib/validation/ValidationError.js"; @@ -45,8 +46,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); - -["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.0").forEach(function(specVersion) { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -167,7 +167,7 @@ test.after.always((t) => { }); }); -["3.0", "2.6", "2.5"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=2.5").forEach(function(specVersion) { test(`theme-library (specVersion ${specVersion}): builder/settings/includeDependency*`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -348,7 +348,7 @@ test.after.always((t) => { }); }); -["3.0"].forEach(function(specVersion) { +SpecificationVersion.getVersionsForRange(">=3.0").forEach(function(specVersion) { test(`Invalid project name (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, diff --git a/test/lib/validation/schema/ui5.js b/test/lib/validation/schema/ui5.js index 433aed2a5..8cc1c77d7 100644 --- a/test/lib/validation/schema/ui5.js +++ b/test/lib/validation/schema/ui5.js @@ -102,7 +102,7 @@ test("Invalid specVersion", async (t) => { message: `Unsupported "specVersion" Your UI5 CLI installation might be outdated. -Supported specification versions: "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0", "1.1", "1.0", "0.1" +Supported specification versions: "3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0", "1.1", "1.0", "0.1" For details, see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions`, params: { errors: [ @@ -112,6 +112,7 @@ For details, see: https://sap.github.io/ui5-tooling/pages/Configuration/#specifi message: "should be equal to one of the allowed values", params: { allowedValues: [ + "3.1", "3.0", "2.6", "2.5",