From f6e643a22ec59178925cb03d3c267feef09a452f Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Fri, 10 Jan 2020 12:22:33 +0100 Subject: [PATCH 1/2] [INTERNAL] Add specification version 1.1 The new 'theme-library' type requires spec version 1.1: https://github.com/SAP/ui5-builder/pull/285 Also change wording of the error message for unsupported spec versions and fix the referenced URL. This should make it clear that the used version of the UI5 CLI might be outdated. --- lib/projectPreprocessor.js | 14 ++++++++------ test/lib/extensions.js | 23 ++++++++++++++++++++++- test/lib/projectPreprocessor.js | 19 ++++++++++++++++++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/lib/projectPreprocessor.js b/lib/projectPreprocessor.js index 3d1813857..82625e979 100644 --- a/lib/projectPreprocessor.js +++ b/lib/projectPreprocessor.js @@ -272,11 +272,11 @@ class ProjectPreprocessor { return false; // ignore this project } - if (project.specVersion !== "0.1" && project.specVersion !== "1.0") { + if (project.specVersion !== "0.1" && project.specVersion !== "1.0" && project.specVersion !== "1.1") { throw new Error( `Unsupported specification version ${project.specVersion} defined for project ` + - `${project.id}. ` + - `See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions`); + `${project.id}. Your UI5 CLI installation might be outdated. ` + + `For details see https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions`); } if (!project.type) { @@ -330,11 +330,13 @@ class ProjectPreprocessor { if (!extension.specVersion) { throw new Error(`No specification version defined for extension ${extension.metadata.name}`); - } else if (extension.specVersion !== "0.1" && extension.specVersion !== "1.0") { + } else if (extension.specVersion !== "0.1" && + extension.specVersion !== "1.0" && + extension.specVersion !== "1.1") { throw new Error( `Unsupported specification version ${extension.specVersion} defined for extension ` + - `${extension.metadata.name}. ` + - `See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions`); + `${extension.metadata.name}. Your UI5 CLI installation might be outdated. ` + + `For details see https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions`); } else if (this.appliedExtensions[extension.metadata.name]) { log.verbose(`Extension with the name ${extension.metadata.name} has already been applied. ` + "This might have been done during dependency lookahead."); diff --git a/test/lib/extensions.js b/test/lib/extensions.js index c3a33fb92..7138cbd45 100644 --- a/test/lib/extensions.js +++ b/test/lib/extensions.js @@ -696,7 +696,8 @@ test("specVersion: Extension with invalid version", async (t) => { const preprocessor = new Preprocessor(); await t.throwsAsync(preprocessor.applyExtension(extension), "Unsupported specification version 0.9 defined for extension shims.a. " + - "See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions", + "Your UI5 CLI installation might be outdated. For details see " + + "https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions", "Rejected with error"); }); @@ -739,3 +740,23 @@ test("specVersion: Extension with valid version 1.0", async (t) => { await preprocessor.applyExtension(extension); t.deepEqual(handleShimStub.getCall(0).args[0].specVersion, "1.0", "Correct spec version"); }); + +test("specVersion: Extension with valid version 1.1", async (t) => { + const extension = { + id: "extension.a", + path: applicationAPath, + dependencies: [], + version: "1.0.0", + specVersion: "1.1", + 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, "1.1", "Correct spec version"); +}); diff --git a/test/lib/projectPreprocessor.js b/test/lib/projectPreprocessor.js index 4e6b60ebc..d88b8e20f 100644 --- a/test/lib/projectPreprocessor.js +++ b/test/lib/projectPreprocessor.js @@ -1597,7 +1597,8 @@ test("specVersion: Project with invalid version", async (t) => { }; await t.throwsAsync(projectPreprocessor.processTree(tree), "Unsupported specification version 0.9 defined for project application.a. " + - "See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions", + "Your UI5 CLI installation might be outdated. For details see " + + "https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions", "Rejected with error"); }); @@ -1633,6 +1634,22 @@ test("specVersion: Project with valid version 1.0", async (t) => { t.deepEqual(res.specVersion, "1.0", "Correct spec version"); }); +test("specVersion: Project with valid version 1.1", async (t) => { + const tree = { + id: "application.a", + path: applicationAPath, + dependencies: [], + version: "1.0.0", + specVersion: "1.1", + type: "application", + metadata: { + name: "xy" + } + }; + const res = await projectPreprocessor.processTree(tree); + t.deepEqual(res.specVersion, "1.1", "Correct spec version"); +}); + test("isBeingProcessed: Is not being processed", (t) => { const preprocessor = new projectPreprocessor.ProjectPreprocessor(); From 42d9e621515a6456e9e347c53e99add8499c94e5 Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Fri, 10 Jan 2020 12:38:17 +0100 Subject: [PATCH 2/2] [INTERNAL] Configuration.md: Add deep link to Specification Version documentation --- docs/Configuration.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index d5bfaa77b..4f48f5dca 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1,2 +1,4 @@ # Configuration -This documentation moved to a new place: [sap.github.io/ui5-tooling/pages/Configuration/](https://sap.github.io/ui5-tooling/pages/Configuration/) +This documentation moved to a new place: [sap.github.io/ui5-tooling/pages/Configuration/](https://sap.github.io/ui5-tooling/pages/Configuration/). + +The **Specification Version Documentation** can be found here: [sap.github.io/ui5-tooling/pages/Configuration/#specification-versions](https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions)