Skip to content

Commit 20bd0c3

Browse files
committed
fix(project): Allow Component.ts
1 parent 2a84111 commit 20bd0c3

File tree

6 files changed

+60
-5
lines changed

6 files changed

+60
-5
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ class Component extends ComponentProject {
292292

293293
async _ensureComponent() {
294294
// Ensure that a Component.js exists
295-
const componentResource = await this._getRawSourceReader().byPath("/Component.js");
295+
const componentResource = await this._getRawSourceReader().byPath("/Component.js") ||
296+
await this._getRawSourceReader().byPath("/Component.ts");
296297
if (!componentResource) {
297298
throw new Error(
298-
`Unable to find required file Component.js in component project ${this.getName()}`);
299+
`Unable to find either required "Component.js" or "Component.ts"` +
300+
` in component project ${this.getName()}`
301+
);
299302
}
300303
}
301304
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sap.ui.define(["sap/ui/core/UIComponent"], function(UIComponent){
2+
"use strict";
3+
return UIComponent.extend('application.h.Component', {
4+
metadata: {
5+
manifest: "json"
6+
}
7+
});
8+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"_version": "1.1.0",
3+
"sap.app": {
4+
"_version": "1.1.0",
5+
"id": "${componentName}",
6+
"type": "application",
7+
"applicationVersion": {
8+
"version": "1.2.2"
9+
},
10+
"embeds": ["embedded"],
11+
"title": "{{title}}"
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import UIComponent from "sap/ui/core/UIComponent";
2+
3+
export default class Component extends UIComponent {
4+
public static metadata = {
5+
"manifest": "json"
6+
};
7+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"_version": "1.1.0",
3+
"sap.app": {
4+
"_version": "1.1.0",
5+
"id": "${componentName}",
6+
"type": "application",
7+
"applicationVersion": {
8+
"version": "1.2.2"
9+
},
10+
"embeds": ["embedded"],
11+
"title": "{{title}}"
12+
}
13+
}

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,22 @@ test("namespace: detect namespace from pom.xml via ${appId} from properties", as
678678
" couldn't be resolved from maven property \"appId\" of pom.xml of project component.h");
679679
});
680680

681-
test("Throw for missing Component.js", async (t) => {
681+
test("Throw when neither Component.js nor Component.ts exists", async (t) => {
682682
const {componentHInput} = t.context;
683683
componentHInput.configuration.resources.configuration.paths.src = "src-no-component";
684-
685684
const error = await t.throwsAsync(Specification.create(componentHInput));
686685
t.is(error.message,
687-
"Unable to find required file Component.js in component project component.h");
686+
"Unable to find either required \"Component.js\" or \"Component.ts\" in component project component.h");
687+
});
688+
689+
test("Do not throw when Component.js exists", async (t) => {
690+
const {componentHInput} = t.context;
691+
componentHInput.configuration.resources.configuration.paths.src = "src-with-component-js";
692+
await t.notThrowsAsync(Specification.create(componentHInput), "Should not throw an error");
693+
});
694+
695+
test("Do not throw when Component.ts exists", async (t) => {
696+
const {componentHInput} = t.context;
697+
componentHInput.configuration.resources.configuration.paths.src = "src-with-component-ts";
698+
await t.notThrowsAsync(Specification.create(componentHInput), "Should not throw an error");
688699
});

0 commit comments

Comments
 (0)