@sap-ux/fe-fpm-writer 0.28.2 → 0.29.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/building-block/index.js +35 -14
- package/package.json +4 -4
|
@@ -38,11 +38,24 @@ const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
|
38
38
|
const validate_1 = require("../common/validate");
|
|
39
39
|
const templates_1 = require("../templates");
|
|
40
40
|
const types_2 = require("../prompts/types");
|
|
41
|
+
const semver_1 = require("semver");
|
|
42
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
41
43
|
const PLACEHOLDERS = {
|
|
42
44
|
'id': 'REPLACE_WITH_BUILDING_BLOCK_ID',
|
|
43
45
|
'entitySet': 'REPLACE_WITH_ENTITY',
|
|
44
46
|
'qualifier': 'REPLACE_WITH_A_QUALIFIER'
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Gets manifest content.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} basePath the base path
|
|
52
|
+
* @param {Editor} fs the memfs editor instance
|
|
53
|
+
* @returns {Manifest | undefined} the manifest content
|
|
54
|
+
*/
|
|
55
|
+
function getManifest(basePath, fs) {
|
|
56
|
+
const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
|
|
57
|
+
return fs.readJSON(manifestPath);
|
|
58
|
+
}
|
|
46
59
|
/**
|
|
47
60
|
* Generates a building block into the provided xml view file.
|
|
48
61
|
*
|
|
@@ -62,7 +75,8 @@ function generateBuildingBlock(basePath, config, fs) {
|
|
|
62
75
|
}
|
|
63
76
|
// Read the view xml and template files and update contents of the view xml file
|
|
64
77
|
const xmlDocument = getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs);
|
|
65
|
-
const
|
|
78
|
+
const manifest = getManifest(basePath, fs);
|
|
79
|
+
const templateDocument = getTemplateDocument(config.buildingBlockData, xmlDocument, fs, manifest);
|
|
66
80
|
fs = updateViewFile(basePath, config.viewOrFragmentPath, config.aggregationPath, xmlDocument, templateDocument, fs);
|
|
67
81
|
return fs;
|
|
68
82
|
}
|
|
@@ -114,12 +128,12 @@ function getOrAddMacrosNamespace(ui5XmlDocument) {
|
|
|
114
128
|
/**
|
|
115
129
|
* Method returns default values for metadata path.
|
|
116
130
|
*
|
|
117
|
-
* @param {
|
|
131
|
+
* @param {boolean} applyContextPath - whether to apply contextPath.
|
|
118
132
|
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
119
133
|
* @returns {MetadataPath} Default values for metadata path.
|
|
120
134
|
*/
|
|
121
|
-
function getDefaultMetaPath(
|
|
122
|
-
if (
|
|
135
|
+
function getDefaultMetaPath(applyContextPath, usePlaceholders) {
|
|
136
|
+
if (applyContextPath) {
|
|
123
137
|
return {
|
|
124
138
|
metaPath: usePlaceholders ? `/${PLACEHOLDERS.qualifier}` : '',
|
|
125
139
|
contextPath: usePlaceholders ? PLACEHOLDERS.entitySet : ''
|
|
@@ -132,21 +146,20 @@ function getDefaultMetaPath(type, usePlaceholders) {
|
|
|
132
146
|
/**
|
|
133
147
|
* Method converts object based metaPath to metadata path.
|
|
134
148
|
*
|
|
135
|
-
* @param {
|
|
149
|
+
* @param {boolean} applyContextPath - whether to apply contextPath.
|
|
136
150
|
* @param {BuildingBlockMetaPath} metaPath - object based metaPath.
|
|
137
151
|
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
138
152
|
* @returns {MetadataPath} Resolved metadata path information.
|
|
139
153
|
*/
|
|
140
|
-
function getMetaPath(
|
|
154
|
+
function getMetaPath(applyContextPath, metaPath, usePlaceholders) {
|
|
141
155
|
if (!metaPath) {
|
|
142
|
-
return getDefaultMetaPath(
|
|
156
|
+
return getDefaultMetaPath(applyContextPath, usePlaceholders);
|
|
143
157
|
}
|
|
144
158
|
const { bindingContextType = 'absolute' } = metaPath;
|
|
145
159
|
let { entitySet, qualifier } = metaPath;
|
|
146
160
|
entitySet = entitySet || (usePlaceholders ? PLACEHOLDERS.entitySet : '');
|
|
147
161
|
const qualifierOrPlaceholder = qualifier || (usePlaceholders ? PLACEHOLDERS.qualifier : '');
|
|
148
|
-
if (
|
|
149
|
-
// Special handling for chart - while runtime does not support approach without contextPath
|
|
162
|
+
if (applyContextPath) {
|
|
150
163
|
const qualifierParts = qualifierOrPlaceholder.split('/');
|
|
151
164
|
qualifier = qualifierParts.pop();
|
|
152
165
|
return {
|
|
@@ -163,16 +176,22 @@ function getMetaPath(type, metaPath, usePlaceholders) {
|
|
|
163
176
|
*
|
|
164
177
|
* @param {BuildingBlock} buildingBlockData - the building block data
|
|
165
178
|
* @param {Document} viewDocument - the view xml file document
|
|
179
|
+
* @param {Manifest} manifest - the manifest content
|
|
166
180
|
* @param {Editor} fs - the memfs editor instance
|
|
167
181
|
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
168
182
|
* @returns {string} the template xml file content
|
|
169
183
|
*/
|
|
170
|
-
function getTemplateContent(buildingBlockData, viewDocument, fs, usePlaceholders) {
|
|
184
|
+
function getTemplateContent(buildingBlockData, viewDocument, manifest, fs, usePlaceholders) {
|
|
171
185
|
const templateFolderName = buildingBlockData.buildingBlockType;
|
|
172
186
|
const templateFilePath = (0, templates_1.getTemplatePath)(`/building-block/${templateFolderName}/View.xml`);
|
|
173
187
|
if (typeof buildingBlockData.metaPath === 'object' || buildingBlockData.metaPath === undefined) {
|
|
188
|
+
// Special handling for chart - while runtime does not support approach without contextPath
|
|
189
|
+
// or for equal or below UI5 v1.96.0 contextPath is applied
|
|
190
|
+
const minUI5Version = manifest ? (0, semver_1.coerce)((0, project_access_1.getMinimumUI5Version)(manifest)) : undefined;
|
|
191
|
+
const applyContextPath = buildingBlockData.buildingBlockType === types_1.BuildingBlockType.Chart ||
|
|
192
|
+
!!(minUI5Version && (0, semver_1.lt)(minUI5Version, '1.97.0'));
|
|
174
193
|
// Convert object based metapath to string
|
|
175
|
-
const metadataPath = getMetaPath(
|
|
194
|
+
const metadataPath = getMetaPath(applyContextPath, buildingBlockData.metaPath, usePlaceholders);
|
|
176
195
|
buildingBlockData = { ...buildingBlockData, metaPath: metadataPath.metaPath };
|
|
177
196
|
if (!buildingBlockData.contextPath && metadataPath.contextPath) {
|
|
178
197
|
buildingBlockData.contextPath = metadataPath.contextPath;
|
|
@@ -193,10 +212,11 @@ function getTemplateContent(buildingBlockData, viewDocument, fs, usePlaceholders
|
|
|
193
212
|
* @param {BuildingBlock} buildingBlockData - the building block data
|
|
194
213
|
* @param {Document} viewDocument - the view xml file document
|
|
195
214
|
* @param {Editor} fs - the memfs editor instance
|
|
215
|
+
* @param {Manifest} manifest - the manifest content
|
|
196
216
|
* @returns {Document} the template xml file document
|
|
197
217
|
*/
|
|
198
|
-
function getTemplateDocument(buildingBlockData, viewDocument, fs) {
|
|
199
|
-
const templateContent = getTemplateContent(buildingBlockData, viewDocument, fs);
|
|
218
|
+
function getTemplateDocument(buildingBlockData, viewDocument, fs, manifest) {
|
|
219
|
+
const templateContent = getTemplateContent(buildingBlockData, viewDocument, manifest, fs);
|
|
200
220
|
const errorHandler = (level, message) => {
|
|
201
221
|
throw new Error(`Unable to parse template file with building block data. Details: [${level}] - ${message}`);
|
|
202
222
|
};
|
|
@@ -275,7 +295,8 @@ function getSerializedFileContent(basePath, config, fs) {
|
|
|
275
295
|
const xmlDocument = config.viewOrFragmentPath
|
|
276
296
|
? getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs)
|
|
277
297
|
: undefined;
|
|
278
|
-
const
|
|
298
|
+
const manifest = getManifest(basePath, fs);
|
|
299
|
+
const content = getTemplateContent(config.buildingBlockData, xmlDocument, manifest, fs, true);
|
|
279
300
|
const filePathProps = getFilePathProps(basePath, config.viewOrFragmentPath);
|
|
280
301
|
return {
|
|
281
302
|
viewOrFragmentPath: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/fe-fpm-writer",
|
|
3
3
|
"description": "SAP Fiori elements flexible programming model writer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"semver": "7.5.4",
|
|
32
32
|
"xml-formatter": "2.6.1",
|
|
33
33
|
"xpath": "0.0.33",
|
|
34
|
-
"@sap-ux/fiori-annotation-api": "0.1.
|
|
35
|
-
"@sap-ux/project-access": "1.27.
|
|
34
|
+
"@sap-ux/fiori-annotation-api": "0.1.40",
|
|
35
|
+
"@sap-ux/project-access": "1.27.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/inquirer": "8.2.6",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/mem-fs-editor": "7.0.1",
|
|
43
43
|
"@types/semver": "7.5.2",
|
|
44
44
|
"@types/vinyl": "2.0.7",
|
|
45
|
-
"@sap-ux/ui-prompting": "0.1.
|
|
45
|
+
"@sap-ux/ui-prompting": "0.1.8"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=18.x"
|