@sap-ux/fe-fpm-writer 0.38.1 → 0.38.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.
@@ -1,5 +1,6 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { CustomPage, InternalCustomPage } from './types';
3
+ import type { Logger } from '@sap-ux/logger';
3
4
  /**
4
5
  * Enhances the provided custom page configuration with default data.
5
6
  *
@@ -22,7 +23,8 @@ export declare function getTemplateRoot(ui5Version?: string): string;
22
23
  * @param {string} basePath - the base path
23
24
  * @param {CustomPage} data - the custom page configuration
24
25
  * @param {Editor} [fs] - the memfs editor instance
26
+ * @param {Logger} [log] - Logger instance
25
27
  * @returns {Promise<Editor>} the updated memfs editor instance
26
28
  */
27
- export declare function generate(basePath: string, data: CustomPage, fs?: Editor): Promise<Editor>;
29
+ export declare function generate(basePath: string, data: CustomPage, fs?: Editor, log?: Logger): Promise<Editor>;
28
30
  //# sourceMappingURL=custom.d.ts.map
@@ -18,6 +18,7 @@ const file_1 = require("../common/file");
18
18
  const building_block_1 = require("../building-block");
19
19
  const types_2 = require("../building-block/types");
20
20
  const xml_1 = require("../building-block/prompts/utils/xml");
21
+ const i18n_1 = require("../i18n");
21
22
  /**
22
23
  * Enhances the provided custom page configuration with default data.
23
24
  *
@@ -61,15 +62,46 @@ function getTemplateRoot(ui5Version) {
61
62
  return (0, templates_1.getTemplatePath)('/page/custom/1.84');
62
63
  }
63
64
  }
65
+ /**
66
+ * Handles the creation of a page building block for a custom page.
67
+ *
68
+ * @param {string} basePath - The base path of the UI5 application.
69
+ * @param {{ pageBuildingBlockTitle: string; minUI5Version?: string }} data - Object containing the building block title and optional minimum UI5 version.
70
+ * @param data.pageBuildingBlockTitle
71
+ * @param data.minUI5Version
72
+ * @param {string} viewPath - The path to the view XML file.
73
+ * @param {Editor} fs - The memfs editor instance.
74
+ * @param {Logger} [log] - Logger instance.
75
+ * @returns {Promise<void>} Resolves when the building block is handled or skipped due to version constraints.
76
+ */
77
+ async function handlePageBuildingBlock(basePath, data, viewPath, fs, log) {
78
+ const minVersion = (0, semver_1.coerce)(data.minUI5Version);
79
+ const t = (0, i18n_1.translate)(i18n_1.i18nNamespaces.buildingBlock, 'pageBuildingBlock.');
80
+ if (minVersion && (0, semver_1.lt)(minVersion.version, '1.136.0')) {
81
+ log?.warn(t('minUi5VersionRequirement', { minUI5Version: data.minUI5Version }));
82
+ return;
83
+ }
84
+ await (0, building_block_1.generateBuildingBlock)(basePath, {
85
+ viewOrFragmentPath: (0, path_1.relative)(basePath, viewPath),
86
+ aggregationPath: (0, xml_1.augmentXpathWithLocalNames)(`/mvc:View/Page`),
87
+ replace: true,
88
+ buildingBlockData: {
89
+ id: 'Page',
90
+ buildingBlockType: types_2.BuildingBlockType.Page,
91
+ title: data.pageBuildingBlockTitle
92
+ }
93
+ }, fs);
94
+ }
64
95
  /**
65
96
  * Add a custom page to an existing UI5 application.
66
97
  *
67
98
  * @param {string} basePath - the base path
68
99
  * @param {CustomPage} data - the custom page configuration
69
100
  * @param {Editor} [fs] - the memfs editor instance
101
+ * @param {Logger} [log] - Logger instance
70
102
  * @returns {Promise<Editor>} the updated memfs editor instance
71
103
  */
72
- async function generate(basePath, data, fs) {
104
+ async function generate(basePath, data, fs, log) {
73
105
  if (!fs) {
74
106
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
75
107
  }
@@ -104,16 +136,7 @@ async function generate(basePath, data, fs) {
104
136
  }
105
137
  }
106
138
  if (data.pageBuildingBlockTitle) {
107
- await (0, building_block_1.generateBuildingBlock)(basePath, {
108
- viewOrFragmentPath: (0, path_1.relative)(basePath, viewPath),
109
- aggregationPath: (0, xml_1.augmentXpathWithLocalNames)(`/mvc:View/Page`),
110
- replace: true,
111
- buildingBlockData: {
112
- id: 'Page',
113
- buildingBlockType: types_2.BuildingBlockType.Page,
114
- title: data.pageBuildingBlockTitle
115
- }
116
- }, fs);
139
+ await handlePageBuildingBlock(basePath, { pageBuildingBlockTitle: data.pageBuildingBlockTitle, minUI5Version: data.minUI5Version }, viewPath, fs, log);
117
140
  }
118
141
  const ext = data.typescript ? 'ts' : 'js';
119
142
  const controllerPath = (0, path_1.join)(config.path, `${config.name}.controller.${ext}`);
@@ -204,6 +204,9 @@ declare const ns1: {
204
204
  };
205
205
  };
206
206
  };
207
+ pageBuildingBlock: {
208
+ minUi5VersionRequirement: string;
209
+ };
207
210
  };
208
211
  export default ns1;
209
212
  //# sourceMappingURL=i18n.d.ts.map
@@ -229,6 +229,9 @@ const ns1 = {
229
229
  'translationAnnotation': 'Description of the Page.'
230
230
  }
231
231
  }
232
+ },
233
+ 'pageBuildingBlock': {
234
+ 'minUi5VersionRequirement': 'The Page building block feature requires SAPUI5 1.136.0 or higher. The current version is {{ minUI5Version }}, so the Page building block will not be added.'
232
235
  }
233
236
  };
234
237
  exports.default = ns1;
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.38.1",
4
+ "version": "0.38.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -31,7 +31,8 @@
31
31
  "xml-formatter": "2.6.1",
32
32
  "xpath": "0.0.33",
33
33
  "@sap-ux/fiori-annotation-api": "0.6.17",
34
- "@sap-ux/project-access": "1.30.13"
34
+ "@sap-ux/project-access": "1.30.13",
35
+ "@sap-ux/logger": "0.7.0"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/inquirer": "8.2.6",