@sap-ux/fe-fpm-writer 0.29.6 → 0.30.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.
@@ -16,5 +16,5 @@ export declare function enhanceManifestAndGetActionsElementReference(manifest: a
16
16
  * @param {Editor} [fs] - the memfs editor instance
17
17
  * @returns {Promise<Editor>} the updated memfs editor instance
18
18
  */
19
- export declare function generateCustomAction(basePath: string, actionConfig: CustomAction, fs?: Editor): Editor;
19
+ export declare function generateCustomAction(basePath: string, actionConfig: CustomAction, fs?: Editor): Promise<Editor>;
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -4,13 +4,13 @@ exports.generateCustomAction = exports.enhanceManifestAndGetActionsElementRefere
4
4
  const mem_fs_1 = require("mem-fs");
5
5
  const mem_fs_editor_1 = require("mem-fs-editor");
6
6
  const types_1 = require("./types");
7
- const path_1 = require("path");
8
7
  const ejs_1 = require("ejs");
9
8
  const validate_1 = require("../common/validate");
10
9
  const defaults_1 = require("../common/defaults");
11
10
  const event_handler_1 = require("../common/event-handler");
12
11
  const templates_1 = require("../templates");
13
12
  const file_1 = require("../common/file");
13
+ const utils_1 = require("../common/utils");
14
14
  /**
15
15
  * Enhances the provided custom action configuration with default data.
16
16
  *
@@ -86,14 +86,13 @@ exports.enhanceManifestAndGetActionsElementReference = enhanceManifestAndGetActi
86
86
  * @param {Editor} [fs] - the memfs editor instance
87
87
  * @returns {Promise<Editor>} the updated memfs editor instance
88
88
  */
89
- function generateCustomAction(basePath, actionConfig, fs) {
89
+ async function generateCustomAction(basePath, actionConfig, fs) {
90
90
  (0, validate_1.validateVersion)(actionConfig.minUI5Version);
91
91
  if (!fs) {
92
92
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
93
93
  }
94
94
  (0, validate_1.validateBasePath)(basePath, fs);
95
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
96
- const manifest = fs.readJSON(manifestPath);
95
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
97
96
  const config = enhanceConfig(actionConfig, manifestPath, manifest);
98
97
  // Apply event handler
99
98
  if (config.eventHandler) {
@@ -27,5 +27,5 @@ export declare const MIN_VERSION = "1.94.0";
27
27
  * @param {Editor} [fs] - the mem-fs editor instance
28
28
  * @returns {Promise<Editor>} the updated mem-fs editor instance
29
29
  */
30
- export declare function enableFPM(basePath: string, config?: FPMConfig, fs?: Editor): Editor;
30
+ export declare function enableFPM(basePath: string, config?: FPMConfig, fs?: Editor): Promise<Editor>;
31
31
  //# sourceMappingURL=index.d.ts.map
package/dist/app/index.js CHANGED
@@ -58,15 +58,11 @@ function adaptMinUI5Version(manifest, fs, manifestPath) {
58
58
  * @param {Editor} [fs] - the mem-fs editor instance
59
59
  * @returns {Promise<Editor>} the updated mem-fs editor instance
60
60
  */
61
- function enableFPM(basePath, config = {}, fs) {
61
+ async function enableFPM(basePath, config = {}, fs) {
62
62
  if (!fs) {
63
63
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
64
64
  }
65
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
66
- if (!fs.exists(manifestPath)) {
67
- throw new Error(`Invalid project folder. Cannot find required file ${manifestPath}`);
68
- }
69
- const manifest = fs.readJSON(manifestPath);
65
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
70
66
  // add FE libs is not yet added
71
67
  if (!manifest['sap.ui5']?.dependencies?.libs?.['sap.fe.templates']) {
72
68
  fs.extendJSON(manifestPath, {
@@ -41,32 +41,12 @@ const types_2 = require("../prompts/types");
41
41
  const semver_1 = require("semver");
42
42
  const project_access_1 = require("@sap-ux/project-access");
43
43
  const file_1 = require("../common/file");
44
+ const utils_1 = require("../common/utils");
44
45
  const PLACEHOLDERS = {
45
46
  'id': 'REPLACE_WITH_BUILDING_BLOCK_ID',
46
47
  'entitySet': 'REPLACE_WITH_ENTITY',
47
48
  'qualifier': 'REPLACE_WITH_A_QUALIFIER'
48
49
  };
49
- /**
50
- * Gets manifest path.
51
- *
52
- * @param {string} basePath the base path
53
- * @param {Editor} fs the memfs editor instance
54
- * @returns {Manifest | undefined} path to manifest file
55
- */
56
- async function getManifestPath(basePath, fs) {
57
- return (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'manifest.json');
58
- }
59
- /**
60
- * Gets manifest content.
61
- *
62
- * @param {string} basePath the base path
63
- * @param {Editor} fs the memfs editor instance
64
- * @returns {Manifest | undefined} the manifest content
65
- */
66
- async function getManifest(basePath, fs) {
67
- const manifestPath = await getManifestPath(basePath, fs);
68
- return fs.readJSON(manifestPath);
69
- }
70
50
  /**
71
51
  * Generates a building block into the provided xml view file.
72
52
  *
@@ -86,12 +66,12 @@ async function generateBuildingBlock(basePath, config, fs) {
86
66
  }
87
67
  // Read the view xml and template files and update contents of the view xml file
88
68
  const xmlDocument = getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs);
89
- const manifest = await getManifest(basePath, fs);
69
+ const { content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
90
70
  const templateDocument = getTemplateDocument(config.buildingBlockData, xmlDocument, fs, manifest);
91
71
  fs = updateViewFile(basePath, config.viewOrFragmentPath, config.aggregationPath, xmlDocument, templateDocument, fs);
92
72
  if (manifest && !(0, validate_1.validateDependenciesLibs)(manifest, ['sap.fe.macros'])) {
93
73
  // "sap.fe.macros" is missing - enhance manifest.json for missing "sap.fe.macros"
94
- const manifestPath = await getManifestPath(basePath, fs);
74
+ const manifestPath = await (0, utils_1.getManifestPath)(basePath, fs);
95
75
  const templatePath = (0, templates_1.getTemplatePath)('/building-block/common/manifest.json');
96
76
  const content = fs.read(manifestPath);
97
77
  const tabInfo = (0, file_1.detectTabSpacing)(content);
@@ -320,7 +300,7 @@ async function getSerializedFileContent(basePath, config, fs) {
320
300
  const xmlDocument = config.viewOrFragmentPath
321
301
  ? getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs)
322
302
  : undefined;
323
- const manifest = await getManifest(basePath, fs);
303
+ const { content: manifest } = await (0, utils_1.getManifest)(basePath, fs, false);
324
304
  const content = getTemplateContent(config.buildingBlockData, xmlDocument, manifest, fs, true);
325
305
  const filePathProps = getFilePathProps(basePath, config.viewOrFragmentPath);
326
306
  return {
@@ -13,7 +13,7 @@ export declare function getManifestRoot(ui5Version?: string): string;
13
13
  * @returns {Promise<Editor>} the updated mem-fs editor instance
14
14
  * @param {string} basePath - the base path
15
15
  * @param {CustomTableColumn} customColumn - the custom column configuration
16
- * @param {Editor} [fs] - the mem-fs editor instance
16
+ * @param {Promise<Editor>} [fs] - the mem-fs editor instance
17
17
  */
18
- export declare function generateCustomColumn(basePath: string, customColumn: CustomTableColumn, fs?: Editor): Editor;
18
+ export declare function generateCustomColumn(basePath: string, customColumn: CustomTableColumn, fs?: Editor): Promise<Editor>;
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -11,6 +11,7 @@ const event_handler_1 = require("../common/event-handler");
11
11
  const file_1 = require("../common/file");
12
12
  const templates_1 = require("../templates");
13
13
  const semver_1 = require("semver");
14
+ const utils_1 = require("../common/utils");
14
15
  /**
15
16
  * Get the template folder for the given UI5 version.
16
17
  *
@@ -63,16 +64,15 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
63
64
  * @returns {Promise<Editor>} the updated mem-fs editor instance
64
65
  * @param {string} basePath - the base path
65
66
  * @param {CustomTableColumn} customColumn - the custom column configuration
66
- * @param {Editor} [fs] - the mem-fs editor instance
67
+ * @param {Promise<Editor>} [fs] - the mem-fs editor instance
67
68
  */
68
- function generateCustomColumn(basePath, customColumn, fs) {
69
+ async function generateCustomColumn(basePath, customColumn, fs) {
69
70
  (0, validate_1.validateVersion)(customColumn.minUI5Version);
70
71
  if (!fs) {
71
72
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
72
73
  }
73
74
  (0, validate_1.validateBasePath)(basePath, fs);
74
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
75
- const manifest = fs.readJSON(manifestPath);
75
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
76
76
  // merge with defaults
77
77
  const completeColumn = enhanceConfig(fs, customColumn, manifestPath, manifest);
78
78
  // enhance manifest with column definition
@@ -177,4 +177,17 @@ export interface FragmentContentData {
177
177
  content: string;
178
178
  requireAttribute?: string;
179
179
  }
180
+ /**
181
+ * Interface contain information about application manifest.
182
+ */
183
+ export interface ManifestData {
184
+ /**
185
+ * Path to manifest.json file.
186
+ */
187
+ path: string;
188
+ /**
189
+ * Parsed content of manifest.json file.
190
+ */
191
+ content: Manifest;
192
+ }
180
193
  //# sourceMappingURL=types.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { FileContentPosition } from '../common/types';
2
+ import type { FileContentPosition, ManifestData } from './types';
3
3
  /**
4
4
  * Method inserts passed text into content by char index position.
5
5
  * In case if position is out of range, then whitespaces would be created.
@@ -31,4 +31,21 @@ export declare function insertTextAtPosition(text: string, content: string, posi
31
31
  * @param fs - the memfs editor instance
32
32
  */
33
33
  export declare function addExtensionTypes(basePath: string, minUI5Version: string | undefined, fs: Editor): void;
34
+ /**
35
+ * Gets manifest path.
36
+ *
37
+ * @param {string} basePath the base path
38
+ * @param {Editor} fs the memfs editor instance
39
+ * @returns {Manifest | undefined} path to manifest file
40
+ */
41
+ export declare function getManifestPath(basePath: string, fs: Editor): Promise<string>;
42
+ /**
43
+ * Gets content and path of the manifest.
44
+ *
45
+ * @param {string} basePath the base path
46
+ * @param {Editor} fs the memfs editor instance
47
+ * @param {boolean} [validate] validate if 'manifest.json' file exists - throw error if file does not exist
48
+ * @returns {Manifest | undefined} The content and path of the manifest
49
+ */
50
+ export declare function getManifest(basePath: string, fs: Editor, validate?: boolean): Promise<ManifestData>;
34
51
  //# sourceMappingURL=utils.d.ts.map
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addExtensionTypes = exports.insertTextAtPosition = exports.insertTextAtAbsolutePosition = void 0;
6
+ exports.getManifest = exports.getManifestPath = exports.addExtensionTypes = exports.insertTextAtPosition = exports.insertTextAtAbsolutePosition = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const path_1 = require("path");
9
9
  const semver_1 = require("semver");
10
+ const project_access_1 = require("@sap-ux/project-access");
10
11
  const templates_1 = require("../templates");
11
12
  /**
12
13
  * Method inserts passed text into content by char index position.
@@ -72,4 +73,34 @@ function addExtensionTypes(basePath, minUI5Version, fs) {
72
73
  }
73
74
  }
74
75
  exports.addExtensionTypes = addExtensionTypes;
76
+ /**
77
+ * Gets manifest path.
78
+ *
79
+ * @param {string} basePath the base path
80
+ * @param {Editor} fs the memfs editor instance
81
+ * @returns {Manifest | undefined} path to manifest file
82
+ */
83
+ async function getManifestPath(basePath, fs) {
84
+ return (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'manifest.json');
85
+ }
86
+ exports.getManifestPath = getManifestPath;
87
+ /**
88
+ * Gets content and path of the manifest.
89
+ *
90
+ * @param {string} basePath the base path
91
+ * @param {Editor} fs the memfs editor instance
92
+ * @param {boolean} [validate] validate if 'manifest.json' file exists - throw error if file does not exist
93
+ * @returns {Manifest | undefined} The content and path of the manifest
94
+ */
95
+ async function getManifest(basePath, fs, validate = true) {
96
+ const path = await getManifestPath(basePath, fs);
97
+ if (validate && !fs.exists(path)) {
98
+ throw new Error(`Invalid project folder. Cannot find required file ${path}`);
99
+ }
100
+ return {
101
+ path,
102
+ content: fs.readJSON(path)
103
+ };
104
+ }
105
+ exports.getManifest = getManifest;
75
106
  //# sourceMappingURL=utils.js.map
@@ -8,7 +8,7 @@ export declare const UI5_CONTROLLER_EXTENSION_OBJECT_PAGE = "sap.fe.templates.Ob
8
8
  * @param {string} basePath - the base path
9
9
  * @param {ControllerExtension} controllerConfig - the controller extension configuration
10
10
  * @param {Editor} [fs] - the memfs editor instance
11
- * @returns {Editor} the updated memfs editor instance
11
+ * @returns {Promise<Editor>} the updated memfs editor instance
12
12
  */
13
- export declare function generateControllerExtension(basePath: string, controllerConfig: ControllerExtension, fs?: Editor): Editor;
13
+ export declare function generateControllerExtension(basePath: string, controllerConfig: ControllerExtension, fs?: Editor): Promise<Editor>;
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -171,16 +171,15 @@ function getManifestReplacer(config) {
171
171
  * @param {string} basePath - the base path
172
172
  * @param {ControllerExtension} controllerConfig - the controller extension configuration
173
173
  * @param {Editor} [fs] - the memfs editor instance
174
- * @returns {Editor} the updated memfs editor instance
174
+ * @returns {Promise<Editor>} the updated memfs editor instance
175
175
  */
176
- function generateControllerExtension(basePath, controllerConfig, fs) {
176
+ async function generateControllerExtension(basePath, controllerConfig, fs) {
177
177
  // Validate the base and view paths
178
178
  if (!fs) {
179
179
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
180
180
  }
181
181
  (0, validate_1.validateBasePath)(basePath, fs);
182
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
183
- const manifest = fs.readJSON(manifestPath);
182
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
184
183
  // merge with defaults
185
184
  const internalConfig = enhanceConfig(controllerConfig, manifestPath, manifest);
186
185
  // enhance manifest with view definition
@@ -8,5 +8,5 @@ import type { CustomFilter } from './types';
8
8
  * @param {Editor} [fs] - the memfs editor instance
9
9
  * @returns {Promise<Editor>} the updated memfs editor instance
10
10
  */
11
- export declare function generateCustomFilter(basePath: string, filterConfig: CustomFilter, fs?: Editor): Editor;
11
+ export declare function generateCustomFilter(basePath: string, filterConfig: CustomFilter, fs?: Editor): Promise<Editor>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -10,6 +10,7 @@ const defaults_1 = require("../common/defaults");
10
10
  const templates_1 = require("../templates");
11
11
  const file_1 = require("../common/file");
12
12
  const event_handler_1 = require("../common/event-handler");
13
+ const utils_1 = require("../common/utils");
13
14
  /**
14
15
  * Enhances the provided custom filter configuration with default data.
15
16
  *
@@ -42,13 +43,12 @@ function enhanceConfig(data, manifestPath, manifest) {
42
43
  * @param {Editor} [fs] - the memfs editor instance
43
44
  * @returns {Promise<Editor>} the updated memfs editor instance
44
45
  */
45
- function generateCustomFilter(basePath, filterConfig, fs) {
46
+ async function generateCustomFilter(basePath, filterConfig, fs) {
46
47
  if (!fs) {
47
48
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
48
49
  }
49
50
  (0, validate_1.validateBasePath)(basePath, fs);
50
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
51
- const manifest = fs.readJSON(manifestPath);
51
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
52
52
  const config = enhanceConfig(filterConfig, manifestPath, manifest);
53
53
  // Apply event handler
54
54
  if (config.eventHandler) {
@@ -66,7 +66,7 @@ export declare function initializeTargetSettings(data: FpmPage, addSettings?: Re
66
66
  * @param dependencies - expected dependencies
67
67
  * @returns the updated memfs editor instance
68
68
  */
69
- export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor, dependencies?: never[]): Editor;
69
+ export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor, dependencies?: never[]): Promise<Editor>;
70
70
  /**
71
71
  * Add an generic page to an existing UI5 application.
72
72
  * Supported pages - ListReport or ObjectPage.
@@ -78,6 +78,6 @@ export declare function validatePageConfig(basePath: string, config: CustomPage
78
78
  * @param fs - the memfs editor instance
79
79
  * @returns the updated memfs editor instance
80
80
  */
81
- export declare function extendPageJSON(basePath: string, data: ObjectPage, enhanceDataFn: EnhancePageConfigFunction, templatePath: string, fs?: Editor): Editor;
81
+ export declare function extendPageJSON(basePath: string, data: ObjectPage, enhanceDataFn: EnhancePageConfigFunction, templatePath: string, fs?: Editor): Promise<Editor>;
82
82
  export {};
83
83
  //# sourceMappingURL=common.d.ts.map
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
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
- const path_1 = require("path");
7
6
  const ejs_1 = require("ejs");
8
7
  const validate_1 = require("../common/validate");
9
8
  const types_1 = require("./types");
@@ -11,6 +10,7 @@ const defaults_1 = require("../common/defaults");
11
10
  const file_1 = require("../common/file");
12
11
  const templates_1 = require("../templates");
13
12
  const semver_1 = require("semver");
13
+ const utils_1 = require("../common/utils");
14
14
  /**
15
15
  * Suffix for patterns to support arbitrary paramters
16
16
  */
@@ -174,12 +174,12 @@ exports.initializeTargetSettings = initializeTargetSettings;
174
174
  * @param dependencies - expected dependencies
175
175
  * @returns the updated memfs editor instance
176
176
  */
177
- function validatePageConfig(basePath, config, fs, dependencies = []) {
177
+ async function validatePageConfig(basePath, config, fs, dependencies = []) {
178
178
  // common validators
179
179
  (0, validate_1.validateBasePath)(basePath, fs, dependencies);
180
180
  // validate config against the manifest
181
181
  if (config.navigation?.sourcePage) {
182
- const manifest = fs.readJSON((0, path_1.join)(basePath, 'webapp/manifest.json'));
182
+ const { content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
183
183
  if (!manifest['sap.ui5']?.routing?.targets?.[config.navigation.sourcePage]) {
184
184
  throw new Error(`Could not find navigation source ${config.navigation.sourcePage}!`);
185
185
  }
@@ -211,13 +211,12 @@ exports.validatePageConfig = validatePageConfig;
211
211
  * @param fs - the memfs editor instance
212
212
  * @returns the updated memfs editor instance
213
213
  */
214
- function extendPageJSON(basePath, data, enhanceDataFn, templatePath, fs) {
214
+ async function extendPageJSON(basePath, data, enhanceDataFn, templatePath, fs) {
215
215
  if (!fs) {
216
216
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
217
217
  }
218
- validatePageConfig(basePath, data, fs);
219
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
220
- const manifest = fs.readJSON(manifestPath);
218
+ await validatePageConfig(basePath, data, fs);
219
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
221
220
  const config = enhanceDataFn(data, manifest);
222
221
  // enhance manifest.json
223
222
  (0, file_1.extendJSON)(fs, {
@@ -24,5 +24,5 @@ export declare function getTemplateRoot(ui5Version?: string): string;
24
24
  * @param {Editor} [fs] - the memfs editor instance
25
25
  * @returns {Promise<Editor>} the updated memfs editor instance
26
26
  */
27
- export declare function generate(basePath: string, data: CustomPage, fs?: Editor): Editor;
27
+ export declare function generate(basePath: string, data: CustomPage, fs?: Editor): Promise<Editor>;
28
28
  //# sourceMappingURL=custom.d.ts.map
@@ -64,13 +64,13 @@ exports.getTemplateRoot = getTemplateRoot;
64
64
  * @param {Editor} [fs] - the memfs editor instance
65
65
  * @returns {Promise<Editor>} the updated memfs editor instance
66
66
  */
67
- function generate(basePath, data, fs) {
67
+ async function generate(basePath, data, fs) {
68
68
  if (!fs) {
69
69
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
70
70
  }
71
71
  (0, validate_1.validateVersion)(data.minUI5Version);
72
- (0, common_1.validatePageConfig)(basePath, data, fs, []);
73
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
72
+ await (0, common_1.validatePageConfig)(basePath, data, fs, []);
73
+ const manifestPath = await (0, utils_1.getManifestPath)(basePath, fs);
74
74
  const config = enhanceData(data, manifestPath, fs);
75
75
  // merge content into existing files
76
76
  const root = getTemplateRoot(data.minUI5Version);
@@ -8,5 +8,5 @@ import type { ListReport } from './types';
8
8
  * @param fs - the memfs editor instance
9
9
  * @returns the updated memfs editor instance
10
10
  */
11
- export declare function generate(basePath: string, data: ListReport, fs?: Editor): Editor;
11
+ export declare function generate(basePath: string, data: ListReport, fs?: Editor): Promise<Editor>;
12
12
  //# sourceMappingURL=list.d.ts.map
package/dist/page/list.js CHANGED
@@ -41,7 +41,7 @@ function enhanceData(data, manifest) {
41
41
  * @param fs - the memfs editor instance
42
42
  * @returns the updated memfs editor instance
43
43
  */
44
- function generate(basePath, data, fs) {
44
+ async function generate(basePath, data, fs) {
45
45
  return (0, common_1.extendPageJSON)(basePath, data, enhanceData, 'page/list/manifest.json', fs);
46
46
  }
47
47
  exports.generate = generate;
@@ -8,5 +8,5 @@ import type { ObjectPage } from './types';
8
8
  * @param fs - the memfs editor instance
9
9
  * @returns the updated memfs editor instance
10
10
  */
11
- export declare function generate(basePath: string, data: ObjectPage, fs?: Editor): Editor;
11
+ export declare function generate(basePath: string, data: ObjectPage, fs?: Editor): Promise<Editor>;
12
12
  //# sourceMappingURL=object.d.ts.map
@@ -33,7 +33,7 @@ function enhanceData(data, manifest) {
33
33
  * @param fs - the memfs editor instance
34
34
  * @returns the updated memfs editor instance
35
35
  */
36
- function generate(basePath, data, fs) {
36
+ async function generate(basePath, data, fs) {
37
37
  return (0, common_1.extendPageJSON)(basePath, data, enhanceData, '/page/object/manifest.json', fs);
38
38
  }
39
39
  exports.generate = generate;
@@ -16,7 +16,7 @@ export declare function getManifestRoot(folderName: string, ui5Version?: string)
16
16
  * @param {Editor} [fs] - the mem-fs editor instance
17
17
  * @returns {Promise<Editor>} the updated mem-fs editor instance
18
18
  */
19
- export declare function generateCustomHeaderSection(basePath: string, customHeaderSection: CustomHeaderSection, fs?: Editor): Editor;
19
+ export declare function generateCustomHeaderSection(basePath: string, customHeaderSection: CustomHeaderSection, fs?: Editor): Promise<Editor>;
20
20
  /**
21
21
  * Add a custom section to an existing UI5 application.
22
22
  *
@@ -25,7 +25,7 @@ export declare function generateCustomHeaderSection(basePath: string, customHead
25
25
  * @param {Editor} [fs] - the mem-fs editor instance
26
26
  * @returns {Promise<Editor>} the updated mem-fs editor instance
27
27
  */
28
- export declare function generateCustomSection(basePath: string, customSection: CustomSection, fs?: Editor): Editor;
28
+ export declare function generateCustomSection(basePath: string, customSection: CustomSection, fs?: Editor): Promise<Editor>;
29
29
  /**
30
30
  * Add a custom sub section to an existing UI5 application.
31
31
  *
@@ -34,5 +34,5 @@ export declare function generateCustomSection(basePath: string, customSection: C
34
34
  * @param {Editor} [fs] - the mem-fs editor instance
35
35
  * @returns {Promise<Editor>} the updated mem-fs editor instance
36
36
  */
37
- export declare function generateCustomSubSection(basePath: string, customSubSection: CustomSubSection, fs?: Editor): Editor;
37
+ export declare function generateCustomSubSection(basePath: string, customSubSection: CustomSubSection, fs?: Editor): Promise<Editor>;
38
38
  //# sourceMappingURL=index.d.ts.map
@@ -11,6 +11,7 @@ const event_handler_1 = require("../common/event-handler");
11
11
  const file_1 = require("../common/file");
12
12
  const templates_1 = require("../templates");
13
13
  const semver_1 = require("semver");
14
+ const utils_1 = require("../common/utils");
14
15
  /**
15
16
  * Get the template folder for the given UI5 version.
16
17
  *
@@ -77,14 +78,13 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
77
78
  * @param {Editor} [fs] - the mem-fs editor instance
78
79
  * @returns {Promise<Editor>} the updated mem-fs editor instance
79
80
  */
80
- function generate(basePath, customSection, manifestTemplateRoot, fs) {
81
+ async function generate(basePath, customSection, manifestTemplateRoot, fs) {
81
82
  (0, validate_1.validateVersion)(customSection.minUI5Version);
82
83
  if (!fs) {
83
84
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
84
85
  }
85
86
  (0, validate_1.validateBasePath)(basePath, fs);
86
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
87
- const manifest = fs.readJSON(manifestPath);
87
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
88
88
  // merge with defaults
89
89
  const completeSection = enhanceConfig(fs, customSection, manifestPath, manifest);
90
90
  // enhance manifest with section definition
@@ -109,7 +109,7 @@ function generate(basePath, customSection, manifestTemplateRoot, fs) {
109
109
  * @param {Editor} [fs] - the mem-fs editor instance
110
110
  * @returns {Promise<Editor>} the updated mem-fs editor instance
111
111
  */
112
- function generateCustomHeaderSection(basePath, customHeaderSection, fs) {
112
+ async function generateCustomHeaderSection(basePath, customHeaderSection, fs) {
113
113
  if (!fs) {
114
114
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
115
115
  }
@@ -119,13 +119,12 @@ function generateCustomHeaderSection(basePath, customHeaderSection, fs) {
119
119
  // Prepare 'templateEdit' - apply namespace and folder path resolution
120
120
  if (customHeaderSection.edit && (!minVersion || (0, semver_1.gte)(minVersion, '1.86.0'))) {
121
121
  editSection = customHeaderSection.edit;
122
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
123
- const manifest = fs.readJSON(manifestPath);
122
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
124
123
  // Set folder, ns and path for edit fragment
125
124
  (0, defaults_1.setCommonDefaults)(editSection, manifestPath, manifest);
126
125
  }
127
126
  // Call standard custom section generation
128
- const { editor, section } = generate(basePath, customHeaderSection, manifestRoot, fs);
127
+ const { editor, section } = await generate(basePath, customHeaderSection, manifestRoot, fs);
129
128
  // Handle 'templateEdit' - edit fragment details
130
129
  if (editSection) {
131
130
  // Apply event handler for edit fragment
@@ -161,9 +160,9 @@ exports.generateCustomHeaderSection = generateCustomHeaderSection;
161
160
  * @param {Editor} [fs] - the mem-fs editor instance
162
161
  * @returns {Promise<Editor>} the updated mem-fs editor instance
163
162
  */
164
- function generateCustomSection(basePath, customSection, fs) {
163
+ async function generateCustomSection(basePath, customSection, fs) {
165
164
  const manifestRoot = getManifestRoot('section', customSection.minUI5Version);
166
- return generate(basePath, customSection, manifestRoot, fs).editor;
165
+ return (await generate(basePath, customSection, manifestRoot, fs)).editor;
167
166
  }
168
167
  exports.generateCustomSection = generateCustomSection;
169
168
  /**
@@ -174,9 +173,9 @@ exports.generateCustomSection = generateCustomSection;
174
173
  * @param {Editor} [fs] - the mem-fs editor instance
175
174
  * @returns {Promise<Editor>} the updated mem-fs editor instance
176
175
  */
177
- function generateCustomSubSection(basePath, customSubSection, fs) {
176
+ async function generateCustomSubSection(basePath, customSubSection, fs) {
178
177
  const manifestRoot = getManifestRoot('subsection', customSubSection.minUI5Version);
179
- return generate(basePath, customSubSection, manifestRoot, fs).editor;
178
+ return (await generate(basePath, customSubSection, manifestRoot, fs)).editor;
180
179
  }
181
180
  exports.generateCustomSubSection = generateCustomSubSection;
182
181
  //# sourceMappingURL=index.js.map
@@ -8,5 +8,5 @@ import type { CustomView } from './types';
8
8
  * @param {Editor} [fs] - the mem-fs editor instance
9
9
  * @returns {Promise<Editor>} the updated mem-fs editor instance
10
10
  */
11
- export declare function generateCustomView(basePath: string, customView: CustomView, fs?: Editor): Editor;
11
+ export declare function generateCustomView(basePath: string, customView: CustomView, fs?: Editor): Promise<Editor>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -10,6 +10,7 @@ const defaults_1 = require("../common/defaults");
10
10
  const event_handler_1 = require("../common/event-handler");
11
11
  const file_1 = require("../common/file");
12
12
  const templates_1 = require("../templates");
13
+ const utils_1 = require("../common/utils");
13
14
  /**
14
15
  * Merge the new view into the list of existing views (if any).
15
16
  *
@@ -79,14 +80,13 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
79
80
  * @param {Editor} [fs] - the mem-fs editor instance
80
81
  * @returns {Promise<Editor>} the updated mem-fs editor instance
81
82
  */
82
- function generateCustomView(basePath, customView, fs) {
83
+ async function generateCustomView(basePath, customView, fs) {
83
84
  (0, validate_1.validateVersion)(customView.minUI5Version);
84
85
  if (!fs) {
85
86
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
86
87
  }
87
88
  (0, validate_1.validateBasePath)(basePath, fs);
88
- const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
89
- const manifest = fs.readJSON(manifestPath);
89
+ const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
90
90
  // merge with defaults
91
91
  const completeView = enhanceConfig(fs, customView, manifestPath, manifest);
92
92
  // enhance manifest with view definition
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.29.6",
4
+ "version": "0.30.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",