@sap-ux/abap-deploy-config-sub-generator 0.1.8 → 0.1.9

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.
@@ -6,7 +6,6 @@ const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generato
6
6
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
7
7
  const abap_deploy_config_inquirer_1 = require("@sap-ux/abap-deploy-config-inquirer");
8
8
  const abap_deploy_config_writer_1 = require("@sap-ux/abap-deploy-config-writer");
9
- const telemetry_1 = require("@sap-ux/telemetry");
10
9
  const ui5_config_1 = require("@sap-ux/ui5-config");
11
10
  const project_access_1 = require("@sap-ux/project-access");
12
11
  const store_1 = require("@sap-ux/store");
@@ -49,11 +48,8 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
49
48
  async initializing() {
50
49
  await super.initializing();
51
50
  await (0, i18n_1.initI18n)();
52
- if (this.env.conflicter) {
53
- this.env.conflicter.force = this.options.force ?? true;
54
- }
55
51
  deploy_config_generator_shared_1.DeploymentGenerator.logger?.debug((0, utils_1.t)('debug.initTelemetry'));
56
- await (0, telemetry_1.initTelemetrySettings)({
52
+ await fiori_generator_shared_1.TelemetryHelper.initTelemetrySettings({
57
53
  consumerModule: {
58
54
  name: '@sap-ux/abap-deploy-config-sub-generator',
59
55
  version: this.rootGeneratorVersion()
@@ -61,6 +57,9 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
61
57
  internalFeature: (0, feature_toggle_1.isInternalFeaturesSettingEnabled)(),
62
58
  watchTelemetrySettingStore: false
63
59
  });
60
+ if (this.env.conflicter) {
61
+ this.env.conflicter.force = this.options.force ?? true;
62
+ }
64
63
  if (!this.launchDeployConfigAsSubGenerator) {
65
64
  await this._initializing();
66
65
  }
@@ -165,14 +164,29 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
165
164
  const prompAnswers = await this.prompt(abapDeployConfigPrompts);
166
165
  this.answers = (0, abap_deploy_config_inquirer_1.reconcileAnswers)(prompAnswers, abapAnswers);
167
166
  }
168
- this._reconcileAnswersWithOptions();
167
+ await this._reconcileAnswersWithOptions();
169
168
  }
170
- _processAbapTargetAnswers() {
169
+ async _processAbapTargetAnswers() {
171
170
  this.answers.destination = this.options.destination || this.answers.destination;
172
- this.answers.url = this.options.url || this.answers.url;
171
+ this.answers.url =
172
+ this.options.url || this.answers.url || (await (0, utils_1.determineUrlFromDestination)(this.answers.destination));
173
173
  this.answers.client = this.options.client || this.answers.client;
174
- this.answers.scp = this.options.scp || this.answers.scp;
175
- this.answers.isS4HC = this.options.isS4HC || this.answers.isS4HC;
174
+ this.answers.scp =
175
+ this.options.scp ||
176
+ this.answers.scp ||
177
+ (await (0, utils_1.determineScpFromTarget)({
178
+ url: this.answers.url,
179
+ client: this.answers.client,
180
+ destination: this.answers.destination
181
+ }));
182
+ this.answers.isS4HC =
183
+ this.options.isS4HC ||
184
+ this.answers.isS4HC ||
185
+ (await (0, utils_1.determineS4HCFromTarget)({
186
+ url: this.answers.url,
187
+ client: this.answers.client,
188
+ destination: this.answers.destination
189
+ }));
176
190
  if (!(0, btp_utils_1.isAppStudio)() && this.answers.scp) {
177
191
  // ensure there is no client for SCP on vscode
178
192
  delete this.answers.client;
@@ -191,7 +205,9 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
191
205
  // Set transport
192
206
  if (!this.answers.transport) {
193
207
  this.answers.transport =
194
- (0, abap_deploy_config_inquirer_1.getTransportAnswer)(this.options) || (0, abap_deploy_config_inquirer_1.getTransportAnswer)(this.answers);
208
+ this.options.transport ??
209
+ ((0, abap_deploy_config_inquirer_1.getTransportAnswer)(this.options) ||
210
+ (0, abap_deploy_config_inquirer_1.getTransportAnswer)(this.answers));
195
211
  }
196
212
  }
197
213
  /**
@@ -199,8 +215,8 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
199
215
  *
200
216
  * Options may be passed from parent generator, or from the command line.
201
217
  */
202
- _reconcileAnswersWithOptions() {
203
- this._processAbapTargetAnswers();
218
+ async _reconcileAnswersWithOptions() {
219
+ await this._processAbapTargetAnswers();
204
220
  this._processBspAppAnswers();
205
221
  this.answers.index = this.options.index ?? this.answers.index;
206
222
  this.answers.overwrite = this.options.overwrite ?? this.answers.overwrite;
@@ -0,0 +1,23 @@
1
+ import type { AbapTarget } from '@sap-ux/ui5-config';
2
+ /**
3
+ * Retrieves the URL for the provided destination.
4
+ *
5
+ * @param destination - the destination name
6
+ * @returns the URL of the destination or undefined if not found
7
+ */
8
+ export declare function determineUrlFromDestination(destination?: string): Promise<string | undefined>;
9
+ /**
10
+ * Determines if the ABAP target is a cloud system.
11
+ *
12
+ * @param target - abap target containing either a destination or a URL
13
+ * @returns - true if the target is a cloud system, false otherwise
14
+ */
15
+ export declare function determineScpFromTarget(target: AbapTarget): Promise<boolean>;
16
+ /**
17
+ * Determine if the ABAP target is an S4 Hana Cloud system.
18
+ *
19
+ * @param target - abap target containing either a destination or a URL
20
+ * @returns - true if the target is an s4hana cloud system, false otherwise
21
+ */
22
+ export declare function determineS4HCFromTarget(target: AbapTarget): Promise<boolean>;
23
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.determineUrlFromDestination = determineUrlFromDestination;
4
+ exports.determineScpFromTarget = determineScpFromTarget;
5
+ exports.determineS4HCFromTarget = determineS4HCFromTarget;
6
+ const btp_utils_1 = require("@sap-ux/btp-utils");
7
+ const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
8
+ const store_1 = require("@sap-ux/store");
9
+ let cachedDestinations = {};
10
+ let cachedBackendSystems = [];
11
+ /**
12
+ * Small utility function to check whether the backend system keys are identical.
13
+ *
14
+ * @param backend - backend system from the store
15
+ * @param target - the abap target passed in
16
+ * @returns true if the systems are the same
17
+ */
18
+ function isSameSystem(backend, target) {
19
+ return (backend.url.trim().replace(/\/$/, '') === target.url?.trim().replace(/\/$/, '') &&
20
+ (backend.client ?? '') === (target?.client ?? ''));
21
+ }
22
+ /**
23
+ * Retrieve the destinations from SAP BTP.
24
+ *
25
+ * @returns destinations object
26
+ */
27
+ async function getDestinations() {
28
+ if (Object.keys(cachedDestinations)?.length === 0) {
29
+ try {
30
+ cachedDestinations = await (0, btp_utils_1.listDestinations)({ stripS4HCApiHosts: true });
31
+ }
32
+ catch (e) {
33
+ deploy_config_generator_shared_1.DeploymentGenerator.logger.error(`Failed to fetch destinations. Error: ${e.message}`);
34
+ }
35
+ }
36
+ return cachedDestinations;
37
+ }
38
+ /**
39
+ * Retrieve the list of backend systems from the secure store.
40
+ *
41
+ * @returns list of backend systems
42
+ */
43
+ async function getBackendSystems() {
44
+ if (cachedBackendSystems?.length === 0) {
45
+ try {
46
+ const systemStore = await (0, store_1.getService)({
47
+ logger: deploy_config_generator_shared_1.DeploymentGenerator.logger,
48
+ entityName: 'system'
49
+ });
50
+ cachedBackendSystems = await systemStore?.getAll();
51
+ }
52
+ catch (e) {
53
+ deploy_config_generator_shared_1.DeploymentGenerator.logger.error(`Failed to fetch systems list. Error: ${e.message}`);
54
+ }
55
+ }
56
+ return cachedBackendSystems;
57
+ }
58
+ /**
59
+ * Retrieves the URL for the provided destination.
60
+ *
61
+ * @param destination - the destination name
62
+ * @returns the URL of the destination or undefined if not found
63
+ */
64
+ async function determineUrlFromDestination(destination) {
65
+ let url;
66
+ if ((0, btp_utils_1.isAppStudio)() && destination) {
67
+ const destinations = await getDestinations();
68
+ url = destinations?.[destination]?.Host;
69
+ }
70
+ return url;
71
+ }
72
+ /**
73
+ * Determines if the ABAP target is a cloud system.
74
+ *
75
+ * @param target - abap target containing either a destination or a URL
76
+ * @returns - true if the target is a cloud system, false otherwise
77
+ */
78
+ async function determineScpFromTarget(target) {
79
+ let isScp = false;
80
+ if ((0, btp_utils_1.isAppStudio)() && target.destination) {
81
+ const destinations = await getDestinations();
82
+ if (destinations?.[target.destination]) {
83
+ isScp = (0, btp_utils_1.isAbapEnvironmentOnBtp)(destinations?.[target.destination]);
84
+ }
85
+ }
86
+ else if (target.url) {
87
+ const backendSystems = await getBackendSystems();
88
+ const backendSystem = backendSystems?.find((backend) => isSameSystem(backend, target));
89
+ isScp = !!backendSystem?.serviceKeys;
90
+ }
91
+ return isScp;
92
+ }
93
+ /**
94
+ * Determine if the ABAP target is an S4 Hana Cloud system.
95
+ *
96
+ * @param target - abap target containing either a destination or a URL
97
+ * @returns - true if the target is an s4hana cloud system, false otherwise
98
+ */
99
+ async function determineS4HCFromTarget(target) {
100
+ let isS4HCloud = false;
101
+ if ((0, btp_utils_1.isAppStudio)() && target.destination) {
102
+ const destinations = await getDestinations();
103
+ if (destinations?.[target.destination]) {
104
+ isS4HCloud = (0, btp_utils_1.isS4HC)(destinations?.[target.destination]);
105
+ }
106
+ }
107
+ else if (target.url) {
108
+ const backendSystems = await getBackendSystems();
109
+ const backendSystem = backendSystems?.find((backend) => isSameSystem(backend, target));
110
+ isS4HCloud = backendSystem?.authenticationType === store_1.AuthenticationType.ReentranceTicket;
111
+ }
112
+ return isS4HCloud;
113
+ }
114
+ //# sourceMappingURL=helpers.js.map
@@ -1,4 +1,5 @@
1
1
  export { indexHtmlExists } from './project';
2
2
  export { handleProjectDoesNotExist } from './error-handler';
3
3
  export { t } from './i18n';
4
+ export { determineScpFromTarget, determineUrlFromDestination, determineS4HCFromTarget } from './helpers';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.t = exports.handleProjectDoesNotExist = exports.indexHtmlExists = void 0;
3
+ exports.determineS4HCFromTarget = exports.determineUrlFromDestination = exports.determineScpFromTarget = exports.t = exports.handleProjectDoesNotExist = exports.indexHtmlExists = void 0;
4
4
  var project_1 = require("./project");
5
5
  Object.defineProperty(exports, "indexHtmlExists", { enumerable: true, get: function () { return project_1.indexHtmlExists; } });
6
6
  var error_handler_1 = require("./error-handler");
7
7
  Object.defineProperty(exports, "handleProjectDoesNotExist", { enumerable: true, get: function () { return error_handler_1.handleProjectDoesNotExist; } });
8
8
  var i18n_1 = require("./i18n");
9
9
  Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
10
+ var helpers_1 = require("./helpers");
11
+ Object.defineProperty(exports, "determineScpFromTarget", { enumerable: true, get: function () { return helpers_1.determineScpFromTarget; } });
12
+ Object.defineProperty(exports, "determineUrlFromDestination", { enumerable: true, get: function () { return helpers_1.determineUrlFromDestination; } });
13
+ Object.defineProperty(exports, "determineS4HCFromTarget", { enumerable: true, get: function () { return helpers_1.determineS4HCFromTarget; } });
10
14
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/SAP/open-ux-tools.git",
7
7
  "directory": "packages/abap-deploy-config-sub-generator"
8
8
  },
9
- "version": "0.1.8",
9
+ "version": "0.1.9",
10
10
  "license": "Apache-2.0",
11
11
  "main": "generators/app/index.js",
12
12
  "files": [
@@ -21,15 +21,14 @@
21
21
  "dependencies": {
22
22
  "i18next": "23.5.1",
23
23
  "@sap-devx/yeoman-ui-types": "1.14.4",
24
- "@sap-ux/abap-deploy-config-inquirer": "1.4.8",
24
+ "@sap-ux/abap-deploy-config-inquirer": "1.4.9",
25
25
  "@sap-ux/abap-deploy-config-writer": "0.1.4",
26
26
  "@sap-ux/btp-utils": "1.1.0",
27
- "@sap-ux/deploy-config-generator-shared": "0.1.4",
27
+ "@sap-ux/deploy-config-generator-shared": "0.1.5",
28
28
  "@sap-ux/feature-toggle": "0.3.0",
29
- "@sap-ux/fiori-generator-shared": "0.12.4",
29
+ "@sap-ux/fiori-generator-shared": "0.12.5",
30
30
  "@sap-ux/logger": "0.7.0",
31
31
  "@sap-ux/project-access": "1.30.2",
32
- "@sap-ux/telemetry": "0.6.3",
33
32
  "@sap-ux/ui5-config": "0.28.2"
34
33
  },
35
34
  "devDependencies": {