@sap-ux/generator-adp 0.9.32 → 0.9.34
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.
|
@@ -9,6 +9,24 @@ const i18n_1 = require("../../utils/i18n");
|
|
|
9
9
|
const types_1 = require("../types");
|
|
10
10
|
const choices_1 = require("./helper/choices");
|
|
11
11
|
exports.DEFAULT_ADAPTATION_ID = 'DEFAULT';
|
|
12
|
+
const UNSUPPORTED_STATUS_CODES = new Set([400, 404, 405]);
|
|
13
|
+
/**
|
|
14
|
+
* Returns a user-friendly error message if the error is an axios error with a status code
|
|
15
|
+
* indicating the API is not supported (400, 404, 405), or the original error message otherwise.
|
|
16
|
+
*
|
|
17
|
+
* @param e - The error to check.
|
|
18
|
+
* @param userMessage - The user-friendly message to return if the error matches.
|
|
19
|
+
* @returns The user-friendly message or the original error message.
|
|
20
|
+
*/
|
|
21
|
+
function getUnsupportedApiMessage(e, userMessage) {
|
|
22
|
+
if ((0, axios_extension_1.isAxiosError)(e)) {
|
|
23
|
+
const status = e.response?.status;
|
|
24
|
+
if (status !== undefined && UNSUPPORTED_STATUS_CODES.has(status)) {
|
|
25
|
+
return userMessage;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return e.message;
|
|
29
|
+
}
|
|
12
30
|
/**
|
|
13
31
|
* Determines the flex version to be used. If the first version is the draft (versionId "0"), use the second version (active version).
|
|
14
32
|
*
|
|
@@ -188,23 +206,34 @@ class KeyUserImportPrompter {
|
|
|
188
206
|
* Loads adaptations for the current provider.
|
|
189
207
|
*/
|
|
190
208
|
async loadAdaptations() {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
209
|
+
try {
|
|
210
|
+
const version = determineFlexVersion(this.flexVersions);
|
|
211
|
+
const lrep = this.provider?.getLayeredRepository();
|
|
212
|
+
const response = await lrep?.listAdaptations(this.componentId, version);
|
|
213
|
+
this.adaptations = response?.adaptations ?? [];
|
|
214
|
+
this.logger.log(`Loaded adaptations: ${JSON.stringify(this.adaptations, null, 2)}`);
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
this.logger.error(`Error loading adaptations for component ${this.componentId}: ${e.message}`);
|
|
218
|
+
this.logger.debug(e);
|
|
219
|
+
throw new Error(getUnsupportedApiMessage(e, (0, i18n_1.t)('error.keyUserAdaptationsNotSupported')));
|
|
198
220
|
}
|
|
199
221
|
}
|
|
200
222
|
/**
|
|
201
223
|
* Loads flex versions for the current provider.
|
|
202
224
|
*/
|
|
203
225
|
async loadFlexVersions() {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
try {
|
|
227
|
+
const lrep = this.provider?.getLayeredRepository();
|
|
228
|
+
const response = await lrep?.getFlexVersions(this.componentId);
|
|
229
|
+
this.flexVersions = response?.versions ?? [];
|
|
230
|
+
this.logger.log(`Loaded flex versions: ${JSON.stringify(this.flexVersions, null, 2)}`);
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
this.logger.error(`Error loading flex versions for component ${this.componentId}: ${e.message}`);
|
|
234
|
+
this.logger.debug(e);
|
|
235
|
+
throw new Error(getUnsupportedApiMessage(e, (0, i18n_1.t)('error.keyUserFlexVersionsNotSupported')));
|
|
236
|
+
}
|
|
208
237
|
}
|
|
209
238
|
/**
|
|
210
239
|
* Resets the state by clearing adaptations, flex versions, and key-user changes.
|
|
@@ -226,6 +255,9 @@ class KeyUserImportPrompter {
|
|
|
226
255
|
await this.provider.isAbapCloud();
|
|
227
256
|
await this.loadFlexVersions();
|
|
228
257
|
await this.loadAdaptations();
|
|
258
|
+
if (!this.adaptations.length) {
|
|
259
|
+
throw new Error((0, i18n_1.t)('error.keyUserNoAdaptations'));
|
|
260
|
+
}
|
|
229
261
|
if (this.adaptations.length === 1 && this.adaptations[0]?.id === exports.DEFAULT_ADAPTATION_ID) {
|
|
230
262
|
return await this.validateKeyUserChanges(exports.DEFAULT_ADAPTATION_ID);
|
|
231
263
|
}
|
|
@@ -321,13 +353,7 @@ class KeyUserImportPrompter {
|
|
|
321
353
|
catch (e) {
|
|
322
354
|
this.logger.error(`Error validating key-user changes for adaptation ${adaptationId}: ${e.message}`);
|
|
323
355
|
this.logger.debug(e);
|
|
324
|
-
|
|
325
|
-
const status = e.response?.status;
|
|
326
|
-
if (status === 400 || status === 404 || status === 405) {
|
|
327
|
-
return (0, i18n_1.t)('error.keyUserNotSupported');
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return e.message;
|
|
356
|
+
return getUnsupportedApiMessage(e, (0, i18n_1.t)('error.keyUserNotSupported'));
|
|
331
357
|
}
|
|
332
358
|
}
|
|
333
359
|
}
|
|
@@ -124,7 +124,9 @@
|
|
|
124
124
|
"keyUserNoChangesDefault": "Only a single adaptation ('DEFAULT') was found and no key-user changes were found for it. Please select a different system to continue, or navigate back to the 'Project Attributes' page and choose not to import key-user changes.",
|
|
125
125
|
"keyUserNoChangesAdaptation": "No key-user changes have been found for the '{{adaptationId}}' adaptation. Please select a different adaptation.",
|
|
126
126
|
"keyUserNoAdaptations": "No context-based adaptations have been found for the selected application. Please refer to the documentation.",
|
|
127
|
-
"keyUserNotSupported": "The selected system does not allow or support
|
|
127
|
+
"keyUserNotSupported": "The selected system does not allow or support importing key-user changes. Please refer to the documentation.",
|
|
128
|
+
"keyUserFlexVersionsNotSupported": "The selected system does not support retrieving flex versions. Please refer to the documentation.",
|
|
129
|
+
"keyUserAdaptationsNotSupported": "The selected system does not support retrieving adaptations. Please refer to the documentation."
|
|
128
130
|
},
|
|
129
131
|
"validators": {
|
|
130
132
|
"ui5VersionNotDetectedError": "The SAPUI5 version of the selected system cannot be determined. You are able to create and edit adaptation projects that use the latest SAPUI5 version, but they are not usable on this system until the system's SAPUI5 version is upgraded to version 1.71 or higher."
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "SAPUI5 Adaptation Project",
|
|
4
4
|
"homepage": "https://help.sap.com/viewer/584e0bcbfd4a4aff91c815cefa0bce2d/Cloud/en-US/ada9567b767941aba8d49fdb4fdedea7.html",
|
|
5
5
|
"description": "Adaptation project allows you to create an app variant for an existing SAP Fiori elements-based or SAPUI5 freestyle application, without changing the original application.",
|
|
6
|
-
"version": "0.9.
|
|
6
|
+
"version": "0.9.34",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"i18next": "25.8.18",
|
|
31
31
|
"yeoman-generator": "5.10.0",
|
|
32
32
|
"uuid": "11.1.0",
|
|
33
|
-
"@sap-ux/adp-tooling": "0.18.
|
|
33
|
+
"@sap-ux/adp-tooling": "0.18.96",
|
|
34
34
|
"@sap-ux/axios-extension": "1.25.24",
|
|
35
35
|
"@sap-ux/btp-utils": "1.1.10",
|
|
36
36
|
"@sap-ux/feature-toggle": "0.3.7",
|
|
37
|
-
"@sap-ux/inquirer-common": "0.11.24",
|
|
38
37
|
"@sap-ux/logger": "0.8.2",
|
|
39
|
-
"@sap-ux/project-access": "1.35.13",
|
|
40
38
|
"@sap-ux/store": "1.5.10",
|
|
41
|
-
"@sap-ux/
|
|
39
|
+
"@sap-ux/inquirer-common": "0.11.25",
|
|
42
40
|
"@sap-ux/project-input-validator": "0.6.68",
|
|
43
|
-
"@sap-ux/
|
|
41
|
+
"@sap-ux/project-access": "1.35.13",
|
|
44
42
|
"@sap-ux/odata-service-writer": "0.30.1",
|
|
43
|
+
"@sap-ux/fiori-generator-shared": "0.13.87",
|
|
44
|
+
"@sap-ux/system-access": "0.6.66",
|
|
45
45
|
"@sap-ux/telemetry": "0.6.87"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"fs-extra": "11.3.4",
|
|
58
58
|
"rimraf": "6.1.3",
|
|
59
59
|
"yeoman-test": "6.3.0",
|
|
60
|
-
"@sap-ux/deploy-config-sub-generator": "0.5.
|
|
60
|
+
"@sap-ux/deploy-config-sub-generator": "0.5.115"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=20.x"
|