@sap-ux/generator-adp 1.0.7 → 1.0.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.
Files changed (41) hide show
  1. package/generators/add-annotations-to-odata/index.js +20 -15
  2. package/generators/add-component-usages/index.js +21 -16
  3. package/generators/add-new-model/index.js +29 -24
  4. package/generators/app/extension-project/index.js +9 -6
  5. package/generators/app/index.js +135 -129
  6. package/generators/app/layer.js +8 -5
  7. package/generators/app/questions/attributes.js +65 -60
  8. package/generators/app/questions/cf-services.js +52 -48
  9. package/generators/app/questions/configuration.js +129 -125
  10. package/generators/app/questions/helper/additional-messages.js +36 -29
  11. package/generators/app/questions/helper/choices.js +25 -16
  12. package/generators/app/questions/helper/conditions.js +23 -14
  13. package/generators/app/questions/helper/default-values.js +13 -8
  14. package/generators/app/questions/helper/message.js +11 -7
  15. package/generators/app/questions/helper/tooltip.js +7 -4
  16. package/generators/app/questions/helper/validators.js +39 -29
  17. package/generators/app/questions/key-user.js +45 -40
  18. package/generators/app/questions/target-env.js +27 -22
  19. package/generators/app/types.js +16 -13
  20. package/generators/base/questions/credentials.js +18 -15
  21. package/generators/base/sub-gen-auth-base.js +30 -24
  22. package/generators/base/sub-gen-base.js +17 -11
  23. package/generators/change-data-source/index.js +13 -8
  24. package/generators/telemetry/collector.js +10 -6
  25. package/generators/telemetry/events.js +5 -2
  26. package/generators/telemetry/index.js +18 -2
  27. package/generators/types.js +5 -2
  28. package/generators/utils/appWizardCache.js +13 -7
  29. package/generators/utils/deps.d.ts +6 -0
  30. package/generators/utils/deps.js +52 -10
  31. package/generators/utils/i18n.js +20 -12
  32. package/generators/utils/logger.js +7 -4
  33. package/generators/utils/opts.js +6 -3
  34. package/generators/utils/parse-json-input.js +9 -5
  35. package/generators/utils/steps.js +48 -37
  36. package/generators/utils/subgenHelpers.js +14 -9
  37. package/generators/utils/templates.d.ts +4 -0
  38. package/generators/utils/templates.js +13 -7
  39. package/generators/utils/type-guards.js +6 -2
  40. package/generators/utils/workspace.js +13 -7
  41. package/package.json +10 -11
@@ -1,10 +1,14 @@
1
- import { isAxiosError } from '@sap-ux/axios-extension';
2
- import { validateEmptyString } from '@sap-ux/project-input-validator';
3
- import { getConfiguredProvider } from '@sap-ux/adp-tooling';
4
- import { t } from '../../utils/i18n.js';
5
- import { keyUserPromptNames } from '../types.js';
6
- import { getAdaptationChoices, getKeyUserSystemChoices } from './helper/choices.js';
7
- export const DEFAULT_ADAPTATION_ID = 'DEFAULT';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyUserImportPrompter = exports.DEFAULT_ADAPTATION_ID = void 0;
4
+ exports.determineFlexVersion = determineFlexVersion;
5
+ const axios_extension_1 = require("@sap-ux/axios-extension");
6
+ const project_input_validator_1 = require("@sap-ux/project-input-validator");
7
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
8
+ const i18n_js_1 = require("../../utils/i18n.js");
9
+ const types_js_1 = require("../types.js");
10
+ const choices_js_1 = require("./helper/choices.js");
11
+ exports.DEFAULT_ADAPTATION_ID = 'DEFAULT';
8
12
  const UNSUPPORTED_STATUS_CODES = new Set([400, 404, 405]);
9
13
  /**
10
14
  * Returns a user-friendly error message if the error is an axios error with a status code
@@ -15,7 +19,7 @@ const UNSUPPORTED_STATUS_CODES = new Set([400, 404, 405]);
15
19
  * @returns The user-friendly message or the original error message.
16
20
  */
