@sap-ux/fe-fpm-writer 0.13.4 → 0.14.0
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 +2 -2
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +3 -2
- package/dist/building-block/index.js +2 -1
- package/dist/column/index.js +2 -2
- 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 +4 -3
- package/dist/page/list.js +1 -1
- package/dist/page/object.js +1 -1
- package/dist/section/index.js +2 -2
- package/dist/view/index.js +2 -2
- 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,11 +77,11 @@ 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);
|
|
84
|
-
Object.assign(actions, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `action/manifest.action.json`)), config)));
|
|
84
|
+
Object.assign(actions, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `action/manifest.action.json`)), config, {})));
|
|
85
85
|
fs.writeJSON(manifestPath, manifest);
|
|
86
86
|
return fs;
|
|
87
87
|
}
|
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
|
}
|
|
@@ -95,6 +95,7 @@ function getOrAddMacrosNamespace(ui5XmlDocument) {
|
|
|
95
95
|
const macrosNamespaceEntry = Object.entries(namespaceMap).find(([_, value]) => value === 'sap.fe.macros');
|
|
96
96
|
if (!macrosNamespaceEntry) {
|
|
97
97
|
ui5XmlDocument.firstChild._nsMap['macros'] = 'sap.fe.macros';
|
|
98
|
+
ui5XmlDocument.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:macros', 'sap.fe.macros');
|
|
98
99
|
}
|
|
99
100
|
return macrosNamespaceEntry ? macrosNamespaceEntry[0] : 'macros';
|
|
100
101
|
}
|
|
@@ -112,7 +113,7 @@ function getTemplateDocument(buildingBlockData, viewDocument, fs) {
|
|
|
112
113
|
const templateContent = ejs_1.render(fs.read(templateFilePath), {
|
|
113
114
|
macrosNamespace: getOrAddMacrosNamespace(viewDocument),
|
|
114
115
|
data: buildingBlockData
|
|
115
|
-
});
|
|
116
|
+
}, {});
|
|
116
117
|
const errorHandler = (level, message) => {
|
|
117
118
|
throw new Error(`Unable to parse template file with building block data. Details: [${level}] - ${message}`);
|
|
118
119
|
};
|
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
|
|
@@ -72,7 +72,7 @@ function generateCustomColumn(basePath, customColumn, fs) {
|
|
|
72
72
|
const completeColumn = enhanceConfig(fs, root, customColumn, manifestPath, manifest);
|
|
73
73
|
// enhance manifest with column definition
|
|
74
74
|
const manifestRoot = getManifestRoot(customColumn.ui5Version);
|
|
75
|
-
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeColumn);
|
|
75
|
+
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeColumn, {});
|
|
76
76
|
fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
|
|
77
77
|
// add fragment
|
|
78
78
|
const viewPath = path_1.join(completeColumn.path, `${completeColumn.name}.fragment.xml`);
|
|
@@ -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
|
@@ -66,15 +66,16 @@ function generate(basePath, data, fs) {
|
|
|
66
66
|
// merge content into existing files
|
|
67
67
|
const root = getTemplateRoot(data.ui5Version);
|
|
68
68
|
// enhance manifest.json
|
|
69
|
-
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config)), common_1.getManifestJsonExtensionHelper(config));
|
|
69
|
+
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config, {})), common_1.getManifestJsonExtensionHelper(config));
|
|
70
70
|
// add extension content
|
|
71
71
|
const viewPath = path_1.join(config.path, `${config.name}.view.xml`);
|
|
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/page/list.js
CHANGED
|
@@ -50,7 +50,7 @@ function generate(basePath, data, fs) {
|
|
|
50
50
|
const manifest = fs.readJSON(manifestPath);
|
|
51
51
|
const config = enhanceData(data, manifest);
|
|
52
52
|
// enhance manifest.json
|
|
53
|
-
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/list/manifest.json')), config)), common_1.getManifestJsonExtensionHelper(config));
|
|
53
|
+
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/list/manifest.json')), config, {})), common_1.getManifestJsonExtensionHelper(config));
|
|
54
54
|
return fs;
|
|
55
55
|
}
|
|
56
56
|
exports.generate = generate;
|
package/dist/page/object.js
CHANGED
|
@@ -41,7 +41,7 @@ function generate(basePath, data, fs) {
|
|
|
41
41
|
const manifest = fs.readJSON(manifestPath);
|
|
42
42
|
const config = enhanceData(data, manifest);
|
|
43
43
|
// enhance manifest.json
|
|
44
|
-
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/object/manifest.json')), config)), common_1.getManifestJsonExtensionHelper(config));
|
|
44
|
+
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/object/manifest.json')), config, {})), common_1.getManifestJsonExtensionHelper(config));
|
|
45
45
|
return fs;
|
|
46
46
|
}
|
|
47
47
|
exports.generate = generate;
|
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);
|
|
@@ -66,7 +66,7 @@ function generateCustomSection(basePath, customSection, fs) {
|
|
|
66
66
|
const completeSection = enhanceConfig(fs, root, customSection, manifestPath, manifest);
|
|
67
67
|
// enhance manifest with section definition
|
|
68
68
|
const manifestRoot = getManifestRoot(root, customSection.ui5Version);
|
|
69
|
-
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeSection);
|
|
69
|
+
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeSection, {});
|
|
70
70
|
fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
|
|
71
71
|
// add fragment
|
|
72
72
|
const viewPath = path_1.join(completeSection.path, `${completeSection.name}.fragment.xml`);
|
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])
|
|
@@ -61,7 +61,7 @@ function generateCustomView(basePath, customView, fs) {
|
|
|
61
61
|
// merge with defaults
|
|
62
62
|
const completeView = enhanceConfig(fs, root, customView, manifestPath, manifest);
|
|
63
63
|
// enhance manifest with view definition
|
|
64
|
-
const filledTemplate = ejs_1.render(fs.read(path_1.join(root, 'view', `manifest.json`)), completeView);
|
|
64
|
+
const filledTemplate = ejs_1.render(fs.read(path_1.join(root, 'view', `manifest.json`)), completeView, {});
|
|
65
65
|
fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
|
|
66
66
|
// add fragment
|
|
67
67
|
const viewPath = path_1.join(completeView.path, `${completeView.name}.fragment.xml`);
|
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.0",
|
|
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>
|