@sap-ux/fiori-elements-writer 2.10.16 → 3.0.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.
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.annotationLibs = void 0;
4
- exports.getAnnotationV4Libs = getAnnotationV4Libs;
5
- exports.annotationLibs = [
1
+ export const annotationLibs = [
6
2
  {
7
3
  annotation: 'UI.Note',
8
4
  library: 'sap.nw.core.gbt.notes.lib.reuse'
@@ -13,13 +9,13 @@ exports.annotationLibs = [
13
9
  * @param metadata - metadata string to be checked for specific annotations
14
10
  * @returns The base component library path
15
11
  */
16
- function getAnnotationV4Libs(metadata) {
12
+ export function getAnnotationV4Libs(metadata) {
17
13
  const libraries = [];
18
14
  // Create a regular expression that matches any of the annotations
19
- const annotationsRegex = new RegExp(exports.annotationLibs.map((annotationLib) => annotationLib.annotation).join('|'), 'g');
15
+ const annotationsRegex = new RegExp(annotationLibs.map((annotationLib) => annotationLib.annotation).join('|'), 'g');
20
16
  const foundAnnotations = annotationsRegex.exec(metadata);
21
17
  foundAnnotations?.forEach((annotation) => {
22
- const rule = exports.annotationLibs.find((rule) => rule.annotation === annotation);
18
+ const rule = annotationLibs.find((rule) => rule.annotation === annotation);
23
19
  if (rule) {
24
20
  libraries.push(rule.library);
25
21
  }
@@ -1,7 +1,7 @@
1
1
  import { OdataVersion } from '@sap-ux/odata-service-writer';
2
- import type { FioriElementsApp, Template } from '../types';
3
- import { TemplateType } from '../types';
4
- import { type TemplateOptions } from './templateAttributes';
2
+ import type { FioriElementsApp, Template } from '../types.js';
3
+ import { TemplateType } from '../types.js';
4
+ import { type TemplateOptions } from './templateAttributes.js';
5
5
  /**
6
6
  * Sets defaults for relevant parameters (`flpAppId`, `startFile`, `localStartFile`, ) when virtual endpoints are used.
7
7
  *
@@ -1,21 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setVirtualEndpointDefaults = setVirtualEndpointDefaults;
7
- exports.setDefaultTemplateSettings = setDefaultTemplateSettings;
8
- exports.getUi5Libs = getUi5Libs;
9
- exports.getManifestLibs = getManifestLibs;
10
- exports.setAppDefaults = setAppDefaults;
11
- exports.getTemplateOptions = getTemplateOptions;
12
- const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
13
- const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
14
- const types_1 = require("../types");
15
- const templateAttributes_1 = require("./templateAttributes");
16
- const annotationCustomUi5Libs_1 = require("./annotationCustomUi5Libs");
17
- const semver_1 = __importDefault(require("semver"));
18
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
1
+ import { OdataVersion, ServiceType } from '@sap-ux/odata-service-writer';
2
+ import readPkgUp from 'read-pkg-up';
3
+ import { dirname } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ import { TableSelectionMode, TableType, TemplateType } from '../types.js';
7
+ import { getBaseComponent, getTemplateUi5Libs, TemplateTypeAttributes, changesPreviewToVersion, getTemplateManifestLibs } from './templateAttributes.js';
8
+ import { getAnnotationV4Libs } from './annotationCustomUi5Libs.js';
9
+ import semVer from 'semver';
10
+ import { getFlpId } from '@sap-ux/fiori-generator-shared';
19
11
  const defaultModelName = 'mainModel'; // UI5 default model name is '' but some floorplans require a named default model
20
12
  const defaultVirtualPreviewFile = 'test/flp.html'; // Default virtual preview file name
21
13
  const defaultIntent = 'app-preview';
@@ -25,7 +17,7 @@ const defaultNavActionTile = 'tile';
25
17
  *
26
18
  * @param feApp - Fiori elements application config
27
19
  */
28
- function setVirtualEndpointDefaults(feApp) {
20
+ export function setVirtualEndpointDefaults(feApp) {
29
21
  feApp.app.flpAppId = defaultIntent;
30
22
  feApp.app.startFile = defaultVirtualPreviewFile;
31
23
  feApp.app.localStartFile = defaultVirtualPreviewFile;
@@ -37,21 +29,21 @@ function setVirtualEndpointDefaults(feApp) {
37
29
  * @param odataVersion - may be used to determine the default properties set
38
30
  * @returns Updated template settings
39
31
  */
40
- function setDefaultTemplateSettings(template, odataVersion) {
32
+ export function setDefaultTemplateSettings(template, odataVersion) {
41
33
  const templateSettings = template.settings;
42
- if (template.type === types_1.TemplateType.AnalyticalListPage) {
34
+ if (template.type === TemplateType.AnalyticalListPage) {
43
35
  const alpSettings = template.settings;
44
36
  Object.assign(templateSettings, {
45
- tableType: alpSettings.tableType ?? types_1.TableType.ANALYTICAL // Overrides the UI5 default: ''
37
+ tableType: alpSettings.tableType ?? TableType.ANALYTICAL // Overrides the UI5 default: ''
46
38
  });
47
- if (odataVersion === odata_service_writer_1.OdataVersion.v4) {
39
+ if (odataVersion === OdataVersion.v4) {
48
40
  const alpV4Settings = template.settings;
49
41
  Object.assign(templateSettings, {
50
- selectionMode: alpV4Settings.selectionMode ?? types_1.TableSelectionMode.NONE
42
+ selectionMode: alpV4Settings.selectionMode ?? TableSelectionMode.NONE
51
43
  });
52
44
  return templateSettings;
53
45
  }
54
- if (odataVersion === odata_service_writer_1.OdataVersion.v2) {
46
+ if (odataVersion === OdataVersion.v2) {
55
47
  const alpSettingsv2 = template.settings;
56
48
  Object.assign(templateSettings, {
57
49
  multiSelect: alpSettingsv2.multiSelect,
@@ -62,12 +54,12 @@ function setDefaultTemplateSettings(template, odataVersion) {
62
54
  return templateSettings;
63
55
  }
64
56
  }
65
- else if (template.type === types_1.TemplateType.ListReportObjectPage || template.type === types_1.TemplateType.Worklist) {
57
+ else if (template.type === TemplateType.ListReportObjectPage || template.type === TemplateType.Worklist) {
66
58
  const tableSettings = template.settings;
67
59
  Object.assign(templateSettings, {
68
- tableType: tableSettings.tableType ?? types_1.TableType.RESPONSIVE // Overrides the UI5 default: ''
60
+ tableType: tableSettings.tableType ?? TableType.RESPONSIVE // Overrides the UI5 default: ''
69
61
  });
70
- if (tableSettings.tableType !== types_1.TableType.TREE) {
62
+ if (tableSettings.tableType !== TableType.TREE) {
71
63
  delete tableSettings.hierarchyQualifier;
72
64
  }
73
65
  }
@@ -81,8 +73,8 @@ function setDefaultTemplateSettings(template, odataVersion) {
81
73
  * @param ui5Libs - ui5 libs
82
74
  * @returns The UI5 libs required by the specified template type and OData version and UI5 annotation libs
83
75
  */
84
- function getUi5Libs(type, version, ui5Libs) {
85
- const templateLibs = (0, templateAttributes_1.getTemplateUi5Libs)(type, version);
76
+ export function getUi5Libs(type, version, ui5Libs) {
77
+ const templateLibs = getTemplateUi5Libs(type, version);
86
78
  return [...templateLibs].concat(ui5Libs ?? []);
87
79
  }
88
80
  /**
@@ -93,8 +85,8 @@ function getUi5Libs(type, version, ui5Libs) {
93
85
  * @param libs - manifest libs
94
86
  * @returns The manifest libs required by the specified template type and OData version and UI5 annotation libs
95
87
  */
96
- function getManifestLibs(type, version, libs) {
97
- const templateLibs = (0, templateAttributes_1.getTemplateManifestLibs)(type, version);
88
+ export function getManifestLibs(type, version, libs) {
89
+ const templateLibs = getTemplateManifestLibs(type, version);
98
90
  return [...templateLibs].concat(libs ?? []);
99
91
  }
100
92
  /**
@@ -107,10 +99,10 @@ function getManifestLibs(type, version, libs) {
107
99
  function setFioriAppDefaults(app, templateType, serviceVersion) {
108
100
  // Generate base UI5 project
109
101
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
110
- app.baseComponent = app.baseComponent || (0, templateAttributes_1.getBaseComponent)(templateType, serviceVersion);
102
+ app.baseComponent = app.baseComponent || getBaseComponent(templateType, serviceVersion);
111
103
  app.flpAction = app.flpAction || defaultNavActionTile;
112
104
  // create `flpAppId` if not already added
113
- app.flpAppId = app.flpAppId || (0, fiori_generator_shared_1.getFlpId)(app.id, app.flpAction);
105
+ app.flpAppId = app.flpAppId || getFlpId(app.id, app.flpAction);
114
106
  }
115
107
  /**
116
108
  * Sets defaults for the specified Fiori elements application.
@@ -118,10 +110,10 @@ function setFioriAppDefaults(app, templateType, serviceVersion) {
118
110
  * @param feApp - Fiori elements application config
119
111
  * @returns Fiori elements app config with updated defaults for unspecified properties
120
112
  */
121
- function setAppDefaults(feApp) {
113
+ export function setAppDefaults(feApp) {
122
114
  // Add template information
123
115
  if (!feApp.app.sourceTemplate?.version || !feApp.app.sourceTemplate?.id) {
124
- const packageInfo = read_pkg_up_1.default.sync({ cwd: __dirname });
116
+ const packageInfo = readPkgUp.sync({ cwd: __dirname });
125
117
  feApp.app.sourceTemplate = {
126
118
  id: `${packageInfo?.packageJson.name}:${feApp.template.type}`,
127
119
  version: packageInfo?.packageJson.version,
@@ -129,8 +121,8 @@ function setAppDefaults(feApp) {
129
121
  };
130
122
  }
131
123
  setFioriAppDefaults(feApp.app, feApp.template.type, feApp.service.version);
132
- const customUi5Libs = feApp.service.version === odata_service_writer_1.OdataVersion.v4 && feApp.service.metadata
133
- ? (0, annotationCustomUi5Libs_1.getAnnotationV4Libs)(feApp.service.metadata)
124
+ const customUi5Libs = feApp.service.version === OdataVersion.v4 && feApp.service.metadata
125
+ ? getAnnotationV4Libs(feApp.service.metadata)
134
126
  : [];
135
127
  // Add ui5 libs for specified template and odata version
136
128
  // Dups will be removed by call to `generateUI5Project`
@@ -142,19 +134,19 @@ function setAppDefaults(feApp) {
142
134
  };
143
135
  // Assign a default annotation name if the service type is EDMX and no local annotation name is provided
144
136
  let serviceType = feApp.service.type;
145
- serviceType ||= odata_service_writer_1.ServiceType.EDMX;
146
- if (serviceType === odata_service_writer_1.ServiceType.EDMX && !feApp.service.localAnnotationsName) {
137
+ serviceType ||= ServiceType.EDMX;
138
+ if (serviceType === ServiceType.EDMX && !feApp.service.localAnnotationsName) {
147
139
  feApp.service.localAnnotationsName = 'annotation';
148
140
  }
149
141
  // OVP must use a named default model
150
- if (feApp.template.type === types_1.TemplateType.OverviewPage) {
142
+ if (feApp.template.type === TemplateType.OverviewPage) {
151
143
  feApp.service.model = defaultModelName;
152
144
  }
153
145
  // minimum UI5 version depending on the template required
154
146
  feApp.ui5 = feApp.ui5 ?? {};
155
147
  if (!feApp.ui5.minUI5Version) {
156
148
  feApp.ui5.minUI5Version =
157
- feApp.ui5.version ?? templateAttributes_1.TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
149
+ feApp.ui5.version ?? TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
158
150
  }
159
151
  // if not explicitly disabled, enable the SAP Fiori tools
160
152
  feApp.appOptions = feApp.appOptions ?? {};
@@ -171,14 +163,14 @@ function setAppDefaults(feApp) {
171
163
  * @param {string} [ui5Version] The version of UI5 framework being used.
172
164
  * @returns {TemplateOptions} An template objects containing options related to changes preview and loader.
173
165
  */
174
- function getTemplateOptions(isEdmxProjectType, serviceVersion, ui5Version) {
175
- const coercedUI5Version = semver_1.default.coerce(ui5Version);
166
+ export function getTemplateOptions(isEdmxProjectType, serviceVersion, ui5Version) {
167
+ const coercedUI5Version = semVer.coerce(ui5Version);
176
168
  // Determine if the changes preview should be enabled based on the project type and UI5 version
177
169
  const changesPreview = isEdmxProjectType && ui5Version
178
- ? semver_1.default.lt(coercedUI5Version, templateAttributes_1.changesPreviewToVersion) // Check if the coerced version is less than the required version
170
+ ? semVer.lt(coercedUI5Version, changesPreviewToVersion) // Check if the coerced version is less than the required version
179
171
  : false;
180
172
  // Determine if the changes loader should be enabled based on the project type and service version
181
- const changesLoader = isEdmxProjectType && serviceVersion === odata_service_writer_1.OdataVersion.v2;
173
+ const changesLoader = isEdmxProjectType && serviceVersion === OdataVersion.v2;
182
174
  return {
183
175
  changesPreview,
184
176
  changesLoader
@@ -1,4 +1,4 @@
1
- import type { FioriElementsApp } from '../types';
1
+ import type { FioriElementsApp } from '../types.js';
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  /**
4
4
  * Extend the manifest.json file passed via the fs reference with the template and settings specified.
@@ -1,14 +1,8 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.extendManifestJson = extendManifestJson;
7
- const types_1 = require("../types");
8
- const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
9
- const node_path_1 = require("node:path");
10
- const ejs_1 = require("ejs");
11
- const semver_1 = __importDefault(require("semver"));
1
+ import { TemplateType } from '../types.js';
2
+ import { OdataVersion } from '@sap-ux/odata-service-writer';
3
+ import { join } from 'node:path';
4
+ import { render } from 'ejs';
5
+ import semVer from 'semver';
12
6
  /**
13
7
  * Extend the manifest.json file passed via the fs reference with the template and settings specified.
14
8
  * This extends by combining the version specific common manifest with the floorplan/template type
@@ -19,20 +13,20 @@ const semver_1 = __importDefault(require("semver"));
19
13
  * @param rootTemplatesPath - The root path where the manifest templates will be found
20
14
  * @param feApp - The application config to be used by the manifest templates
21
15
  */
22
- function extendManifestJson(fs, targetPath, rootTemplatesPath, feApp) {
16
+ export function extendManifestJson(fs, targetPath, rootTemplatesPath, feApp) {
23
17
  let templatePath = feApp.template.type;
24
18
  // FEOP and ALP v4 are variants of LROP and so we use the same template and settings
25
- if (feApp.service.version === odata_service_writer_1.OdataVersion.v4 &&
19
+ if (feApp.service.version === OdataVersion.v4 &&
26
20
  [
27
- types_1.TemplateType.FormEntryObjectPage,
28
- types_1.TemplateType.AnalyticalListPage,
29
- types_1.TemplateType.ListReportObjectPage,
30
- types_1.TemplateType.Worklist
21
+ TemplateType.FormEntryObjectPage,
22
+ TemplateType.AnalyticalListPage,
23
+ TemplateType.ListReportObjectPage,
24
+ TemplateType.Worklist
31
25
  ].includes(feApp.template.type)) {
32
- templatePath = types_1.TemplateType.ListReportObjectPage;
26
+ templatePath = TemplateType.ListReportObjectPage;
33
27
  // starting with UI5 v1.94.0, contextPath should be used instead of 'entitySet' in manifest for v4 LROP based apps
34
- const minVersion = semver_1.default.coerce(feApp.ui5?.minUI5Version);
35
- if (!minVersion || semver_1.default.gte(minVersion, '1.94.0')) {
28
+ const minVersion = semVer.coerce(feApp.ui5?.minUI5Version);
29
+ if (!minVersion || semVer.gte(minVersion, '1.94.0')) {
36
30
  const entityConfig = feApp.template.settings.entityConfig;
37
31
  if (entityConfig.mainEntityParameterName) {
38
32
  // If the main entity is parameterised, clear the navigation entity configuration
@@ -60,16 +54,16 @@ function extendManifestJson(fs, targetPath, rootTemplatesPath, feApp) {
60
54
  };
61
55
  // Manifest paths to be extended
62
56
  const extendTemplatePaths = [
63
- (0, node_path_1.join)(rootTemplatesPath, 'common', 'extend', 'webapp'),
64
- (0, node_path_1.join)(rootTemplatesPath, templatePath, 'extend', 'webapp'),
65
- (0, node_path_1.join)(rootTemplatesPath, `v${feApp.service.version}`, templatePath, 'extend', 'webapp'),
66
- (0, node_path_1.join)(rootTemplatesPath, `v${feApp.service.version}`, 'common', 'extend', 'webapp')
57
+ join(rootTemplatesPath, 'common', 'extend', 'webapp'),
58
+ join(rootTemplatesPath, templatePath, 'extend', 'webapp'),
59
+ join(rootTemplatesPath, `v${feApp.service.version}`, templatePath, 'extend', 'webapp'),
60
+ join(rootTemplatesPath, `v${feApp.service.version}`, 'common', 'extend', 'webapp')
67
61
  ];
68
- const manifestPath = (0, node_path_1.join)(targetPath, 'webapp', 'manifest.json');
62
+ const manifestPath = join(targetPath, 'webapp', 'manifest.json');
69
63
  extendTemplatePaths.forEach((extendTemplatePath) => {
70
- const manifestTemplatePath = (0, node_path_1.join)(extendTemplatePath, 'manifest.json');
64
+ const manifestTemplatePath = join(extendTemplatePath, 'manifest.json');
71
65
  if (fs.exists(manifestTemplatePath)) {
72
- fs.extendJSON(manifestPath, JSON.parse((0, ejs_1.render)(fs.read(manifestTemplatePath), templateSettings, {})));
66
+ fs.extendJSON(manifestPath, JSON.parse(render(fs.read(manifestTemplatePath), templateSettings, {})));
73
67
  }
74
68
  });
75
69
  }
@@ -1,4 +1,4 @@
1
- import { OdataVersion, TemplateType } from '../types';
1
+ import { OdataVersion, TemplateType } from '../types.js';
2
2
  export declare const minSupportedUI5Version = "1.65.0";
3
3
  export declare const minSupportedUI5VersionV4 = "1.84.0";
4
4
  export declare const changesPreviewToVersion = "1.78.0";
@@ -1,23 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TemplateTypeAttributes = exports.escapeFLPText = exports.changesPreviewToVersion = exports.minSupportedUI5VersionV4 = exports.minSupportedUI5Version = void 0;
4
- exports.getBaseComponent = getBaseComponent;
5
- exports.getTemplateUi5Libs = getTemplateUi5Libs;
6
- exports.getTemplateManifestLibs = getTemplateManifestLibs;
7
- const types_1 = require("../types");
1
+ import { OdataVersion, TemplateType } from '../types.js';
8
2
  // first version with SAP Fiori 3 theme
9
- exports.minSupportedUI5Version = '1.65.0';
10
- exports.minSupportedUI5VersionV4 = '1.84.0';
11
- exports.changesPreviewToVersion = '1.78.0';
3
+ export const minSupportedUI5Version = '1.65.0';
4
+ export const minSupportedUI5VersionV4 = '1.84.0';
5
+ export const changesPreviewToVersion = '1.78.0';
12
6
  // Specific escaping is required for FLP texts in flpSandbox.html template file
13
7
  // Escapes '\' with '\\\\' and '"' with '\"' to correctly render inputs in a secure way
14
- const escapeFLPText = (s) => s.replace(/\\/g, '\\\\').replace(/(")/g, '\\$&');
15
- exports.escapeFLPText = escapeFLPText;
8
+ export const escapeFLPText = (s) => s.replace(/\\/g, '\\\\').replace(/(")/g, '\\$&');
16
9
  const appComponentLibGeneric = 'sap/suite/ui/generic/template/lib/AppComponent';
17
10
  const appComponentLibOVP = 'sap/ovp/app/Component';
18
11
  const appComponentLibFioriElements = 'sap/fe/core/AppComponent';
19
12
  const commonUi5Libs = {
20
- [types_1.OdataVersion.v2]: [
13
+ [OdataVersion.v2]: [
21
14
  'sap.m',
22
15
  'sap.ushell',
23
16
  'sap.ui.core',
@@ -26,56 +19,56 @@ const commonUi5Libs = {
26
19
  'sap.ui.generic.app',
27
20
  'sap.suite.ui.generic.template'
28
21
  ],
29
- [types_1.OdataVersion.v4]: ['sap.m', 'sap.fe.templates']
22
+ [OdataVersion.v4]: ['sap.m', 'sap.fe.templates']
30
23
  };
31
24
  const templateLibs = {
32
- [types_1.OdataVersion.v2]: {
33
- [types_1.TemplateType.AnalyticalListPage]: {
25
+ [OdataVersion.v2]: {
26
+ [TemplateType.AnalyticalListPage]: {
34
27
  baseComponent: appComponentLibGeneric,
35
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v2]]
28
+ ui5Libs: [...commonUi5Libs[OdataVersion.v2]]
36
29
  },
37
- [types_1.TemplateType.ListReportObjectPage]: {
30
+ [TemplateType.ListReportObjectPage]: {
38
31
  baseComponent: appComponentLibGeneric,
39
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v2]]
32
+ ui5Libs: [...commonUi5Libs[OdataVersion.v2]]
40
33
  },
41
- [types_1.TemplateType.OverviewPage]: {
34
+ [TemplateType.OverviewPage]: {
42
35
  baseComponent: appComponentLibOVP,
43
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v2], 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout']
36
+ ui5Libs: [...commonUi5Libs[OdataVersion.v2], 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout']
44
37
  },
45
- [types_1.TemplateType.Worklist]: {
38
+ [TemplateType.Worklist]: {
46
39
  baseComponent: appComponentLibGeneric,
47
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v2], 'sap.collaboration']
40
+ ui5Libs: [...commonUi5Libs[OdataVersion.v2], 'sap.collaboration']
48
41
  }
49
42
  },
50
- [types_1.OdataVersion.v4]: {
51
- [types_1.TemplateType.ListReportObjectPage]: {
43
+ [OdataVersion.v4]: {
44
+ [TemplateType.ListReportObjectPage]: {
52
45
  baseComponent: appComponentLibFioriElements,
53
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ushell'],
54
- manifestLibs: [...commonUi5Libs[types_1.OdataVersion.v4]]
46
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
47
+ manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
55
48
  },
56
- [types_1.TemplateType.FormEntryObjectPage]: {
49
+ [TemplateType.FormEntryObjectPage]: {
57
50
  baseComponent: appComponentLibFioriElements,
58
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ushell'],
59
- manifestLibs: [...commonUi5Libs[types_1.OdataVersion.v4]]
51
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
52
+ manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
60
53
  },
61
- [types_1.TemplateType.AnalyticalListPage]: {
54
+ [TemplateType.AnalyticalListPage]: {
62
55
  baseComponent: appComponentLibFioriElements,
63
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ushell'],
64
- manifestLibs: [...commonUi5Libs[types_1.OdataVersion.v4]]
56
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
57
+ manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
65
58
  },
66
- [types_1.TemplateType.Worklist]: {
59
+ [TemplateType.Worklist]: {
67
60
  baseComponent: appComponentLibFioriElements,
68
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ushell'],
69
- manifestLibs: [...commonUi5Libs[types_1.OdataVersion.v4]]
61
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
62
+ manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
70
63
  },
71
- [types_1.TemplateType.OverviewPage]: {
64
+ [TemplateType.OverviewPage]: {
72
65
  baseComponent: appComponentLibOVP,
73
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ushell', 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout'],
74
- manifestLibs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout']
66
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell', 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout'],
67
+ manifestLibs: [...commonUi5Libs[OdataVersion.v4], 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout']
75
68
  },
76
- [types_1.TemplateType.FlexibleProgrammingModel]: {
69
+ [TemplateType.FlexibleProgrammingModel]: {
77
70
  baseComponent: appComponentLibFioriElements,
78
- ui5Libs: [...commonUi5Libs[types_1.OdataVersion.v4], 'sap.fe.core', 'sap.ushell'],
71
+ ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.fe.core', 'sap.ushell'],
79
72
  manifestLibs: ['sap.m', 'sap.fe.core']
80
73
  }
81
74
  }
@@ -87,7 +80,7 @@ const templateLibs = {
87
80
  * @param version - The odata service version determines the appropriate base component to use
88
81
  * @returns The base component library path
89
82
  */
90
- function getBaseComponent(type, version) {
83
+ export function getBaseComponent(type, version) {
91
84
  return templateLibs[version][type]?.baseComponent;
92
85
  }
93
86
  /**
@@ -97,7 +90,7 @@ function getBaseComponent(type, version) {
97
90
  * @param version - The odata service version determines the appropriate base component to use
98
91
  * @returns The Ui5 libs required by the specified template type and OData version
99
92
  */
100
- function getTemplateUi5Libs(type, version) {
93
+ export function getTemplateUi5Libs(type, version) {
101
94
  return templateLibs[version][type]?.ui5Libs ?? [];
102
95
  }
103
96
  /**
@@ -107,57 +100,57 @@ function getTemplateUi5Libs(type, version) {
107
100
  * @param version - The odata service version determines the appropriate base component to use
108
101
  * @returns The manifest libs required by the specified template type and OData version
109
102
  */
110
- function getTemplateManifestLibs(type, version) {
103
+ export function getTemplateManifestLibs(type, version) {
111
104
  return templateLibs[version][type]?.manifestLibs ?? [];
112
105
  }
113
- exports.TemplateTypeAttributes = {
114
- [types_1.TemplateType.Worklist]: {
115
- supportedODataVersions: [types_1.OdataVersion.v2, types_1.OdataVersion.v4],
106
+ export const TemplateTypeAttributes = {
107
+ [TemplateType.Worklist]: {
108
+ supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
116
109
  minimumUi5Version: {
117
- [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
118
- [types_1.OdataVersion.v4]: '1.99.0'
110
+ [OdataVersion.v2]: minSupportedUI5Version,
111
+ [OdataVersion.v4]: '1.99.0'
119
112
  },
120
113
  annotationGenerationSupport: {
121
- [types_1.OdataVersion.v4]: true
114
+ [OdataVersion.v4]: true
122
115
  }
123
116
  },
124
- [types_1.TemplateType.ListReportObjectPage]: {
125
- supportedODataVersions: [types_1.OdataVersion.v2, types_1.OdataVersion.v4],
117
+ [TemplateType.ListReportObjectPage]: {
118
+ supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
126
119
  minimumUi5Version: {
127
- [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
128
- [types_1.OdataVersion.v4]: '1.84.0'
120
+ [OdataVersion.v2]: minSupportedUI5Version,
121
+ [OdataVersion.v4]: '1.84.0'
129
122
  },
130
123
  annotationGenerationSupport: {
131
- [types_1.OdataVersion.v4]: true
124
+ [OdataVersion.v4]: true
132
125
  }
133
126
  },
134
- [types_1.TemplateType.AnalyticalListPage]: {
135
- supportedODataVersions: [types_1.OdataVersion.v2, types_1.OdataVersion.v4],
127
+ [TemplateType.AnalyticalListPage]: {
128
+ supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
136
129
  minimumUi5Version: {
137
- [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
138
- [types_1.OdataVersion.v4]: '1.90.0'
130
+ [OdataVersion.v2]: minSupportedUI5Version,
131
+ [OdataVersion.v4]: '1.90.0'
139
132
  }
140
133
  },
141
- [types_1.TemplateType.OverviewPage]: {
142
- supportedODataVersions: [types_1.OdataVersion.v2, types_1.OdataVersion.v4],
134
+ [TemplateType.OverviewPage]: {
135
+ supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
143
136
  minimumUi5Version: {
144
- [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
145
- [types_1.OdataVersion.v4]: '1.96.8'
137
+ [OdataVersion.v2]: minSupportedUI5Version,
138
+ [OdataVersion.v4]: '1.96.8'
146
139
  }
147
140
  },
148
- [types_1.TemplateType.FormEntryObjectPage]: {
149
- supportedODataVersions: [types_1.OdataVersion.v4],
141
+ [TemplateType.FormEntryObjectPage]: {
142
+ supportedODataVersions: [OdataVersion.v4],
150
143
  minimumUi5Version: {
151
- [types_1.OdataVersion.v4]: '1.90.0'
144
+ [OdataVersion.v4]: '1.90.0'
152
145
  },
153
146
  annotationGenerationSupport: {
154
- [types_1.OdataVersion.v4]: true
147
+ [OdataVersion.v4]: true
155
148
  }
156
149
  },
157
- [types_1.TemplateType.FlexibleProgrammingModel]: {
158
- supportedODataVersions: [types_1.OdataVersion.v4],
150
+ [TemplateType.FlexibleProgrammingModel]: {
151
+ supportedODataVersions: [OdataVersion.v4],
159
152
  minimumUi5Version: {
160
- [types_1.OdataVersion.v4]: '1.94.0'
153
+ [OdataVersion.v4]: '1.94.0'
161
154
  }
162
155
  }
163
156
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal types, not exported for consumer use
3
3
  */
4
- import type { EntityConfig } from '../types';
4
+ import type { EntityConfig } from '../types.js';
5
5
  /**
6
6
  * Internal interface used to write entity settings while maintaining a stable external interface
7
7
  *
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { FioriElementsApp } from './types';
2
+ import type { FioriElementsApp } from './types.js';
3
3
  /**
4
4
  * Processes the template for the Flexible Programming Model (FPM).
5
5
  * Generates a custom page and updates the UI5 local yaml.
package/dist/fpmConfig.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateFpmConfig = generateFpmConfig;
4
- const fe_fpm_writer_1 = require("@sap-ux/fe-fpm-writer");
1
+ import { generateCustomPage } from '@sap-ux/fe-fpm-writer';
5
2
  /**
6
3
  * Processes the template for the Flexible Programming Model (FPM).
7
4
  * Generates a custom page and updates the UI5 local yaml.
@@ -11,9 +8,9 @@ const fe_fpm_writer_1 = require("@sap-ux/fe-fpm-writer");
11
8
  * @param fs - reference to a mem-fs editor
12
9
  * @returns {Promise<void>}
13
10
  */
14
- async function generateFpmConfig(feApp, basePath, fs) {
11
+ export async function generateFpmConfig(feApp, basePath, fs) {
15
12
  const config = feApp.template.settings;
16
- await (0, fe_fpm_writer_1.generateCustomPage)(basePath, {
13
+ await generateCustomPage(basePath, {
17
14
  entity: config.entityConfig.mainEntityName,
18
15
  name: config.pageName,
19
16
  minUI5Version: feApp.ui5?.minUI5Version,
package/dist/i18n.js CHANGED
@@ -1,23 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.i18n = void 0;
7
- exports.initI18n = initI18n;
8
- exports.t = t;
9
- const i18next_1 = __importDefault(require("i18next"));
10
- const fiori_elements_writer_i18n_json_1 = __importDefault(require("./translations/fiori-elements-writer.i18n.json"));
1
+ import i18next from 'i18next';
2
+ import translations from './translations/fiori-elements-writer.i18n.json' with { type: 'json' };
11
3
  const NS = 'fiori-freestyle-writer';
12
- exports.i18n = i18next_1.default.createInstance();
4
+ export const i18n = i18next.createInstance();
13
5
  /**
14
6
  * Initialize i18next with the translations for this module.
15
7
  */
16
- async function initI18n() {
17
- await exports.i18n.init({
8
+ export async function initI18n() {
9
+ await i18n.init({
18
10
  resources: {
19
11
  en: {
20
- [NS]: fiori_elements_writer_i18n_json_1.default
12
+ [NS]: translations
21
13
  }
22
14
  },
23
15
  lng: 'en',
@@ -34,10 +26,8 @@ async function initI18n() {
34
26
  * @param options additional options
35
27
  * @returns {string} localized string stored for the given key
36
28
  */
37
- function t(key, options) {
38
- return exports.i18n.t(key, options);
29
+ export function t(key, options) {
30
+ return i18n.t(key, options);
39
31
  }
40
- initI18n().catch(() => {
41
- // Ignore any errors since the write will still work
42
- });
32
+ void initI18n().catch(() => undefined);
43
33
  //# sourceMappingURL=i18n.js.map
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { App } from '@sap-ux/ui5-application-writer';
3
- import type { FioriElementsApp } from './types';
4
- import { TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 } from './data/templateAttributes';
3
+ import type { FioriElementsApp } from './types.js';
4
+ import { TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 } from './data/templateAttributes.js';
5
5
  import type { Logger } from '@sap-ux/logger';
6
6
  export declare const V2_FE_TYPES_AVAILABLE = "1.108.0";
7
7
  /**
@@ -15,5 +15,5 @@ export declare const V2_FE_TYPES_AVAILABLE = "1.108.0";
15
15
  */
16
16
  declare function generate<T extends {}>(basePath: string, data: FioriElementsApp<T>, fs?: Editor, log?: Logger): Promise<Editor>;
17
17
  export { generate, FioriElementsApp, App, TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 };
18
- export * from './types';
18
+ export * from './types.js';
19
19
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,45 +1,23 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.minSupportedUI5VersionV4 = exports.minSupportedUI5Version = exports.TemplateTypeAttributes = exports.V2_FE_TYPES_AVAILABLE = void 0;
21
- exports.generate = generate;
22
- const node_path_1 = require("node:path");
23
- const ejs_1 = require("ejs");
24
- const ui5_application_writer_1 = require("@sap-ux/ui5-application-writer");
25
- const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
26
- const ui5_test_writer_1 = require("@sap-ux/ui5-test-writer");
27
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
28
- const types_1 = require("./types");
29
- const validate_1 = require("./validate");
30
- const defaults_1 = require("./data/defaults");
31
- const templateAttributes_1 = require("./data/templateAttributes");
32
- Object.defineProperty(exports, "TemplateTypeAttributes", { enumerable: true, get: function () { return templateAttributes_1.TemplateTypeAttributes; } });
33
- Object.defineProperty(exports, "minSupportedUI5Version", { enumerable: true, get: function () { return templateAttributes_1.minSupportedUI5Version; } });
34
- Object.defineProperty(exports, "minSupportedUI5VersionV4", { enumerable: true, get: function () { return templateAttributes_1.minSupportedUI5VersionV4; } });
35
- const manifestSettings_1 = require("./data/manifestSettings");
36
- const semver_1 = __importDefault(require("semver"));
37
- const i18n_1 = require("./i18n");
38
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
39
- const fpmConfig_1 = require("./fpmConfig");
40
- const cap_config_writer_1 = require("@sap-ux/cap-config-writer");
41
- const writeAnnotations_1 = require("./writeAnnotations");
42
- exports.V2_FE_TYPES_AVAILABLE = '1.108.0';
1
+ import { dirname, join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { render } from 'ejs';
4
+ const __dirname = dirname(fileURLToPath(import.meta.url));
5
+ import { generate as generateUi5Project } from '@sap-ux/ui5-application-writer';
6
+ import { generate as addOdataService, OdataVersion, ServiceType } from '@sap-ux/odata-service-writer';
7
+ import { generateOPAFiles } from '@sap-ux/ui5-test-writer';
8
+ import cloneDeep from 'lodash/cloneDeep.js';
9
+ import { TemplateType } from './types.js';
10
+ import { validateApp, validateRequiredProperties } from './validate.js';
11
+ import { setAppDefaults, setDefaultTemplateSettings, getTemplateOptions, setVirtualEndpointDefaults } from './data/defaults.js';
12
+ import { TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4, escapeFLPText } from './data/templateAttributes.js';
13
+ import { extendManifestJson } from './data/manifestSettings.js';
14
+ import semVer from 'semver';
15
+ import { initI18n } from './i18n.js';
16
+ import { getBootstrapResourceUrls, getPackageScripts } from '@sap-ux/fiori-generator-shared';
17
+ import { generateFpmConfig } from './fpmConfig.js';
18
+ import { applyCAPUpdates } from '@sap-ux/cap-config-writer';
19
+ import { writeAnnotations } from './writeAnnotations.js';
20
+ export const V2_FE_TYPES_AVAILABLE = '1.108.0';
43
21
  /**
44
22
  * Get TypeScript Ignore Glob Pattern.
45
23
  *
@@ -50,12 +28,12 @@ exports.V2_FE_TYPES_AVAILABLE = '1.108.0';
50
28
  function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
51
29
  let ignore = [];
52
30
  // isV2FETypesAvailable - Boolean to indicate if V2 Fiori Element types were available in the UI5 version
53
- const isV2FETypesAvailable = feApp.ui5?.version ? semver_1.default.gte(coercedUI5Version, exports.V2_FE_TYPES_AVAILABLE) : false;
31
+ const isV2FETypesAvailable = feApp.ui5?.version ? semVer.gte(coercedUI5Version, V2_FE_TYPES_AVAILABLE) : false;
54
32
  const tsIgnoreGlob = ['**/*.js'];
55
33
  ignore = tsIgnoreGlob;
56
34
  // Add local ui5.d.ts if types are missing in UI5 version for V2 Odata services
57
35
  // OR template is OVP
58
- if (feApp.service.version === odata_service_writer_1.OdataVersion.v2) {
36
+ if (feApp.service.version === OdataVersion.v2) {
59
37
  if (isV2FETypesAvailable) {
60
38
  ignore.push('**/ui5.d.ts');
61
39
  }
@@ -63,7 +41,7 @@ function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
63
41
  // do nothing
64
42
  }
65
43
  }
66
- else if (feApp.template.type !== types_1.TemplateType.OverviewPage) {
44
+ else if (feApp.template.type !== TemplateType.OverviewPage) {
67
45
  ignore.push('**/ui5.d.ts');
68
46
  }
69
47
  return ignore;
@@ -90,7 +68,7 @@ function getOpaConfig({ useVirtualPreviewEndpoints }, flpAppId) {
90
68
  * @returns - boolean indicating if tests are to be added
91
69
  */
92
70
  function shouldAddTest(service, addTests) {
93
- return (!!addTests && service?.version === odata_service_writer_1.OdataVersion.v4 && (!!service?.metadata || service?.type === odata_service_writer_1.ServiceType.CDS));
71
+ return (!!addTests && service?.version === OdataVersion.v4 && (!!service?.metadata || service?.type === ServiceType.CDS));
94
72
  }
95
73
  /**
96
74
  * Generate a UI5 application based on the specified Fiori Elements floorplan template.
@@ -104,20 +82,20 @@ function shouldAddTest(service, addTests) {
104
82
  async function generate(basePath, data, fs, log) {
105
83
  // Load i18n translations asynchronously to ensure proper initialization.
106
84
  // This addresses occasional issues where i18n is not initialized in time, causing tests to fail.
107
- await (0, i18n_1.initI18n)();
85
+ await initI18n();
108
86
  // Clone rather than modifying callers refs
109
- const feApp = (0, cloneDeep_1.default)(data);
87
+ const feApp = cloneDeep(data);
110
88
  // Ensure input data contains at least the mandatory properties required for app generation
111
- (0, validate_1.validateRequiredProperties)(feApp);
112
- (0, defaults_1.setAppDefaults)(feApp);
113
- fs = await (0, ui5_application_writer_1.generate)(basePath, feApp, fs);
114
- feApp.template.settings = (0, defaults_1.setDefaultTemplateSettings)(feApp.template, feApp.service.version);
89
+ validateRequiredProperties(feApp);
90
+ setAppDefaults(feApp);
91
+ fs = await generateUi5Project(basePath, feApp, fs);
92
+ feApp.template.settings = setDefaultTemplateSettings(feApp.template, feApp.service.version);
115
93
  // This is done after `generateUi5Project` since defaults are set if values are not provided
116
- (0, validate_1.validateApp)(feApp);
117
- await (0, odata_service_writer_1.generate)(basePath, feApp.service, fs);
118
- const coercedUI5Version = semver_1.default.coerce(feApp.ui5?.version);
94
+ validateApp(feApp);
95
+ await addOdataService(basePath, feApp.service, fs);
96
+ const coercedUI5Version = semVer.coerce(feApp.ui5?.version);
119
97
  // Add new files from templates e.g.
120
- const rootTemplatesPath = (0, node_path_1.join)(__dirname, '..', 'templates');
98
+ const rootTemplatesPath = join(__dirname, '..', 'templates');
121
99
  // Add templates common to all template types
122
100
  const isTypeScriptEnabled = feApp.appOptions?.typescript === true;
123
101
  const ignore = [
@@ -126,15 +104,15 @@ async function generate(basePath, data, fs, log) {
126
104
  ...(feApp.appOptions?.useVirtualPreviewEndpoints ? ['**/webapp/test/**'] : [])
127
105
  ];
128
106
  if (feApp.appOptions?.useVirtualPreviewEndpoints) {
129
- (0, defaults_1.setVirtualEndpointDefaults)(feApp);
107
+ setVirtualEndpointDefaults(feApp);
130
108
  }
131
109
  // Determine if the project type is 'EDMXBackend'.
132
110
  const isEdmxProjectType = feApp.app.projectType === 'EDMXBackend';
133
111
  // Get resource bootstrap URLs based on the project type
134
- const { uShellBootstrapResourceUrl, uiBootstrapResourceUrl } = (0, fiori_generator_shared_1.getBootstrapResourceUrls)(isEdmxProjectType, feApp.ui5?.frameworkUrl, feApp.ui5?.version);
112
+ const { uShellBootstrapResourceUrl, uiBootstrapResourceUrl } = getBootstrapResourceUrls(isEdmxProjectType, feApp.ui5?.frameworkUrl, feApp.ui5?.version);
135
113
  const ui5Libs = isEdmxProjectType ? feApp.ui5?.ui5Libs : undefined;
136
114
  // Define template options with changes preview and loader settings based on project type
137
- const templateOptions = (0, defaults_1.getTemplateOptions)(isEdmxProjectType, feApp.service.version, feApp.ui5?.version);
115
+ const templateOptions = getTemplateOptions(isEdmxProjectType, feApp.service.version, feApp.ui5?.version);
138
116
  const appConfig = {
139
117
  ...feApp,
140
118
  templateOptions,
@@ -143,42 +121,42 @@ async function generate(basePath, data, fs, log) {
143
121
  ui5Libs
144
122
  };
145
123
  // Copy templates with configuration
146
- fs.copyTpl((0, node_path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
124
+ fs.copyTpl(join(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
147
125
  ...appConfig,
148
- escapeFLPText: templateAttributes_1.escapeFLPText
126
+ escapeFLPText
149
127
  }, undefined, {
150
128
  globOptions: { ignore, dot: true }
151
129
  });
152
- fs.copyTpl((0, node_path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
130
+ fs.copyTpl(join(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
153
131
  ...appConfig,
154
132
  templateOptions,
155
- escapeFLPText: templateAttributes_1.escapeFLPText
133
+ escapeFLPText
156
134
  }, undefined, {
157
135
  globOptions: { ignore, dot: true }
158
136
  });
159
137
  // Extend common files
160
- const packagePath = (0, node_path_1.join)(basePath, 'package.json');
138
+ const packagePath = join(basePath, 'package.json');
161
139
  // Extend package.json
162
- fs.extendJSON(packagePath, JSON.parse((0, ejs_1.render)(fs.read((0, node_path_1.join)(rootTemplatesPath, 'common', 'extend', 'package.json')), feApp, {})));
140
+ fs.extendJSON(packagePath, JSON.parse(render(fs.read(join(rootTemplatesPath, 'common', 'extend', 'package.json')), feApp, {})));
163
141
  // Special handling for FPM because it is not based on template files but used the fpm writer
164
- if (feApp.template.type === types_1.TemplateType.FlexibleProgrammingModel) {
165
- await (0, fpmConfig_1.generateFpmConfig)(feApp, basePath, fs);
142
+ if (feApp.template.type === TemplateType.FlexibleProgrammingModel) {
143
+ await generateFpmConfig(feApp, basePath, fs);
166
144
  }
167
145
  else {
168
146
  // Copy odata version specific common templates and version specific, floorplan specific templates
169
- const templateVersionPath = (0, node_path_1.join)(rootTemplatesPath, `v${feApp.service?.version}`);
170
- [(0, node_path_1.join)(templateVersionPath, 'common', 'add'), (0, node_path_1.join)(templateVersionPath, feApp.template.type, 'add')].forEach((templatePath) => {
171
- fs.copyTpl((0, node_path_1.join)(templatePath, '**/*.*'), basePath, feApp, {}, { ignoreNoMatch: true, globOptions: { ignore, dot: true } });
147
+ const templateVersionPath = join(rootTemplatesPath, `v${feApp.service?.version}`);
148
+ [join(templateVersionPath, 'common', 'add'), join(templateVersionPath, feApp.template.type, 'add')].forEach((templatePath) => {
149
+ fs.copyTpl(join(templatePath, '**/*.*'), basePath, feApp, {}, { ignoreNoMatch: true, globOptions: { ignore, dot: true } });
172
150
  });
173
151
  }
174
152
  // Update manifest.json with template specific settings
175
- (0, manifestSettings_1.extendManifestJson)(fs, basePath, rootTemplatesPath, feApp);
153
+ extendManifestJson(fs, basePath, rootTemplatesPath, feApp);
176
154
  const packageJson = JSON.parse(fs.read(packagePath));
177
155
  const addTest = shouldAddTest(feApp.service, feApp.appOptions?.addTests);
178
156
  if (isEdmxProjectType) {
179
157
  // Add scripts to package.json only for non-CAP projects
180
158
  packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
181
- ...(0, fiori_generator_shared_1.getPackageScripts)({
159
+ ...getPackageScripts({
182
160
  localOnly: !feApp.service?.url,
183
161
  addMock: !!feApp.service?.metadata,
184
162
  addTest,
@@ -208,17 +186,18 @@ async function generate(basePath, data, fs, log) {
208
186
  disableRootPackageJsonUpdates: feApp.appOptions?.disableCapRootPkgJsonUpdates
209
187
  };
210
188
  // apply cap updates when service is cap
211
- await (0, cap_config_writer_1.applyCAPUpdates)(fs, feApp.service.capService, settings);
189
+ await applyCAPUpdates(fs, feApp.service.capService, settings);
212
190
  }
213
191
  if (feApp.appOptions?.addAnnotations) {
214
- await (0, writeAnnotations_1.writeAnnotations)(basePath, feApp, fs, log);
192
+ await writeAnnotations(basePath, feApp, fs, log);
215
193
  }
216
194
  // OPA tests must be generated last since they depend on other parts of the app, such as annotations, being in place
217
195
  if (addTest) {
218
196
  const opaConfig = getOpaConfig({ useVirtualPreviewEndpoints: feApp.appOptions?.useVirtualPreviewEndpoints }, feApp.app.flpAppId);
219
- await (0, ui5_test_writer_1.generateOPAFiles)(basePath, opaConfig, data.service.metadata, fs, log);
197
+ await generateOPAFiles(basePath, opaConfig, data.service.metadata, fs, log);
220
198
  }
221
199
  return fs;
222
200
  }
223
- __exportStar(require("./types"), exports);
201
+ export { generate, TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 };
202
+ export * from './types.js';
224
203
  //# sourceMappingURL=index.js.map
package/dist/types.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OdataVersion = exports.TableSelectionMode = exports.TableType = exports.ValidationError = exports.TemplateType = void 0;
4
- exports.TemplateType = {
1
+ export const TemplateType = {
5
2
  Worklist: 'worklist',
6
3
  ListReportObjectPage: 'lrop',
7
4
  AnalyticalListPage: 'alp',
@@ -12,7 +9,7 @@ exports.TemplateType = {
12
9
  /**
13
10
  * General validation error thrown if app config options contain invalid combinations
14
11
  */
15
- class ValidationError extends Error {
12
+ export class ValidationError extends Error {
16
13
  /**
17
14
  * ValidationError constructor.
18
15
  *
@@ -23,20 +20,18 @@ class ValidationError extends Error {
23
20
  this.name = this.constructor.name;
24
21
  }
25
22
  }
26
- exports.ValidationError = ValidationError;
27
- exports.TableType = {
23
+ export const TableType = {
28
24
  GRID: 'GridTable',
29
25
  ANALYTICAL: 'AnalyticalTable',
30
26
  RESPONSIVE: 'ResponsiveTable',
31
27
  TREE: 'TreeTable'
32
28
  };
33
- exports.TableSelectionMode = {
29
+ export const TableSelectionMode = {
34
30
  NONE: 'None',
35
31
  AUTO: 'Auto',
36
32
  MULTI: 'Multi',
37
33
  SINGLE: 'Single'
38
34
  };
39
35
  // We need this for the service version
40
- var odata_service_writer_1 = require("@sap-ux/odata-service-writer");
41
- Object.defineProperty(exports, "OdataVersion", { enumerable: true, get: function () { return odata_service_writer_1.OdataVersion; } });
36
+ export { OdataVersion } from '@sap-ux/odata-service-writer';
42
37
  //# sourceMappingURL=types.js.map
@@ -1,4 +1,4 @@
1
- import type { FioriElementsApp } from './types';
1
+ import type { FioriElementsApp } from './types.js';
2
2
  /**
3
3
  * Validates a selection of specified app settings.
4
4
  *
package/dist/validate.js CHANGED
@@ -1,24 +1,17 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateApp = validateApp;
7
- exports.validateRequiredProperties = validateRequiredProperties;
8
- const semver_1 = __importDefault(require("semver"));
9
- const templateAttributes_1 = require("./data/templateAttributes");
10
- const i18n_1 = require("./i18n");
11
- const types_1 = require("./types");
1
+ import semVer from 'semver';
2
+ import { TemplateTypeAttributes } from './data/templateAttributes.js';
3
+ import { t } from './i18n.js';
4
+ import { ValidationError } from './types.js';
12
5
  /**
13
6
  * Validates a selection of specified app settings.
14
7
  *
15
8
  * @param feApp - Fiori elements application configuration
16
9
  */
17
- function validateApp(feApp) {
10
+ export function validateApp(feApp) {
18
11
  // Validate odata version
19
12
  if (feApp.service.version &&
20
- !templateAttributes_1.TemplateTypeAttributes[feApp.template.type].supportedODataVersions.includes(feApp.service.version)) {
21
- throw new types_1.ValidationError((0, i18n_1.t)('error.unsupportedOdataVersion', {
13
+ !TemplateTypeAttributes[feApp.template.type].supportedODataVersions.includes(feApp.service.version)) {
14
+ throw new ValidationError(t('error.unsupportedOdataVersion', {
22
15
  serviceVersion: feApp.service.version,
23
16
  templateType: feApp.template.type
24
17
  }));
@@ -26,32 +19,32 @@ function validateApp(feApp) {
26
19
  // Validate ui5 versions if present (defaults will apply otherwise)
27
20
  let ui5Version = null;
28
21
  if (feApp.ui5?.version) {
29
- ui5Version = semver_1.default.coerce(feApp.ui5?.version);
22
+ ui5Version = semVer.coerce(feApp.ui5?.version);
30
23
  if (!ui5Version) {
31
- throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'version', ui5Version: feApp.ui5?.version }));
24
+ throw new ValidationError(t('error.invalidUI5Version', { versionProperty: 'version', ui5Version: feApp.ui5?.version }));
32
25
  }
33
26
  }
34
27
  let minUI5Version;
35
- const minRequiredUI5Version = templateAttributes_1.TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
28
+ const minRequiredUI5Version = TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
36
29
  if (feApp.ui5?.minUI5Version) {
37
- minUI5Version = semver_1.default.coerce(feApp.ui5?.minUI5Version);
30
+ minUI5Version = semVer.coerce(feApp.ui5?.minUI5Version);
38
31
  if (!minUI5Version) {
39
- throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'minUI5Version', ui5Version: feApp.ui5?.minUI5Version }));
32
+ throw new ValidationError(t('error.invalidUI5Version', { versionProperty: 'minUI5Version', ui5Version: feApp.ui5?.minUI5Version }));
40
33
  }
41
34
  }
42
35
  else {
43
- minUI5Version = semver_1.default.coerce(minRequiredUI5Version);
36
+ minUI5Version = semVer.coerce(minRequiredUI5Version);
44
37
  }
45
- if (ui5Version && semver_1.default.lt(ui5Version, minRequiredUI5Version)) {
46
- throw new types_1.ValidationError((0, i18n_1.t)('error.unsupportedUI5Version', {
38
+ if (ui5Version && semVer.lt(ui5Version, minRequiredUI5Version)) {
39
+ throw new ValidationError(t('error.unsupportedUI5Version', {
47
40
  versionProperty: 'version',
48
41
  ui5Version: feApp.ui5?.version,
49
42
  templateType: feApp.template.type,
50
43
  minRequiredUI5Version
51
44
  }));
52
45
  }
53
- if (semver_1.default.lt(minUI5Version, minRequiredUI5Version)) {
54
- throw new types_1.ValidationError((0, i18n_1.t)('error.unsupportedUI5Version', {
46
+ if (semVer.lt(minUI5Version, minRequiredUI5Version)) {
47
+ throw new ValidationError(t('error.unsupportedUI5Version', {
55
48
  versionProperty: 'minUI5Version',
56
49
  ui5Version: feApp.ui5?.minUI5Version,
57
50
  templateType: feApp.template.type,
@@ -64,10 +57,10 @@ function validateApp(feApp) {
64
57
  *
65
58
  * @param feApp - Fiori elements application configuration
66
59
  */
67
- function validateRequiredProperties(feApp) {
60
+ export function validateRequiredProperties(feApp) {
68
61
  // Service is mandatory for generation of Fiori Elements apps
69
62
  if (!feApp.service) {
70
- throw new types_1.ValidationError((0, i18n_1.t)('error.missingRequiredProperty', {
63
+ throw new ValidationError(t('error.missingRequiredProperty', {
71
64
  propertyName: 'FioriElementsApp.service'
72
65
  }));
73
66
  }
@@ -1,4 +1,4 @@
1
- import { type FioriElementsApp } from './types';
1
+ import { type FioriElementsApp } from './types.js';
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  import type { Logger } from '@sap-ux/logger';
4
4
  /**
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeAnnotations = writeAnnotations;
4
- const node_path_1 = require("node:path");
5
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
6
- const types_1 = require("./types");
7
- const annotation_generator_1 = require("@sap-ux/annotation-generator");
8
- const templateAttributes_1 = require("./data/templateAttributes");
9
- const i18n_1 = require("./i18n");
1
+ import { sep } from 'node:path';
2
+ import { getCapFolderPathsSync } from '@sap-ux/fiori-generator-shared';
3
+ import { TemplateType } from './types.js';
4
+ import { generateAnnotations } from '@sap-ux/annotation-generator';
5
+ import { TemplateTypeAttributes } from './data/templateAttributes.js';
6
+ import { t } from './i18n.js';
10
7
  /**
11
8
  * Generates the annotation file path based on whether the CAP service is available.
12
9
  *
@@ -16,10 +13,10 @@ const i18n_1 = require("./i18n");
16
13
  */
17
14
  function getAnnotationFilePath(appName, capService) {
18
15
  if (capService) {
19
- const appPath = capService.appPath ?? (0, fiori_generator_shared_1.getCapFolderPathsSync)(capService.projectPath).app;
20
- return `${appPath}${node_path_1.sep}${appName}${node_path_1.sep}annotations.cds`;
16
+ const appPath = capService.appPath ?? getCapFolderPathsSync(capService.projectPath).app;
17
+ return `${appPath}${sep}${appName}${sep}annotations.cds`;
21
18
  }
22
- return `webapp${node_path_1.sep}annotations${node_path_1.sep}annotation.xml`;
19
+ return `webapp${sep}annotations${sep}annotation.xml`;
23
20
  }
24
21
  /**
25
22
  * Writes annotation files for the given application configuration.
@@ -29,13 +26,13 @@ function getAnnotationFilePath(appName, capService) {
29
26
  * @param fs - The file system editor instance.
30
27
  * @param log - The logger instance.
31
28
  */
32
- async function writeAnnotations(basePath, feApp, fs, log) {
33
- if (templateAttributes_1.TemplateTypeAttributes[feApp.template.type]?.annotationGenerationSupport?.[feApp.service.version]) {
29
+ export async function writeAnnotations(basePath, feApp, fs, log) {
30
+ if (TemplateTypeAttributes[feApp.template.type]?.annotationGenerationSupport?.[feApp.service.version]) {
34
31
  const { settings } = feApp.template;
35
32
  const { capService } = feApp.service;
36
33
  const { name: packageName } = feApp.package ?? {};
37
34
  const entitySetName = settings?.entityConfig?.mainEntityName ?? '';
38
- const addLineItems = feApp.template.type === types_1.TemplateType.ListReportObjectPage || feApp.template.type === types_1.TemplateType.Worklist;
35
+ const addLineItems = feApp.template.type === TemplateType.ListReportObjectPage || feApp.template.type === TemplateType.Worklist;
39
36
  let serviceName = 'mainService';
40
37
  let projectPath = basePath;
41
38
  if (capService) {
@@ -55,14 +52,14 @@ async function writeAnnotations(basePath, feApp, fs, log) {
55
52
  project: projectPath
56
53
  };
57
54
  try {
58
- await (0, annotation_generator_1.generateAnnotations)(fs, serviceParameters, options);
55
+ await generateAnnotations(fs, serviceParameters, options);
59
56
  }
60
57
  catch (err) {
61
- log?.error(`${(0, i18n_1.t)('error.errorGeneratingDefaultAnnotations')} ${err}`);
58
+ log?.error(`${t('error.errorGeneratingDefaultAnnotations')} ${err}`);
62
59
  }
63
60
  }
64
61
  else {
65
- log?.warn((0, i18n_1.t)('warn.invalidTypeForAnnotationGeneration', {
62
+ log?.warn(t('warn.invalidTypeForAnnotationGeneration', {
66
63
  templateType: feApp.template.type,
67
64
  odataVersion: feApp.service.version
68
65
  }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-elements-writer",
3
3
  "description": "SAP Fiori elements application writer",
4
- "version": "2.10.16",
4
+ "version": "3.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -10,6 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Afiori-elements-writer"
12
12
  },
13
+ "type": "module",
13
14
  "license": "Apache-2.0",
14
15
  "main": "dist/index.js",
15
16
  "files": [
@@ -27,17 +28,18 @@
27
28
  "mem-fs-editor": "9.4.0",
28
29
  "read-pkg-up": "7.0.1",
29
30
  "semver": "7.7.4",
30
- "@sap-ux/odata-service-writer": "0.32.2",
31
- "@sap-ux/ui5-application-writer": "1.9.2",
32
- "@sap-ux/fe-fpm-writer": "0.44.3",
33
- "@sap-ux/ui5-config": "0.31.1",
34
- "@sap-ux/ui5-test-writer": "0.9.15",
35
- "@sap-ux/fiori-generator-shared": "0.15.6",
36
- "@sap-ux/cap-config-writer": "0.13.6",
37
- "@sap-ux/annotation-generator": "0.5.3",
38
- "@sap-ux/logger": "0.9.0"
31
+ "@sap-ux/odata-service-writer": "1.0.1",
32
+ "@sap-ux/ui5-application-writer": "2.0.0",
33
+ "@sap-ux/fe-fpm-writer": "1.0.1",
34
+ "@sap-ux/ui5-config": "1.0.0",
35
+ "@sap-ux/ui5-test-writer": "1.0.1",
36
+ "@sap-ux/cap-config-writer": "1.0.1",
37
+ "@sap-ux/fiori-generator-shared": "1.0.1",
38
+ "@sap-ux/annotation-generator": "1.0.1",
39
+ "@sap-ux/logger": "1.0.0"
39
40
  },
40
41
  "devDependencies": {
42
+ "@jest/globals": "30.3.0",
41
43
  "@types/ejs": "3.1.5",
42
44
  "@types/fs-extra": "11.0.4",
43
45
  "@types/lodash": "4.17.24",
@@ -45,8 +47,8 @@
45
47
  "@types/mem-fs": "1.1.2",
46
48
  "@types/semver": "7.7.1",
47
49
  "fs-extra": "11.3.4",
48
- "@sap-ux/project-access": "1.38.1",
49
- "@sap-ux/eslint-plugin-fiori-tools": "10.2.2"
50
+ "@sap-ux/project-access": "2.0.1",
51
+ "@sap-ux/eslint-plugin-fiori-tools": "10.4.1"
50
52
  },
51
53
  "engines": {
52
54
  "node": ">=22.x"
@@ -57,8 +59,8 @@
57
59
  "watch": "tsc --watch",
58
60
  "lint": "eslint",
59
61
  "lint:fix": "eslint --fix",
60
- "test": "jest --ci --forceExit --detectOpenHandles --colors",
61
- "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
62
+ "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
63
+ "test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
62
64
  "link": "pnpm link --global",
63
65
  "unlink": "pnpm unlink --global"
64
66
  }