Skip to content
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
19 changes: 15 additions & 4 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration
This document describes the configuration of UI5 Build and Development Tooling based projects and extensions.

The content represents the **[Specification Version](#specification-versions) `0.1`**.
The content represents the **[Specification Version](#specification-versions) `1.0`**.

## Contents
- [Project Configuration](#project-configuration)
Expand Down Expand Up @@ -282,8 +282,19 @@ shims:
## Specification Versions
The specification version as configured in the `specVersion` property, defines the version a configuration is based on.

**List of all available specification versions:**
### Compatibility Matrix

Version | Description
Version | [UI5 CLI](https://github.com/SAP/ui5-cli) Release
--- | ---
**0.1** | Initial version
**0.1** | v0.0.1+
**1.0** | v1.0.0+

### Specification Version 0.1
Initial version.

Version 0.1 projects are compatible with [UI5 CLI](https://github.com/SAP/ui5-cli) v0.0.1 and above.

### Specification Version 1.0
First stable release.

Version 1.0 projects are supported by [UI5 CLI](https://github.com/SAP/ui5-cli) v1.0.0 and above.
14 changes: 8 additions & 6 deletions lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ class ProjectPreprocessor {
return false; // ignore this project
}

if (project.specVersion !== "0.1") {
if (project.specVersion !== "0.1" && project.specVersion !== "1.0") {
throw new Error(
`Invalid specification version defined for project ${project.id}: ${project.specVersion}. ` +
"The currently only allowed version is \"0.1\"");
"See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions");
}

if (!project.type) {
Expand Down Expand Up @@ -324,10 +324,11 @@ class ProjectPreprocessor {

if (!extension.specVersion) {
throw new Error(`No specification version defined for extension ${extension.metadata.name}`);
} else if (extension.specVersion !== "0.1") {
} else if (extension.specVersion !== "0.1" && extension.specVersion !== "1.0") {
throw new Error(
`Invalid specification version defined for extension ${extension.metadata.name}: ` +
`${extension.specVersion}. The currently only allowed version is "0.1"`);
`Invalid specification version defined for extension ` +
`${extension.metadata.name}: ${extension.specVersion}. ` +
`See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#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 Expand Up @@ -510,5 +511,6 @@ module.exports = {
*/
processTree: function(tree) {
return new ProjectPreprocessor().processTree(tree);
}
},
ProjectPreprocessor
};
2 changes: 1 addition & 1 deletion test/fixtures/application.a/ui5.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
specVersion: "0.1"
specVersion: "1.0"
type: application
metadata:
name: application.a
86 changes: 86 additions & 0 deletions test/lib/extensions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const {test} = require("ava");
const path = require("path");
const sinon = require("sinon");
const projectPreprocessor = require("../..").projectPreprocessor;
const Preprocessor = require("../..").projectPreprocessor.ProjectPreprocessor;
const applicationAPath = path.join(__dirname, "..", "fixtures", "application.a");
const legacyLibraryAPath = path.join(__dirname, "..", "fixtures", "legacy.library.a");
const legacyLibraryBPath = path.join(__dirname, "..", "fixtures", "legacy.library.b");
Expand All @@ -10,6 +12,10 @@ const legacyCollectionLibraryX = path.join(__dirname, "..", "fixtures", "legacy.
const legacyCollectionLibraryY = path.join(__dirname, "..", "fixtures", "legacy.collection.a",
"src", "legacy.library.y");

test.afterEach.always((t) => {
sinon.restore();
});

test("Project with project-shim extension with dependency configuration", (t) => {
const tree = {
id: "application.a",
Expand Down Expand Up @@ -570,3 +576,83 @@ test("Project with task extension dependency - task module not found", async (t)
const error = await t.throws(projectPreprocessor.processTree(tree));
t.regex(error.message, /^Cannot find module.*/, "Rejected with error");
});

test("specVersion: Missing version", async (t) => {
const extension = {
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
kind: "extension",
type: "project-shim",
metadata: {
name: "shims.a"
},
shims: {}
};
const preprocessor = new Preprocessor();
await t.throws(preprocessor.applyExtension(extension),
"No specification version defined for extension shims.a",
"Rejected with error");
});

test("specVersion: Extension with invalid version", async (t) => {
const extension = {
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.9",
kind: "extension",
type: "project-shim",
metadata: {
name: "shims.a"
},
shims: {}
};
const preprocessor = new Preprocessor();
await t.throws(preprocessor.applyExtension(extension),
"Invalid specification version defined for extension shims.a: 0.9. " +
"See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions",
"Rejected with error");
});

test("specVersion: Extension with valid version 0.1", async (t) => {
const extension = {
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.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, "0.1", "Correct spec version");
});

test("specVersion: Extension with valid version 1.0", async (t) => {
const extension = {
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "1.0",
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.0", "Correct spec version");
});
80 changes: 73 additions & 7 deletions test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test("Project with inline configuration", (t) => {
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.1",
specVersion: "1.0",
type: "application",
metadata: {
name: "xy"
Expand All @@ -43,7 +43,7 @@ test("Project with inline configuration", (t) => {
id: "application.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
specVersion: "1.0",
path: applicationAPath
}, "Parsed correctly");
});
Expand Down Expand Up @@ -113,7 +113,7 @@ test("Project with ui5.yaml at default location", (t) => {
id: "application.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
specVersion: "1.0",
path: applicationAPath
}, "Parsed correctly");
});
Expand Down Expand Up @@ -332,7 +332,7 @@ test("Ignores additional application-projects", (t) => {
id: "application.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
specVersion: "1.0",
path: applicationAPath
}, "Parsed correctly");
});
Expand Down Expand Up @@ -540,7 +540,7 @@ test("Project tree B with inline configs", (t) => {
const treeAWithInlineConfigs = {
id: "application.a",
version: "1.0.0",
specVersion: "0.1",
specVersion: "1.0",
path: applicationAPath,
type: "application",
metadata: {
Expand Down Expand Up @@ -654,7 +654,7 @@ const expectedTreeAWithInlineConfigs = {
"id": "application.a",
"kind": "project",
"version": "1.0.0",
"specVersion": "0.1",
"specVersion": "1.0",
"path": applicationAPath,
"_level": 0,
"type": "application",
Expand Down Expand Up @@ -760,7 +760,7 @@ const expectedTreeAWithConfigPaths = {
"id": "application.a",
"kind": "project",
"version": "1.0.0",
"specVersion": "0.1",
"specVersion": "1.0",
"path": applicationAPath,
"configPath": path.join(applicationAPath, "ui5.yaml"),
"_level": 0,
Expand Down Expand Up @@ -1370,3 +1370,69 @@ test("Library version in package.json data is missing", (t) => {
t.is(error.message, "\"version\" is missing for project " + tree.id);
});
});

test("specVersion: Missing version", (t) => {
const tree = {
id: "application.a",
path: "non-existent",
dependencies: [],
version: "1.0.0",
type: "application",
metadata: {
name: "xy"
}
};
return t.throws(projectPreprocessor.processTree(tree),
"No specification version defined for root project application.a",
"Rejected with error");
});

test("specVersion: Project with invalid version", async (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.9",
type: "application",
metadata: {
name: "xy"
}
};
await t.throws(projectPreprocessor.processTree(tree),
"Invalid specification version defined for project application.a: 0.9. " +
"See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions",
"Rejected with error");
});

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

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