Skip to content

Commit a679e16

Browse files
committed
refactor(project): Restrict component type to specVersion >= 5
1 parent 6372e01 commit a679e16

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

packages/project/lib/validation/schema/specVersion/kind/project.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44

55
"type": "object",
66
"required": ["specVersion", "type"],
7+
"allOf": [
8+
{
9+
"if": {
10+
"required": ["type"],
11+
"properties": {
12+
"type": {
13+
"const": "component"
14+
}
15+
}
16+
},
17+
"then": {
18+
"properties": {
19+
"specVersion": {
20+
"const": "5.0",
21+
"errorMessage": "The 'component' type is only supported with specVersion '5.0' and higher."
22+
}
23+
}
24+
}
25+
}
26+
],
727
"properties": {
828
"specVersion": { "enum": ["5.0", "4.0", "3.2", "3.1", "3.0", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
929
"kind": {

packages/project/test/fixtures/component.a/ui5-test-configPath.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
specVersion: "3.1"
2+
specVersion: "5.0"
33
type: component
44
metadata:
55
name: component.a

packages/project/test/fixtures/component.a/ui5-test-error.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
specVersion: "3.1"
2+
specVersion: "5.0"
33
type: component
44
metadata:
55
name: component.a
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
specVersion: "3.1"
2+
specVersion: "5.0"
33
type: component
44
metadata:
55
name: component.a

packages/project/test/lib/specifications/types/Component.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.beforeEach((t) => {
1717
version: "1.0.0",
1818
modulePath: componentAPath,
1919
configuration: {
20-
specVersion: "3.1",
20+
specVersion: "5.0",
2121
kind: "project",
2222
type: "component",
2323
metadata: {name: "component.a"}
@@ -29,7 +29,7 @@ test.beforeEach((t) => {
2929
version: "1.0.0",
3030
modulePath: componentHPath,
3131
configuration: {
32-
specVersion: "3.1",
32+
specVersion: "5.0",
3333
kind: "project",
3434
type: "component",
3535
metadata: {name: "component.h"},
@@ -405,7 +405,7 @@ test("_configureAndValidatePaths: Custom src directory", async (t) => {
405405
version: "1.0.0",
406406
modulePath: componentHPath,
407407
configuration: {
408-
specVersion: "3.1",
408+
specVersion: "5.0",
409409
kind: "project",
410410
type: "component",
411411
metadata: {name: "component.h"},

packages/project/test/lib/validation/schema/specVersion/kind/project.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test("Type library (no kind)", async (t) => {
8383

8484
test("Type component", async (t) => {
8585
await assertValidation(t, {
86-
"specVersion": "3.1",
86+
"specVersion": "5.0",
8787
"kind": "project",
8888
"type": "component",
8989
"metadata": {
@@ -94,14 +94,40 @@ test("Type component", async (t) => {
9494

9595
test("Type component (no kind)", async (t) => {
9696
await assertValidation(t, {
97-
"specVersion": "3.1",
97+
"specVersion": "5.0",
9898
"type": "component",
9999
"metadata": {
100100
"name": "my-component"
101101
}
102102
});
103103
});
104104

105+
test("Type component, legacy specVersion", async (t) => {
106+
await assertValidation(t, {
107+
"specVersion": "4.0",
108+
"kind": "project",
109+
"type": "component",
110+
"metadata": {
111+
"name": "my-component"
112+
}
113+
}, [{
114+
dataPath: "/specVersion",
115+
keyword: "errorMessage",
116+
message: "The 'component' type is only supported with specVersion '5.0' and higher.",
117+
params: {
118+
errors: [{
119+
dataPath: "/specVersion",
120+
keyword: "const",
121+
message: "should be equal to constant",
122+
params: {
123+
allowedValue: "5.0",
124+
},
125+
schemaPath: "#/allOf/0/then/properties/specVersion/const",
126+
}],
127+
}
128+
}]);
129+
});
130+
105131
test("Type theme-library", async (t) => {
106132
await assertValidation(t, {
107133
"specVersion": "2.0",

0 commit comments

Comments
 (0)