@sap-ux/fiori-elements-writer 2.10.16 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/annotationCustomUi5Libs.js +4 -8
- package/dist/data/defaults.d.ts +3 -3
- package/dist/data/defaults.js +38 -46
- package/dist/data/manifestSettings.d.ts +1 -1
- package/dist/data/manifestSettings.js +21 -27
- package/dist/data/templateAttributes.d.ts +1 -1
- package/dist/data/templateAttributes.js +63 -70
- package/dist/data/types.d.ts +1 -1
- package/dist/data/types.js +1 -2
- package/dist/fpmConfig.d.ts +1 -1
- package/dist/fpmConfig.js +3 -6
- package/dist/i18n.js +9 -19
- package/dist/index.d.ts +3 -3
- package/dist/index.js +55 -76
- package/dist/types.js +5 -10
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +19 -26
- package/dist/writeAnnotations.d.ts +1 -1
- package/dist/writeAnnotations.js +15 -18
- package/package.json +16 -14
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
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(
|
|
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 =
|
|
18
|
+
const rule = annotationLibs.find((rule) => rule.annotation === annotation);
|
|
23
19
|
if (rule) {
|
|
24
20
|
libraries.push(rule.library);
|
|
25
21
|
}
|
package/dist/data/defaults.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/data/defaults.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 ===
|
|
34
|
+
if (template.type === TemplateType.AnalyticalListPage) {
|
|
43
35
|
const alpSettings = template.settings;
|
|
44
36
|
Object.assign(templateSettings, {
|
|
45
|
-
tableType: alpSettings.tableType ??
|
|
37
|
+
tableType: alpSettings.tableType ?? TableType.ANALYTICAL // Overrides the UI5 default: ''
|
|
46
38
|
});
|
|
47
|
-
if (odataVersion ===
|
|
39
|
+
if (odataVersion === OdataVersion.v4) {
|
|
48
40
|
const alpV4Settings = template.settings;
|
|
49
41
|
Object.assign(templateSettings, {
|
|
50
|
-
selectionMode: alpV4Settings.selectionMode ??
|
|
42
|
+
selectionMode: alpV4Settings.selectionMode ?? TableSelectionMode.NONE
|
|
51
43
|
});
|
|
52
44
|
return templateSettings;
|
|
53
45
|
}
|
|
54
|
-
if (odataVersion ===
|
|
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 ===
|
|
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 ??
|
|
60
|
+
tableType: tableSettings.tableType ?? TableType.RESPONSIVE // Overrides the UI5 default: ''
|
|
69
61
|
});
|
|
70
|
-
if (tableSettings.tableType !==
|
|
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 =
|
|
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 =
|
|
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 ||
|
|
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 ||
|
|
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 =
|
|
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 ===
|
|
133
|
-
?
|
|
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 ||=
|
|
146
|
-
if (serviceType ===
|
|
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 ===
|
|
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 ??
|
|
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 =
|
|
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
|
-
?
|
|
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 ===
|
|
173
|
+
const changesLoader = isEdmxProjectType && serviceVersion === OdataVersion.v2;
|
|
182
174
|
return {
|
|
183
175
|
changesPreview,
|
|
184
176
|
changesLoader
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
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 ===
|
|
19
|
+
if (feApp.service.version === OdataVersion.v4 &&
|
|
26
20
|
[
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
TemplateType.FormEntryObjectPage,
|
|
22
|
+
TemplateType.AnalyticalListPage,
|
|
23
|
+
TemplateType.ListReportObjectPage,
|
|
24
|
+
TemplateType.Worklist
|
|
31
25
|
].includes(feApp.template.type)) {
|
|
32
|
-
templatePath =
|
|
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 =
|
|
35
|
-
if (!minVersion ||
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 =
|
|
62
|
+
const manifestPath = join(targetPath, 'webapp', 'manifest.json');
|
|
69
63
|
extendTemplatePaths.forEach((extendTemplatePath) => {
|
|
70
|
-
const manifestTemplatePath =
|
|
64
|
+
const manifestTemplatePath = join(extendTemplatePath, 'manifest.json');
|
|
71
65
|
if (fs.exists(manifestTemplatePath)) {
|
|
72
|
-
fs.extendJSON(manifestPath, JSON.parse(
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
22
|
+
[OdataVersion.v4]: ['sap.m', 'sap.fe.templates']
|
|
30
23
|
};
|
|
31
24
|
const templateLibs = {
|
|
32
|
-
[
|
|
33
|
-
[
|
|
25
|
+
[OdataVersion.v2]: {
|
|
26
|
+
[TemplateType.AnalyticalListPage]: {
|
|
34
27
|
baseComponent: appComponentLibGeneric,
|
|
35
|
-
ui5Libs: [...commonUi5Libs[
|
|
28
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v2]]
|
|
36
29
|
},
|
|
37
|
-
[
|
|
30
|
+
[TemplateType.ListReportObjectPage]: {
|
|
38
31
|
baseComponent: appComponentLibGeneric,
|
|
39
|
-
ui5Libs: [...commonUi5Libs[
|
|
32
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v2]]
|
|
40
33
|
},
|
|
41
|
-
[
|
|
34
|
+
[TemplateType.OverviewPage]: {
|
|
42
35
|
baseComponent: appComponentLibOVP,
|
|
43
|
-
ui5Libs: [...commonUi5Libs[
|
|
36
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v2], 'sap.ovp', 'sap.ui.rta', 'sap.ui.layout']
|
|
44
37
|
},
|
|
45
|
-
[
|
|
38
|
+
[TemplateType.Worklist]: {
|
|
46
39
|
baseComponent: appComponentLibGeneric,
|
|
47
|
-
ui5Libs: [...commonUi5Libs[
|
|
40
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v2], 'sap.collaboration']
|
|
48
41
|
}
|
|
49
42
|
},
|
|
50
|
-
[
|
|
51
|
-
[
|
|
43
|
+
[OdataVersion.v4]: {
|
|
44
|
+
[TemplateType.ListReportObjectPage]: {
|
|
52
45
|
baseComponent: appComponentLibFioriElements,
|
|
53
|
-
ui5Libs: [...commonUi5Libs[
|
|
54
|
-
manifestLibs: [...commonUi5Libs[
|
|
46
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
|
|
47
|
+
manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
|
|
55
48
|
},
|
|
56
|
-
[
|
|
49
|
+
[TemplateType.FormEntryObjectPage]: {
|
|
57
50
|
baseComponent: appComponentLibFioriElements,
|
|
58
|
-
ui5Libs: [...commonUi5Libs[
|
|
59
|
-
manifestLibs: [...commonUi5Libs[
|
|
51
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
|
|
52
|
+
manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
|
|
60
53
|
},
|
|
61
|
-
[
|
|
54
|
+
[TemplateType.AnalyticalListPage]: {
|
|
62
55
|
baseComponent: appComponentLibFioriElements,
|
|
63
|
-
ui5Libs: [...commonUi5Libs[
|
|
64
|
-
manifestLibs: [...commonUi5Libs[
|
|
56
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
|
|
57
|
+
manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
|
|
65
58
|
},
|
|
66
|
-
[
|
|
59
|
+
[TemplateType.Worklist]: {
|
|
67
60
|
baseComponent: appComponentLibFioriElements,
|
|
68
|
-
ui5Libs: [...commonUi5Libs[
|
|
69
|
-
manifestLibs: [...commonUi5Libs[
|
|
61
|
+
ui5Libs: [...commonUi5Libs[OdataVersion.v4], 'sap.ushell'],
|
|
62
|
+
manifestLibs: [...commonUi5Libs[OdataVersion.v4]]
|
|
70
63
|
},
|
|
71
|
-
[
|
|
64
|
+
[TemplateType.OverviewPage]: {
|
|
72
65
|
baseComponent: appComponentLibOVP,
|
|
73
|
-
ui5Libs: [...commonUi5Libs[
|
|
74
|
-
manifestLibs: [...commonUi5Libs[
|
|
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
|
-
[
|
|
69
|
+
[TemplateType.FlexibleProgrammingModel]: {
|
|
77
70
|
baseComponent: appComponentLibFioriElements,
|
|
78
|
-
ui5Libs: [...commonUi5Libs[
|
|
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
|
-
|
|
114
|
-
[
|
|
115
|
-
supportedODataVersions: [
|
|
106
|
+
export const TemplateTypeAttributes = {
|
|
107
|
+
[TemplateType.Worklist]: {
|
|
108
|
+
supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
|
|
116
109
|
minimumUi5Version: {
|
|
117
|
-
[
|
|
118
|
-
[
|
|
110
|
+
[OdataVersion.v2]: minSupportedUI5Version,
|
|
111
|
+
[OdataVersion.v4]: '1.99.0'
|
|
119
112
|
},
|
|
120
113
|
annotationGenerationSupport: {
|
|
121
|
-
[
|
|
114
|
+
[OdataVersion.v4]: true
|
|
122
115
|
}
|
|
123
116
|
},
|
|
124
|
-
[
|
|
125
|
-
supportedODataVersions: [
|
|
117
|
+
[TemplateType.ListReportObjectPage]: {
|
|
118
|
+
supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
|
|
126
119
|
minimumUi5Version: {
|
|
127
|
-
[
|
|
128
|
-
[
|
|
120
|
+
[OdataVersion.v2]: minSupportedUI5Version,
|
|
121
|
+
[OdataVersion.v4]: '1.84.0'
|
|
129
122
|
},
|
|
130
123
|
annotationGenerationSupport: {
|
|
131
|
-
[
|
|
124
|
+
[OdataVersion.v4]: true
|
|
132
125
|
}
|
|
133
126
|
},
|
|
134
|
-
[
|
|
135
|
-
supportedODataVersions: [
|
|
127
|
+
[TemplateType.AnalyticalListPage]: {
|
|
128
|
+
supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
|
|
136
129
|
minimumUi5Version: {
|
|
137
|
-
[
|
|
138
|
-
[
|
|
130
|
+
[OdataVersion.v2]: minSupportedUI5Version,
|
|
131
|
+
[OdataVersion.v4]: '1.90.0'
|
|
139
132
|
}
|
|
140
133
|
},
|
|
141
|
-
[
|
|
142
|
-
supportedODataVersions: [
|
|
134
|
+
[TemplateType.OverviewPage]: {
|
|
135
|
+
supportedODataVersions: [OdataVersion.v2, OdataVersion.v4],
|
|
143
136
|
minimumUi5Version: {
|
|
144
|
-
[
|
|
145
|
-
[
|
|
137
|
+
[OdataVersion.v2]: minSupportedUI5Version,
|
|
138
|
+
[OdataVersion.v4]: '1.96.8'
|
|
146
139
|
}
|
|
147
140
|
},
|
|
148
|
-
[
|
|
149
|
-
supportedODataVersions: [
|
|
141
|
+
[TemplateType.FormEntryObjectPage]: {
|
|
142
|
+
supportedODataVersions: [OdataVersion.v4],
|
|
150
143
|
minimumUi5Version: {
|
|
151
|
-
[
|
|
144
|
+
[OdataVersion.v4]: '1.90.0'
|
|
152
145
|
},
|
|
153
146
|
annotationGenerationSupport: {
|
|
154
|
-
[
|
|
147
|
+
[OdataVersion.v4]: true
|
|
155
148
|
}
|
|
156
149
|
},
|
|
157
|
-
[
|
|
158
|
-
supportedODataVersions: [
|
|
150
|
+
[TemplateType.FlexibleProgrammingModel]: {
|
|
151
|
+
supportedODataVersions: [OdataVersion.v4],
|
|
159
152
|
minimumUi5Version: {
|
|
160
|
-
[
|
|
153
|
+
[OdataVersion.v4]: '1.94.0'
|
|
161
154
|
}
|
|
162
155
|
}
|
|
163
156
|
};
|
package/dist/data/types.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/data/types.js
CHANGED
package/dist/fpmConfig.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
8
|
+
export async function initI18n() {
|
|
9
|
+
await i18n.init({
|
|
18
10
|
resources: {
|
|
19
11
|
en: {
|
|
20
|
-
[NS]:
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
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 ?
|
|
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 ===
|
|
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 !==
|
|
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 ===
|
|
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
|
|
85
|
+
await initI18n();
|
|
108
86
|
// Clone rather than modifying callers refs
|
|
109
|
-
const feApp = (
|
|
87
|
+
const feApp = cloneDeep(data);
|
|
110
88
|
// Ensure input data contains at least the mandatory properties required for app generation
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
fs = await (
|
|
114
|
-
feApp.template.settings =
|
|
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
|
-
|
|
117
|
-
await (
|
|
118
|
-
const coercedUI5Version =
|
|
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 =
|
|
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
|
-
|
|
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 } =
|
|
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 =
|
|
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(
|
|
124
|
+
fs.copyTpl(join(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
|
|
147
125
|
...appConfig,
|
|
148
|
-
escapeFLPText
|
|
126
|
+
escapeFLPText
|
|
149
127
|
}, undefined, {
|
|
150
128
|
globOptions: { ignore, dot: true }
|
|
151
129
|
});
|
|
152
|
-
fs.copyTpl(
|
|
130
|
+
fs.copyTpl(join(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
|
|
153
131
|
...appConfig,
|
|
154
132
|
templateOptions,
|
|
155
|
-
escapeFLPText
|
|
133
|
+
escapeFLPText
|
|
156
134
|
}, undefined, {
|
|
157
135
|
globOptions: { ignore, dot: true }
|
|
158
136
|
});
|
|
159
137
|
// Extend common files
|
|
160
|
-
const packagePath =
|
|
138
|
+
const packagePath = join(basePath, 'package.json');
|
|
161
139
|
// Extend package.json
|
|
162
|
-
fs.extendJSON(packagePath, JSON.parse(
|
|
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 ===
|
|
165
|
-
await
|
|
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 =
|
|
170
|
-
[
|
|
171
|
-
fs.copyTpl(
|
|
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
|
-
|
|
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
|
-
...
|
|
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
|
|
189
|
+
await applyCAPUpdates(fs, feApp.service.capService, settings);
|
|
212
190
|
}
|
|
213
191
|
if (feApp.appOptions?.addAnnotations) {
|
|
214
|
-
await
|
|
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
|
|
197
|
+
await generateOPAFiles(basePath, opaConfig, data.service.metadata, fs, log);
|
|
220
198
|
}
|
|
221
199
|
return fs;
|
|
222
200
|
}
|
|
223
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/dist/validate.d.ts
CHANGED
package/dist/validate.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
!
|
|
21
|
-
throw new
|
|
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 =
|
|
22
|
+
ui5Version = semVer.coerce(feApp.ui5?.version);
|
|
30
23
|
if (!ui5Version) {
|
|
31
|
-
throw new
|
|
24
|
+
throw new ValidationError(t('error.invalidUI5Version', { versionProperty: 'version', ui5Version: feApp.ui5?.version }));
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
27
|
let minUI5Version;
|
|
35
|
-
const minRequiredUI5Version =
|
|
28
|
+
const minRequiredUI5Version = TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
|
|
36
29
|
if (feApp.ui5?.minUI5Version) {
|
|
37
|
-
minUI5Version =
|
|
30
|
+
minUI5Version = semVer.coerce(feApp.ui5?.minUI5Version);
|
|
38
31
|
if (!minUI5Version) {
|
|
39
|
-
throw new
|
|
32
|
+
throw new ValidationError(t('error.invalidUI5Version', { versionProperty: 'minUI5Version', ui5Version: feApp.ui5?.minUI5Version }));
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
35
|
else {
|
|
43
|
-
minUI5Version =
|
|
36
|
+
minUI5Version = semVer.coerce(minRequiredUI5Version);
|
|
44
37
|
}
|
|
45
|
-
if (ui5Version &&
|
|
46
|
-
throw new
|
|
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 (
|
|
54
|
-
throw new
|
|
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
|
|
63
|
+
throw new ValidationError(t('error.missingRequiredProperty', {
|
|
71
64
|
propertyName: 'FioriElementsApp.service'
|
|
72
65
|
}));
|
|
73
66
|
}
|
package/dist/writeAnnotations.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 ??
|
|
20
|
-
return `${appPath}${
|
|
16
|
+
const appPath = capService.appPath ?? getCapFolderPathsSync(capService.projectPath).app;
|
|
17
|
+
return `${appPath}${sep}${appName}${sep}annotations.cds`;
|
|
21
18
|
}
|
|
22
|
-
return `webapp${
|
|
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 (
|
|
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 ===
|
|
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
|
|
55
|
+
await generateAnnotations(fs, serviceParameters, options);
|
|
59
56
|
}
|
|
60
57
|
catch (err) {
|
|
61
|
-
log?.error(`${
|
|
58
|
+
log?.error(`${t('error.errorGeneratingDefaultAnnotations')} ${err}`);
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
else {
|
|
65
|
-
log?.warn(
|
|
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": "
|
|
4
|
+
"version": "3.0.0",
|
|
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.
|
|
31
|
-
"@sap-ux/ui5-application-writer": "
|
|
32
|
-
"@sap-ux/fe-fpm-writer": "0.
|
|
33
|
-
"@sap-ux/ui5-config": "0.
|
|
34
|
-
"@sap-ux/ui5-test-writer": "0.
|
|
35
|
-
"@sap-ux/fiori-generator-shared": "0.
|
|
36
|
-
"@sap-ux/cap-config-writer": "0.
|
|
37
|
-
"@sap-ux/annotation-generator": "0.
|
|
38
|
-
"@sap-ux/logger": "0.
|
|
31
|
+
"@sap-ux/odata-service-writer": "1.0.0",
|
|
32
|
+
"@sap-ux/ui5-application-writer": "2.0.0",
|
|
33
|
+
"@sap-ux/fe-fpm-writer": "1.0.0",
|
|
34
|
+
"@sap-ux/ui5-config": "1.0.0",
|
|
35
|
+
"@sap-ux/ui5-test-writer": "1.0.0",
|
|
36
|
+
"@sap-ux/fiori-generator-shared": "1.0.0",
|
|
37
|
+
"@sap-ux/cap-config-writer": "1.0.0",
|
|
38
|
+
"@sap-ux/annotation-generator": "1.0.0",
|
|
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": "
|
|
49
|
-
"@sap-ux/eslint-plugin-fiori-tools": "10.
|
|
50
|
+
"@sap-ux/project-access": "2.0.0",
|
|
51
|
+
"@sap-ux/eslint-plugin-fiori-tools": "10.4.0"
|
|
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
|
}
|