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

[BREAKING] Schema: Restrict metadata.name for specVersion >= 3.0 #552

Merged
merged 3 commits into from
Jan 27, 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
5 changes: 4 additions & 1 deletion lib/specifications/Specification.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Specification {
this._log.verbose(err.message);
throw new Error(
`${config.kind} ${config.metadata.name} defines unsupported Specification Version ` +
`${originalSpecVersion}. Please manually upgrade to 2.0 or higher. ` +
`${originalSpecVersion}. Please manually upgrade to 3.0 or higher. ` +
`For details see https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions - ` +
`An attempted migration to a supported specification version failed, ` +
`likely due to unrecognized configuration. Check verbose log for details.`);
Expand Down Expand Up @@ -249,6 +249,9 @@ class Specification {
}

_migrateLegacyProject(config) {
// Stick to 2.6 since 3.0 adds further restrictions (i.e. for the name) and enables
// functionality for extensions that shouldn't be enabled if the specVersion is not
// explicitly set to 3.x
config.specVersion = "2.6";

// propertiesFileSourceEncoding (relevant for applications and libraries) default
Expand Down
19 changes: 19 additions & 0 deletions lib/validation/schema/specVersion/kind/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@
"type": "string"
}
}
},
"metadata-3.0": {
"type": "object",
"required": ["name"],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 3,
"maxLength": 50,
"pattern": "^(?:@[0-9a-z-_.]+\\/)?[a-z][0-9a-z-_.]*$",
"title": "Extension Name",
"description": "Unique identifier for the extension. E.g. ui5-task-fearless-rock",
"errorMessage": "Not a valid extension name. It must consist of lowercase alphanumeric characters, dash, underscore and period only. Additionally, it may contain an npm-style package scope. For details see: https://sap.github.io/ui5-tooling/stable/pages/Configuration/#name"
},
"copyright": {
"type": "string"
}
}
}
}
}
69 changes: 50 additions & 19 deletions lib/validation/schema/specVersion/kind/extension/project-shim.json
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", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"] }
"specVersion": { "enum": ["3.0"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"]
"enum": ["3.0"]
},
"kind": {
"enum": ["extension"]
Expand All @@ -22,7 +22,7 @@
"enum": ["project-shim"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
"$ref": "../extension.json#/definitions/metadata-3.0"
},
"shims": {
"$ref": "#/definitions/shims"
Expand All @@ -34,22 +34,53 @@
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["2.0"]
},
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["project-shim"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"shims": {
"$ref": "#/definitions/shims"
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"]
},
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["project-shim"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"shims": {
"$ref": "#/definitions/shims"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": {
"enum": ["2.0"]
},
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["project-shim"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"shims": {
"$ref": "#/definitions/shims"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
"required": ["specVersion", "kind", "type", "metadata", "middleware"],
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"] }
"specVersion": { "enum": ["3.0"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"] },
"specVersion": { "enum": ["3.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["server-middleware"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
"$ref": "../extension.json#/definitions/metadata-3.0"
},
"middleware": {
"$ref": "#/definitions/middleware"
Expand All @@ -33,20 +33,49 @@
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["server-middleware"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"middleware": {
"$ref": "#/definitions/middleware"
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["server-middleware"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"middleware": {
"$ref": "#/definitions/middleware"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["server-middleware"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"middleware": {
"$ref": "#/definitions/middleware"
}
}
}
},
Expand Down
63 changes: 46 additions & 17 deletions lib/validation/schema/specVersion/kind/extension/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
"required": ["specVersion", "kind", "type", "metadata", "task"],
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"] }
"specVersion": { "enum": ["3.0"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.0"] },
"specVersion": { "enum": ["3.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["task"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
"$ref": "../extension.json#/definitions/metadata-3.0"
},
"task": {
"$ref": "#/definitions/task"
Expand All @@ -32,20 +32,49 @@
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["task"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"task": {
"$ref": "#/definitions/task"
"if": {
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"] }
}
},
"then": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["task"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"task": {
"$ref": "#/definitions/task"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"specVersion": { "enum": ["2.0"] },
"kind": {
"enum": ["extension"]
},
"type": {
"enum": ["task"]
},
"metadata": {
"$ref": "../extension.json#/definitions/metadata"
},
"task": {
"$ref": "#/definitions/task"
}
}
}
},
Expand Down
31 changes: 31 additions & 0 deletions lib/validation/schema/specVersion/kind/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,37 @@
}
}
},
"metadata-3.0": {
"type": "object",
"required": ["name"],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 3,
"maxLength": 50,
"pattern": "^(?:@[0-9a-z-_.]+\\/)?[a-z][0-9a-z-_.]*$",
"title": "Project Name",
"description": "Unique identifier for the project. E.g. organization.product.project",
"errorMessage": "Not a valid project name. It must consist of lowercase alphanumeric characters, dash, underscore and period only. Additionally, it may contain an npm-style package scope. For details see: https://sap.github.io/ui5-tooling/stable/pages/Configuration/#name"
},
"copyright": {
"type": "string"
},
"deprecated": {
"type": "boolean",
"default": false
},
"sapInternal": {
"type": "boolean",
"default": false
},
"allowSapInternal": {
"type": "boolean",
"default": false
}
}
},
"resources-configuration-propertiesFileSourceEncoding": {
"enum": ["UTF-8", "ISO-8859-1"],
"default": "UTF-8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"enum": ["application"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
"$ref": "../project.json#/definitions/metadata-3.0"
},
"framework": {
"$ref": "../project.json#/definitions/framework"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"enum": ["library"]
},
"metadata": {
"$ref": "../project.json#/definitions/metadata"
"$ref": "../project.json#/definitions/metadata-3.0"
},
"framework": {
"$ref": "../project.json#/definitions/framework"
Expand Down
Loading