@sap-ux/fe-fpm-writer 0.13.5 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/index.js +1 -1
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +3 -2
- package/dist/column/index.js +1 -1
- package/dist/common/event-handler.d.ts +2 -1
- package/dist/common/event-handler.js +5 -3
- package/dist/common/types.d.ts +4 -0
- package/dist/page/custom.js +3 -2
- package/dist/section/index.js +1 -1
- package/dist/view/index.js +1 -1
- package/package.json +2 -2
- package/templates/app/Component.ts +20 -0
- package/templates/common/EventHandler.ts +5 -0
- package/templates/page/custom/1.84/ext/Controller.ts +42 -0
- package/templates/page/custom/1.84/ext/View.xml +1 -1
- package/templates/page/custom/1.94/ext/Controller.ts +42 -0
- package/templates/page/custom/1.94/ext/View.xml +1 -1
package/dist/action/index.js
CHANGED
|
@@ -77,7 +77,7 @@ function generateCustomAction(basePath, actionConfig, fs) {
|
|
|
77
77
|
const root = path_1.join(__dirname, '../../templates');
|
|
78
78
|
// Apply event handler
|
|
79
79
|
if (config.eventHandler) {
|
|
80
|
-
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler);
|
|
80
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler, false, config.typescript);
|
|
81
81
|
}
|
|
82
82
|
// enhance manifest with action definition and controller reference
|
|
83
83
|
const actions = enhanceManifestAndGetActionsElementReference(manifest, config.target);
|
package/dist/app/index.d.ts
CHANGED
package/dist/app/index.js
CHANGED
|
@@ -68,8 +68,9 @@ function enableFPM(basePath, config = {}, fs) {
|
|
|
68
68
|
}
|
|
69
69
|
// replace Component.js
|
|
70
70
|
if (config.replaceAppComponent) {
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const ext = config.typescript ? 'ts' : 'js';
|
|
72
|
+
const componentTemplate = path_1.join(__dirname, `../../templates/app/Component.${ext}`);
|
|
73
|
+
fs.copyTpl(componentTemplate, path_1.join(basePath, `webapp/Component.${ext}`), manifest['sap.app']);
|
|
73
74
|
}
|
|
74
75
|
return fs;
|
|
75
76
|
}
|
package/dist/column/index.js
CHANGED
|
@@ -42,7 +42,7 @@ function enhanceConfig(fs, root, data, manifestPath, manifest) {
|
|
|
42
42
|
defaults_1.setCommonDefaults(config, manifestPath, manifest);
|
|
43
43
|
// Apply event handler
|
|
44
44
|
if (config.eventHandler) {
|
|
45
|
-
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler);
|
|
45
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler, false, config.typescript);
|
|
46
46
|
}
|
|
47
47
|
// generate column content
|
|
48
48
|
const content = config.properties && config.properties.length > 0
|
|
@@ -8,7 +8,8 @@ import type { EventHandlerConfiguration, InternalCustomElement } from '../common
|
|
|
8
8
|
* @param {InternalCustomElement} config - configuration
|
|
9
9
|
* @param {EventHandlerConfiguration | true | string} [eventHandler] - eventHandler for creation
|
|
10
10
|
* @param {boolean} [controllerSuffix=false] - append controller suffix to new file
|
|
11
|
+
* @param {boolean} typescript - create Typescript file instead of Javascript
|
|
11
12
|
* @returns {string} full namespace path to method
|
|
12
13
|
*/
|
|
13
|
-
export declare function applyEventHandlerConfiguration(fs: Editor, root: string, config: Partial<InternalCustomElement>, eventHandler: EventHandlerConfiguration | true | string, controllerSuffix?: boolean): string;
|
|
14
|
+
export declare function applyEventHandlerConfiguration(fs: Editor, root: string, config: Partial<InternalCustomElement>, eventHandler: EventHandlerConfiguration | true | string, controllerSuffix?: boolean, typescript?: boolean): string;
|
|
14
15
|
//# sourceMappingURL=event-handler.d.ts.map
|
|
@@ -11,9 +11,10 @@ const utils_1 = require("../common/utils");
|
|
|
11
11
|
* @param {InternalCustomElement} config - configuration
|
|
12
12
|
* @param {EventHandlerConfiguration | true | string} [eventHandler] - eventHandler for creation
|
|
13
13
|
* @param {boolean} [controllerSuffix=false] - append controller suffix to new file
|
|
14
|
+
* @param {boolean} typescript - create Typescript file instead of Javascript
|
|
14
15
|
* @returns {string} full namespace path to method
|
|
15
16
|
*/
|
|
16
|
-
function applyEventHandlerConfiguration(fs, root, config, eventHandler, controllerSuffix = false) {
|
|
17
|
+
function applyEventHandlerConfiguration(fs, root, config, eventHandler, controllerSuffix = false, typescript) {
|
|
17
18
|
if (typeof eventHandler === 'string') {
|
|
18
19
|
// Existing event handler is passed - no need for file creation/update
|
|
19
20
|
return eventHandler;
|
|
@@ -33,9 +34,10 @@ function applyEventHandlerConfiguration(fs, root, config, eventHandler, controll
|
|
|
33
34
|
fileName = eventHandler.fileName;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
const
|
|
37
|
+
const ext = typescript ? 'ts' : 'js';
|
|
38
|
+
const controllerPath = path_1.join(config.path || '', `${fileName}${controllerSuffix ? '.controller' : ''}.${ext}`);
|
|
37
39
|
if (!fs.exists(controllerPath)) {
|
|
38
|
-
fs.copyTpl(path_1.join(root,
|
|
40
|
+
fs.copyTpl(path_1.join(root, `common/EventHandler.${ext}`), controllerPath, {
|
|
39
41
|
eventHandlerFnName
|
|
40
42
|
});
|
|
41
43
|
}
|
package/dist/common/types.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface CustomElement {
|
|
|
21
21
|
* If nothing can be generated for the given version then an exception is thrown.
|
|
22
22
|
*/
|
|
23
23
|
ui5Version?: number;
|
|
24
|
+
/**
|
|
25
|
+
* If set to true then all code snippets are generated in Typescript instead of Javascript.
|
|
26
|
+
*/
|
|
27
|
+
typescript?: boolean;
|
|
24
28
|
}
|
|
25
29
|
export interface InternalCustomElement extends CustomElement {
|
|
26
30
|
ns: string;
|
package/dist/page/custom.js
CHANGED
|
@@ -72,9 +72,10 @@ function generate(basePath, data, fs) {
|
|
|
72
72
|
if (!fs.exists(viewPath)) {
|
|
73
73
|
fs.copyTpl(path_1.join(root, 'ext/View.xml'), viewPath, config);
|
|
74
74
|
}
|
|
75
|
-
const
|
|
75
|
+
const ext = data.typescript ? 'ts' : 'js';
|
|
76
|
+
const controllerPath = path_1.join(config.path, `${config.name}.controller.${ext}`);
|
|
76
77
|
if (!fs.exists(controllerPath)) {
|
|
77
|
-
fs.copyTpl(path_1.join(root,
|
|
78
|
+
fs.copyTpl(path_1.join(root, `ext/Controller.${ext}`), controllerPath, config);
|
|
78
79
|
}
|
|
79
80
|
return fs;
|
|
80
81
|
}
|
package/dist/section/index.js
CHANGED
|
@@ -39,7 +39,7 @@ function enhanceConfig(fs, root, data, manifestPath, manifest) {
|
|
|
39
39
|
defaults_1.setCommonDefaults(config, manifestPath, manifest);
|
|
40
40
|
// Apply event handler
|
|
41
41
|
if (config.eventHandler) {
|
|
42
|
-
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler);
|
|
42
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler, false, config.typescript);
|
|
43
43
|
}
|
|
44
44
|
// generate section content
|
|
45
45
|
config.content = config.control || defaults_1.getDefaultFragmentContent(config.name, config.eventHandler);
|
package/dist/view/index.js
CHANGED
|
@@ -24,7 +24,7 @@ function enhanceConfig(fs, root, data, manifestPath, manifest) {
|
|
|
24
24
|
defaults_1.setCommonDefaults(config, manifestPath, manifest);
|
|
25
25
|
// Apply event handler
|
|
26
26
|
if (config.eventHandler) {
|
|
27
|
-
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler, true);
|
|
27
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler, true, config.typescript);
|
|
28
28
|
}
|
|
29
29
|
// existing views
|
|
30
30
|
const existingViews = (_e = (_d = ((_c = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets) === null || _c === void 0 ? void 0 : _c[data.target])
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/fe-fpm-writer",
|
|
3
3
|
"description": "SAP Fiori elements flexible programming model writer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/semver": "7.3.9",
|
|
34
34
|
"@types/mem-fs-editor": "7.0.1",
|
|
35
35
|
"@types/mem-fs": "1.1.2",
|
|
36
|
-
"@sap-ux/ui5-config": "0.14.
|
|
36
|
+
"@sap-ux/ui5-config": "0.14.5"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import AppComponent from 'sap/fe/core/AppComponent';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @namespace <%- app.id %>
|
|
5
|
+
*/
|
|
6
|
+
export default class Component extends AppComponent {
|
|
7
|
+
|
|
8
|
+
public static metadata = {
|
|
9
|
+
manifest: "json"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
|
|
14
|
+
* @public
|
|
15
|
+
* @override
|
|
16
|
+
*/
|
|
17
|
+
//public init() : void {
|
|
18
|
+
// super.init();
|
|
19
|
+
//}
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Controller from 'sap/ui/core/mvc/Controller'; /** If UI5 version 1.94 or newer can be used, the change the base controller to sap/fe/core/PageController to get full FEv4 FPM support */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @namespace <%- ns %>.<%- name %>.controller
|
|
5
|
+
*/
|
|
6
|
+
export default class <%- name %> extends Controller {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Called when a controller is instantiated and its View controls (if available) are already created.
|
|
10
|
+
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
|
|
11
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
12
|
+
*/
|
|
13
|
+
// public onInit(): void {
|
|
14
|
+
//
|
|
15
|
+
//}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
|
|
19
|
+
* (NOT before the first rendering! onInit() is used for that one!).
|
|
20
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
21
|
+
*/
|
|
22
|
+
// public onBeforeRendering(): void {
|
|
23
|
+
//
|
|
24
|
+
// },
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
|
|
28
|
+
* This hook is the same one that SAPUI5 controls get after being rendered.
|
|
29
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
30
|
+
*/
|
|
31
|
+
// public onAfterRendering(): void {
|
|
32
|
+
//
|
|
33
|
+
// },
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
|
|
37
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
38
|
+
*/
|
|
39
|
+
// public onExit(): void {
|
|
40
|
+
//
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
|
|
2
2
|
xmlns:html="http://www.w3.org/1999/xhtml" controllerName="<%- ns %>.<%- name %>">
|
|
3
|
-
<Page title="<%- view.title %>">
|
|
3
|
+
<Page id="<%- name %>" title="<%- view.title %>">
|
|
4
4
|
<content></content>
|
|
5
5
|
</Page>
|
|
6
6
|
</mvc:View>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Controller from 'sap/fe/core/PageController';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @namespace <%- ns %>.<%- name %>.controller
|
|
5
|
+
*/
|
|
6
|
+
export default class <%- name %> extends Controller {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Called when a controller is instantiated and its View controls (if available) are already created.
|
|
10
|
+
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
|
|
11
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
12
|
+
*/
|
|
13
|
+
// public onInit(): void {
|
|
14
|
+
//
|
|
15
|
+
//}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
|
|
19
|
+
* (NOT before the first rendering! onInit() is used for that one!).
|
|
20
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
21
|
+
*/
|
|
22
|
+
// public onBeforeRendering(): void {
|
|
23
|
+
//
|
|
24
|
+
// },
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
|
|
28
|
+
* This hook is the same one that SAPUI5 controls get after being rendered.
|
|
29
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
30
|
+
*/
|
|
31
|
+
// public onAfterRendering(): void {
|
|
32
|
+
//
|
|
33
|
+
// },
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
|
|
37
|
+
* @memberOf <%- ns %>.<%- name %>
|
|
38
|
+
*/
|
|
39
|
+
// public onExit(): void {
|
|
40
|
+
//
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
|
|
2
2
|
xmlns:html="http://www.w3.org/1999/xhtml" controllerName="<%- ns %>.<%- name %>">
|
|
3
|
-
<Page title="<%- view.title %>">
|
|
3
|
+
<Page id="<%- name %>" title="<%- view.title %>">
|
|
4
4
|
<content></content>
|
|
5
5
|
</Page>
|
|
6
6
|
</mvc:View>
|