@sap-ux/preview-middleware 0.16.149 → 0.16.150
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/client/utils/version.js +32 -15
- package/dist/client/utils/version.ts +44 -19
- package/package.json +4 -4
|
@@ -12,13 +12,29 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Check if the given version info is valid.
|
|
16
|
+
* @param versionInfo to check
|
|
17
|
+
* @throws Error if the version info is invalid
|
|
18
|
+
*/
|
|
19
|
+
function checkVersionInfo(versionInfo) {
|
|
20
|
+
if (isNaN(versionInfo.major) || isNaN(versionInfo.minor) || isNaN(versionInfo.patch ?? 0)) {
|
|
21
|
+
throw new Error('Invalid version info');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve the UI5 version.
|
|
27
|
+
* If no library is given, the version from 'sap.ui.core' will be retrieved.
|
|
28
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
29
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
16
30
|
*
|
|
31
|
+
* @param library - (optional) specific library name to get the version from, e.g. 'sap.m'
|
|
17
32
|
* @returns Ui5VersionInfo
|
|
18
33
|
*/
|
|
19
34
|
async function getUi5Version() {
|
|
35
|
+
let library = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'sap.ui.core';
|
|
20
36
|
let version = (await VersionInfo.load({
|
|
21
|
-
library
|
|
37
|
+
library
|
|
22
38
|
}))?.version;
|
|
23
39
|
if (!version) {
|
|
24
40
|
Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
|
|
@@ -34,37 +50,38 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
|
|
|
34
50
|
|
|
35
51
|
/**
|
|
36
52
|
* Checks if the given version is lower than the required minimal version.
|
|
53
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
54
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
55
|
+
*
|
|
37
56
|
* @param ui5VersionInfo to check
|
|
38
57
|
* @param minUi5VersionInfo to check against (default is 1.71)
|
|
58
|
+
* @throws Error if the version info is invalid
|
|
39
59
|
*
|
|
40
60
|
* @returns boolean
|
|
41
61
|
*/
|
|
42
62
|
function isLowerThanMinimalUi5Version(ui5VersionInfo) {
|
|
43
63
|
let minUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
64
|
+
checkVersionInfo(ui5VersionInfo);
|
|
65
|
+
checkVersionInfo(minUi5VersionInfo);
|
|
66
|
+
return ui5VersionInfo.major < minUi5VersionInfo.major || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor || ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor === minUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) < (minUi5VersionInfo?.patch ?? 0);
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
/**
|
|
56
70
|
* Checks if the given version is equal to the specified version.
|
|
71
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
72
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
73
|
+
*
|
|
57
74
|
* @param ui5VersionInfo to check
|
|
58
75
|
* @param targetUi5VersionInfo to check against (default is 1.71)
|
|
76
|
+
* @throws Error if the version info is invalid
|
|
59
77
|
*
|
|
60
78
|
* @returns boolean
|
|
61
79
|
*/
|
|
62
80
|
function isVersionEqualOrHasNewerPatch(ui5VersionInfo) {
|
|
63
81
|
let targetUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return false;
|
|
82
|
+
checkVersionInfo(ui5VersionInfo);
|
|
83
|
+
checkVersionInfo(targetUi5VersionInfo);
|
|
84
|
+
return ui5VersionInfo.major === targetUi5VersionInfo.major && ui5VersionInfo.minor === targetUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0);
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
/**
|
|
@@ -23,12 +23,29 @@ const minVersionInfo = {
|
|
|
23
23
|
} as Readonly<Ui5VersionInfo>;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Check if the given version info is valid.
|
|
27
|
+
* @param versionInfo to check
|
|
28
|
+
* @throws Error if the version info is invalid
|
|
29
|
+
*/
|
|
30
|
+
function checkVersionInfo(versionInfo: Ui5VersionInfo): void {
|
|
31
|
+
if(isNaN(versionInfo.major) ||
|
|
32
|
+
isNaN(versionInfo.minor) ||
|
|
33
|
+
isNaN(versionInfo.patch ?? 0)) {
|
|
34
|
+
throw new Error('Invalid version info');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the UI5 version.
|
|
40
|
+
* If no library is given, the version from 'sap.ui.core' will be retrieved.
|
|
41
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
42
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
27
43
|
*
|
|
44
|
+
* @param library - (optional) specific library name to get the version from, e.g. 'sap.m'
|
|
28
45
|
* @returns Ui5VersionInfo
|
|
29
46
|
*/
|
|
30
|
-
export async function getUi5Version(): Promise<Ui5VersionInfo> {
|
|
31
|
-
let version = ((await VersionInfo.load({ library
|
|
47
|
+
export async function getUi5Version(library: string = 'sap.ui.core'): Promise<Ui5VersionInfo> {
|
|
48
|
+
let version = ((await VersionInfo.load({ library })) as SingleVersionInfo)?.version;
|
|
32
49
|
if (!version) {
|
|
33
50
|
Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
|
|
34
51
|
version = '1.121.0';
|
|
@@ -44,8 +61,12 @@ export async function getUi5Version(): Promise<Ui5VersionInfo> {
|
|
|
44
61
|
|
|
45
62
|
/**
|
|
46
63
|
* Checks if the given version is lower than the required minimal version.
|
|
64
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
65
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
66
|
+
*
|
|
47
67
|
* @param ui5VersionInfo to check
|
|
48
68
|
* @param minUi5VersionInfo to check against (default is 1.71)
|
|
69
|
+
* @throws Error if the version info is invalid
|
|
49
70
|
*
|
|
50
71
|
* @returns boolean
|
|
51
72
|
*/
|
|
@@ -53,21 +74,25 @@ export function isLowerThanMinimalUi5Version(
|
|
|
53
74
|
ui5VersionInfo: Ui5VersionInfo,
|
|
54
75
|
minUi5VersionInfo: Ui5VersionInfo = minVersionInfo
|
|
55
76
|
): boolean {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
checkVersionInfo(ui5VersionInfo);
|
|
78
|
+
checkVersionInfo(minUi5VersionInfo);
|
|
79
|
+
return (
|
|
80
|
+
ui5VersionInfo.major < minUi5VersionInfo.major ||
|
|
81
|
+
(ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor) ||
|
|
82
|
+
(ui5VersionInfo.major === minUi5VersionInfo.major &&
|
|
83
|
+
ui5VersionInfo.minor === minUi5VersionInfo.minor &&
|
|
84
|
+
(ui5VersionInfo?.patch ?? 0) < (minUi5VersionInfo?.patch ?? 0))
|
|
85
|
+
);
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
/**
|
|
68
89
|
* Checks if the given version is equal to the specified version.
|
|
90
|
+
* Note that the patch version of actual SAPUI5 version might differ from the lib that has been used for the version request (e.g. SAPUI5 1.96.38 contains sap.ui.core 1.96.36).
|
|
91
|
+
* For details see the patch info of the respective SAPUI5 version (e.g. https://ui5.sap.com/1.96.38/patchinfo.html).
|
|
92
|
+
*
|
|
69
93
|
* @param ui5VersionInfo to check
|
|
70
94
|
* @param targetUi5VersionInfo to check against (default is 1.71)
|
|
95
|
+
* @throws Error if the version info is invalid
|
|
71
96
|
*
|
|
72
97
|
* @returns boolean
|
|
73
98
|
*/
|
|
@@ -75,13 +100,13 @@ export function isVersionEqualOrHasNewerPatch(
|
|
|
75
100
|
ui5VersionInfo: Ui5VersionInfo,
|
|
76
101
|
targetUi5VersionInfo: Ui5VersionInfo = minVersionInfo
|
|
77
102
|
): boolean {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
checkVersionInfo(ui5VersionInfo);
|
|
104
|
+
checkVersionInfo(targetUi5VersionInfo);
|
|
105
|
+
return (
|
|
106
|
+
ui5VersionInfo.major === targetUi5VersionInfo.major &&
|
|
107
|
+
ui5VersionInfo.minor === targetUi5VersionInfo.minor &&
|
|
108
|
+
(ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0)
|
|
109
|
+
);
|
|
85
110
|
}
|
|
86
111
|
|
|
87
112
|
/**
|
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.16.
|
|
12
|
+
"version": "0.16.150",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"ejs": "3.1.10",
|
|
26
26
|
"mem-fs": "2.1.0",
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
|
-
"@sap-ux/logger": "0.6.0",
|
|
29
28
|
"@sap-ux/feature-toggle": "0.2.3",
|
|
29
|
+
"@sap-ux/logger": "0.6.0",
|
|
30
30
|
"@sap-ux/btp-utils": "0.17.1",
|
|
31
31
|
"@sap-ux/adp-tooling": "0.12.96",
|
|
32
32
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.28",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"supertest": "6.3.3",
|
|
47
47
|
"@sap-ux-private/playwright": "0.1.0",
|
|
48
48
|
"dotenv": "16.3.1",
|
|
49
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.
|
|
50
|
-
"@sap-ux/store": "1.0.0",
|
|
49
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.43",
|
|
51
50
|
"@sap-ux/axios-extension": "1.17.7",
|
|
51
|
+
"@sap-ux/store": "1.0.0",
|
|
52
52
|
"@sap-ux/ui5-info": "0.8.3",
|
|
53
53
|
"@sap-ux/i18n": "0.2.0"
|
|
54
54
|
},
|