Skip to content

Commit

Permalink
[INTERNAL] Add specification version 1.1
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
  • Loading branch information
RandomByte committed Jan 10, 2020
1 parent cb588a9 commit 896ca9e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
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
20 changes: 20 additions & 0 deletions test/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,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");
});
16 changes: 16 additions & 0 deletions test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,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 896ca9e

Please sign in to comment.