@sap-ux/fiori-elements-writer 0.22.0 → 0.23.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.
- package/dist/data/{annotationReuseLibs.d.ts → annotationCustomUi5Libs.d.ts} +2 -3
- package/dist/data/{annotationReuseLibs.js → annotationCustomUi5Libs.js} +3 -4
- package/dist/data/defaults.d.ts +2 -2
- package/dist/data/defaults.js +23 -24
- package/dist/data/manifestSettings.js +7 -4
- package/dist/data/templateAttributes.js +2 -4
- package/dist/i18n.js +11 -22
- package/dist/index.js +80 -88
- package/dist/validate.js +8 -9
- package/package.json +7 -7
|
@@ -4,11 +4,10 @@ type AnnotationLibs = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const annotationLibs: AnnotationLibs[];
|
|
6
6
|
/**
|
|
7
|
-
* Returns the reuse libraries associated with annotation entries in the metadata
|
|
8
|
-
*
|
|
7
|
+
* @description Returns the reuse libraries associated with annotation entries in the metadata.
|
|
9
8
|
* @param metadata - metadata string to be checked for specific annotations
|
|
10
9
|
* @returns The base component library path
|
|
11
10
|
*/
|
|
12
11
|
export declare function getAnnotationV4Libs(metadata: string): string[];
|
|
13
12
|
export {};
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=annotationCustomUi5Libs.d.ts.map
|
|
@@ -8,8 +8,7 @@ exports.annotationLibs = [
|
|
|
8
8
|
}
|
|
9
9
|
];
|
|
10
10
|
/**
|
|
11
|
-
* Returns the reuse libraries associated with annotation entries in the metadata
|
|
12
|
-
*
|
|
11
|
+
* @description Returns the reuse libraries associated with annotation entries in the metadata.
|
|
13
12
|
* @param metadata - metadata string to be checked for specific annotations
|
|
14
13
|
* @returns The base component library path
|
|
15
14
|
*/
|
|
@@ -18,7 +17,7 @@ function getAnnotationV4Libs(metadata) {
|
|
|
18
17
|
// Create a regular expression that matches any of the annotations
|
|
19
18
|
const annotationsRegex = new RegExp(exports.annotationLibs.map((annotationLib) => annotationLib.annotation).join('|'), 'g');
|
|
20
19
|
const foundAnnotations = annotationsRegex.exec(metadata);
|
|
21
|
-
foundAnnotations
|
|
20
|
+
foundAnnotations?.forEach((annotation) => {
|
|
22
21
|
const rule = exports.annotationLibs.find((rule) => rule.annotation === annotation);
|
|
23
22
|
if (rule) {
|
|
24
23
|
libraries.push(rule.library);
|
|
@@ -27,4 +26,4 @@ function getAnnotationV4Libs(metadata) {
|
|
|
27
26
|
return Array.from(libraries);
|
|
28
27
|
}
|
|
29
28
|
exports.getAnnotationV4Libs = getAnnotationV4Libs;
|
|
30
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=annotationCustomUi5Libs.js.map
|
package/dist/data/defaults.d.ts
CHANGED
|
@@ -14,10 +14,10 @@ export declare function setDefaultTemplateSettings<T extends {}>(template: Templ
|
|
|
14
14
|
*
|
|
15
15
|
* @param type - The template type of the required base component
|
|
16
16
|
* @param version - The odata service version determines the appropriate base component to use
|
|
17
|
-
* @param
|
|
17
|
+
* @param ui5Libs - ui5 libs
|
|
18
18
|
* @returns The UI5 libs required by the specified template type and OData version and UI5 annotation libs
|
|
19
19
|
*/
|
|
20
|
-
export declare function getUi5Libs(type: TemplateType, version: OdataVersion,
|
|
20
|
+
export declare function getUi5Libs(type: TemplateType, version: OdataVersion, ui5Libs?: string | string[]): string[];
|
|
21
21
|
/**
|
|
22
22
|
* Sets defaults for the specified Fiori elements application.
|
|
23
23
|
*
|
package/dist/data/defaults.js
CHANGED
|
@@ -8,7 +8,7 @@ const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
|
8
8
|
const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
|
|
9
9
|
const types_1 = require("../types");
|
|
10
10
|
const templateAttributes_1 = require("./templateAttributes");
|
|
11
|
-
const
|
|
11
|
+
const annotationCustomUi5Libs_1 = require("./annotationCustomUi5Libs");
|
|
12
12
|
const defaultModelName = 'mainModel'; // UI5 default model name is '' but some floorplans require a named default model
|
|
13
13
|
/**
|
|
14
14
|
* Updates the template settings to defaults if not provided.
|
|
@@ -18,17 +18,16 @@ const defaultModelName = 'mainModel'; // UI5 default model name is '' but some f
|
|
|
18
18
|
* @returns Updated template settings
|
|
19
19
|
*/
|
|
20
20
|
function setDefaultTemplateSettings(template, odataVersion) {
|
|
21
|
-
var _a, _b, _c;
|
|
22
21
|
const templateSettings = template.settings;
|
|
23
22
|
if (template.type === types_1.TemplateType.AnalyticalListPage) {
|
|
24
23
|
const alpSettings = template.settings;
|
|
25
24
|
Object.assign(templateSettings, {
|
|
26
|
-
tableType:
|
|
25
|
+
tableType: alpSettings.tableType ?? types_1.TableType.ANALYTICAL // Overrides the UI5 default: ''
|
|
27
26
|
});
|
|
28
27
|
if (odataVersion === odata_service_writer_1.OdataVersion.v4) {
|
|
29
28
|
const alpV4Settings = template.settings;
|
|
30
29
|
Object.assign(templateSettings, {
|
|
31
|
-
selectionMode:
|
|
30
|
+
selectionMode: alpV4Settings.selectionMode ?? types_1.TableSelectionMode.NONE
|
|
32
31
|
});
|
|
33
32
|
return templateSettings;
|
|
34
33
|
}
|
|
@@ -46,7 +45,7 @@ function setDefaultTemplateSettings(template, odataVersion) {
|
|
|
46
45
|
else if (template.type === types_1.TemplateType.ListReportObjectPage || template.type === types_1.TemplateType.Worklist) {
|
|
47
46
|
const tableSettings = template.settings;
|
|
48
47
|
Object.assign(templateSettings, {
|
|
49
|
-
tableType:
|
|
48
|
+
tableType: tableSettings.tableType ?? types_1.TableType.RESPONSIVE // Overrides the UI5 default: ''
|
|
50
49
|
});
|
|
51
50
|
if (tableSettings.tableType !== types_1.TableType.TREE) {
|
|
52
51
|
delete tableSettings.hierarchyQualifier;
|
|
@@ -60,18 +59,12 @@ exports.setDefaultTemplateSettings = setDefaultTemplateSettings;
|
|
|
60
59
|
*
|
|
61
60
|
* @param type - The template type of the required base component
|
|
62
61
|
* @param version - The odata service version determines the appropriate base component to use
|
|
63
|
-
* @param
|
|
62
|
+
* @param ui5Libs - ui5 libs
|
|
64
63
|
* @returns The UI5 libs required by the specified template type and OData version and UI5 annotation libs
|
|
65
64
|
*/
|
|
66
|
-
function getUi5Libs(type, version,
|
|
65
|
+
function getUi5Libs(type, version, ui5Libs) {
|
|
67
66
|
const templateLibs = (0, templateAttributes_1.getTemplateUi5Libs)(type, version);
|
|
68
|
-
|
|
69
|
-
let annotationLibs = (0, annotationReuseLibs_1.getAnnotationV4Libs)(metadata);
|
|
70
|
-
return [...templateLibs, ...annotationLibs].concat(ui5Libs !== null && ui5Libs !== void 0 ? ui5Libs : []);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return [...templateLibs].concat(ui5Libs !== null && ui5Libs !== void 0 ? ui5Libs : []);
|
|
74
|
-
}
|
|
67
|
+
return [...templateLibs].concat(ui5Libs ?? []);
|
|
75
68
|
}
|
|
76
69
|
exports.getUi5Libs = getUi5Libs;
|
|
77
70
|
/**
|
|
@@ -81,25 +74,31 @@ exports.getUi5Libs = getUi5Libs;
|
|
|
81
74
|
* @returns Fiori elements app config with updated defaults for unspecified properties
|
|
82
75
|
*/
|
|
83
76
|
function setAppDefaults(feApp) {
|
|
84
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
77
|
// Add template information
|
|
86
|
-
if (!
|
|
78
|
+
if (!feApp.app.sourceTemplate?.version || !feApp.app.sourceTemplate?.id) {
|
|
87
79
|
const packageInfo = read_pkg_up_1.default.sync({ cwd: __dirname });
|
|
88
80
|
feApp.app.sourceTemplate = {
|
|
89
|
-
id: `${packageInfo
|
|
90
|
-
version: packageInfo
|
|
91
|
-
toolsId:
|
|
81
|
+
id: `${packageInfo?.packageJson.name}:${feApp.template.type}`,
|
|
82
|
+
version: packageInfo?.packageJson.version,
|
|
83
|
+
toolsId: feApp.app.sourceTemplate?.toolsId
|
|
92
84
|
};
|
|
93
85
|
}
|
|
94
86
|
// Generate base UI5 project
|
|
95
87
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
96
88
|
feApp.app.baseComponent = feApp.app.baseComponent || (0, templateAttributes_1.getBaseComponent)(feApp.template.type, feApp.service.version);
|
|
89
|
+
const customUi5Libs = feApp.service.version === odata_service_writer_1.OdataVersion.v4 && feApp.service.metadata
|
|
90
|
+
? (0, annotationCustomUi5Libs_1.getAnnotationV4Libs)(feApp.service.metadata)
|
|
91
|
+
: [];
|
|
97
92
|
// Add ui5 libs for specified template and odata version
|
|
98
93
|
// Dups will be removed by call to `generateUI5Project`
|
|
99
|
-
feApp.ui5 =
|
|
94
|
+
feApp.ui5 = {
|
|
95
|
+
...feApp.ui5,
|
|
96
|
+
ui5Libs: getUi5Libs(feApp.template.type, feApp.service.version, feApp.ui5?.ui5Libs),
|
|
97
|
+
customUi5Libs: customUi5Libs
|
|
98
|
+
};
|
|
100
99
|
// Assign a default annotation name if the service type is EDMX and no local annotation name is provided
|
|
101
100
|
let serviceType = feApp.service.type;
|
|
102
|
-
serviceType
|
|
101
|
+
serviceType ||= odata_service_writer_1.ServiceType.EDMX;
|
|
103
102
|
if (serviceType === odata_service_writer_1.ServiceType.EDMX && !feApp.service.localAnnotationsName) {
|
|
104
103
|
feApp.service.localAnnotationsName = 'annotation';
|
|
105
104
|
}
|
|
@@ -108,13 +107,13 @@ function setAppDefaults(feApp) {
|
|
|
108
107
|
feApp.service.model = defaultModelName;
|
|
109
108
|
}
|
|
110
109
|
// minimum UI5 version depending on the template required
|
|
111
|
-
feApp.ui5 =
|
|
110
|
+
feApp.ui5 = feApp.ui5 ?? {};
|
|
112
111
|
if (!feApp.ui5.minUI5Version) {
|
|
113
112
|
feApp.ui5.minUI5Version =
|
|
114
|
-
|
|
113
|
+
feApp.ui5.version ?? templateAttributes_1.TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
|
|
115
114
|
}
|
|
116
115
|
// if not explicitly disabled, enable the SAP Fiori tools
|
|
117
|
-
feApp.appOptions =
|
|
116
|
+
feApp.appOptions = feApp.appOptions ?? {};
|
|
118
117
|
if (feApp.appOptions.sapux !== false) {
|
|
119
118
|
feApp.appOptions.sapux = true;
|
|
120
119
|
}
|
|
@@ -20,7 +20,6 @@ const semver_1 = __importDefault(require("semver"));
|
|
|
20
20
|
* @param feApp - The application config to be used by the manifest templates
|
|
21
21
|
*/
|
|
22
22
|
function extendManifestJson(fs, targetPath, rootTemplatesPath, feApp) {
|
|
23
|
-
var _a, _b;
|
|
24
23
|
let templatePath = feApp.template.type;
|
|
25
24
|
// FEOP and ALP v4 are variants of LROP and so we use the same template and settings
|
|
26
25
|
if (feApp.service.version === odata_service_writer_1.OdataVersion.v4 &&
|
|
@@ -32,17 +31,21 @@ function extendManifestJson(fs, targetPath, rootTemplatesPath, feApp) {
|
|
|
32
31
|
].includes(feApp.template.type)) {
|
|
33
32
|
templatePath = types_1.TemplateType.ListReportObjectPage;
|
|
34
33
|
// starting with UI5 v1.94.0, contextPath should be used instead of 'entitySet' in manifest for v4 LROP based apps
|
|
35
|
-
const minVersion = semver_1.default.coerce(
|
|
34
|
+
const minVersion = semver_1.default.coerce(feApp.ui5?.minUI5Version);
|
|
36
35
|
if (!minVersion || semver_1.default.gte(minVersion, '1.94.0')) {
|
|
37
36
|
const entityConfig = feApp.template.settings.entityConfig;
|
|
38
37
|
entityConfig.contextPath = `/${entityConfig.mainEntityName}`;
|
|
39
|
-
if (
|
|
38
|
+
if (entityConfig.navigationEntity?.EntitySet) {
|
|
40
39
|
entityConfig.navigationEntity.contextPath = `${entityConfig.contextPath}/${entityConfig.navigationEntity.Name}`;
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
// Enhance template settings
|
|
45
|
-
const templateSettings =
|
|
44
|
+
const templateSettings = {
|
|
45
|
+
...feApp.template.settings,
|
|
46
|
+
defaultModel: feApp.service.model,
|
|
47
|
+
type: feApp.template.type
|
|
48
|
+
};
|
|
46
49
|
// Manifest paths to be extended
|
|
47
50
|
const extendTemplatePaths = [
|
|
48
51
|
(0, path_1.join)(rootTemplatesPath, 'common', 'extend', 'webapp'),
|
|
@@ -79,8 +79,7 @@ const templateLibs = {
|
|
|
79
79
|
* @returns The base component library path
|
|
80
80
|
*/
|
|
81
81
|
function getBaseComponent(type, version) {
|
|
82
|
-
|
|
83
|
-
return (_a = templateLibs[version][type]) === null || _a === void 0 ? void 0 : _a.baseComponent;
|
|
82
|
+
return templateLibs[version][type]?.baseComponent;
|
|
84
83
|
}
|
|
85
84
|
exports.getBaseComponent = getBaseComponent;
|
|
86
85
|
/**
|
|
@@ -91,8 +90,7 @@ exports.getBaseComponent = getBaseComponent;
|
|
|
91
90
|
* @returns The Ui5 libs required by the specified template type and OData version
|
|
92
91
|
*/
|
|
93
92
|
function getTemplateUi5Libs(type, version) {
|
|
94
|
-
|
|
95
|
-
return (_b = (_a = templateLibs[version][type]) === null || _a === void 0 ? void 0 : _a.ui5Libs) !== null && _b !== void 0 ? _b : [];
|
|
93
|
+
return templateLibs[version][type]?.ui5Libs ?? [];
|
|
96
94
|
}
|
|
97
95
|
exports.getTemplateUi5Libs = getTemplateUi5Libs;
|
|
98
96
|
exports.TemplateTypeAttributes = {
|
package/dist/i18n.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,19 +10,17 @@ const NS = 'fiori-freestyle-writer';
|
|
|
19
10
|
/**
|
|
20
11
|
* Initialize i18next with the translations for this module.
|
|
21
12
|
*/
|
|
22
|
-
function initI18n() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ns: [NS]
|
|
34
|
-
});
|
|
13
|
+
async function initI18n() {
|
|
14
|
+
await i18next_1.default.init({
|
|
15
|
+
resources: {
|
|
16
|
+
en: {
|
|
17
|
+
[NS]: fiori_elements_writer_i18n_json_1.default
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
lng: 'en',
|
|
21
|
+
fallbackLng: 'en',
|
|
22
|
+
defaultNS: NS,
|
|
23
|
+
ns: [NS]
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
26
|
exports.initI18n = initI18n;
|
package/dist/index.js
CHANGED
|
@@ -13,15 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
18
|
};
|
|
@@ -55,10 +46,9 @@ exports.V2_FE_TYPES_AVAILABLE = '1.108.0';
|
|
|
55
46
|
* @returns ignore pattern
|
|
56
47
|
*/
|
|
57
48
|
function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
|
|
58
|
-
var _a;
|
|
59
49
|
let ignore = [];
|
|
60
50
|
// isV2FETypesAvailable - Boolean to indicate if V2 Fiori Element types were available in the UI5 version
|
|
61
|
-
const isV2FETypesAvailable =
|
|
51
|
+
const isV2FETypesAvailable = feApp.ui5?.version ? semver_1.default.gte(coercedUI5Version, exports.V2_FE_TYPES_AVAILABLE) : false;
|
|
62
52
|
const tsIgnoreGlob = ['**/*.js'];
|
|
63
53
|
ignore = tsIgnoreGlob;
|
|
64
54
|
// Add local ui5.d.ts if types are missing in UI5 version for V2 Odata services
|
|
@@ -84,87 +74,89 @@ function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
|
|
|
84
74
|
* @param fs - an optional reference to a mem-fs editor
|
|
85
75
|
* @returns Reference to a mem-fs-editor
|
|
86
76
|
*/
|
|
87
|
-
function generate(basePath, data, fs) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
77
|
+
async function generate(basePath, data, fs) {
|
|
78
|
+
// Load i18n translations asynchronously to ensure proper initialization.
|
|
79
|
+
// This addresses occasional issues where i18n is not initialized in time, causing tests to fail.
|
|
80
|
+
await (0, i18n_1.initI18n)();
|
|
81
|
+
// Clone rather than modifying callers refs
|
|
82
|
+
const feApp = (0, cloneDeep_1.default)(data);
|
|
83
|
+
// Ensure input data contains at least the mandatory properties required for app generation
|
|
84
|
+
(0, validate_1.validateRequiredProperties)(feApp);
|
|
85
|
+
(0, defaults_1.setAppDefaults)(feApp);
|
|
86
|
+
fs = await (0, ui5_application_writer_1.generate)(basePath, feApp, fs);
|
|
87
|
+
feApp.template.settings = (0, defaults_1.setDefaultTemplateSettings)(feApp.template, feApp.service.version);
|
|
88
|
+
// This is done after `generateUi5Project` since defaults are set if values are not provided
|
|
89
|
+
(0, validate_1.validateApp)(feApp);
|
|
90
|
+
await (0, odata_service_writer_1.generate)(basePath, feApp.service, fs);
|
|
91
|
+
const coercedUI5Version = semver_1.default.coerce(feApp.ui5?.version);
|
|
92
|
+
const templateOptions = {
|
|
93
|
+
changesPreview: feApp.ui5?.version ? semver_1.default.lt(coercedUI5Version, templateAttributes_2.changesPreviewToVersion) : false,
|
|
94
|
+
changesLoader: feApp.service.version === odata_service_writer_1.OdataVersion.v2
|
|
95
|
+
};
|
|
96
|
+
// Add new files from templates e.g.
|
|
97
|
+
const rootTemplatesPath = (0, path_1.join)(__dirname, '..', 'templates');
|
|
98
|
+
// Add templates common to all template types
|
|
99
|
+
const jsIgnoreGlob = ['**/*.ts'];
|
|
100
|
+
let ignore = jsIgnoreGlob;
|
|
101
|
+
if (feApp.appOptions?.typescript === true) {
|
|
102
|
+
ignore = getTypeScriptIgnoreGlob(feApp, coercedUI5Version);
|
|
103
|
+
}
|
|
104
|
+
fs.copyTpl((0, path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
|
|
105
|
+
...feApp,
|
|
106
|
+
templateOptions,
|
|
107
|
+
escapeFLPText: templateAttributes_2.escapeFLPText
|
|
108
|
+
}, undefined, {
|
|
109
|
+
globOptions: { ignore, dot: true }
|
|
110
|
+
});
|
|
111
|
+
// Extend common files
|
|
112
|
+
const packagePath = (0, path_1.join)(basePath, 'package.json');
|
|
113
|
+
// Extend package.json
|
|
114
|
+
fs.extendJSON(packagePath, JSON.parse((0, ejs_1.render)(fs.read((0, path_1.join)(rootTemplatesPath, 'common', 'extend', 'package.json')), feApp, {})));
|
|
115
|
+
// Special handling for FPM because it is not based on template files but used the fpm writer
|
|
116
|
+
if (feApp.template.type === types_1.TemplateType.FlexibleProgrammingModel) {
|
|
117
|
+
const config = feApp.template.settings;
|
|
118
|
+
(0, fe_fpm_writer_1.generateCustomPage)(basePath, {
|
|
119
|
+
entity: config.entityConfig.mainEntityName,
|
|
120
|
+
name: config.pageName,
|
|
121
|
+
minUI5Version: feApp.ui5?.minUI5Version,
|
|
122
|
+
typescript: feApp.appOptions?.typescript
|
|
123
|
+
}, fs);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Copy odata version specific common templates and version specific, floorplan specific templates
|
|
127
|
+
const templateVersionPath = (0, path_1.join)(rootTemplatesPath, `v${feApp.service?.version}`);
|
|
128
|
+
[(0, path_1.join)(templateVersionPath, 'common', 'add'), (0, path_1.join)(templateVersionPath, feApp.template.type, 'add')].forEach((templatePath) => {
|
|
129
|
+
fs.copyTpl((0, path_1.join)(templatePath, '**/*.*'), basePath, feApp, {}, { ignoreNoMatch: true, globOptions: { ignore, dot: true } });
|
|
119
130
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, fs);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
// Copy odata version specific common templates and version specific, floorplan specific templates
|
|
136
|
-
const templateVersionPath = (0, path_1.join)(rootTemplatesPath, `v${(_f = feApp.service) === null || _f === void 0 ? void 0 : _f.version}`);
|
|
137
|
-
[(0, path_1.join)(templateVersionPath, 'common', 'add'), (0, path_1.join)(templateVersionPath, feApp.template.type, 'add')].forEach((templatePath) => {
|
|
138
|
-
fs.copyTpl((0, path_1.join)(templatePath, '**/*.*'), basePath, feApp, {}, { ignoreNoMatch: true, globOptions: { ignore, dot: true } });
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
// Update manifest.json with template specific settings
|
|
142
|
-
(0, manifestSettings_1.extendManifestJson)(fs, basePath, rootTemplatesPath, feApp);
|
|
143
|
-
const packageJson = JSON.parse(fs.read(packagePath));
|
|
144
|
-
// Add tests only if v4, for now, and we have metadata (and therefore a mock server config) or has a cds service
|
|
145
|
-
const addTest = !!feApp.appOptions.addTests &&
|
|
146
|
-
((_g = feApp.service) === null || _g === void 0 ? void 0 : _g.version) === odata_service_writer_1.OdataVersion.v4 &&
|
|
147
|
-
(!!((_h = feApp.service) === null || _h === void 0 ? void 0 : _h.metadata) || feApp.service.type === odata_service_writer_1.ServiceType.CDS);
|
|
148
|
-
packageJson.scripts = Object.assign((_j = packageJson.scripts) !== null && _j !== void 0 ? _j : {}, Object.assign({}, (0, packageConfig_1.getPackageJsonTasks)({
|
|
149
|
-
localOnly: !((_k = feApp.service) === null || _k === void 0 ? void 0 : _k.url),
|
|
150
|
-
addMock: !!((_l = feApp.service) === null || _l === void 0 ? void 0 : _l.metadata),
|
|
131
|
+
}
|
|
132
|
+
// Update manifest.json with template specific settings
|
|
133
|
+
(0, manifestSettings_1.extendManifestJson)(fs, basePath, rootTemplatesPath, feApp);
|
|
134
|
+
const packageJson = JSON.parse(fs.read(packagePath));
|
|
135
|
+
// Add tests only if v4, for now, and we have metadata (and therefore a mock server config) or has a cds service
|
|
136
|
+
const addTest = !!feApp.appOptions.addTests &&
|
|
137
|
+
feApp.service?.version === odata_service_writer_1.OdataVersion.v4 &&
|
|
138
|
+
(!!feApp.service?.metadata || feApp.service.type === odata_service_writer_1.ServiceType.CDS);
|
|
139
|
+
packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
|
|
140
|
+
...(0, packageConfig_1.getPackageJsonTasks)({
|
|
141
|
+
localOnly: !feApp.service?.url,
|
|
142
|
+
addMock: !!feApp.service?.metadata,
|
|
151
143
|
addTest,
|
|
152
|
-
sapClient:
|
|
144
|
+
sapClient: feApp.service?.client,
|
|
153
145
|
flpAppId: feApp.app.flpAppId,
|
|
154
|
-
startFile:
|
|
155
|
-
localStartFile:
|
|
156
|
-
generateIndex:
|
|
157
|
-
})
|
|
158
|
-
fs.writeJSON(packagePath, packageJson);
|
|
159
|
-
if (addTest) {
|
|
160
|
-
(0, ui5_test_writer_1.generateOPAFiles)(basePath, {
|
|
161
|
-
htmlTarget: ((_r = feApp.appOptions) === null || _r === void 0 ? void 0 : _r.generateIndex)
|
|
162
|
-
? 'index.html'
|
|
163
|
-
: `test/flpSandbox.html?sap-ui-xx-viewCache=false#${feApp.app.flpAppId}`
|
|
164
|
-
}, fs);
|
|
165
|
-
}
|
|
166
|
-
return fs;
|
|
146
|
+
startFile: data?.app?.startFile,
|
|
147
|
+
localStartFile: data?.app?.localStartFile,
|
|
148
|
+
generateIndex: feApp.appOptions?.generateIndex
|
|
149
|
+
})
|
|
167
150
|
});
|
|
151
|
+
fs.writeJSON(packagePath, packageJson);
|
|
152
|
+
if (addTest) {
|
|
153
|
+
(0, ui5_test_writer_1.generateOPAFiles)(basePath, {
|
|
154
|
+
htmlTarget: feApp.appOptions?.generateIndex
|
|
155
|
+
? 'index.html'
|
|
156
|
+
: `test/flpSandbox.html?sap-ui-xx-viewCache=false#${feApp.app.flpAppId}`
|
|
157
|
+
}, fs);
|
|
158
|
+
}
|
|
159
|
+
return fs;
|
|
168
160
|
}
|
|
169
161
|
exports.generate = generate;
|
|
170
162
|
__exportStar(require("./types"), exports);
|
package/dist/validate.js
CHANGED
|
@@ -14,7 +14,6 @@ const types_1 = require("./types");
|
|
|
14
14
|
* @param feApp - Fiori elements application configuration
|
|
15
15
|
*/
|
|
16
16
|
function validateApp(feApp) {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
17
|
// Validate odata version
|
|
19
18
|
if (feApp.service.version &&
|
|
20
19
|
!templateAttributes_1.TemplateTypeAttributes[feApp.template.type].supportedODataVersions.includes(feApp.service.version)) {
|
|
@@ -25,18 +24,18 @@ function validateApp(feApp) {
|
|
|
25
24
|
}
|
|
26
25
|
// Validate ui5 versions if present (defaults will apply otherwise)
|
|
27
26
|
let ui5Version = null;
|
|
28
|
-
if (
|
|
29
|
-
ui5Version = semver_1.default.coerce(
|
|
27
|
+
if (feApp.ui5?.version) {
|
|
28
|
+
ui5Version = semver_1.default.coerce(feApp.ui5?.version);
|
|
30
29
|
if (!ui5Version) {
|
|
31
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'version', ui5Version:
|
|
30
|
+
throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'version', ui5Version: feApp.ui5?.version }));
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
let minUI5Version;
|
|
35
34
|
const minRequiredUI5Version = templateAttributes_1.TemplateTypeAttributes[feApp.template.type].minimumUi5Version[feApp.service.version];
|
|
36
|
-
if (
|
|
37
|
-
minUI5Version = semver_1.default.coerce(
|
|
35
|
+
if (feApp.ui5?.minUI5Version) {
|
|
36
|
+
minUI5Version = semver_1.default.coerce(feApp.ui5?.minUI5Version);
|
|
38
37
|
if (!minUI5Version) {
|
|
39
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'minUI5Version', ui5Version:
|
|
38
|
+
throw new types_1.ValidationError((0, i18n_1.t)('error.invalidUI5Version', { versionProperty: 'minUI5Version', ui5Version: feApp.ui5?.minUI5Version }));
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
else {
|
|
@@ -45,7 +44,7 @@ function validateApp(feApp) {
|
|
|
45
44
|
if (ui5Version && semver_1.default.lt(ui5Version, minRequiredUI5Version)) {
|
|
46
45
|
throw new types_1.ValidationError((0, i18n_1.t)('error.unsupportedUI5Version', {
|
|
47
46
|
versionProperty: 'version',
|
|
48
|
-
ui5Version:
|
|
47
|
+
ui5Version: feApp.ui5?.version,
|
|
49
48
|
templateType: feApp.template.type,
|
|
50
49
|
minRequiredUI5Version
|
|
51
50
|
}));
|
|
@@ -53,7 +52,7 @@ function validateApp(feApp) {
|
|
|
53
52
|
if (semver_1.default.lt(minUI5Version, minRequiredUI5Version)) {
|
|
54
53
|
throw new types_1.ValidationError((0, i18n_1.t)('error.unsupportedUI5Version', {
|
|
55
54
|
versionProperty: 'minUI5Version',
|
|
56
|
-
ui5Version:
|
|
55
|
+
ui5Version: feApp.ui5?.minUI5Version,
|
|
57
56
|
templateType: feApp.template.type,
|
|
58
57
|
minRequiredUI5Version
|
|
59
58
|
}));
|
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": "0.
|
|
4
|
+
"version": "0.23.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"read-pkg-up": "7.0.1",
|
|
29
29
|
"semver": "7.5.4",
|
|
30
|
-
"@sap-ux/
|
|
31
|
-
"@sap-ux/
|
|
32
|
-
"@sap-ux/
|
|
33
|
-
"@sap-ux/
|
|
34
|
-
"@sap-ux/ui5-test-writer": "0.
|
|
30
|
+
"@sap-ux/odata-service-writer": "0.21.0",
|
|
31
|
+
"@sap-ux/ui5-application-writer": "0.27.1",
|
|
32
|
+
"@sap-ux/fe-fpm-writer": "0.25.0",
|
|
33
|
+
"@sap-ux/ui5-config": "0.23.0",
|
|
34
|
+
"@sap-ux/ui5-test-writer": "0.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/ejs": "3.1.2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/mem-fs": "1.1.2",
|
|
42
42
|
"@types/semver": "7.5.2",
|
|
43
43
|
"fs-extra": "10.0.0",
|
|
44
|
-
"@sap-ux/eslint-plugin-fiori-tools": "0.
|
|
44
|
+
"@sap-ux/eslint-plugin-fiori-tools": "0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=18.x"
|