17
21
  function getUnsupportedApiMessage(e, userMessage) {
18
- if (isAxiosError(e)) {
22
+ if ((0, axios_extension_1.isAxiosError)(e)) {
19
23
  const status = e.response?.status;
20
24
  if (status !== undefined && UNSUPPORTED_STATUS_CODES.has(status)) {
21
25
  return userMessage;
@@ -29,7 +33,7 @@ function getUnsupportedApiMessage(e, userMessage) {
29
33
  * @param {FlexVersion[]} flexVersions - The list of flex versions.
30
34
  * @returns {string} The flex version to be used.
31
35
  */
32
- export function determineFlexVersion(flexVersions) {
36
+ function determineFlexVersion(flexVersions) {
33
37
  if (!flexVersions?.length) {
34
38
  return '';
35
39
  }
@@ -41,7 +45,7 @@ export function determineFlexVersion(flexVersions) {
41
45
  /**
42
46
  * Prompter class that guides the user through importing key-user changes.
43
47
  */
44
- export class KeyUserImportPrompter {
48
+ class KeyUserImportPrompter {
45
49
  systemLookup;
46
50
  componentId;
47
51
  defaultProvider;
@@ -100,10 +104,10 @@ export class KeyUserImportPrompter {
100
104
  */
101
105
  getPrompts(promptOptions) {
102
106
  const keyedPrompts = {
103
- [keyUserPromptNames.keyUserSystem]: this.getSystemPrompt(promptOptions?.[keyUserPromptNames.keyUserSystem]),
104
- [keyUserPromptNames.keyUserUsername]: this.getUsernamePrompt(promptOptions?.[keyUserPromptNames.keyUserUsername]),
105
- [keyUserPromptNames.keyUserPassword]: this.getPasswordPrompt(promptOptions?.[keyUserPromptNames.keyUserPassword]),
106
- [keyUserPromptNames.keyUserAdaptation]: this.getAdaptationPrompt(promptOptions?.[keyUserPromptNames.keyUserAdaptation])
107
+ [types_js_1.keyUserPromptNames.keyUserSystem]: this.getSystemPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserSystem]),
108
+ [types_js_1.keyUserPromptNames.keyUserUsername]: this.getUsernamePrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserUsername]),
109
+ [types_js_1.keyUserPromptNames.keyUserPassword]: this.getPasswordPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserPassword]),
110
+ [types_js_1.keyUserPromptNames.keyUserAdaptation]: this.getAdaptationPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserAdaptation])
107
111
  };
108
112
  const questions = Object.entries(keyedPrompts)
109
113
  .filter(([promptName, _]) => {
@@ -122,11 +126,11 @@ export class KeyUserImportPrompter {
122
126
  getSystemPrompt(options) {
123
127
  return {
124
128
  type: 'list',
125
- name: keyUserPromptNames.keyUserSystem,
126
- message: t('prompts.systemLabel'),
129
+ name: types_js_1.keyUserPromptNames.keyUserSystem,
130
+ message: (0, i18n_js_1.t)('prompts.systemLabel'),
127
131
  choices: async () => {
128
132
  const systems = await this.systemLookup.getSystems();
129
- return getKeyUserSystemChoices(systems, this.defaultSystem);
133
+ return (0, choices_js_1.getKeyUserSystemChoices)(systems, this.defaultSystem);
130
134
  },
131
135
  guiOptions: {
132
136
  mandatory: true,
@@ -145,15 +149,15 @@ export class KeyUserImportPrompter {
145
149
  getUsernamePrompt(options) {
146
150
  return {
147
151
  type: 'input',
148
- name: keyUserPromptNames.keyUserUsername,
149
- message: t('prompts.usernameLabel'),
152
+ name: types_js_1.keyUserPromptNames.keyUserUsername,
153
+ message: (0, i18n_js_1.t)('prompts.usernameLabel'),
150
154
  default: options?.default ?? '',
151
155
  filter: (val) => val.trim(),
152
156
  guiOptions: {
153
157
  mandatory: true
154
158
  },
155
159
  when: (answers) => !!answers.keyUserSystem && this.isAuthRequired,
156
- validate: (value) => validateEmptyString(value)
160
+ validate: (value) => (0, project_input_validator_1.validateEmptyString)(value)
157
161
  };
158
162
  }
159
163
  /**
@@ -165,8 +169,8 @@ export class KeyUserImportPrompter {
165
169
  getPasswordPrompt(options) {
166
170
  return {
167
171
  type: 'password',
168
- name: keyUserPromptNames.keyUserPassword,
169
- message: t('prompts.passwordLabel'),
172
+ name: types_js_1.keyUserPromptNames.keyUserPassword,
173
+ message: (0, i18n_js_1.t)('prompts.passwordLabel'),
170
174
  mask: '*',
171
175
  default: options?.default ?? '',
172
176
  guiOptions: {
@@ -186,14 +190,14 @@ export class KeyUserImportPrompter {
186
190
  getAdaptationPrompt(_) {
187
191
  return {
188
192
  type: 'list',
189
- name: keyUserPromptNames.keyUserAdaptation,
190
- message: t('prompts.keyUserAdaptationLabel'),
193
+ name: types_js_1.keyUserPromptNames.keyUserAdaptation,
194
+ message: (0, i18n_js_1.t)('prompts.keyUserAdaptationLabel'),
191
195
  guiOptions: {
192
196
  mandatory: true,
193
- breadcrumb: t('prompts.keyUserAdaptationBreadcrumb')
197
+ breadcrumb: (0, i18n_js_1.t)('prompts.keyUserAdaptationBreadcrumb')
194
198
  },
195
- choices: () => getAdaptationChoices(this.adaptations),
196
- default: () => getAdaptationChoices(this.adaptations)[0]?.name,
199
+ choices: () => (0, choices_js_1.getAdaptationChoices)(this.adaptations),
200
+ default: () => (0, choices_js_1.getAdaptationChoices)(this.adaptations)[0]?.name,
197
201
  validate: async (adaptation) => await this.validateKeyUserChanges(adaptation?.id),
198
202
  when: () => this.adaptations.length > 1
199
203
  };
@@ -212,7 +216,7 @@ export class KeyUserImportPrompter {
212
216
  catch (e) {
213
217
  this.logger.error(`Error loading adaptations for component ${this.componentId}: ${e.message}`);
214
218
  this.logger.debug(e);
215
- throw new Error(getUnsupportedApiMessage(e, t('error.keyUserAdaptationsNotSupported')));
219
+ throw new Error(getUnsupportedApiMessage(e, (0, i18n_js_1.t)('error.keyUserAdaptationsNotSupported')));
216
220
  }
217
221
  }
218
222
  /**
@@ -228,7 +232,7 @@ export class KeyUserImportPrompter {
228
232
  catch (e) {
229
233
  this.logger.error(`Error loading flex versions for component ${this.componentId}: ${e.message}`);
230
234
  this.logger.debug(e);
231
- throw new Error(getUnsupportedApiMessage(e, t('error.keyUserFlexVersionsNotSupported')));
235
+ throw new Error(getUnsupportedApiMessage(e, (0, i18n_js_1.t)('error.keyUserFlexVersionsNotSupported')));
232
236
  }
233
237
  }
234
238
  /**
@@ -252,10 +256,10 @@ export class KeyUserImportPrompter {
252
256
  await this.loadFlexVersions();
253
257
  await this.loadAdaptations();
254
258
  if (!this.adaptations.length) {
255
- throw new Error(t('error.keyUserNoAdaptations'));
259
+ throw new Error((0, i18n_js_1.t)('error.keyUserNoAdaptations'));
256
260
  }
257
- if (this.adaptations.length === 1 && this.adaptations[0]?.id === DEFAULT_ADAPTATION_ID) {
258
- return await this.validateKeyUserChanges(DEFAULT_ADAPTATION_ID);
261
+ if (this.adaptations.length === 1 && this.adaptations[0]?.id === exports.DEFAULT_ADAPTATION_ID) {
262
+ return await this.validateKeyUserChanges(exports.DEFAULT_ADAPTATION_ID);
259
263
  }
260
264
  return true;
261
265
  }
@@ -267,7 +271,7 @@ export class KeyUserImportPrompter {
267
271
  * @returns An error message if validation fails, or true if the system selection is valid.
268
272
  */
269
273
  async validateSystem(system, answers) {
270
- const validationResult = validateEmptyString(system);
274
+ const validationResult = (0, project_input_validator_1.validateEmptyString)(system);
271
275
  if (typeof validationResult === 'string') {
272
276
  return validationResult;
273
277
  }
@@ -286,7 +290,7 @@ export class KeyUserImportPrompter {
286
290
  username: answers.keyUserUsername,
287
291
  password: answers.keyUserPassword
288
292
  };
289
- this.provider = await getConfiguredProvider(options, this.logger);
293
+ this.provider = await (0, adp_tooling_1.getConfiguredProvider)(options, this.logger);
290
294
  return await this.loadDataAndValidateKeyUserChanges();
291
295
  }
292
296
  }
@@ -303,7 +307,7 @@ export class KeyUserImportPrompter {
303
307
  * @returns An error message if validation fails, or true if the password is valid.
304
308
  */
305
309
  async validatePassword(password, answers) {
306
- const validationResult = validateEmptyString(password);
310
+ const validationResult = (0, project_input_validator_1.validateEmptyString)(password);
307
311
  if (typeof validationResult === 'string') {
308
312
  return validationResult;
309
313
  }
@@ -315,7 +319,7 @@ export class KeyUserImportPrompter {
315
319
  username: answers.keyUserUsername,
316
320
  password
317
321
  };
318
- this.provider = await getConfiguredProvider(options, this.logger);
322
+ this.provider = await (0, adp_tooling_1.getConfiguredProvider)(options, this.logger);
319
323
  return await this.loadDataAndValidateKeyUserChanges();
320
324
  }
321
325
  catch (e) {
@@ -338,19 +342,20 @@ export class KeyUserImportPrompter {
338
342
  this.keyUserChanges = data?.contents ?? [];
339
343
  this.logger.debug(`Retrieved ${this.keyUserChanges.length} key-user change(s) for adaptation ${adaptationId}`);
340
344
  if (!this.keyUserChanges.length) {
341
- if (adaptationId === DEFAULT_ADAPTATION_ID && this.adaptations.length === 1) {
342
- return t('error.keyUserNoChangesDefault');
345
+ if (adaptationId === exports.DEFAULT_ADAPTATION_ID && this.adaptations.length === 1) {
346
+ return (0, i18n_js_1.t)('error.keyUserNoChangesDefault');
343
347
  }
344
348
  this.logger.warn(`No key-user changes found for adaptation: ${adaptationId}`);
345
- return t('error.keyUserNoChangesAdaptation', { adaptationId });
349
+ return (0, i18n_js_1.t)('error.keyUserNoChangesAdaptation', { adaptationId });
346
350
  }
347
351
  return true;
348
352
  }
349
353
  catch (e) {
350
354
  this.logger.error(`Error validating key-user changes for adaptation ${adaptationId}: ${e.message}`);
351
355
  this.logger.debug(e);
352
- return getUnsupportedApiMessage(e, t('error.keyUserNotSupported'));
356
+ return getUnsupportedApiMessage(e, (0, i18n_js_1.t)('error.keyUserNotSupported'));
353
357
  }
354
358
  }
355
359
  }
360
+ exports.KeyUserImportPrompter = KeyUserImportPrompter;
356
361
  //# sourceMappingURL=key-user.js.map
@@ -1,9 +1,14 @@
1
- import { MessageType } from '@sap-devx/yeoman-ui-types';
2
- import { getDefaultTargetFolder } from '@sap-ux/fiori-generator-shared';
3
- import { t } from '../../utils/i18n.js';
4
- import { TargetEnv } from '../types.js';
5
- import { getTargetEnvAdditionalMessages } from './helper/additional-messages.js';
6
- import { validateEnvironment, validateProjectPath } from './helper/validators.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTargetEnvPrompt = getTargetEnvPrompt;
4
+ exports.getEnvironments = getEnvironments;
5
+ exports.getProjectPathPrompt = getProjectPathPrompt;
6
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
7
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
8
+ const i18n_js_1 = require("../../utils/i18n.js");
9
+ const types_js_1 = require("../types.js");
10
+ const additional_messages_js_1 = require("./helper/additional-messages.js");
11
+ const validators_js_1 = require("./helper/validators.js");
7
12
  /**
8
13
  * Returns the target environment prompt.
9
14
  *
@@ -13,20 +18,20 @@ import { validateEnvironment, validateProjectPath } from './helper/validators.js
13
18
  * @param {CfConfig} cfConfig - The CF config service instance.
14
19
  * @returns {object[]} The target environment prompt.
15
20
  */
16
- export function getTargetEnvPrompt(appWizard, isCfInstalled, isCFLoggedIn, cfConfig) {
21
+ function getTargetEnvPrompt(appWizard, isCfInstalled, isCFLoggedIn, cfConfig) {
17
22
  return {
18
23
  type: 'list',
19
24
  name: 'targetEnv',
20
- message: t('prompts.targetEnvLabel'),
25
+ message: (0, i18n_js_1.t)('prompts.targetEnvLabel'),
21
26
  choices: () => getEnvironments(appWizard, isCfInstalled),
22
27
  default: () => getEnvironments(appWizard, isCfInstalled)[0]?.name,
23
28
  guiOptions: {
24
29
  mandatory: true,
25
- hint: t('prompts.targetEnvTooltip'),
26
- breadcrumb: t('prompts.targetEnvBreadcrumb')
30
+ hint: (0, i18n_js_1.t)('prompts.targetEnvTooltip'),
31
+ breadcrumb: (0, i18n_js_1.t)('prompts.targetEnvBreadcrumb')
27
32
  },
28
- validate: (value) => validateEnvironment(value, isCFLoggedIn, cfConfig),
29
- additionalMessages: (value) => getTargetEnvAdditionalMessages(value, isCFLoggedIn, cfConfig)
33
+ validate: (value) => (0, validators_js_1.validateEnvironment)(value, isCFLoggedIn, cfConfig),
34
+ additionalMessages: (value) => (0, additional_messages_js_1.getTargetEnvAdditionalMessages)(value, isCFLoggedIn, cfConfig)
30
35
  };
31
36
  }
32
37
  /**
@@ -36,13 +41,13 @@ export function getTargetEnvPrompt(appWizard, isCfInstalled, isCFLoggedIn, cfCon
36
41
  * @param {boolean} isCfInstalled - Whether Cloud Foundry is installed.
37
42
  * @returns {object[]} The environments.
38
43
  */
39
- export function getEnvironments(appWizard, isCfInstalled) {
40
- const choices = [{ name: 'ABAP', value: TargetEnv.ABAP }];
44
+ function getEnvironments(appWizard, isCfInstalled) {
45
+ const choices = [{ name: 'ABAP', value: types_js_1.TargetEnv.ABAP }];
41
46
  if (isCfInstalled) {
42
- choices.push({ name: 'SAP BTP, Cloud Foundry environment', value: TargetEnv.CF });
47
+ choices.push({ name: 'SAP BTP, Cloud Foundry environment', value: types_js_1.TargetEnv.CF });
43
48
  }
44
49
  else {
45
- appWizard.showInformation(t('error.cfNotInstalled'), MessageType.prompt);
50
+ appWizard.showInformation((0, i18n_js_1.t)('error.cfNotInstalled'), yeoman_ui_types_1.MessageType.prompt);
46
51
  }
47
52
  return choices;
48
53
  }
@@ -53,19 +58,19 @@ export function getEnvironments(appWizard, isCfInstalled) {
53
58
  * @param {any} vscode - The VSCode instance.
54
59
  * @returns {YUIQuestion<ProjectLocationAnswers>[]} The project path prompt.
55
60
  */
56
- export function getProjectPathPrompt(logger, vscode) {
61
+ function getProjectPathPrompt(logger, vscode) {
57
62
  return {
58
63
  type: 'input',
59
64
  name: 'projectLocation',
60
65
  guiOptions: {
61
66
  type: 'folder-browser',
62
67
  mandatory: true,
63
- hint: t('prompts.projectLocationTooltip'),
64
- breadcrumb: t('prompts.projectLocationBreadcrumb')
68
+ hint: (0, i18n_js_1.t)('prompts.projectLocationTooltip'),
69
+ breadcrumb: (0, i18n_js_1.t)('prompts.projectLocationBreadcrumb')
65
70
  },
66
- message: t('prompts.projectLocationLabel'),
67
- validate: (value) => validateProjectPath(value, logger),
68
- default: () => getDefaultTargetFolder(vscode),
71
+ message: (0, i18n_js_1.t)('prompts.projectLocationLabel'),
72
+ validate: (value) => (0, validators_js_1.validateProjectPath)(value, logger),
73
+ default: () => (0, fiori_generator_shared_1.getDefaultTargetFolder)(vscode),
69
74
  store: false
70
75
  };
71
76
  }
@@ -1,7 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SystemType = exports.cfLoginPromptNames = exports.TargetEnv = exports.targetEnvPromptNames = exports.keyUserPromptNames = exports.attributePromptNames = exports.configPromptNames = void 0;
1
4
  /**
2
5
  * Enumeration of prompt names used in the configuration.
3
6
  */
4
- export var configPromptNames;
7
+ var configPromptNames;
5
8
  (function (configPromptNames) {
6
9
  configPromptNames["system"] = "system";
7
10
  configPromptNames["systemValidationCli"] = "systemValidationCli";
@@ -16,8 +19,8 @@ export var configPromptNames;
16
19
  configPromptNames["fioriId"] = "fioriId";
17
20
  configPromptNames["ach"] = "ach";
18
21
  configPromptNames["shouldCreateExtProject"] = "shouldCreateExtProject";
19
- })(configPromptNames || (configPromptNames = {}));
20
- export var attributePromptNames;
22
+ })(configPromptNames || (exports.configPromptNames = configPromptNames = {}));
23
+ var attributePromptNames;
21
24
  (function (attributePromptNames) {
22
25
  attributePromptNames["projectName"] = "projectName";
23
26
  attributePromptNames["title"] = "title";
@@ -29,23 +32,23 @@ export var attributePromptNames;
29
32
  attributePromptNames["addDeployConfig"] = "addDeployConfig";
30
33
  attributePromptNames["addFlpConfig"] = "addFlpConfig";
31
34
  attributePromptNames["importKeyUserChanges"] = "importKeyUserChanges";
32
- })(attributePromptNames || (attributePromptNames = {}));
35
+ })(attributePromptNames || (exports.attributePromptNames = attributePromptNames = {}));
33
36
  /**
34
37
  * Enumeration of prompt names used in the key-user import.
35
38
  */
36
- export var keyUserPromptNames;
39
+ var keyUserPromptNames;
37
40
  (function (keyUserPromptNames) {
38
41
  keyUserPromptNames["keyUserSystem"] = "keyUserSystem";
39
42
  keyUserPromptNames["keyUserUsername"] = "keyUserUsername";
40
43
  keyUserPromptNames["keyUserPassword"] = "keyUserPassword";
41
44
  keyUserPromptNames["keyUserAdaptation"] = "keyUserAdaptation";
42
- })(keyUserPromptNames || (keyUserPromptNames = {}));
43
- export var targetEnvPromptNames;
45
+ })(keyUserPromptNames || (exports.keyUserPromptNames = keyUserPromptNames = {}));
46
+ var targetEnvPromptNames;
44
47
  (function (targetEnvPromptNames) {
45
48
  targetEnvPromptNames["targetEnv"] = "targetEnv";
46
- })(targetEnvPromptNames || (targetEnvPromptNames = {}));
47
- export const TargetEnv = { ABAP: 'ABAP', CF: 'CF' };
48
- export var cfLoginPromptNames;
49
+ })(targetEnvPromptNames || (exports.targetEnvPromptNames = targetEnvPromptNames = {}));
50
+ exports.TargetEnv = { ABAP: 'ABAP', CF: 'CF' };
51
+ var cfLoginPromptNames;
49
52
  (function (cfLoginPromptNames) {
50
53
  cfLoginPromptNames["cfLoggedInMainMessage"] = "cfLoggedInMainMessage";
51
54
  cfLoginPromptNames["cfLoggedApiEndpointMessage"] = "cfLoggedApiEndpointMessage";
@@ -54,10 +57,10 @@ export var cfLoginPromptNames;
54
57
  cfLoginPromptNames["cfLoggedInEndingMessage"] = "cfLoggedInEndingMessage";
55
58
  cfLoginPromptNames["cfExternalLogin"] = "cfExternalLogin";
56
59
  cfLoginPromptNames["cfExternalLoginSuccessMessage"] = "cfExternalLoginSuccessMessage";
57
- })(cfLoginPromptNames || (cfLoginPromptNames = {}));
58
- export var SystemType;
60
+ })(cfLoginPromptNames || (exports.cfLoginPromptNames = cfLoginPromptNames = {}));
61
+ var SystemType;
59
62
  (function (SystemType) {
60
63
  SystemType["CLOUD_READY"] = "cloudReady";
61
64
  SystemType["ON_PREM"] = "onPremise";
62
- })(SystemType || (SystemType = {}));
65
+ })(SystemType || (exports.SystemType = SystemType = {}));
63
66
  //# sourceMappingURL=types.js.map
@@ -1,8 +1,11 @@
1
- import { isAppStudio } from '@sap-ux/btp-utils';
2
- import { validateEmptyString } from '@sap-ux/project-input-validator';
3
- import { getConfiguredProvider } from '@sap-ux/adp-tooling';
4
- import { t } from '../../utils/i18n.js';
5
- import { configPromptNames } from '../../app/types.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCredentialsPrompts = getCredentialsPrompts;
4
+ const btp_utils_1 = require("@sap-ux/btp-utils");
5
+ const project_input_validator_1 = require("@sap-ux/project-input-validator");
6
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
7
+ const i18n_js_1 = require("../../utils/i18n.js");
8
+ const types_js_1 = require("../../app/types.js");
6
9
  /**
7
10
  * Returns the username prompt.
8
11
  *
@@ -10,7 +13,7 @@ import { configPromptNames } from '../../app/types.js';
10
13
  * @param {ToolsLogger} logger - The logger.
11
14
  * @returns {YUIQuestion<Credentials>[]} The username prompt.
12
15
  */
13
- export function getCredentialsPrompts(abapTarget, logger) {
16
+ function getCredentialsPrompts(abapTarget, logger) {
14
17
  return [getUsernamePrompt(), getPasswordPrompt(abapTarget, logger)];
15
18
  }
16
19
  /**
@@ -21,9 +24,9 @@ export function getCredentialsPrompts(abapTarget, logger) {
21
24
  function getUsernamePrompt() {
22
25
  return {
23
26
  type: 'input',
24
- name: configPromptNames.username,
25
- message: t('prompts.usernameLabel'),
26
- validate: validateEmptyString,
27
+ name: types_js_1.configPromptNames.username,
28
+ message: (0, i18n_js_1.t)('prompts.usernameLabel'),
29
+ validate: project_input_validator_1.validateEmptyString,
27
30
  guiOptions: {
28
31
  mandatory: true
29
32
  }
@@ -37,23 +40,23 @@ function getUsernamePrompt() {
37
40
  * @returns {PasswordQuestion<Credentials>} The password prompt.
38
41
  */
39
42
  function getPasswordPrompt(abapTarget, logger) {
40
- const system = (isAppStudio() ? abapTarget.destination : abapTarget.url) ?? '';
43
+ const system = ((0, btp_utils_1.isAppStudio)() ? abapTarget.destination : abapTarget.url) ?? '';
41
44
  return {
42
45
  type: 'password',
43
- name: configPromptNames.password,
44
- message: t('prompts.passwordLabel'),
46
+ name: types_js_1.configPromptNames.password,
47
+ message: (0, i18n_js_1.t)('prompts.passwordLabel'),
45
48
  mask: '*',
46
49
  guiOptions: {
47
50
  mandatory: true,
48
51
  type: 'login'
49
52
  },
50
53
  validate: async (value, answers) => {
51
- const validationResult = validateEmptyString(value);
54
+ const validationResult = (0, project_input_validator_1.validateEmptyString)(value);
52
55
  if (typeof validationResult === 'string') {
53
56
  return validationResult;
54
57
  }
55
58
  if (!answers.username) {
56
- return t('error.pleaseProvideAllRequiredData');
59
+ return (0, i18n_js_1.t)('error.pleaseProvideAllRequiredData');
57
60
  }
58
61
  try {
59
62
  const credentials = {
@@ -81,7 +84,7 @@ function getPasswordPrompt(abapTarget, logger) {
81
84
  * an error.
82
85
  */
83
86
  async function assertAuthenticated(credentials, logger) {
84
- const abapProvider = await getConfiguredProvider(credentials, logger);
87
+ const abapProvider = await (0, adp_tooling_1.getConfiguredProvider)(credentials, logger);
85
88
  const layeredRepositoryService = abapProvider.getLayeredRepository();
86
89
  await layeredRepositoryService.getCsrfToken();
87
90
  }
@@ -1,17 +1,22 @@
1
- import path from 'node:path';
2
- import { Prompts } from '@sap-devx/yeoman-ui-types';
3
- import { isAppStudio } from '@sap-ux/btp-utils';
4
- import { createAbapServiceProvider } from '@sap-ux/system-access';
5
- import { getVariant, getAdpConfig, ManifestService, ManifestServiceCF, SystemLookup, isCFEnvironment } from '@sap-ux/adp-tooling';
6
- import { initI18n } from '../utils/i18n.js';
7
- import SubGeneratorBase from './sub-gen-base.js';
8
- import { getCredentialsPrompts } from './questions/credentials.js';
9
- import { getSubGenAuthPages } from '../utils/steps.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_path_1 = __importDefault(require("node:path"));
7
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
8
+ const btp_utils_1 = require("@sap-ux/btp-utils");
9
+ const system_access_1 = require("@sap-ux/system-access");
10
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
11
+ const i18n_js_1 = require("../utils/i18n.js");
12
+ const sub_gen_base_js_1 = __importDefault(require("./sub-gen-base.js"));
13
+ const credentials_js_1 = require("./questions/credentials.js");
14
+ const steps_js_1 = require("../utils/steps.js");
10
15
  /**
11
16
  * Base class for *sub* generators that need authentication handling.
12
17
  * Adds functionality on top of {@link SubGeneratorBase}.
13
18
  */
14
- export default class SubGeneratorWithAuthBase extends SubGeneratorBase {
19
+ class SubGeneratorWithAuthBase extends sub_gen_base_js_1.default {
15
20
  /**
16
21
  * The ABAP target.
17
22
  */
@@ -72,21 +77,21 @@ export default class SubGeneratorWithAuthBase extends SubGeneratorBase {
72
77
  * Subclasses must call this to benefit from the built-in auth handling.
73
78
  */
74
79
  async onInit() {
75
- await initI18n();
76
- this.systemLookup = new SystemLookup(this.logger);
77
- this.isCFProject = await isCFEnvironment(this.projectPath);
80
+ await (0, i18n_js_1.initI18n)();
81
+ this.systemLookup = new adp_tooling_1.SystemLookup(this.logger);
82
+ this.isCFProject = await (0, adp_tooling_1.isCFEnvironment)(this.projectPath);
78
83
  if (this.isCFProject) {
79
84
  this.system = '';
80
85
  this.logger.log('CF project detected, will use build output for manifest');
81
- this._registerPrompts(new Prompts(getSubGenAuthPages(this.generatorType, this.system)));
86
+ this._registerPrompts(new yeoman_ui_types_1.Prompts((0, steps_js_1.getSubGenAuthPages)(this.generatorType, this.system)));
82
87
  this.prompts.splice(0, 1, []);
83
88
  return;
84
89
  }
85
- const adpConfig = await getAdpConfig(this.projectPath, path.join(this.projectPath, 'ui5.yaml'));
90
+ const adpConfig = await (0, adp_tooling_1.getAdpConfig)(this.projectPath, node_path_1.default.join(this.projectPath, 'ui5.yaml'));
86
91
  this.abapTarget = adpConfig.target;
87
- this.system = (isAppStudio() ? this.abapTarget.destination : this.abapTarget.url) ?? '';
92
+ this.system = ((0, btp_utils_1.isAppStudio)() ? this.abapTarget.destination : this.abapTarget.url) ?? '';
88
93
  this.logger.log(`Successfully retrieved abap target\n${JSON.stringify(this.abapTarget, null, 2)}`);
89
- this._registerPrompts(new Prompts(getSubGenAuthPages(this.generatorType, this.system)));
94
+ this._registerPrompts(new yeoman_ui_types_1.Prompts((0, steps_js_1.getSubGenAuthPages)(this.generatorType, this.system)));
90
95
  try {
91
96
  this.requiresAuth = await this.systemLookup.getSystemRequiresAuth(this.system);
92
97
  this.logger.log(`System ${this.system} requires authentication: ${this.requiresAuth}`);
@@ -107,20 +112,20 @@ export default class SubGeneratorWithAuthBase extends SubGeneratorBase {
107
112
  * @returns {Promise<Manifest>} The manifest.
108
113
  */
109
114
  async getManifest() {
110
- this.variant = await getVariant(this.projectPath);
115
+ this.variant = await (0, adp_tooling_1.getVariant)(this.projectPath);
111
116
  if (this.isCFProject) {
112
- this.manifestService = await ManifestServiceCF.init(this.projectPath, this.logger);
117
+ this.manifestService = await adp_tooling_1.ManifestServiceCF.init(this.projectPath, this.logger);
113
118
  }
114
119
  else {
115
120
  let requestOptions;
116
121
  if (this.requiresAuth) {
117
- const credentials = (await this.prompt(getCredentialsPrompts(this.abapTarget, this.logger)));
122
+ const credentials = (await this.prompt((0, credentials_js_1.getCredentialsPrompts)(this.abapTarget, this.logger)));
118
123
  requestOptions = { auth: { username: credentials.username, password: credentials.password } };
119
124
  }
120
- const yamlPath = path.join(this.projectPath, 'ui5.yaml');
121
- const { target, ignoreCertErrors = false } = await getAdpConfig(this.projectPath, yamlPath);
122
- const provider = await createAbapServiceProvider(target, { ...requestOptions, ignoreCertErrors }, true, this.logger);
123
- this.manifestService = await ManifestService.initMergedManifest(provider, this.projectPath, this.variant, this.logger);
125
+ const yamlPath = node_path_1.default.join(this.projectPath, 'ui5.yaml');
126
+ const { target, ignoreCertErrors = false } = await (0, adp_tooling_1.getAdpConfig)(this.projectPath, yamlPath);
127
+ const provider = await (0, system_access_1.createAbapServiceProvider)(target, { ...requestOptions, ignoreCertErrors }, true, this.logger);
128
+ this.manifestService = await adp_tooling_1.ManifestService.initMergedManifest(provider, this.projectPath, this.variant, this.logger);
124
129
  }
125
130
  const manifest = this.manifestService.getManifest();
126
131
  const oDataSources = this.manifestService.getManifestDataSources();
@@ -138,4 +143,5 @@ export default class SubGeneratorWithAuthBase extends SubGeneratorBase {
138
143
  return manifest;
139
144
  }
140
145
  }
146
+ exports.default = SubGeneratorWithAuthBase;
141
147
  //# sourceMappingURL=sub-gen-auth-base.js.map
@@ -1,12 +1,17 @@
1
- import Generator from 'yeoman-generator';
2
- import { AppWizard } from '@sap-devx/yeoman-ui-types';
3
- import { t } from '../utils/i18n.js';
4
- import { setHeaderTitle } from '../utils/opts.js';
5
- import AdpGeneratorLogger from '../utils/logger.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
7
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
8
+ const i18n_js_1 = require("../utils/i18n.js");
9
+ const opts_js_1 = require("../utils/opts.js");
10
+ const logger_js_1 = __importDefault(require("../utils/logger.js"));
6
11
  /**
7
12
  * Shared base class for all ADP generators.
8
13
  */
9
- export default class SubGeneratorBase extends Generator {
14
+ class SubGeneratorBase extends yeoman_generator_1.default {
10
15
  setPromptsCallback;
11
16
  prompts;
12
17
  /**
@@ -41,10 +46,10 @@ export default class SubGeneratorBase extends Generator {
41
46
  constructor(args, opts, type) {
42
47
  super(args, opts);
43
48
  this.type = type;
44
- this.appWizard = opts.appWizard ?? AppWizard.create(opts);
45
- AdpGeneratorLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
46
- this.logger = AdpGeneratorLogger.logger;
47
- setHeaderTitle(opts, this.logger, this.type);
49
+ this.appWizard = opts.appWizard ?? yeoman_ui_types_1.AppWizard.create(opts);
50
+ logger_js_1.default.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
51
+ this.logger = logger_js_1.default.logger;
52
+ (0, opts_js_1.setHeaderTitle)(opts, this.logger, this.type);
48
53
  this.setPromptsCallback = (fn) => {
49
54
  // Persist callback so we can attach it once prompts are created
50
55
  this.pendingPromptsCallback = fn;
@@ -86,7 +91,7 @@ export default class SubGeneratorBase extends Generator {
86
91
  return {
87
92
  type: 'input',
88
93
  name: 'errorMessagePrompt',
89
- message: t('error.backendCommunicationError'),
94
+ message: (0, i18n_js_1.t)('error.backendCommunicationError'),
90
95
  guiOptions: {
91
96
  type: 'label',
92
97
  hint: errorMessage
@@ -95,4 +100,5 @@ export default class SubGeneratorBase extends Generator {
95
100
  };
96
101
  }
97
102
  }
103
+ exports.default = SubGeneratorBase;
98
104
  //# sourceMappingURL=sub-gen-base.js.map