Skip to content

Commit

Permalink
[FEATURE] Add specification version 1.1 (#252)
Browse files Browse the repository at this point in the history
The new 'theme-library' type requires spec version 1.1:
SAP/ui5-builder#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.

Configuration.md: Add deep link to Specification Version documentation
  • Loading branch information
RandomByte authored Jan 10, 2020
1 parent cb588a9 commit 5a83308
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
4 changes: 3 additions & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 8 additions & 6 deletions lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.");
Expand Down
23 changes: 22 additions & 1 deletion test/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down Expand Up @@ -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");
});
19 changes: 18 additions & 1 deletion test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 5a83308

Please sign in to comment.