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] specVersion 2.2 #341

Merged
merged 2 commits into from
Aug 11, 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
5 changes: 3 additions & 2 deletions lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ 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.1" && project.specVersion !== "2.2") {
throw new Error(
`Unsupported specification version ${project.specVersion} defined for project ` +
`${project.id}. Your UI5 CLI installation might be outdated. ` +
Expand Down Expand Up @@ -354,7 +354,8 @@ class ProjectPreprocessor {
extension.specVersion !== "1.0" &&
extension.specVersion !== "1.1" &&
extension.specVersion !== "2.0" &&
extension.specVersion !== "2.1") {
extension.specVersion !== "2.1" &&
extension.specVersion !== "2.2") {
throw new Error(
`Unsupported specification version ${extension.specVersion} defined for extension ` +
`${extension.metadata.name}. Your UI5 CLI installation might be outdated. ` +
Expand Down
4 changes: 2 additions & 2 deletions lib/translators/ui5Framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const utils = {
if (!project.framework) {
return;
}
if (project.specVersion !== "2.0" && project.specVersion !== "2.1") {
if (project.specVersion !== "2.0" && project.specVersion !== "2.1" && project.specVersion !== "2.2") {
log.warn(`Project ${project.metadata.name} defines invalid ` +
`specification version ${project.specVersion} for framework.libraries configuration`);
return;
Expand Down Expand Up @@ -239,7 +239,7 @@ module.exports = {
});
queue.push(...project.dependencies);

if ((project.specVersion === "2.0" || project.specVersion === "2.1") &&
if ((project.specVersion === "2.0" || project.specVersion === "2.1" || project.specVersion === "2.2") &&
project.framework && project.framework.libraries) {
const frameworkDeps = project.framework.libraries
.filter((dependency) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion"],
"properties": {
"specVersion": { "enum": ["2.1", "2.0"] },
"specVersion": { "enum": ["2.2", "2.1", "2.0"] },
"kind": {
"enum": ["project", "extension", null],
"$comment": "Using null to allow not defining 'kind' which defaults to project"
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/2.0/kind/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion", "kind", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.1", "2.0"] },
"specVersion": { "enum": ["2.2", "2.1", "2.0"] },
"kind": {
"enum": ["extension"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"required": ["specVersion", "kind", "type", "metadata", "shims"],
"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["2.1"]
"enum": ["2.1", "2.2"]
},
"kind": {
"enum": ["extension"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"required": ["specVersion", "kind", "type", "metadata", "middleware"],
"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["extension"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"required": ["specVersion", "kind", "type", "metadata", "task"],
"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["extension"]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/2.0/kind/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion", "type"],
"properties": {
"specVersion": { "enum": ["2.1", "2.0"] },
"specVersion": { "enum": ["2.2", "2.1", "2.0"] },
"kind": {
"enum": ["project", null],
"$comment": "Using null to allow not defining 'kind' which defaults to project"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

"type": "object",
"required": ["specVersion", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.1", "2.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["application"]
}
},

"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["project", null]
},
Expand Down
14 changes: 2 additions & 12 deletions lib/validation/schema/specVersion/2.0/kind/project/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

"type": "object",
"required": ["specVersion", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.1","2.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["library"]
}
},

"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["project", null]
},
Expand Down
20 changes: 2 additions & 18 deletions lib/validation/schema/specVersion/2.0/kind/project/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,15 @@

"type": "object",
"required": ["specVersion", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.1","2.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["module"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
},
"resources": {
"$ref": "#/definitions/resources"
}
},

"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["project", null]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,15 @@

"type": "object",
"required": ["specVersion", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.1", "2.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["theme-library"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
},
"framework": {
"$ref": "../project.json#/definitions/framework"
},
"resources": {
"$ref": "library.json#/definitions/resources"
},
"builder": {
"$ref": "#/definitions/builder"
},
"server": {
"$ref": "../project.json#/definitions/server"
}
},

"if": {
"properties": {
"specVersion": { "enum": ["2.1"] }
"specVersion": { "enum": ["2.1", "2.2"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1"] },
"specVersion": { "enum": ["2.1", "2.2"] },
"kind": {
"enum": ["project", null]
},
Expand Down
6 changes: 3 additions & 3 deletions lib/validation/schema/ui5.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"properties": {
"specVersion": {
"enum": [
"2.1", "2.0",
"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.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.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.1", "2.0"] }
"specVersion": { "enum": ["2.2", "2.1", "2.0"] }
}
},
"then": {
Expand Down
16 changes: 16 additions & 0 deletions test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,22 @@ test("specVersion: Project with valid version 2.1", async (t) => {
t.deepEqual(res.specVersion, "2.1", "Correct spec version");
});

test("specVersion: Project with valid version 2.2", async (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "2.2",
type: "application",
metadata: {
name: "xy"
}
};
const res = await projectPreprocessor.processTree(tree);
t.deepEqual(res.specVersion, "2.2", "Correct spec version");
});

test("isBeingProcessed: Is not being processed", (t) => {
const preprocessor = new projectPreprocessor._ProjectPreprocessor({});

Expand Down
24 changes: 13 additions & 11 deletions test/lib/validation/schema/__helper__/customConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ module.exports = {
]);
});

test(`${type}: Valid customConfiguration (specVersion 2.1)`, async (t) => {
await assertValidation(t, Object.assign( {
"specVersion": "2.1",
"type": type,
"metadata": {
"name": "my-" + type
},
"customConfiguration": {
"foo": "bar"
}
}, additionalConfiguration));
["2.2", "2.1"].forEach((specVersion) => {
test(`${type}: Valid customConfiguration (specVersion ${specVersion})`, async (t) => {
await assertValidation(t, Object.assign( {
"specVersion": specVersion,
"type": type,
"metadata": {
"name": "my-" + type
},
"customConfiguration": {
"foo": "bar"
}
}, additionalConfiguration));
});
});
}
};
6 changes: 3 additions & 3 deletions test/lib/validation/schema/__helper__/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {

customConfiguration.defineTests(test, assertValidation, type, additionalConfiguration);

["2.0", "2.1"].forEach((specVersion) => {
["2.2", "2.1", "2.0"].forEach((specVersion) => {
test(`kind: extension / type: ${type} basic (${specVersion})`, async (t) => {
await assertValidation(t, Object.assign({
"specVersion": specVersion,
Expand All @@ -44,7 +44,7 @@ module.exports = {
params: {
"additionalProperty": "resources"
},
schemaPath: specVersion === "2.1" ? "#/then/additionalProperties" : "#/else/additionalProperties"
schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties"
}]);
});

Expand All @@ -65,7 +65,7 @@ module.exports = {
additionalProperty: "notAllowed",
},
schemaPath:
specVersion === "2.1" ? "#/then/additionalProperties" : "#/else/additionalProperties"
specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties"
}]);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/lib/validation/schema/__helper__/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
* @param {string} type one of "application", "library" and "theme-library"
*/
defineTests: function(test, assertValidation, type) {
["2.0", "2.1"].forEach((specVersion) => {
["2.2", "2.1", "2.0"].forEach((specVersion) => {
test(`${type} (specVersion ${specVersion}): framework configuration: OpenUI5`, async (t) => {
const config = {
"specVersion": specVersion,
Expand Down
7 changes: 3 additions & 4 deletions test/lib/validation/schema/__helper__/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ module.exports = {
// customConfiguration tests
customConfiguration.defineTests(test, assertValidation, type);


// version specific tests
["2.0", "2.1"].forEach((specVersion) => {
// tests for all kinds and version 2.0 and 2.1
["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, {
"specVersion": specVersion,
Expand Down Expand Up @@ -279,7 +278,7 @@ module.exports = {
params: {
additionalProperty: "notAllowed",
},
schemaPath: specVersion === "2.1" ? "#/then/additionalProperties" : "#/else/additionalProperties",
schemaPath: specVersion !== "2.0" ? "#/then/additionalProperties" : "#/else/additionalProperties",
}]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.after.always((t) => {
};
t.context.ajvCoverage.verify(thresholds);
});
["2.0", "2.1"].forEach((specVersion) => {
["2.2", "2.1", "2.0"].forEach((specVersion) => {
test(`Type project-shim (${specVersion})`, async (t) => {
await assertValidation(t, {
"specVersion": specVersion,
Expand Down
Loading