@sap-ux/preview-middleware 1.0.19 → 1.0.21
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/README.md +1 -1
- package/dist/base/flp.d.ts +10 -0
- package/dist/base/flp.js +30 -5
- package/dist/base/test.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ Array of additional application configurations:
|
|
|
71
71
|
| `framework` | `string` | mandatory | `undefined` | Currently `OPA5`, `QUnit` (only QUnit 2.3.2 provided as third-party module using [OpenUI5](https://github.com/SAP/openui5/blob/master/THIRDPARTY.txt)/SAPUI5) and `Testsuite` are supported. `Testsuite` will generate a testsuite for all configured frameworks that can be be used with a test runner (such as karma) |
|
|
72
72
|
| `path` | `string` | optional | `(calculated)` | The mount point to be used for test suite. By default, `/test/opaTests.qunit.html` is used for `OPA5`, `/test/unitTests.qunit.html` is used for `QUnit`, and `/test/testsuite.qunit.html` is used for `Testsuite` |
|
|
73
73
|
| `init` | `string` | optional | `undefined` | The mount point to be used for custom test runner script |
|
|
74
|
-
| `pattern` | `string` | optional | `(calculated)` | Optional glob pattern to find the tests. By default, `/test/**/*Journey.{js,ts}` is used for `OPA5` and `/test/**/*Test.{js,ts}` is used for `QUnit` (not applicable for `Testsuite`) |
|
|
74
|
+
| `pattern` | `string` | optional | `(calculated)` | Optional glob pattern to find the tests. By default, `/test/**/*Journey{,.gen}.{js,ts}` is used for `OPA5` and `/test/**/*Test.{js,ts}` is used for `QUnit` (not applicable for `Testsuite`) |
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
## [Usage](#usage)
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -149,6 +149,16 @@ export declare class FlpSandbox {
|
|
|
149
149
|
* @private
|
|
150
150
|
*/
|
|
151
151
|
private addCardGeneratorMiddlewareRoute;
|
|
152
|
+
/**
|
|
153
|
+
* Extracts protocol and baseUrl from a request and calls getUi5Version.
|
|
154
|
+
* Handles both express Request and connect IncomingMessage (karma test runner).
|
|
155
|
+
*
|
|
156
|
+
* @param req - the incoming request
|
|
157
|
+
* @param baseUrl - the base path to include when fetching the UI5 version
|
|
158
|
+
* @returns the parsed UI5 version
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
private getUi5VersionFromRequest;
|
|
152
162
|
/**
|
|
153
163
|
* Read the UI5 version.
|
|
154
164
|
* In case of an error, the default UI5 version '1.121.0' is returned.
|
package/dist/base/flp.js
CHANGED
|
@@ -350,11 +350,7 @@ export class FlpSandbox {
|
|
|
350
350
|
else {
|
|
351
351
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
352
352
|
this.templateConfig.baseUrl = ('ui5-patched-router' in req && req['ui5-patched-router']?.baseUrl) || '';
|
|
353
|
-
const ui5Version = await this.
|
|
354
|
-
//use protocol from request header referer as fallback for connect API (karma test runner)
|
|
355
|
-
'protocol' in req
|
|
356
|
-
? req.protocol
|
|
357
|
-
: (req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http'), req.headers.host, this.templateConfig.baseUrl);
|
|
353
|
+
const ui5Version = await this.getUi5VersionFromRequest(req, this.templateConfig.baseUrl);
|
|
358
354
|
this.checkDeleteConnectors(ui5Version.major, ui5Version.minor, ui5Version.isCdn);
|
|
359
355
|
if (ui5Version.major === 1 && ui5Version.minor < 120) {
|
|
360
356
|
this.removeFlexExtensionPointEnabled();
|
|
@@ -388,9 +384,37 @@ export class FlpSandbox {
|
|
|
388
384
|
this.logger.debug(`Add route for ${previewGeneratorPath}`);
|
|
389
385
|
this.router.get(previewGeneratorPath, async (req, res, next) => {
|
|
390
386
|
this.templateConfig.enableCardGenerator = !!this.cardGenerator?.path;
|
|
387
|
+
if (this.templateConfig.enableCardGenerator) {
|
|
388
|
+
// check for min ui5 version of card generator feature
|
|
389
|
+
const baseUrl = 'ui5-patched-router' in req ? (req['ui5-patched-router']?.baseUrl ?? '') : '';
|
|
390
|
+
const ui5Version = await this.getUi5VersionFromRequest(req, baseUrl);
|
|
391
|
+
const minMinor = this.projectType === 'CAPNodejs' || this.projectType === 'CAPJava' ? 149 : 121;
|
|
392
|
+
if ((ui5Version.major === 1 && ui5Version.minor < minMinor) ||
|
|
393
|
+
ui5Version.major >= 2 ||
|
|
394
|
+
ui5Version.label?.includes('legacy-free')) {
|
|
395
|
+
this.templateConfig.enableCardGenerator = false;
|
|
396
|
+
this.logger.warn(`Feature cardGenerator disabled: UI5 version ${ui5Version.major}.${ui5Version.minor}.${ui5Version.patch} does not meet the minimum required version 1.${minMinor}.0 for project type '${this.projectType}'.`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
391
399
|
await this.flpGetHandler(req, res, next);
|
|
392
400
|
});
|
|
393
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Extracts protocol and baseUrl from a request and calls getUi5Version.
|
|
404
|
+
* Handles both express Request and connect IncomingMessage (karma test runner).
|
|
405
|
+
*
|
|
406
|
+
* @param req - the incoming request
|
|
407
|
+
* @param baseUrl - the base path to include when fetching the UI5 version
|
|
408
|
+
* @returns the parsed UI5 version
|
|
409
|
+
* @private
|
|
410
|
+
*/
|
|
411
|
+
async getUi5VersionFromRequest(req, baseUrl = '') {
|
|
412
|
+
// use protocol from request header referer as fallback for connect API (karma test runner)
|
|
413
|
+
const protocol = 'protocol' in req
|
|
414
|
+
? req.protocol
|
|
415
|
+
: (req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http');
|
|
416
|
+
return this.getUi5Version(protocol, req.headers.host, baseUrl);
|
|
417
|
+
}
|
|
394
418
|
/**
|
|
395
419
|
* Read the UI5 version.
|
|
396
420
|
* In case of an error, the default UI5 version '1.121.0' is returned.
|
|
@@ -425,6 +449,7 @@ export class FlpSandbox {
|
|
|
425
449
|
}
|
|
426
450
|
const [major, minor, patch] = version.split('.').map((versionPart) => Number.parseInt(versionPart, 10));
|
|
427
451
|
const label = version.split(/-(.*)/s)?.[1];
|
|
452
|
+
// check for min ui5 version of flp.enhancedHomePage feature
|
|
428
453
|
if (this.flpConfig.enhancedHomePage &&
|
|
429
454
|
((major < 2 && minor < 123) || major >= 2 || label?.includes('legacy-free'))) {
|
|
430
455
|
this.flpConfig.enhancedHomePage = this.templateConfig.enhancedHomePage = false;
|
package/dist/base/test.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export type TestConfigDefaults = {
|
|
|
98
98
|
opa5: {
|
|
99
99
|
path: '/test/opaTests.qunit.html';
|
|
100
100
|
init: '/test/opaTests.qunit.js';
|
|
101
|
-
pattern: '/test/**/*Journey.{js,ts}';
|
|
101
|
+
pattern: '/test/**/*Journey{,.gen}.{js,ts}';
|
|
102
102
|
framework: 'OPA5';
|
|
103
103
|
};
|
|
104
104
|
testsuite: {
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
12
12
|
},
|
|
13
|
-
"version": "1.0.
|
|
13
|
+
"version": "1.0.21",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": "@SAP/ux-tools-team",
|
|
16
16
|
"main": "dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"nock": "14.0.11",
|
|
55
55
|
"npm-run-all2": "8.0.4",
|
|
56
56
|
"supertest": "7.2.2",
|
|
57
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.
|
|
57
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.21",
|
|
58
58
|
"@sap-ux-private/playwright": "1.0.2",
|
|
59
59
|
"@sap-ux/axios-extension": "2.0.3",
|
|
60
60
|
"@sap-ux/store": "2.0.1",
|