Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add specification version 1.1 #252

Merged
merged 2 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also adopt the old Configuration.md file to point to the #specifiction-version anchor? Currently it just points to the Configuration page.

Copy link
Member Author

@RandomByte RandomByte Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done by adding an additional link. The old Configuration.md also contained more than just the Specification Versions documentation.

`${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