@sap-ux/preview-middleware 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/flp.d.ts +10 -1
- package/dist/base/flp.js +76 -38
- package/package.json +5 -4
package/dist/base/flp.d.ts
CHANGED
|
@@ -134,7 +134,16 @@ export declare class FlpSandbox {
|
|
|
134
134
|
* @param manifest manifest of the additional target app
|
|
135
135
|
* @param app configuration for the preview
|
|
136
136
|
*/
|
|
137
|
-
addApp(manifest: Manifest, app: App): void
|
|
137
|
+
addApp(manifest: Manifest, app: App): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Get the i18n text of the given property.
|
|
140
|
+
*
|
|
141
|
+
* @param projectRoot absolute path to the project root
|
|
142
|
+
* @param propertyValue value of the property
|
|
143
|
+
* @returns i18n text of the property
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private getI18nTextFromProperty;
|
|
138
147
|
/**
|
|
139
148
|
* Gets the UI5 libs dependencies from manifest.json.
|
|
140
149
|
*
|
package/dist/base/flp.js
CHANGED
|
@@ -15,6 +15,7 @@ const fs_1 = require("fs");
|
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const express_1 = require("express");
|
|
17
17
|
const flex_1 = require("./flex");
|
|
18
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
18
19
|
const adp_tooling_1 = require("@sap-ux/adp-tooling");
|
|
19
20
|
const test_1 = require("./test");
|
|
20
21
|
const DEVELOPER_MODE_CONFIG = new Map([
|
|
@@ -143,7 +144,7 @@ class FlpSandbox {
|
|
|
143
144
|
},
|
|
144
145
|
locateReuseLibsScript: (_e = this.config.libs) !== null && _e !== void 0 ? _e : (yield this.hasLocateReuseLibsScript())
|
|
145
146
|
};
|
|
146
|
-
this.addApp(manifest, {
|
|
147
|
+
yield this.addApp(manifest, {
|
|
147
148
|
componentId,
|
|
148
149
|
target: (_f = resources[componentId !== null && componentId !== void 0 ? componentId : id]) !== null && _f !== void 0 ? _f : this.templateConfig.basePath,
|
|
149
150
|
local: '.',
|
|
@@ -159,7 +160,7 @@ class FlpSandbox {
|
|
|
159
160
|
if (this.test) {
|
|
160
161
|
this.addTestRoutes(this.test, id);
|
|
161
162
|
}
|
|
162
|
-
this.addRoutesForAdditionalApps();
|
|
163
|
+
yield this.addRoutesForAdditionalApps();
|
|
163
164
|
this.logger.info(`Initialized for app ${id}`);
|
|
164
165
|
this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
|
|
165
166
|
});
|
|
@@ -269,29 +270,31 @@ class FlpSandbox {
|
|
|
269
270
|
*/
|
|
270
271
|
addRoutesForAdditionalApps() {
|
|
271
272
|
var _a, _b;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
273
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
+
for (const app of this.config.apps) {
|
|
275
|
+
let manifest;
|
|
276
|
+
if (app.local) {
|
|
277
|
+
manifest = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(app.local, 'webapp/manifest.json'), 'utf-8'));
|
|
278
|
+
this.router.use(app.target, (0, express_1.static)((0, path_1.join)(app.local, 'webapp')));
|
|
279
|
+
this.logger.info(`Serving additional application at ${app.target} from ${app.local}`);
|
|
280
|
+
}
|
|
281
|
+
else if (app.componentId) {
|
|
282
|
+
manifest = {
|
|
283
|
+
'sap.app': {
|
|
284
|
+
id: app.componentId,
|
|
285
|
+
title: app.intent ? `${app.intent.object}-${app.intent.action}` : app.componentId
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (manifest) {
|
|
290
|
+
yield this.addApp(manifest, app);
|
|
291
|
+
this.logger.info(`Adding additional intent: ${(_a = app.intent) === null || _a === void 0 ? void 0 : _a.object}-${(_b = app.intent) === null || _b === void 0 ? void 0 : _b.action}`);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
this.logger.info(`Invalid application config for route ${app.target} because neither componentId nor local folder provided.`);
|
|
295
|
+
}
|
|
293
296
|
}
|
|
294
|
-
}
|
|
297
|
+
});
|
|
295
298
|
}
|
|
296
299
|
/**
|
|
297
300
|
* Retrieves the configuration settings for UI5 flexibility services.
|
|
@@ -416,21 +419,56 @@ class FlpSandbox {
|
|
|
416
419
|
* @param app configuration for the preview
|
|
417
420
|
*/
|
|
418
421
|
addApp(manifest, app) {
|
|
419
|
-
var _a, _b, _c, _d, _e, _f;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
423
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
const id = manifest['sap.app'].id;
|
|
425
|
+
(_a = app.intent) !== null && _a !== void 0 ? _a : (app.intent = {
|
|
426
|
+
object: id.replace(/\./g, ''),
|
|
427
|
+
action: 'preview'
|
|
428
|
+
});
|
|
429
|
+
let title = (_b = manifest['sap.app'].title) !== null && _b !== void 0 ? _b : id;
|
|
430
|
+
let description = (_c = manifest['sap.app'].description) !== null && _c !== void 0 ? _c : '';
|
|
431
|
+
if (app.local) {
|
|
432
|
+
title = (_d = (yield this.getI18nTextFromProperty(app.local, manifest['sap.app'].title))) !== null && _d !== void 0 ? _d : id;
|
|
433
|
+
description = (_e = (yield this.getI18nTextFromProperty(app.local, manifest['sap.app'].description))) !== null && _e !== void 0 ? _e : '';
|
|
434
|
+
}
|
|
435
|
+
this.templateConfig.ui5.resources[id] = app.target;
|
|
436
|
+
this.templateConfig.apps[`${(_f = app.intent) === null || _f === void 0 ? void 0 : _f.object}-${(_g = app.intent) === null || _g === void 0 ? void 0 : _g.action}`] = {
|
|
437
|
+
title: title,
|
|
438
|
+
description: description,
|
|
439
|
+
additionalInformation: `SAPUI5.Component=${(_h = app.componentId) !== null && _h !== void 0 ? _h : id}`,
|
|
440
|
+
applicationType: 'URL',
|
|
441
|
+
url: app.target,
|
|
442
|
+
applicationDependencies: { manifest: true }
|
|
443
|
+
};
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Get the i18n text of the given property.
|
|
448
|
+
*
|
|
449
|
+
* @param projectRoot absolute path to the project root
|
|
450
|
+
* @param propertyValue value of the property
|
|
451
|
+
* @returns i18n text of the property
|
|
452
|
+
* @private
|
|
453
|
+
*/
|
|
454
|
+
getI18nTextFromProperty(projectRoot, propertyValue) {
|
|
455
|
+
var _a, _b, _c, _d;
|
|
456
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
457
|
+
//i18n model format could be {{key}} or {i18n>key}
|
|
458
|
+
if (!propertyValue || propertyValue.search(/{{\w+}}|{i18n>\w+}/g) === -1) {
|
|
459
|
+
return propertyValue;
|
|
460
|
+
}
|
|
461
|
+
const propertyI18nKey = propertyValue.replace(/i18n>|[{}]/g, '');
|
|
462
|
+
const projectAccess = yield (0, project_access_1.createProjectAccess)(projectRoot);
|
|
463
|
+
try {
|
|
464
|
+
const bundle = (yield projectAccess.getApplication('').getI18nBundles())['sap.app'];
|
|
465
|
+
return (_d = (_c = (_b = (_a = bundle[propertyI18nKey]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : propertyI18nKey;
|
|
466
|
+
}
|
|
467
|
+
catch (e) {
|
|
468
|
+
this.logger.warn('Failed to load i18n properties bundle');
|
|
469
|
+
}
|
|
470
|
+
return propertyI18nKey;
|
|
424
471
|
});
|
|
425
|
-
this.templateConfig.ui5.resources[id] = app.target;
|
|
426
|
-
this.templateConfig.apps[`${(_b = app.intent) === null || _b === void 0 ? void 0 : _b.object}-${(_c = app.intent) === null || _c === void 0 ? void 0 : _c.action}`] = {
|
|
427
|
-
title: (_d = manifest['sap.app'].title) !== null && _d !== void 0 ? _d : id,
|
|
428
|
-
description: (_e = manifest['sap.app'].description) !== null && _e !== void 0 ? _e : '',
|
|
429
|
-
additionalInformation: `SAPUI5.Component=${(_f = app.componentId) !== null && _f !== void 0 ? _f : id}`,
|
|
430
|
-
applicationType: 'URL',
|
|
431
|
-
url: app.target,
|
|
432
|
-
applicationDependencies: { manifest: true }
|
|
433
|
-
};
|
|
434
472
|
}
|
|
435
473
|
/**
|
|
436
474
|
* Gets the UI5 libs dependencies from manifest.json.
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.13.
|
|
12
|
+
"version": "0.13.2",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"ejs": "3.1.9",
|
|
26
26
|
"@sap-ux/logger": "0.5.1",
|
|
27
27
|
"@sap-ux/adp-tooling": "0.9.6",
|
|
28
|
-
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.16"
|
|
28
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.16",
|
|
29
|
+
"@sap-ux/project-access": "1.19.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/ejs": "3.1.2",
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"@sap-ux-private/playwright": "0.0.3",
|
|
41
42
|
"dotenv": "16.3.1",
|
|
42
43
|
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.3",
|
|
43
|
-
"@sap-ux/
|
|
44
|
+
"@sap-ux/axios-extension": "1.11.4",
|
|
44
45
|
"@sap-ux/store": "0.5.0",
|
|
45
|
-
"@sap-ux/
|
|
46
|
+
"@sap-ux/i18n": "0.0.5"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"express": "4"
|