From 3e280267b60a9a72183d5ab0905d838b6fcfaf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20O=C3=9Fwald?= <1410947+matz3@users.noreply.github.com> Date: Tue, 9 Feb 2021 17:34:32 +0100 Subject: [PATCH] [FEATURE] specVersion 2.3 (#388) - Adds libraryPreload/componentPreload excludes configuration JIRA: CPOUI5FOUNDATION-233 --- lib/projectPreprocessor.js | 6 +- lib/translators/ui5Framework.js | 12 +- lib/validation/schema/specVersion/2.0.json | 2 +- .../specVersion/2.0/kind/extension.json | 2 +- .../2.0/kind/extension/project-shim.json | 4 +- .../2.0/kind/extension/server-middleware.json | 4 +- .../specVersion/2.0/kind/extension/task.json | 4 +- .../schema/specVersion/2.0/kind/project.json | 38 +- .../2.0/kind/project/application.json | 117 ++++-- .../specVersion/2.0/kind/project/library.json | 138 +++++-- .../specVersion/2.0/kind/project/module.json | 4 +- .../2.0/kind/project/theme-library.json | 4 +- lib/validation/schema/ui5.json | 6 +- test/lib/extensions.js | 40 ++ test/lib/projectPreprocessor.js | 16 + .../schema/__helper__/customConfiguration.js | 5 +- .../validation/schema/__helper__/extension.js | 9 +- .../validation/schema/__helper__/framework.js | 58 +-- .../validation/schema/__helper__/project.js | 30 +- .../schema/specVersion/2.0/kind/extension.js | 17 +- .../2.0/kind/extension/project-shim.js | 20 +- .../2.0/kind/extension/server-middleware.js | 3 + .../specVersion/2.0/kind/extension/task.js | 3 + .../schema/specVersion/2.0/kind/project.js | 15 +- .../2.0/kind/project/application.js | 232 +++++++---- .../specVersion/2.0/kind/project/library.js | 364 ++++++++++++++---- .../specVersion/2.0/kind/project/module.js | 17 +- .../2.0/kind/project/theme-library.js | 42 +- test/lib/validation/schema/ui5.js | 35 +- 29 files changed, 883 insertions(+), 364 deletions(-) diff --git a/lib/projectPreprocessor.js b/lib/projectPreprocessor.js index fae7a620a..451bc7e11 100644 --- a/lib/projectPreprocessor.js +++ b/lib/projectPreprocessor.js @@ -282,7 +282,8 @@ class ProjectPreprocessor { if (project.specVersion !== "0.1" && project.specVersion !== "1.0" && project.specVersion !== "1.1" && project.specVersion !== "2.0" && - project.specVersion !== "2.1" && project.specVersion !== "2.2") { + project.specVersion !== "2.1" && project.specVersion !== "2.2" && + project.specVersion !== "2.3") { throw new Error( `Unsupported specification version ${project.specVersion} defined for project ` + `${project.id}. Your UI5 CLI installation might be outdated. ` + @@ -359,7 +360,8 @@ class ProjectPreprocessor { extension.specVersion !== "1.1" && extension.specVersion !== "2.0" && extension.specVersion !== "2.1" && - extension.specVersion !== "2.2") { + extension.specVersion !== "2.2" && + extension.specVersion !== "2.3") { throw new Error( `Unsupported specification version ${extension.specVersion} defined for extension ` + `${extension.metadata.name}. Your UI5 CLI installation might be outdated. ` + diff --git a/lib/translators/ui5Framework.js b/lib/translators/ui5Framework.js index 09eb4f866..7f550b560 100644 --- a/lib/translators/ui5Framework.js +++ b/lib/translators/ui5Framework.js @@ -83,7 +83,10 @@ const utils = { if (!project.framework) { return; } - if (project.specVersion !== "2.0" && project.specVersion !== "2.1" && project.specVersion !== "2.2") { + if ( + project.specVersion !== "2.0" && project.specVersion !== "2.1" && + project.specVersion !== "2.2" && project.specVersion !== "2.3" + ) { log.warn(`Project ${project.metadata.name} defines invalid ` + `specification version ${project.specVersion} for framework.libraries configuration`); return; @@ -241,8 +244,11 @@ module.exports = { }); queue.push(...project.dependencies); - if ((project.specVersion === "2.0" || project.specVersion === "2.1" || project.specVersion === "2.2") && - project.framework && project.framework.libraries) { + if ( + ( + project.specVersion === "2.0" || project.specVersion === "2.1" || + project.specVersion === "2.2" || project.specVersion === "2.3" + ) && project.framework && project.framework.libraries) { const frameworkDeps = project.framework.libraries .filter((dependency) => { if (dependency.optional && frameworkLibs[dependency.name]) { diff --git a/lib/validation/schema/specVersion/2.0.json b/lib/validation/schema/specVersion/2.0.json index 35a7eac0b..dd569fc0e 100644 --- a/lib/validation/schema/specVersion/2.0.json +++ b/lib/validation/schema/specVersion/2.0.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion"], "properties": { - "specVersion": { "enum": ["2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["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/specVersion/2.0/kind/extension.json b/lib/validation/schema/specVersion/2.0/kind/extension.json index fcff79e40..37c1ef9de 100644 --- a/lib/validation/schema/specVersion/2.0/kind/extension.json +++ b/lib/validation/schema/specVersion/2.0/kind/extension.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion", "kind", "type", "metadata"], "properties": { - "specVersion": { "enum": ["2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["2.3", "2.2", "2.1", "2.0"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.json b/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.json index cfafd1834..b62b77e35 100644 --- a/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.json +++ b/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.json @@ -6,14 +6,14 @@ "required": ["specVersion", "kind", "type", "metadata", "shims"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.1", "2.2", "2.3"] } } }, "then": { "additionalProperties": false, "properties": { "specVersion": { - "enum": ["2.1", "2.2"] + "enum": ["2.1", "2.2", "2.3"] }, "kind": { "enum": ["extension"] diff --git a/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.json b/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.json index 3f37e16be..0e227f4a3 100644 --- a/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.json +++ b/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.json @@ -7,13 +7,13 @@ "required": ["specVersion", "kind", "type", "metadata", "middleware"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.1", "2.2", "2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.1", "2.2", "2.3"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/2.0/kind/extension/task.json b/lib/validation/schema/specVersion/2.0/kind/extension/task.json index 8656ef15a..496d73cba 100644 --- a/lib/validation/schema/specVersion/2.0/kind/extension/task.json +++ b/lib/validation/schema/specVersion/2.0/kind/extension/task.json @@ -6,13 +6,13 @@ "required": ["specVersion", "kind", "type", "metadata", "task"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.1", "2.2", "2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.1", "2.2", "2.3"] }, "kind": { "enum": ["extension"] }, diff --git a/lib/validation/schema/specVersion/2.0/kind/project.json b/lib/validation/schema/specVersion/2.0/kind/project.json index 6f86b942a..13f83e353 100644 --- a/lib/validation/schema/specVersion/2.0/kind/project.json +++ b/lib/validation/schema/specVersion/2.0/kind/project.json @@ -5,7 +5,7 @@ "type": "object", "required": ["specVersion", "type"], "properties": { - "specVersion": { "enum": ["2.2", "2.1", "2.0"] }, + "specVersion": { "enum": ["2.3", "2.2", "2.1", "2.0"] }, "kind": { "enum": ["project", null], "$comment": "Using null to allow not defining 'kind' which defaults to project" @@ -223,6 +223,42 @@ } } }, + "builder-componentPreload-specVersion-2.3": { + "type": "object", + "additionalProperties": false, + "properties": { + "paths": { + "type": "array", + "items": { + "type": "string" + } + }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, + "excludes": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "builder-libraryPreload": { + "type": "object", + "additionalProperties": false, + "properties": { + "excludes": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "server": { "type": "object", "additionalProperties": false, diff --git a/lib/validation/schema/specVersion/2.0/kind/project/application.json b/lib/validation/schema/specVersion/2.0/kind/project/application.json index 3ce92af51..c48a5cbac 100644 --- a/lib/validation/schema/specVersion/2.0/kind/project/application.json +++ b/lib/validation/schema/specVersion/2.0/kind/project/application.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.3"] }, "kind": { "enum": ["project", null] }, @@ -29,7 +29,7 @@ "$ref": "#/definitions/resources" }, "builder": { - "$ref": "#/definitions/builder" + "$ref": "#/definitions/builder-specVersion-2.3" }, "server": { "$ref": "../project.json#/definitions/server" @@ -41,29 +41,67 @@ } }, "else": { - "additionalProperties": false, - "properties": { - "specVersion": { "enum": ["2.0"] }, - "kind": { - "enum": ["project", null] - }, - "type": { - "enum": ["application"] - }, - "metadata": { - "$ref": "../project.json#/definitions/metadata" - }, - "framework": { - "$ref": "../project.json#/definitions/framework" - }, - "resources": { - "$ref": "#/definitions/resources" - }, - "builder": { - "$ref": "#/definitions/builder" - }, - "server": { - "$ref": "../project.json#/definitions/server" + "if": { + "properties": { + "specVersion": { "enum": ["2.1", "2.2"] } + } + }, + "then": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.1", "2.2"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["application"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "framework": { + "$ref": "../project.json#/definitions/framework" + }, + "resources": { + "$ref": "#/definitions/resources" + }, + "builder": { + "$ref": "#/definitions/builder" + }, + "server": { + "$ref": "../project.json#/definitions/server" + }, + "customConfiguration": { + "type": "object", + "additionalProperties": true + } + } + }, + "else": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.0"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["application"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "framework": { + "$ref": "../project.json#/definitions/framework" + }, + "resources": { + "$ref": "#/definitions/resources" + }, + "builder": { + "$ref": "#/definitions/builder" + }, + "server": { + "$ref": "../project.json#/definitions/server" + } } } }, @@ -121,6 +159,33 @@ "$ref": "../project.json#/definitions/customTasks" } } + }, + "builder-specVersion-2.3": { + "type": "object", + "additionalProperties": false, + "properties": { + "resources": { + "$ref": "../project.json#/definitions/builder-resources" + }, + "cachebuster": { + "type": "object", + "additionalProperties": false, + "properties": { + "signatureType": { + "enum": ["time", "hash"] + } + } + }, + "bundles": { + "$ref": "../project.json#/definitions/builder-bundles" + }, + "componentPreload": { + "$ref": "../project.json#/definitions/builder-componentPreload-specVersion-2.3" + }, + "customTasks": { + "$ref": "../project.json#/definitions/customTasks" + } + } } } } diff --git a/lib/validation/schema/specVersion/2.0/kind/project/library.json b/lib/validation/schema/specVersion/2.0/kind/project/library.json index cd2086013..2e4f0cbbc 100644 --- a/lib/validation/schema/specVersion/2.0/kind/project/library.json +++ b/lib/validation/schema/specVersion/2.0/kind/project/library.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.3"] }, "kind": { "enum": ["project", null] }, @@ -29,7 +29,7 @@ "$ref": "#/definitions/resources" }, "builder": { - "$ref": "#/definitions/builder" + "$ref": "#/definitions/builder-specVersion-2.3" }, "server": { "$ref": "../project.json#/definitions/server" @@ -41,33 +41,70 @@ } }, "else": { - "additionalProperties": false, - "properties": { - "specVersion": { "enum": ["2.0"] }, - "kind": { - "enum": ["project", null] - }, - "type": { - "enum": ["library"] - }, - "metadata": { - "$ref": "../project.json#/definitions/metadata" - }, - "framework": { - "$ref": "../project.json#/definitions/framework" - }, - "resources": { - "$ref": "#/definitions/resources" - }, - "builder": { - "$ref": "#/definitions/builder" - }, - "server": { - "$ref": "../project.json#/definitions/server" + "if": { + "properties": { + "specVersion": { "enum": ["2.1", "2.2"] } + } + }, + "then": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.1", "2.2"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["library"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "framework": { + "$ref": "../project.json#/definitions/framework" + }, + "resources": { + "$ref": "#/definitions/resources" + }, + "builder": { + "$ref": "#/definitions/builder" + }, + "server": { + "$ref": "../project.json#/definitions/server" + }, + "customConfiguration": { + "type": "object", + "additionalProperties": true + } + } + }, + "else": { + "additionalProperties": false, + "properties": { + "specVersion": { "enum": ["2.0"] }, + "kind": { + "enum": ["project", null] + }, + "type": { + "enum": ["library"] + }, + "metadata": { + "$ref": "../project.json#/definitions/metadata" + }, + "framework": { + "$ref": "../project.json#/definitions/framework" + }, + "resources": { + "$ref": "#/definitions/resources" + }, + "builder": { + "$ref": "#/definitions/builder" + }, + "server": { + "$ref": "../project.json#/definitions/server" + } } } }, - "definitions": { "resources": { "type": "object", @@ -96,6 +133,18 @@ } } }, + "builder-jsdoc": { + "type": "object", + "additionalProperties": false, + "properties": { + "excludes": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "builder": { "type": "object", "additionalProperties": false, @@ -104,16 +153,7 @@ "$ref": "../project.json#/definitions/builder-resources" }, "jsdoc": { - "type": "object", - "additionalProperties": false, - "properties": { - "excludes": { - "type": "array", - "items": { - "type": "string" - } - } - } + "$ref": "#/definitions/builder-jsdoc" }, "bundles": { "$ref": "../project.json#/definitions/builder-bundles" @@ -125,6 +165,30 @@ "$ref": "../project.json#/definitions/customTasks" } } + }, + "builder-specVersion-2.3": { + "type": "object", + "additionalProperties": false, + "properties": { + "resources": { + "$ref": "../project.json#/definitions/builder-resources" + }, + "jsdoc": { + "$ref": "#/definitions/builder-jsdoc" + }, + "bundles": { + "$ref": "../project.json#/definitions/builder-bundles" + }, + "componentPreload": { + "$ref": "../project.json#/definitions/builder-componentPreload-specVersion-2.3" + }, + "libraryPreload": { + "$ref": "../project.json#/definitions/builder-libraryPreload" + }, + "customTasks": { + "$ref": "../project.json#/definitions/customTasks" + } + } } } } diff --git a/lib/validation/schema/specVersion/2.0/kind/project/module.json b/lib/validation/schema/specVersion/2.0/kind/project/module.json index d315140a4..afdeb12ab 100644 --- a/lib/validation/schema/specVersion/2.0/kind/project/module.json +++ b/lib/validation/schema/specVersion/2.0/kind/project/module.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.1", "2.2", "2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.1", "2.2", "2.3"] }, "kind": { "enum": ["project", null] }, diff --git a/lib/validation/schema/specVersion/2.0/kind/project/theme-library.json b/lib/validation/schema/specVersion/2.0/kind/project/theme-library.json index 210949d2d..45ec55dad 100644 --- a/lib/validation/schema/specVersion/2.0/kind/project/theme-library.json +++ b/lib/validation/schema/specVersion/2.0/kind/project/theme-library.json @@ -6,13 +6,13 @@ "required": ["specVersion", "type", "metadata"], "if": { "properties": { - "specVersion": { "enum": ["2.1", "2.2"] } + "specVersion": { "enum": ["2.1", "2.2", "2.3"] } } }, "then": { "additionalProperties": false, "properties": { - "specVersion": { "enum": ["2.1", "2.2"] }, + "specVersion": { "enum": ["2.1", "2.2", "2.3"] }, "kind": { "enum": ["project", null] }, diff --git a/lib/validation/schema/ui5.json b/lib/validation/schema/ui5.json index 0671a590a..1fd8e141a 100644 --- a/lib/validation/schema/ui5.json +++ b/lib/validation/schema/ui5.json @@ -10,16 +10,16 @@ "properties": { "specVersion": { "enum": [ - "2.2", "2.1", "2.0", + "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: \"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: \"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": ["2.2", "2.1", "2.0"] } + "specVersion": { "enum": ["2.3", "2.2", "2.1", "2.0"] } } }, "then": { diff --git a/test/lib/extensions.js b/test/lib/extensions.js index 6c30f4831..6ecc68978 100644 --- a/test/lib/extensions.js +++ b/test/lib/extensions.js @@ -851,3 +851,43 @@ test("specVersion: Extension with valid version 2.1", async (t) => { await preprocessor.applyExtension(extension); t.deepEqual(handleShimStub.getCall(0).args[0].specVersion, "2.1", "Correct spec version"); }); + +test("specVersion: Extension with valid version 2.2", async (t) => { + const extension = { + id: "extension.a", + path: applicationAPath, + dependencies: [], + version: "1.0.0", + specVersion: "2.2", + kind: "extension", + type: "project-shim", + metadata: { + name: "shims.a" + }, + shims: {} + }; + const preprocessor = new Preprocessor({}); + const handleShimStub = sinon.stub(preprocessor, "handleShim"); + await preprocessor.applyExtension(extension); + t.deepEqual(handleShimStub.getCall(0).args[0].specVersion, "2.2", "Correct spec version"); +}); + +test("specVersion: Extension with valid version 2.3", async (t) => { + const extension = { + id: "extension.a", + path: applicationAPath, + dependencies: [], + version: "1.0.0", + specVersion: "2.3", + kind: "extension", + type: "project-shim", + metadata: { + name: "shims.a" + }, + shims: {} + }; + const preprocessor = new Preprocessor({}); + const handleShimStub = sinon.stub(preprocessor, "handleShim"); + await preprocessor.applyExtension(extension); + t.deepEqual(handleShimStub.getCall(0).args[0].specVersion, "2.3", "Correct spec version"); +}); diff --git a/test/lib/projectPreprocessor.js b/test/lib/projectPreprocessor.js index a05323049..cead35f24 100644 --- a/test/lib/projectPreprocessor.js +++ b/test/lib/projectPreprocessor.js @@ -1734,6 +1734,22 @@ test("specVersion: Project with valid version 2.2", async (t) => { t.deepEqual(res.specVersion, "2.2", "Correct spec version"); }); +test("specVersion: Project with valid version 2.3", async (t) => { + const tree = { + id: "application.a", + path: applicationAPath, + dependencies: [], + version: "1.0.0", + specVersion: "2.3", + type: "application", + metadata: { + name: "xy" + } + }; + const res = await projectPreprocessor.processTree(tree); + t.deepEqual(res.specVersion, "2.3", "Correct spec version"); +}); + test("isBeingProcessed: Is not being processed", (t) => { const preprocessor = new projectPreprocessor._ProjectPreprocessor({}); diff --git a/test/lib/validation/schema/__helper__/customConfiguration.js b/test/lib/validation/schema/__helper__/customConfiguration.js index cae656219..ba4218237 100644 --- a/test/lib/validation/schema/__helper__/customConfiguration.js +++ b/test/lib/validation/schema/__helper__/customConfiguration.js @@ -30,13 +30,12 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "customConfiguration", - }, - schemaPath: "#/else/additionalProperties", + } } ]); }); - ["2.2", "2.1"].forEach((specVersion) => { + ["2.3", "2.2", "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 0770622c3..a7ce990ba 100644 --- a/test/lib/validation/schema/__helper__/extension.js +++ b/test/lib/validation/schema/__helper__/extension.js @@ -18,7 +18,7 @@ module.exports = { customConfiguration.defineTests(test, assertValidation, type, additionalConfiguration); - ["2.2", "2.1", "2.0"].forEach((specVersion) => { + ["2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { test(`kind: extension / type: ${type} basic (${specVersion})`, async (t) => { await assertValidation(t, Object.assign({ "specVersion": specVersion, @@ -43,8 +43,7 @@ module.exports = { message: "should NOT have additional properties", params: { "additionalProperty": "resources" - }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties" + } }]); }); @@ -63,9 +62,7 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: - specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties" + } }]); }); }); diff --git a/test/lib/validation/schema/__helper__/framework.js b/test/lib/validation/schema/__helper__/framework.js index 71a1181e5..9595112f4 100644 --- a/test/lib/validation/schema/__helper__/framework.js +++ b/test/lib/validation/schema/__helper__/framework.js @@ -10,7 +10,7 @@ module.exports = { * @param {string} type one of "application", "library" and "theme-library" */ defineTests: function(test, assertValidation, type) { - ["2.2", "2.1", "2.0"].forEach((specVersion) => { + ["2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { test(`${type} (specVersion ${specVersion}): framework configuration: OpenUI5`, async (t) => { const config = { "specVersion": specVersion, @@ -89,8 +89,7 @@ module.exports = { "OpenUI5", "SAPUI5", ], - }, - schemaPath: "../project.json#/definitions/framework/properties/name/enum", + } }, { dataPath: "/framework/version", @@ -110,12 +109,10 @@ module.exports = { "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*" + "[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-]" + "[0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", - }, - schemaPath: "../project.json#/definitions/framework/properties/version/pattern", + } } ] - }, - schemaPath: "../project.json#/definitions/framework/properties/version/errorMessage", + } }, { dataPath: "/framework/libraries/0", @@ -123,8 +120,7 @@ module.exports = { message: "should be object", params: { type: "object", - }, - schemaPath: "../project.json#/definitions/framework/properties/libraries/items/type" + } }, { dataPath: "/framework/libraries/1", @@ -132,9 +128,7 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "library", - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/additionalProperties", + } }, { dataPath: "/framework/libraries/1", @@ -142,8 +136,7 @@ module.exports = { message: "should have required property 'name'", params: { missingProperty: "name", - }, - schemaPath: "../project.json#/definitions/framework/properties/libraries/items/required", + } }, { dataPath: "/framework/libraries/2/optional", @@ -151,10 +144,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean" - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries" + - "/items/properties/optional/type", + } }, { dataPath: "/framework/libraries/3/development", @@ -162,10 +152,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean" - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries" + - "/items/properties/development/type" + } } ]); }); @@ -185,8 +172,7 @@ module.exports = { message: "should have required property 'name'", params: { missingProperty: "name" - }, - schemaPath: "../project.json#/definitions/framework/required", + } } ]); }); @@ -229,10 +215,7 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "development", - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/" + - "then/additionalProperties", + } }, { dataPath: "/framework/libraries/0", @@ -240,15 +223,10 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "optional", - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/then/" + - "additionalProperties", + } }, ], - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/then/errorMessage", + } }, { dataPath: "/framework/libraries/1/optional", @@ -256,10 +234,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/properties/" + - "optional/type", + } }, { dataPath: "/framework/libraries/1/development", @@ -267,10 +242,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/framework/properties/libraries/items/properties/" + - "development/type", + } }, ]); }); diff --git a/test/lib/validation/schema/__helper__/project.js b/test/lib/validation/schema/__helper__/project.js index 418e920ee..9b5aeb93b 100644 --- a/test/lib/validation/schema/__helper__/project.js +++ b/test/lib/validation/schema/__helper__/project.js @@ -23,7 +23,7 @@ module.exports = { customConfiguration.defineTests(test, assertValidation, type); // version specific tests - ["2.2", "2.1", "2.0"].forEach((specVersion) => { + ["2.3", "2.2", "2.1", "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, { @@ -35,8 +35,7 @@ module.exports = { message: "should have required property 'metadata'", params: { missingProperty: "metadata", - }, - schemaPath: "#/required", + } }]); }); @@ -51,8 +50,7 @@ module.exports = { message: "should be object", params: { type: "object", - }, - schemaPath: "../project.json#/definitions/metadata/type", + } }]); }); @@ -67,8 +65,7 @@ module.exports = { message: "should have required property 'name'", params: { missingProperty: "name", - }, - schemaPath: "../project.json#/definitions/metadata/required", + } }]); }); @@ -86,8 +83,7 @@ module.exports = { message: "should be string", params: { type: "string" - }, - schemaPath: "../project.json#/definitions/metadata/properties/name/type", + } } ]); }); @@ -107,8 +103,7 @@ module.exports = { message: "should be string", params: { type: "string" - }, - schemaPath: "../project.json#/definitions/metadata/properties/copyright/type", + } } ]); }); @@ -128,8 +123,7 @@ module.exports = { message: "should NOT have additional properties", params: { additionalProperty: "copyrihgt" - }, - schemaPath: "../project.json#/definitions/metadata/additionalProperties", + } } ]); }); @@ -171,8 +165,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: "../project.json#/definitions/metadata/properties/deprecated/type", + } } ]); }); @@ -214,8 +207,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: "../project.json#/definitions/metadata/properties/sapInternal/type", + } } ]); }); @@ -257,8 +249,7 @@ module.exports = { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: "../project.json#/definitions/metadata/properties/allowSapInternal/type", + } } ]); }); @@ -278,7 +269,6 @@ module.exports = { params: { additionalProperty: "notAllowed", }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties", }]); }); }); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/extension.js b/test/lib/validation/schema/specVersion/2.0/kind/extension.js index a7cb45a12..3dee7a1b0 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/extension.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/extension.js @@ -10,6 +10,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -33,7 +36,7 @@ test.after.always((t) => { }; t.context.ajvCoverage.verify(thresholds); }); -["2.2", "2.1", "2.0"].forEach((specVersion) => { +["2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { test(`Type project-shim (${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -87,8 +90,7 @@ test.after.always((t) => { message: "should have required property 'type'", params: { missingProperty: "type", - }, - schemaPath: "#/required", + } }]); }); @@ -110,8 +112,7 @@ test.after.always((t) => { "server-middleware", "project-shim" ], - }, - schemaPath: "#/properties/type/enum", + } }]); }); @@ -129,8 +130,7 @@ test.after.always((t) => { message: "should have required property 'specVersion'", params: { missingProperty: "specVersion", - }, - schemaPath: "#/required", + } }]); }); @@ -146,8 +146,7 @@ test.after.always((t) => { message: "should have required property 'metadata'", params: { missingProperty: "metadata", - }, - schemaPath: "#/required", + } }]); }); }); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.js b/test/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.js index 6b5391fb6..11442a358 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/extension/project-shim.js @@ -11,6 +11,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -79,8 +82,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { "additionalProperty": "middleware" - }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties", + } }, { dataPath: "/shims", @@ -88,8 +90,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: "#/definitions/shims/additionalProperties", + } }, { dataPath: "/shims/dependencies/my-dependency", @@ -97,8 +98,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "#/definitions/shims/properties/dependencies/patternProperties/.%2B/type", + } }, { dataPath: "/shims/collections/foo", @@ -106,8 +106,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: "#/definitions/shims/properties/collections/patternProperties/.%2B/additionalProperties" + } }, { dataPath: "/shims/collections/foo/modules/lib-1", @@ -115,10 +114,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: - "#/definitions/shims/properties/collections/patternProperties/.%2B/properties/" + - "modules/patternProperties/.%2B/type" + } } ]); }); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.js b/test/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.js index 5e1d906a5..ee89dc9c7 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/extension/server-middleware.js @@ -11,6 +11,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/extension/task.js b/test/lib/validation/schema/specVersion/2.0/kind/extension/task.js index 936ff2dda..809d0f137 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/extension/task.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/extension/task.js @@ -11,6 +11,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/project.js b/test/lib/validation/schema/specVersion/2.0/kind/project.js index 39c41a933..d02ef6cc4 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/project.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/project.js @@ -10,6 +10,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -131,8 +134,7 @@ test("No type", async (t) => { message: "should have required property 'type'", params: { missingProperty: "type", - }, - schemaPath: "#/required", + } }]); }); @@ -148,8 +150,7 @@ test("No type, no kind", async (t) => { message: "should have required property 'type'", params: { missingProperty: "type", - }, - schemaPath: "#/required", + } }]); }); @@ -172,8 +173,7 @@ test("Invalid type", async (t) => { "theme-library", "module", ], - }, - schemaPath: "#/properties/type/enum", + } }]); }); @@ -190,7 +190,6 @@ test("No specVersion", async (t) => { message: "should have required property 'specVersion'", params: { missingProperty: "specVersion", - }, - schemaPath: "#/required", + } }]); }); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/project/application.js b/test/lib/validation/schema/specVersion/2.0/kind/project/application.js index bb286726d..8c168dec4 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/project/application.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/project/application.js @@ -11,6 +11,14 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + if (error.params && Array.isArray(error.params.errors)) { + error.params.errors.forEach(($) => { + delete $.schemaPath; + }); + } + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -28,14 +36,14 @@ test.after.always((t) => { t.context.ajvCoverage.createReport("html", {dir: "coverage/ajv-project-application"}); const thresholds = { statements: 80, - branches: 70, + branches: 75, functions: 100, lines: 80 }; t.context.ajvCoverage.verify(thresholds); }); -["2.2", "2.1", "2.0"].forEach(function(specVersion) { +["2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -220,8 +228,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: "#/additionalProperties", + } }, { dataPath: "/resources/configuration", @@ -229,8 +236,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: "#/properties/configuration/additionalProperties", + } }, { dataPath: "/resources/configuration/propertiesFileSourceEncoding", @@ -241,8 +247,7 @@ test.after.always((t) => { "UTF-8", "ISO-8859-1" ], - }, - schemaPath: "../project.json#/definitions/resources-configuration-propertiesFileSourceEncoding/enum" + } }, { dataPath: "/resources/configuration/paths", @@ -250,8 +255,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "app", - }, - schemaPath: "#/properties/configuration/properties/paths/additionalProperties", + } }, { dataPath: "/resources/configuration/paths/webapp", @@ -259,8 +263,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string" - }, - schemaPath: "#/properties/configuration/properties/paths/properties/webapp/type" + } } ]); await assertValidation(t, { @@ -281,8 +284,7 @@ test.after.always((t) => { message: "should be object", params: { type: "object" - }, - schemaPath: "#/properties/configuration/properties/paths/type", + } } ]); }); @@ -358,7 +360,8 @@ test.after.always((t) => { "path": "some/invalid/path", "paths": "some/invalid/glob/**/pattern/Component.js", "namespaces": "some/invalid/namespace", - } + }, + "libraryPreload": {} // Only supported for type library } }, [ { @@ -367,8 +370,15 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "jsdoc" - }, - schemaPath: "#/additionalProperties" + } + }, + { + dataPath: "/builder", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "libraryPreload" + } }, { dataPath: "/builder/bundles/0/bundleDefinition/sections/0", @@ -376,10 +386,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "declareModules", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/additionalProperties", + } }, { dataPath: "/builder/bundles/0/bundleDefinition/sections/0/name", @@ -387,10 +394,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/name/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition", @@ -398,8 +402,7 @@ test.after.always((t) => { message: "should have required property 'name'", params: { missingProperty: "name", - }, - schemaPath: "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/required", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/defaultFileTypes/1", @@ -407,10 +410,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/defaultFileTypes/items/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/0", @@ -418,10 +418,7 @@ test.after.always((t) => { message: "should have required property 'mode'", params: { missingProperty: "mode", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/required", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/0/declareRawModules", @@ -429,10 +426,7 @@ test.after.always((t) => { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/declareRawModules/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/1/mode", @@ -445,10 +439,7 @@ test.after.always((t) => { "require", "provided", ], - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/mode/enum", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/1/filters", @@ -456,10 +447,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/filters/type", + } }, { dataPath: "/builder/bundles/1/bundleOptions", @@ -467,10 +455,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "additionalProperties", + } }, { dataPath: "/builder/bundles/1/bundleOptions/optimize", @@ -478,10 +463,7 @@ test.after.always((t) => { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "properties/optimize/type", + } }, { dataPath: "/builder/bundles/1/bundleOptions/numberOfParts", @@ -489,10 +471,7 @@ test.after.always((t) => { message: "should be number", params: { type: "number", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "properties/numberOfParts/type", + } }, { dataPath: "/builder/componentPreload", @@ -500,8 +479,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "path", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/additionalProperties", + } }, { dataPath: "/builder/componentPreload/paths", @@ -509,8 +487,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/properties/paths/type", + } }, { dataPath: "/builder/componentPreload/namespaces", @@ -518,12 +495,137 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/properties/namespaces/type", + } } ]); }); }); +["2.2", "2.1", "2.0"].forEach(function(specVersion) { + test(`Unsupported builder/componentPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "application", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + "some/excluded/files/**", + "some/other/excluded/files/**" + ] + } + } + }, [ + { + dataPath: "/builder/componentPreload", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "excludes", + }, + }, + ]); + }); +}); + +["2.3"].forEach(function(specVersion) { + test(`application (specVersion ${specVersion}): builder/componentPreload/excludes`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "kind": "project", + "type": "application", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + "some/excluded/files/**", + "some/other/excluded/files/**" + ] + } + } + }); + }); + test(`Invalid builder/componentPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "application", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": "some/excluded/files/**" + } + } + }, [ + { + dataPath: "/builder/componentPreload/excludes", + keyword: "type", + message: "should be array", + params: { + type: "array", + }, + }, + ]); + await assertValidation(t, { + "specVersion": specVersion, + "type": "application", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + true, + 1, + {} + ], + "notAllowed": true + } + } + }, [ + { + dataPath: "/builder/componentPreload", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "notAllowed", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/0", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/1", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/2", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + ]); + }); +}); project.defineTests(test, assertValidation, "application"); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/project/library.js b/test/lib/validation/schema/specVersion/2.0/kind/project/library.js index 69f5e9f01..b3b1da8d5 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/project/library.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/project/library.js @@ -11,6 +11,14 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + if (error.params && Array.isArray(error.params.errors)) { + error.params.errors.forEach(($) => { + delete $.schemaPath; + }); + } + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -28,14 +36,14 @@ test.after.always((t) => { t.context.ajvCoverage.createReport("html", {dir: "coverage/ajv-project-library"}); const thresholds = { statements: 80, - branches: 70, + branches: 75, functions: 100, lines: 80 }; t.context.ajvCoverage.verify(thresholds); }); -["2.2", "2.1", "2.0"].forEach(function(specVersion) { +["2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { test(`library (specVersion ${specVersion}): Valid configuration`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -296,8 +304,7 @@ test.after.always((t) => { "UTF-8", "ISO-8859-1", ], - }, - schemaPath: "../project.json#/definitions/resources-configuration-propertiesFileSourceEncoding/enum", + } }, { dataPath: "/resources/configuration/paths", @@ -305,8 +312,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "webapp", - }, - schemaPath: "#/properties/configuration/properties/paths/additionalProperties", + } }, { dataPath: "/resources/configuration/paths/src", @@ -314,8 +320,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: "#/properties/configuration/properties/paths/properties/src/type", + } }, { dataPath: "/resources/configuration/paths/test", @@ -323,8 +328,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: "#/properties/configuration/properties/paths/properties/test/type", + } }, { dataPath: "/builder/resources/excludes", @@ -332,8 +336,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "../project.json#/definitions/builder-resources/properties/excludes/type", + } }, { dataPath: "/builder/jsdoc/excludes", @@ -341,8 +344,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "#/properties/jsdoc/properties/excludes/type", + } }, { dataPath: "/builder/bundles/0/bundleDefinition/sections/0", @@ -350,10 +352,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "declareModules", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/additionalProperties", + } }, { dataPath: "/builder/bundles/0/bundleDefinition/sections/0/name", @@ -361,10 +360,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/name/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition", @@ -372,8 +368,7 @@ test.after.always((t) => { message: "should have required property 'name'", params: { missingProperty: "name", - }, - schemaPath: "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/required", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/defaultFileTypes/1", @@ -381,10 +376,7 @@ test.after.always((t) => { message: "should be string", params: { type: "string", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/defaultFileTypes/items/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/0", @@ -392,10 +384,7 @@ test.after.always((t) => { message: "should have required property 'mode'", params: { missingProperty: "mode", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/required", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/0/declareRawModules", @@ -403,10 +392,7 @@ test.after.always((t) => { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/declareRawModules/type", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/1/mode", @@ -419,10 +405,7 @@ test.after.always((t) => { "require", "provided", ], - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/mode/enum", + } }, { dataPath: "/builder/bundles/1/bundleDefinition/sections/1/filters", @@ -430,10 +413,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleDefinition/" + - "properties/sections/items/properties/filters/type", + } }, { dataPath: "/builder/bundles/1/bundleOptions", @@ -441,10 +421,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "notAllowed", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "additionalProperties", + } }, { dataPath: "/builder/bundles/1/bundleOptions/optimize", @@ -452,10 +429,7 @@ test.after.always((t) => { message: "should be boolean", params: { type: "boolean", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "properties/optimize/type", + } }, { dataPath: "/builder/bundles/1/bundleOptions/numberOfParts", @@ -463,10 +437,7 @@ test.after.always((t) => { message: "should be number", params: { type: "number", - }, - schemaPath: - "../project.json#/definitions/builder-bundles/items/properties/bundleOptions/" + - "properties/numberOfParts/type", + } }, { dataPath: "/builder/componentPreload", @@ -474,8 +445,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "path", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/additionalProperties", + } }, { dataPath: "/builder/componentPreload/paths", @@ -483,8 +453,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/properties/paths/type", + } }, { dataPath: "/builder/componentPreload/namespaces", @@ -492,8 +461,7 @@ test.after.always((t) => { message: "should be array", params: { type: "array", - }, - schemaPath: "../project.json#/definitions/builder-componentPreload/properties/namespaces/type", + } }, { dataPath: "/builder/customTasks/0", @@ -501,8 +469,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "afterTask", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/0/additionalProperties", + } }, { dataPath: "/builder/customTasks/0", @@ -510,8 +477,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "beforeTask", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/1/additionalProperties", + } }, { dataPath: "/builder/customTasks/1", @@ -519,8 +485,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "afterTask", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/0/additionalProperties", + } }, { dataPath: "/builder/customTasks/1", @@ -528,8 +493,7 @@ test.after.always((t) => { message: "should have required property 'name'", params: { missingProperty: "name", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/0/required", + } }, { dataPath: "/builder/customTasks/1", @@ -537,8 +501,7 @@ test.after.always((t) => { message: "should have required property 'beforeTask'", params: { missingProperty: "beforeTask", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/0/required", + } }, { dataPath: "/builder/customTasks/2", @@ -546,8 +509,7 @@ test.after.always((t) => { message: "should be object", params: { type: "object", - }, - schemaPath: "../project.json#/definitions/customTasks/items/oneOf/0/type", + } }, { dataPath: "/server/settings/httpPort", @@ -555,8 +517,7 @@ test.after.always((t) => { message: "should be number", params: { type: "number", - }, - schemaPath: "../project.json#/definitions/server/properties/settings/properties/httpPort/type", + } }, { dataPath: "/server/settings/httpsPort", @@ -564,8 +525,7 @@ test.after.always((t) => { message: "should be number", params: { type: "number", - }, - schemaPath: "../project.json#/definitions/server/properties/settings/properties/httpsPort/type", + } } ]); }); @@ -591,10 +551,254 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "cachebuster" - }, - schemaPath: "#/additionalProperties" + } }]); }); }); +["2.2", "2.1", "2.0"].forEach(function(specVersion) { + test(`Unsupported builder/libraryPreload configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "libraryPreload": {} + } + }, [ + { + dataPath: "/builder", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "libraryPreload", + }, + }, + ]); + }); + test(`Unsupported builder/componentPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + "some/excluded/files/**", + "some/other/excluded/files/**" + ] + } + } + }, [ + { + dataPath: "/builder/componentPreload", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "excludes", + }, + }, + ]); + }); +}); + +["2.3"].forEach(function(specVersion) { + test(`library (specVersion ${specVersion}): builder/libraryPreload/excludes`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "kind": "project", + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "libraryPreload": { + "excludes": [ + "some/excluded/files/**", + "some/other/excluded/files/**" + ] + } + } + }); + }); + test(`Invalid builder/libraryPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "libraryPreload": { + "excludes": "some/excluded/files/**" + } + } + }, [ + { + dataPath: "/builder/libraryPreload/excludes", + keyword: "type", + message: "should be array", + params: { + type: "array", + }, + }, + ]); + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "libraryPreload": { + "excludes": [ + true, + 1, + {} + ], + "notAllowed": true + } + } + }, [ + { + dataPath: "/builder/libraryPreload", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "notAllowed", + }, + }, + { + dataPath: "/builder/libraryPreload/excludes/0", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/libraryPreload/excludes/1", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/libraryPreload/excludes/2", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + ]); + }); + + + test(`library (specVersion ${specVersion}): builder/componentPreload/excludes`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "kind": "project", + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + "some/excluded/files/**", + "some/other/excluded/files/**" + ] + } + } + }); + }); + test(`Invalid builder/componentPreload/excludes configuration (specVersion ${specVersion})`, async (t) => { + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": "some/excluded/files/**" + } + } + }, [ + { + dataPath: "/builder/componentPreload/excludes", + keyword: "type", + message: "should be array", + params: { + type: "array", + }, + }, + ]); + await assertValidation(t, { + "specVersion": specVersion, + "type": "library", + "metadata": { + "name": "com.sap.ui5.test", + "copyright": "yes" + }, + "builder": { + "componentPreload": { + "excludes": [ + true, + 1, + {} + ], + "notAllowed": true + } + } + }, [ + { + dataPath: "/builder/componentPreload", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "notAllowed", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/0", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/1", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + { + dataPath: "/builder/componentPreload/excludes/2", + keyword: "type", + message: "should be string", + params: { + type: "string", + }, + }, + ]); + }); +}); + project.defineTests(test, assertValidation, "library"); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/project/module.js b/test/lib/validation/schema/specVersion/2.0/kind/project/module.js index d4b3d8011..b3b6c1484 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/project/module.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/project/module.js @@ -11,6 +11,9 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -35,7 +38,7 @@ test.after.always((t) => { t.context.ajvCoverage.verify(thresholds); }); -["2.2", "2.1", "2.0"].forEach((specVersion) => { +["2.3", "2.2", "2.1", "2.0"].forEach((specVersion) => { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -69,8 +72,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { "additionalProperty": "framework" - }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties", + } }]); }); @@ -92,8 +94,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { "additionalProperty": "propertiesFileSourceEncoding" - }, - schemaPath: "#/definitions/resources/properties/configuration/additionalProperties" + } }]); }); @@ -112,16 +113,14 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { "additionalProperty": "builder" - }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties", + } }, { dataPath: "", keyword: "additionalProperties", message: "should NOT have additional properties", params: { "additionalProperty": "server" - }, - schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties", + } }]); }); }); diff --git a/test/lib/validation/schema/specVersion/2.0/kind/project/theme-library.js b/test/lib/validation/schema/specVersion/2.0/kind/project/theme-library.js index 197792b82..7060baf32 100644 --- a/test/lib/validation/schema/specVersion/2.0/kind/project/theme-library.js +++ b/test/lib/validation/schema/specVersion/2.0/kind/project/theme-library.js @@ -11,6 +11,14 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + if (error.params && Array.isArray(error.params.errors)) { + error.params.errors.forEach(($) => { + delete $.schemaPath; + }); + } + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -27,16 +35,16 @@ test.before((t) => { test.after.always((t) => { t.context.ajvCoverage.createReport("html", {dir: "coverage/ajv-project-theme-library"}); const thresholds = { - statements: 75, + statements: 80, branches: 70, functions: 100, - lines: 75 + lines: 80 }; t.context.ajvCoverage.verify(thresholds); }); -["2.2", "2.1", "2.0"].forEach(function(specVersion) { +["2.3", "2.2", "2.1", "2.0"].forEach(function(specVersion) { test(`Valid configuration (specVersion ${specVersion})`, async (t) => { await assertValidation(t, { "specVersion": specVersion, @@ -116,7 +124,11 @@ test.after.always((t) => { "excludes": [ "some/project/name/thirdparty/**" ] - } + }, + // componentPreload is only supported for types application/library + "componentPreload": {}, + // libraryPreload is only supported for type library + "libraryPreload": {}, } }, [{ dataPath: "/builder", @@ -124,8 +136,7 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "cachebuster" - }, - schemaPath: "#/additionalProperties" + } }, { dataPath: "/builder", @@ -133,8 +144,23 @@ test.after.always((t) => { message: "should NOT have additional properties", params: { additionalProperty: "jsdoc" - }, - schemaPath: "#/additionalProperties" + } + }, + { + dataPath: "/builder", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "componentPreload" + } + }, + { + dataPath: "/builder", + keyword: "additionalProperties", + message: "should NOT have additional properties", + params: { + additionalProperty: "libraryPreload" + } }]); }); }); diff --git a/test/lib/validation/schema/ui5.js b/test/lib/validation/schema/ui5.js index 8ea7abfca..2bd9b6a35 100644 --- a/test/lib/validation/schema/ui5.js +++ b/test/lib/validation/schema/ui5.js @@ -10,6 +10,14 @@ async function assertValidation(t, config, expectedErrors = undefined) { instanceOf: ValidationError, name: "ValidationError" }); + validationError.errors.forEach((error) => { + delete error.schemaPath; + if (error.params && Array.isArray(error.params.errors)) { + error.params.errors.forEach(($) => { + delete $.schemaPath; + }); + } + }); t.deepEqual(validationError.errors, expectedErrors); } else { await t.notThrowsAsync(validation); @@ -41,8 +49,7 @@ test("Undefined", async (t) => { message: "should be object", params: { type: "object", - }, - schemaPath: "#/type", + } }]); }); @@ -54,8 +61,7 @@ test("Missing specVersion, type", async (t) => { message: "should have required property 'specVersion'", params: { missingProperty: "specVersion", - }, - schemaPath: "#/required", + } }, { dataPath: "", @@ -63,8 +69,7 @@ test("Missing specVersion, type", async (t) => { message: "should have required property 'type'", params: { missingProperty: "type", - }, - schemaPath: "#/required", + } } ]); @@ -80,8 +85,7 @@ test("Missing type", async (t) => { message: "should have required property 'type'", params: { missingProperty: "type", - }, - schemaPath: "#/required", + } } ]); }); @@ -96,7 +100,7 @@ test("Invalid specVersion", async (t) => { message: `Unsupported "specVersion" Your UI5 CLI installation might be outdated. -Supported specification versions: "2.2", "2.1", "2.0", "1.1", "1.0", "0.1" +Supported specification versions: "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: [ @@ -106,6 +110,7 @@ For details see: https://sap.github.io/ui5-tooling/pages/Configuration/#specific message: "should be equal to one of the allowed values", params: { allowedValues: [ + "2.3", "2.2", "2.1", "2.0", @@ -113,12 +118,10 @@ For details see: https://sap.github.io/ui5-tooling/pages/Configuration/#specific "1.0", "0.1", ], - }, - schemaPath: "#/properties/specVersion/enum", + } }, ], - }, - schemaPath: "#/properties/specVersion/errorMessage", + } } ]); }); @@ -139,8 +142,7 @@ test("Invalid type", async (t) => { "theme-library", "module" ] - }, - schemaPath: "#/properties/type/enum", + } } ]); }); @@ -160,8 +162,7 @@ test("Invalid kind", async (t) => { "extension", null ], - }, - schemaPath: "#/properties/kind/enum", + } } ]); });