@sap-ux/fe-fpm-writer 0.25.1 → 0.25.2
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/common/validate.d.ts +2 -1
- package/dist/common/validate.js +8 -4
- package/dist/page/common.d.ts +11 -2
- package/dist/page/common.js +27 -3
- package/dist/page/custom.js +4 -1
- package/dist/page/list.js +4 -1
- package/dist/page/object.js +4 -1
- package/dist/page/types.d.ts +17 -2
- package/dist/page/types.js +7 -0
- package/package.json +1 -1
- package/templates/page/custom/1.84/manifest.json +3 -0
- package/templates/page/custom/1.94/manifest.json +3 -0
- package/templates/page/list/manifest.json +3 -0
- package/templates/page/object/manifest.json +3 -0
|
@@ -11,9 +11,10 @@ export declare function validateVersion(ui5Version?: string): boolean;
|
|
|
11
11
|
*
|
|
12
12
|
* @param {string} basePath - the base path
|
|
13
13
|
* @param {Editor} fs - the memfs editor instance
|
|
14
|
+
* @param {string[]} dependencies - expected dependencies
|
|
14
15
|
* @returns true if the path is valid, otherwise, throws and error
|
|
15
16
|
*/
|
|
16
|
-
export declare function validateBasePath(basePath: string, fs?: Editor): boolean;
|
|
17
|
+
export declare function validateBasePath(basePath: string, fs?: Editor, dependencies?: string[]): boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Returns the message property if the error is an instance of `Error` else a string representation of the error.
|
|
19
20
|
*
|
package/dist/common/validate.js
CHANGED
|
@@ -24,9 +24,10 @@ exports.validateVersion = validateVersion;
|
|
|
24
24
|
*
|
|
25
25
|
* @param {string} basePath - the base path
|
|
26
26
|
* @param {Editor} fs - the memfs editor instance
|
|
27
|
+
* @param {string[]} dependencies - expected dependencies
|
|
27
28
|
* @returns true if the path is valid, otherwise, throws and error
|
|
28
29
|
*/
|
|
29
|
-
function validateBasePath(basePath, fs) {
|
|
30
|
+
function validateBasePath(basePath, fs, dependencies = ['sap.fe.templates']) {
|
|
30
31
|
if (!fs) {
|
|
31
32
|
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
32
33
|
}
|
|
@@ -36,9 +37,12 @@ function validateBasePath(basePath, fs) {
|
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
38
39
|
const manifest = fs.readJSON(manifestPath);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const libs = manifest['sap.ui5']?.dependencies?.libs;
|
|
41
|
+
dependencies.forEach((dependency) => {
|
|
42
|
+
if (libs?.[dependency] === undefined) {
|
|
43
|
+
throw new Error(`Dependency ${dependency} is missing in the manifest.json. Fiori elements FPM requires the SAP FE libraries.`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
42
46
|
}
|
|
43
47
|
return true;
|
|
44
48
|
}
|
package/dist/page/common.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import type { ManifestNamespace } from '@sap-ux/project-access';
|
|
3
|
-
import type { CustomPage, FCL, FpmPage, InternalCustomPage, InternalObjectPage, ObjectPage, ListReport, Navigation, InternalListReport } from './types';
|
|
3
|
+
import type { CustomPage, FCL, FpmPage, InternalCustomPage, InternalObjectPage, ObjectPage, ListReport, Navigation, InternalListReport, Libraries } from './types';
|
|
4
|
+
import { PageType } from './types';
|
|
4
5
|
import type { Manifest } from '../common/types';
|
|
5
6
|
type EnhancePageConfigFunction = (data: ObjectPage | ListReport, manifest: Manifest) => InternalObjectPage | InternalListReport;
|
|
6
7
|
/**
|
|
@@ -41,6 +42,13 @@ export declare function getManifestJsonExtensionHelper(config: InternalCustomPag
|
|
|
41
42
|
* @returns fcl configuration
|
|
42
43
|
*/
|
|
43
44
|
export declare function getFclConfig(manifest: Manifest, navigation?: Navigation): FCL;
|
|
45
|
+
/**
|
|
46
|
+
* Get the library dependencies for a given page type.
|
|
47
|
+
*
|
|
48
|
+
* @param pageType - Page type for which the dependencies are to be added
|
|
49
|
+
* @returns Library dependencies
|
|
50
|
+
*/
|
|
51
|
+
export declare function getLibraryDependencies(pageType: PageType): Libraries;
|
|
44
52
|
/**
|
|
45
53
|
* Create target settings for a Fiori elements page.
|
|
46
54
|
*
|
|
@@ -55,9 +63,10 @@ export declare function initializeTargetSettings(data: FpmPage, addSettings?: Re
|
|
|
55
63
|
* @param basePath - the base path
|
|
56
64
|
* @param config - the custom page configuration
|
|
57
65
|
* @param fs - the memfs editor instance
|
|
66
|
+
* @param dependencies - expected dependencies
|
|
58
67
|
* @returns the updated memfs editor instance
|
|
59
68
|
*/
|
|
60
|
-
export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor): Editor;
|
|
69
|
+
export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor, dependencies?: never[]): Editor;
|
|
61
70
|
/**
|
|
62
71
|
* Add an generic page to an existing UI5 application.
|
|
63
72
|
* Supported pages - ListReport or ObjectPage.
|
package/dist/page/common.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extendPageJSON = exports.validatePageConfig = exports.initializeTargetSettings = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0;
|
|
3
|
+
exports.extendPageJSON = exports.validatePageConfig = exports.initializeTargetSettings = exports.getLibraryDependencies = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0;
|
|
4
4
|
const mem_fs_1 = require("mem-fs");
|
|
5
5
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const ejs_1 = require("ejs");
|
|
8
8
|
const validate_1 = require("../common/validate");
|
|
9
|
+
const types_1 = require("./types");
|
|
9
10
|
const defaults_1 = require("../common/defaults");
|
|
10
11
|
const file_1 = require("../common/file");
|
|
11
12
|
const templates_1 = require("../templates");
|
|
@@ -121,6 +122,28 @@ function getFclConfig(manifest, navigation) {
|
|
|
121
122
|
return config;
|
|
122
123
|
}
|
|
123
124
|
exports.getFclConfig = getFclConfig;
|
|
125
|
+
/**
|
|
126
|
+
* Get the library dependencies for a given page type.
|
|
127
|
+
*
|
|
128
|
+
* @param pageType - Page type for which the dependencies are to be added
|
|
129
|
+
* @returns Library dependencies
|
|
130
|
+
*/
|
|
131
|
+
function getLibraryDependencies(pageType) {
|
|
132
|
+
const libraries = {};
|
|
133
|
+
switch (pageType) {
|
|
134
|
+
case types_1.PageType.CustomPage: {
|
|
135
|
+
libraries['sap.fe.core'] = {};
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case types_1.PageType.ListReport:
|
|
139
|
+
case types_1.PageType.ObjectPage: {
|
|
140
|
+
libraries['sap.fe.templates'] = {};
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return libraries;
|
|
145
|
+
}
|
|
146
|
+
exports.getLibraryDependencies = getLibraryDependencies;
|
|
124
147
|
/**
|
|
125
148
|
* Create target settings for a Fiori elements page.
|
|
126
149
|
*
|
|
@@ -148,11 +171,12 @@ exports.initializeTargetSettings = initializeTargetSettings;
|
|
|
148
171
|
* @param basePath - the base path
|
|
149
172
|
* @param config - the custom page configuration
|
|
150
173
|
* @param fs - the memfs editor instance
|
|
174
|
+
* @param dependencies - expected dependencies
|
|
151
175
|
* @returns the updated memfs editor instance
|
|
152
176
|
*/
|
|
153
|
-
function validatePageConfig(basePath, config, fs) {
|
|
177
|
+
function validatePageConfig(basePath, config, fs, dependencies = []) {
|
|
154
178
|
// common validators
|
|
155
|
-
(0, validate_1.validateBasePath)(basePath, fs);
|
|
179
|
+
(0, validate_1.validateBasePath)(basePath, fs, dependencies);
|
|
156
180
|
// validate config against the manifest
|
|
157
181
|
if (config.navigation?.sourcePage) {
|
|
158
182
|
const manifest = fs.readJSON((0, path_1.join)(basePath, 'webapp/manifest.json'));
|
package/dist/page/custom.js
CHANGED
|
@@ -5,6 +5,7 @@ const path_1 = require("path");
|
|
|
5
5
|
const mem_fs_1 = require("mem-fs");
|
|
6
6
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
7
7
|
const ejs_1 = require("ejs");
|
|
8
|
+
const types_1 = require("./types");
|
|
8
9
|
const common_1 = require("./common");
|
|
9
10
|
const defaults_1 = require("../common/defaults");
|
|
10
11
|
const validate_1 = require("../common/validate");
|
|
@@ -25,6 +26,8 @@ function enhanceData(data, manifestPath, fs) {
|
|
|
25
26
|
// set common defaults
|
|
26
27
|
const config = (0, defaults_1.setCommonDefaults)(data, manifestPath, manifest);
|
|
27
28
|
config.settings = (0, common_1.initializeTargetSettings)(data);
|
|
29
|
+
// set library dependencies
|
|
30
|
+
config.libraries = (0, common_1.getLibraryDependencies)(types_1.PageType.CustomPage);
|
|
28
31
|
// set FCL configuration
|
|
29
32
|
const fclConfig = (0, common_1.getFclConfig)(manifest, config.navigation);
|
|
30
33
|
config.fcl = fclConfig.fcl;
|
|
@@ -66,7 +69,7 @@ function generate(basePath, data, fs) {
|
|
|
66
69
|
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
67
70
|
}
|
|
68
71
|
(0, validate_1.validateVersion)(data.minUI5Version);
|
|
69
|
-
(0, common_1.validatePageConfig)(basePath, data, fs);
|
|
72
|
+
(0, common_1.validatePageConfig)(basePath, data, fs, []);
|
|
70
73
|
const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
|
|
71
74
|
const config = enhanceData(data, manifestPath, fs);
|
|
72
75
|
// merge content into existing files
|
package/dist/page/list.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const common_1 = require("./common");
|
|
5
|
+
const types_1 = require("./types");
|
|
5
6
|
/**
|
|
6
7
|
* Enhances the provided list report configuration with default data.
|
|
7
8
|
*
|
|
@@ -13,9 +14,11 @@ function enhanceData(data, manifest) {
|
|
|
13
14
|
const config = {
|
|
14
15
|
...data,
|
|
15
16
|
settings: (0, common_1.initializeTargetSettings)(data, data.settings),
|
|
16
|
-
name:
|
|
17
|
+
name: types_1.PageType.ListReport,
|
|
17
18
|
...(0, common_1.getFclConfig)(manifest)
|
|
18
19
|
};
|
|
20
|
+
// set library dependencies
|
|
21
|
+
config.libraries = (0, common_1.getLibraryDependencies)(types_1.PageType.ListReport);
|
|
19
22
|
// use standard file name if i18n enhancement required
|
|
20
23
|
if (config.settings.enhanceI18n === true) {
|
|
21
24
|
config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
|
package/dist/page/object.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const common_1 = require("./common");
|
|
5
|
+
const types_1 = require("./types");
|
|
5
6
|
/**
|
|
6
7
|
* Enhances the provided list report configuration with default data.
|
|
7
8
|
*
|
|
@@ -13,9 +14,11 @@ function enhanceData(data, manifest) {
|
|
|
13
14
|
const config = {
|
|
14
15
|
...data,
|
|
15
16
|
settings: (0, common_1.initializeTargetSettings)(data, data.settings),
|
|
16
|
-
name:
|
|
17
|
+
name: types_1.PageType.ObjectPage,
|
|
17
18
|
...(0, common_1.getFclConfig)(manifest)
|
|
18
19
|
};
|
|
20
|
+
// set library dependencies
|
|
21
|
+
config.libraries = (0, common_1.getLibraryDependencies)(types_1.PageType.ObjectPage);
|
|
19
22
|
// use standard file name if i18n enhancement required
|
|
20
23
|
if (config.settings.enhanceI18n === true) {
|
|
21
24
|
config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
|
package/dist/page/types.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ export interface Navigation {
|
|
|
16
16
|
*/
|
|
17
17
|
navKey?: boolean;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Libraries to be added to the application
|
|
21
|
+
*/
|
|
22
|
+
export type Libraries = {
|
|
23
|
+
[key: string]: {};
|
|
24
|
+
};
|
|
19
25
|
export type StandardPageSettings = {
|
|
20
26
|
enhanceI18n?: string | true;
|
|
21
27
|
variantManagement?: 'Page' | 'None';
|
|
@@ -52,6 +58,10 @@ export interface FpmPage {
|
|
|
52
58
|
* If nothing can be generated for the given version then an exception is thrown.
|
|
53
59
|
*/
|
|
54
60
|
minUI5Version?: string;
|
|
61
|
+
/**
|
|
62
|
+
* UI5 Libraries that should be added to the application.
|
|
63
|
+
*/
|
|
64
|
+
libraries?: Libraries;
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
57
67
|
* Configuration options for adding a list report page.
|
|
@@ -115,15 +125,20 @@ export interface FCL {
|
|
|
115
125
|
export type InternalFpmPage = FCL & {
|
|
116
126
|
settings: Record<string, unknown | undefined>;
|
|
117
127
|
};
|
|
128
|
+
export declare enum PageType {
|
|
129
|
+
ListReport = "ListReport",
|
|
130
|
+
ObjectPage = "ObjectPage",
|
|
131
|
+
CustomPage = "CustomPage"
|
|
132
|
+
}
|
|
118
133
|
/**
|
|
119
134
|
* Additional internal configuration options that will be calculated based on the provided input as well as the target application.
|
|
120
135
|
*/
|
|
121
136
|
export type InternalCustomPage = CustomPage & InternalFpmPage & InternalCustomElement;
|
|
122
137
|
export type InternalListReport = ListReport & InternalFpmPage & {
|
|
123
|
-
name:
|
|
138
|
+
name: PageType.ListReport;
|
|
124
139
|
navigation?: Navigation;
|
|
125
140
|
};
|
|
126
141
|
export type InternalObjectPage = ObjectPage & InternalFpmPage & {
|
|
127
|
-
name:
|
|
142
|
+
name: PageType.ObjectPage;
|
|
128
143
|
};
|
|
129
144
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/page/types.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageType = void 0;
|
|
4
|
+
var PageType;
|
|
5
|
+
(function (PageType) {
|
|
6
|
+
PageType["ListReport"] = "ListReport";
|
|
7
|
+
PageType["ObjectPage"] = "ObjectPage";
|
|
8
|
+
PageType["CustomPage"] = "CustomPage";
|
|
9
|
+
})(PageType || (exports.PageType = PageType = {}));
|
|
3
10
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED