Skip to content

[FEATURE] Add specVersion 3.1 and builder resource excludes for modules #639

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

Merged
merged 5 commits into from
Aug 21, 2023
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
22 changes: 19 additions & 3 deletions lib/specifications/SpecificationVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const SPEC_VERSION_PATTERN = /^\d+\.\d+$/;
const SUPPORTED_VERSIONS = [
"0.1", "1.0", "1.1",
"2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6",
"3.0"
"3.0", "3.1"
];

/**
Expand Down Expand Up @@ -63,8 +63,8 @@ class SpecificationVersion {
* Test whether the instance's Specification Version falls into the provided range
*
* @public
@param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
for example <code>2.2 - 2.4</code>
* @param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
* for example <code>2.2 - 2.4</code> or <code>=3.0</code>
* @returns {boolean} True if the instance's Specification Version falls into the provided range
*/
satisfies(range) {
Expand Down Expand Up @@ -263,6 +263,22 @@ for example <code>2.2 - 2.4</code>
const comparator = new SpecificationVersion(specVersion);
return comparator.neq(testVersion);
}

/**
* Creates an array of Specification Versions that match with the provided range. This is mainly used
* for testing purposes. I.e. to execute identical tests for a range of specification versions.
*
* @public
* @param {string} range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
* for example <code>2.2 - 2.4</code> or <code>=3.0</code>
* @returns {string[]} Array of versions that match the specified range
*/
static getVersionsForRange(range) {
return SUPPORTED_VERSIONS.filter((specVersion) => {
const comparator = new SpecificationVersion(specVersion);
return comparator.satisfies(range);
});
}
}

function getUnsupportedSpecVersionMessage(specVersion) {
Expand Down
8 changes: 7 additions & 1 deletion lib/specifications/types/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ class Application extends ComponentProject {
return null; // Applications do not have a dedicated test directory
}

/**
* Get a resource reader for the sources of the project (excluding any test resources)
* without a virtual base path
*
* @returns {@ui5/fs/ReaderCollection} Reader collection
*/
_getRawSourceReader() {
return createReader({
fsBasePath: this.getSourcePath(),
virBasePath: "/",
name: `Source reader for application project ${this.getName()}`,
name: `Raw source reader for application project ${this.getName()}`,
project: this
});
}
Expand Down
5 changes: 3 additions & 2 deletions lib/specifications/types/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ class Library extends ComponentProject {
}

/**
*
* Get a resource reader for the sources of the project (excluding any test resources)
* without a virtual base path.
* In the future the path structure can be flat or namespaced depending on the project
* setup
*
* @returns {@ui5/fs/ReaderCollection} Reader collection
*/
_getRawSourceReader() {
return resourceFactory.createReader({
fsBasePath: this.getSourcePath(),
virBasePath: "/",
name: `Source reader for library project ${this.getName()}`,
name: `Raw source reader for library project ${this.getName()}`,
project: this
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/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": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "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": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["3.0"]
"enum": ["3.0", "3.1"]
},
"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": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.0", "3.1"] },
"kind": {
"enum": ["extension"]
},
Expand Down
4 changes: 2 additions & 2 deletions lib/validation/schema/specVersion/kind/extension/task.json
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": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.0", "3.1"] },
"kind": {
"enum": ["extension"]
},
Expand Down
3 changes: 2 additions & 1 deletion lib/validation/schema/specVersion/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": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"kind": {
"enum": ["project", null],
"$comment": "Using null to allow not defining 'kind' which defaults to project"
Expand All @@ -19,6 +19,7 @@
]
}
},

"if": {
"properties": {
"type": {"const": null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"required": ["specVersion", "type", "metadata"],
"if": {
"properties": {
"specVersion": { "enum": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.0", "3.1"] },
"kind": {
"enum": ["project", null]
},
Expand Down
4 changes: 2 additions & 2 deletions lib/validation/schema/specVersion/kind/project/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"required": ["specVersion", "type", "metadata"],
"if": {
"properties": {
"specVersion": { "enum": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.0", "3.1"] },
"kind": {
"enum": ["project", null]
},
Expand Down
91 changes: 69 additions & 22 deletions lib/validation/schema/specVersion/kind/project/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"required": ["specVersion", "type", "metadata"],
"if": {
"properties": {
"specVersion": { "enum": ["3.0"] }
"specVersion": { "enum": ["3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.1"] },
"kind": {
"enum": ["project", null]
},
Expand All @@ -26,7 +26,7 @@
"$ref": "#/definitions/resources"
},
"builder": {
"$ref": "#/definitions/builder-specVersion-2.5"
"$ref": "#/definitions/builder-specVersion-3.1"
},
"server": {
"$ref": "../project.json#/definitions/server"
Expand All @@ -40,21 +40,21 @@
"else": {
"if": {
"properties": {
"specVersion": { "enum": ["2.5", "2.6"] }
"specVersion": { "enum": ["3.0"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.5", "2.6"] },
"specVersion": { "enum": ["3.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["module"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
"$ref": "../project.json#/definitions/metadata-3.0"
},
"resources": {
"$ref": "#/definitions/resources"
Expand All @@ -74,13 +74,13 @@
"else": {
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] }
"specVersion": { "enum": ["2.5", "2.6"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] },
"specVersion": { "enum": ["2.5", "2.6"] },
"kind": {
"enum": ["project", null]
},
Expand All @@ -93,27 +93,62 @@
"resources": {
"$ref": "#/definitions/resources"
},
"builder": {
"$ref": "#/definitions/builder-specVersion-2.5"
},
"server": {
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["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", "2.2", "2.3", "2.4"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["module"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
},
"resources": {
"$ref": "#/definitions/resources"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.0"] },
"kind": {
"enum": ["project", null]
},
"type": {
"enum": ["module"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
},
"resources": {
"$ref": "#/definitions/resources"
}
}
}
}
Expand Down Expand Up @@ -149,6 +184,18 @@
"$ref": "../project.json#/definitions/builder-settings"
}
}
},
"builder-specVersion-3.1": {
"type": "object",
"additionalProperties": false,
"properties": {
"resources": {
"$ref": "../project.json#/definitions/builder-resources"
},
"settings": {
"$ref": "../project.json#/definitions/builder-settings"
}
Comment on lines +195 to +197
Copy link
Member

Choose a reason for hiding this comment

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

I think this also makes sense to add, but we never talked about it, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I missed that.

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"required": ["specVersion", "type", "metadata"],
"if": {
"properties": {
"specVersion": { "enum": ["3.0"] }
"specVersion": { "enum": ["3.0", "3.1"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["3.0"] },
"specVersion": { "enum": ["3.0", "3.1"] },
"kind": {
"enum": ["project", null]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/specVersion.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion"],
"properties": {
"specVersion": { "enum": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "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
6 changes: 3 additions & 3 deletions lib/validation/schema/ui5.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"properties": {
"specVersion": {
"enum": [
"3.0",
"3.1", "3.0",
"2.6", "2.5", "2.4", "2.3", "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: \"3.0\", \"2.6\", \"2.5\", \"2.4\", \"2.3\", \"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"
"errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"3.1\", \"3.0\", \"2.6\", \"2.5\", \"2.4\", \"2.3\", \"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": ["3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }
"specVersion": { "enum": ["3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }
}
},
"then": {
Expand Down
Loading