@sap-ux/cf-deploy-config-inquirer 0.6.7 → 1.0.1

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/i18n.js CHANGED
@@ -1,31 +1,23 @@
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
- exports.i18n = exports.defaultProjectNumber = void 0;
7
- exports.initI18nCfDeployConfigInquirer = initI18nCfDeployConfigInquirer;
8
- exports.t = t;
9
- const i18next_1 = __importDefault(require("i18next"));
10
- const cf_deploy_config_inquirer_i18n_json_1 = __importDefault(require("./translations/cf-deploy-config-inquirer.i18n.json"));
1
+ import i18next from 'i18next';
2
+ import translations from './translations/cf-deploy-config-inquirer.i18n.json' with { type: 'json' };
11
3
  const cfInquirerNamespace = 'cf-deploy-config-inquirer';
12
- exports.defaultProjectNumber = 1;
13
- exports.i18n = i18next_1.default.createInstance();
4
+ export const defaultProjectNumber = 1;
5
+ export const i18n = i18next.createInstance();
14
6
  /**
15
7
  * Initialize i18next with the translations for this module.
16
8
  */
17
- async function initI18nCfDeployConfigInquirer() {
18
- await exports.i18n.init({
9
+ export async function initI18nCfDeployConfigInquirer() {
10
+ await i18n.init({
19
11
  lng: 'en',
20
12
  fallbackLng: 'en',
21
13
  interpolation: {
22
14
  defaultVariables: {
23
- defaultProjectNumber: exports.defaultProjectNumber
15
+ defaultProjectNumber
24
16
  }
25
17
  },
26
18
  showSupportNotice: false
27
19
  });
28
- exports.i18n.addResourceBundle('en', cfInquirerNamespace, cf_deploy_config_inquirer_i18n_json_1.default);
20
+ i18n.addResourceBundle('en', cfInquirerNamespace, translations);
29
21
  }
30
22
  /**
31
23
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -34,13 +26,11 @@ async function initI18nCfDeployConfigInquirer() {
34
26
  * @param options additional options
35
27
  * @returns {string} localized string stored for the given key
36
28
  */
37
- function t(key, options) {
29
+ export function t(key, options) {
38
30
  if (!options?.ns) {
39
31
  options = Object.assign(options ?? {}, { ns: cfInquirerNamespace });
40
32
  }
41
- return exports.i18n.t(key, options);
33
+ return i18n.t(key, options);
42
34
  }
43
- initI18nCfDeployConfigInquirer().catch(() => {
44
- // Needed for lint
45
- });
35
+ void initI18nCfDeployConfigInquirer().catch(() => undefined);
46
36
  //# sourceMappingURL=i18n.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { CfDeployConfigPromptOptions, CfDeployConfigQuestions, CfSystemChoice, CfDeployConfigAnswers, CfAppRouterDeployConfigPromptOptions, CfAppRouterDeployConfigQuestions, CfAppRouterDeployConfigAnswers, CfDeployConfigRouterAnswers, CfDeployConfigRouterQuestions } from './types';
2
- import { promptNames, appRouterPromptNames, RouterModuleType } from './types';
1
+ import type { CfDeployConfigPromptOptions, CfDeployConfigQuestions, CfSystemChoice, CfDeployConfigAnswers, CfAppRouterDeployConfigPromptOptions, CfAppRouterDeployConfigQuestions, CfAppRouterDeployConfigAnswers, CfDeployConfigRouterAnswers, CfDeployConfigRouterQuestions } from './types.js';
2
+ import { promptNames, appRouterPromptNames, RouterModuleType } from './types.js';
3
3
  import type { InquirerAdapter } from '@sap-ux/inquirer-common';
4
4
  import type { Logger } from '@sap-ux/logger';
5
5
  /**
package/dist/index.js CHANGED
@@ -1,20 +1,8 @@
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
- exports.RouterModuleType = exports.appRouterPromptNames = exports.promptNames = void 0;
7
- exports.getPrompts = getPrompts;
8
- exports.prompt = prompt;
9
- exports.getAppRouterPrompts = getAppRouterPrompts;
10
- const prompts_1 = require("./prompts");
11
- const types_1 = require("./types");
12
- Object.defineProperty(exports, "promptNames", { enumerable: true, get: function () { return types_1.promptNames; } });
13
- Object.defineProperty(exports, "appRouterPromptNames", { enumerable: true, get: function () { return types_1.appRouterPromptNames; } });
14
- Object.defineProperty(exports, "RouterModuleType", { enumerable: true, get: function () { return types_1.RouterModuleType; } });
15
- const i18n_1 = require("./i18n");
16
- const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
17
- const logger_helper_1 = __importDefault(require("./logger-helper"));
1
+ import { getQuestions, getAppRouterQuestions } from './prompts/index.js';
2
+ import { promptNames, appRouterPromptNames, RouterModuleType } from './types.js';
3
+ import { initI18nCfDeployConfigInquirer } from './i18n.js';
4
+ import autocomplete from 'inquirer-autocomplete-prompt';
5
+ import LoggerHelper from './logger-helper.js';
18
6
  /**
19
7
  * Retrieves Cloud Foundry deployment configuration prompts.
20
8
  *
@@ -26,10 +14,10 @@ const logger_helper_1 = __importDefault(require("./logger-helper"));
26
14
  */
27
15
  async function getPrompts(promptOptions, logger) {
28
16
  if (logger) {
29
- logger_helper_1.default.logger = logger;
17
+ LoggerHelper.logger = logger;
30
18
  }
31
- await (0, i18n_1.initI18nCfDeployConfigInquirer)();
32
- return (0, prompts_1.getQuestions)(promptOptions, logger_helper_1.default.logger);
19
+ await initI18nCfDeployConfigInquirer();
20
+ return getQuestions(promptOptions, LoggerHelper.logger);
33
21
  }
34
22
  /**
35
23
  * Retrieves the application router configuration prompts.
@@ -41,10 +29,10 @@ async function getPrompts(promptOptions, logger) {
41
29
  */
42
30
  async function getAppRouterPrompts(promptOptions, logger) {
43
31
  if (logger) {
44
- logger_helper_1.default.logger = logger;
32
+ LoggerHelper.logger = logger;
45
33
  }
46
- await (0, i18n_1.initI18nCfDeployConfigInquirer)();
47
- return (0, prompts_1.getAppRouterQuestions)(promptOptions, logger_helper_1.default.logger);
34
+ await initI18nCfDeployConfigInquirer();
35
+ return getAppRouterQuestions(promptOptions, LoggerHelper.logger);
48
36
  }
49
37
  /**
50
38
  * Prompt for cf inquirer inputs.
@@ -56,11 +44,12 @@ async function getAppRouterPrompts(promptOptions, logger) {
56
44
  */
57
45
  async function prompt(adapter, promptOptions, logger) {
58
46
  const cfPrompts = await getPrompts(promptOptions, logger);
59
- if (adapter?.promptModule && promptOptions[types_1.promptNames.destinationName]?.useAutocomplete) {
47
+ if (adapter?.promptModule && promptOptions[promptNames.destinationName]?.useAutocomplete) {
60
48
  const pm = adapter.promptModule;
61
- pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
49
+ pm.registerPrompt('autocomplete', autocomplete);
62
50
  }
63
51
  const answers = await adapter.prompt(cfPrompts);
64
52
  return answers;
65
53
  }
54
+ export { getPrompts, promptNames, prompt, appRouterPromptNames, getAppRouterPrompts, RouterModuleType };
66
55
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("@sap-ux/logger");
1
+ import { ToolsLogger } from '@sap-ux/logger';
4
2
  /**
5
3
  * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
4
  */
7
- class LoggerHelper {
8
- static _logger = new logger_1.ToolsLogger({ logPrefix: '@sap-ux/cf-deploy-config-inquirer' });
5
+ export default class LoggerHelper {
6
+ static _logger = new ToolsLogger({ logPrefix: '@sap-ux/cf-deploy-config-inquirer' });
9
7
  /**
10
8
  * Get the logger.
11
9
  *
@@ -23,5 +21,4 @@ class LoggerHelper {
23
21
  LoggerHelper._logger = value;
24
22
  }
25
23
  }
26
- exports.default = LoggerHelper;
27
24
  //# sourceMappingURL=logger-helper.js.map
@@ -1,4 +1,4 @@
1
- import type { CfAppRouterDeployConfigQuestions, CfAppRouterDeployConfigPromptOptions } from '../types';
1
+ import type { CfAppRouterDeployConfigQuestions, CfAppRouterDeployConfigPromptOptions } from '../types.js';
2
2
  import type { Logger } from '@sap-ux/logger';
3
3
  /**
4
4
  * Retrieves a list of deployment questions based on the application root and prompt options.
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppRouterQuestions = getAppRouterQuestions;
4
- const i18n_1 = require("../i18n");
5
- const types_1 = require("../types");
6
- const validators_1 = require("./validators");
7
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
1
+ import { t } from '../i18n.js';
2
+ import { appRouterPromptNames, RouterModuleType } from '../types.js';
3
+ import { validateMtaPath, validateMtaId, validateAbapService } from './validators.js';
4
+ import { getCFAbapInstanceChoices, ErrorHandler } from '@sap-ux/inquirer-common';
8
5
  /**
9
6
  * Generates a prompt for selecting the MTA path.
10
7
  *
@@ -16,12 +13,12 @@ function getMtaPathPrompt(mtaPath) {
16
13
  type: 'input',
17
14
  guiOptions: {
18
15
  type: 'folder-browser',
19
- breadcrumb: (0, i18n_1.t)('prompts.mtaPathBreadcrumbMessage')
16
+ breadcrumb: t('prompts.mtaPathBreadcrumbMessage')
20
17
  },
21
- name: types_1.appRouterPromptNames.mtaPath,
22
- message: (0, i18n_1.t)('prompts.mtaPathMessage'),
18
+ name: appRouterPromptNames.mtaPath,
19
+ message: t('prompts.mtaPathMessage'),
23
20
  default: () => mtaPath,
24
- validate: (input) => (0, validators_1.validateMtaPath)(input)
21
+ validate: (input) => validateMtaPath(input)
25
22
  };
26
23
  }
27
24
  /**
@@ -36,9 +33,9 @@ function getMtaIdPrompt() {
36
33
  mandatory: true,
37
34
  breadcrumb: true
38
35
  },
39
- name: types_1.appRouterPromptNames.mtaId,
40
- message: (0, i18n_1.t)('prompts.mtaIdMessage'),
41
- validate: (input, previousAnswers) => (0, validators_1.validateMtaId)(input, previousAnswers),
36
+ name: appRouterPromptNames.mtaId,
37
+ message: t('prompts.mtaIdMessage'),
38
+ validate: (input, previousAnswers) => validateMtaId(input, previousAnswers),
42
39
  filter: (input) => input.replace(/\./g, '-')
43
40
  };
44
41
  }
@@ -50,11 +47,11 @@ function getMtaIdPrompt() {
50
47
  function getMtaDescriptionPrompt() {
51
48
  return {
52
49
  type: 'input',
53
- name: types_1.appRouterPromptNames.mtaDescription,
50
+ name: appRouterPromptNames.mtaDescription,
54
51
  guiOptions: {
55
52
  breadcrumb: true
56
53
  },
57
- message: (0, i18n_1.t)('prompts.mtaDescriptionMessage'),
54
+ message: t('prompts.mtaDescriptionMessage'),
58
55
  filter: (input) => input?.trim() ?? 'Fiori elements app'
59
56
  };
60
57
  }
@@ -66,7 +63,7 @@ function getMtaDescriptionPrompt() {
66
63
  function getMtaVersionPrompt() {
67
64
  return {
68
65
  default: '0.0.1',
69
- name: types_1.appRouterPromptNames.mtaVersion
66
+ name: appRouterPromptNames.mtaVersion
70
67
  };
71
68
  }
72
69
  /**
@@ -80,17 +77,17 @@ function getMtaVersionPrompt() {
80
77
  function getRouterTypePrompt() {
81
78
  return {
82
79
  type: 'list',
83
- name: types_1.appRouterPromptNames.routerType,
80
+ name: appRouterPromptNames.routerType,
84
81
  guiOptions: {
85
82
  mandatory: true,
86
83
  breadcrumb: true
87
84
  },
88
- default: () => types_1.RouterModuleType.Managed, // Should always be the preferred choice
89
- message: (0, i18n_1.t)('prompts.routerTypeMessage'),
85
+ default: () => RouterModuleType.Managed, // Should always be the preferred choice
86
+ message: t('prompts.routerTypeMessage'),
90
87
  choices: [
91
- { name: (0, i18n_1.t)('routerType.managedAppRouter'), value: types_1.RouterModuleType.Managed },
92
- { name: (0, i18n_1.t)('routerType.appFrontAppService'), value: types_1.RouterModuleType.AppFront },
93
- { name: (0, i18n_1.t)('routerType.standaloneAppRouter'), value: types_1.RouterModuleType.Standard }
88
+ { name: t('routerType.managedAppRouter'), value: RouterModuleType.Managed },
89
+ { name: t('routerType.appFrontAppService'), value: RouterModuleType.AppFront },
90
+ { name: t('routerType.standaloneAppRouter'), value: RouterModuleType.Standard }
94
91
  ]
95
92
  };
96
93
  }
@@ -104,13 +101,13 @@ function getRouterTypePrompt() {
104
101
  */
105
102
  function getConnectivityServicePrompt() {
106
103
  return {
107
- when: (previousAnswers) => previousAnswers.routerType === types_1.RouterModuleType.Standard,
104
+ when: (previousAnswers) => previousAnswers.routerType === RouterModuleType.Standard,
108
105
  type: 'confirm',
109
- name: types_1.appRouterPromptNames.addConnectivityService,
106
+ name: appRouterPromptNames.addConnectivityService,
110
107
  guiOptions: {
111
- breadcrumb: (0, i18n_1.t)('prompts.addConnectivityServiceBreadcrumbMessage')
108
+ breadcrumb: t('prompts.addConnectivityServiceBreadcrumbMessage')
112
109
  },
113
- message: (0, i18n_1.t)('prompts.addConnectivityMessage'),
110
+ message: t('prompts.addConnectivityMessage'),
114
111
  default: () => {
115
112
  return false;
116
113
  }
@@ -126,10 +123,10 @@ function getConnectivityServicePrompt() {
126
123
  */
127
124
  function getDestinationService() {
128
125
  return {
129
- when: (previousAnswers) => previousAnswers.routerType === types_1.RouterModuleType.Standard,
126
+ when: (previousAnswers) => previousAnswers.routerType === RouterModuleType.Standard,
130
127
  type: 'confirm',
131
- name: types_1.appRouterPromptNames.addABAPServiceBinding,
132
- message: (0, i18n_1.t)('prompts.serviceAdvancedOptionMessage'),
128
+ name: appRouterPromptNames.addABAPServiceBinding,
129
+ message: t('prompts.serviceAdvancedOptionMessage'),
133
130
  default: () => {
134
131
  return false;
135
132
  }
@@ -143,18 +140,18 @@ function getDestinationService() {
143
140
  * @returns {CfAppRouterDeployConfigQuestions} - The prompt configuration object for selecting for selecting an ABAP environment service.
144
141
  */
145
142
  function getServiceProvider() {
146
- const errorHandler = new inquirer_common_1.ErrorHandler(undefined, undefined, '@sap-ux/cf-deploy-config-inquirer');
143
+ const errorHandler = new ErrorHandler(undefined, undefined, '@sap-ux/cf-deploy-config-inquirer');
147
144
  return {
148
145
  when: (previousAnswers) => {
149
- return !!previousAnswers.addABAPServiceBinding && previousAnswers.routerType === types_1.RouterModuleType.Standard;
146
+ return !!previousAnswers.addABAPServiceBinding && previousAnswers.routerType === RouterModuleType.Standard;
150
147
  },
151
148
  type: 'list',
152
- name: types_1.appRouterPromptNames.abapServiceProvider,
149
+ name: appRouterPromptNames.abapServiceProvider,
153
150
  guiOptions: {
154
- breadcrumb: (0, i18n_1.t)('prompts.abapEnvBindingBreadcrumbMessage')
151
+ breadcrumb: t('prompts.abapEnvBindingBreadcrumbMessage')
155
152
  },
156
153
  choices: async () => {
157
- const abapChoices = await (0, inquirer_common_1.getCFAbapInstanceChoices)(errorHandler);
154
+ const abapChoices = await getCFAbapInstanceChoices(errorHandler);
158
155
  const choices = [];
159
156
  if (abapChoices.length > 0) {
160
157
  abapChoices.forEach((choice) => {
@@ -165,13 +162,13 @@ function getServiceProvider() {
165
162
  });
166
163
  }
167
164
  else {
168
- choices.push({ name: (0, i18n_1.t)('errors.abapEnvsUnavailable'), value: 'NO_ABAP_ENVS' });
165
+ choices.push({ name: t('errors.abapEnvsUnavailable'), value: 'NO_ABAP_ENVS' });
169
166
  }
170
167
  return choices;
171
168
  },
172
- message: (0, i18n_1.t)('prompts.selectServiceMessage'),
173
- default: () => (0, i18n_1.t)('errors.abapEnvsUnavailable'),
174
- validate: (choice) => (0, validators_1.validateAbapService)(choice, errorHandler)
169
+ message: t('prompts.selectServiceMessage'),
170
+ default: () => t('errors.abapEnvsUnavailable'),
171
+ validate: (choice) => validateAbapService(choice, errorHandler)
175
172
  };
176
173
  }
177
174
  /**
@@ -181,26 +178,26 @@ function getServiceProvider() {
181
178
  * @param {Logger} [log] - The logger instance to use for logging.
182
179
  * @returns {CfAppRouterDeployConfigQuestions[]} Returns an array of questions related to cf deployment configuration.
183
180
  */
184
- async function getAppRouterQuestions(promptOptions, log) {
185
- const mtaPath = promptOptions[types_1.appRouterPromptNames.mtaPath];
181
+ export async function getAppRouterQuestions(promptOptions, log) {
182
+ const mtaPath = promptOptions[appRouterPromptNames.mtaPath];
186
183
  // add mta path prompt to question array
187
184
  const questions = [];
188
185
  questions.push(getMtaPathPrompt(mtaPath));
189
186
  // Mapping of options
190
187
  const questionMapping = [
191
- { key: types_1.appRouterPromptNames.mtaId, getQuestion: getMtaIdPrompt },
192
- { key: types_1.appRouterPromptNames.mtaDescription, getQuestion: getMtaDescriptionPrompt },
193
- { key: types_1.appRouterPromptNames.mtaVersion, getQuestion: getMtaVersionPrompt },
194
- { key: types_1.appRouterPromptNames.routerType, getQuestion: getRouterTypePrompt },
188
+ { key: appRouterPromptNames.mtaId, getQuestion: getMtaIdPrompt },
189
+ { key: appRouterPromptNames.mtaDescription, getQuestion: getMtaDescriptionPrompt },
190
+ { key: appRouterPromptNames.mtaVersion, getQuestion: getMtaVersionPrompt },
191
+ { key: appRouterPromptNames.routerType, getQuestion: getRouterTypePrompt },
195
192
  {
196
- key: types_1.appRouterPromptNames.addConnectivityService,
193
+ key: appRouterPromptNames.addConnectivityService,
197
194
  getQuestion: getConnectivityServicePrompt,
198
- logMessage: (0, i18n_1.t)('info.addConnectivityService')
195
+ logMessage: t('info.addConnectivityService')
199
196
  },
200
197
  {
201
- key: types_1.appRouterPromptNames.addABAPServiceBinding,
198
+ key: appRouterPromptNames.addABAPServiceBinding,
202
199
  getQuestion: getDestinationService,
203
- logMessage: (0, i18n_1.t)('info.addABAPServiceBinding')
200
+ logMessage: t('info.addABAPServiceBinding')
204
201
  }
205
202
  ];
206
203
  // Iterate over the mapping to add questions
@@ -208,13 +205,13 @@ async function getAppRouterQuestions(promptOptions, log) {
208
205
  const shouldAddQuestion = promptOptions[key] ?? false;
209
206
  if (shouldAddQuestion) {
210
207
  if (logMessage) {
211
- log?.info((0, i18n_1.t)(logMessage));
208
+ log?.info(t(logMessage));
212
209
  }
213
210
  questions.push(getQuestion());
214
211
  }
215
212
  }
216
213
  // Add prompts for selecting abap environment if addABAPServiceBinding is true
217
- if (promptOptions[types_1.appRouterPromptNames.addABAPServiceBinding]) {
214
+ if (promptOptions[appRouterPromptNames.addABAPServiceBinding]) {
218
215
  questions.push(getServiceProvider());
219
216
  }
220
217
  return questions;
@@ -1,3 +1,3 @@
1
- export * from './prompts';
2
- export * from './app-router-prompts';
1
+ export * from './prompts.js';
2
+ export * from './app-router-prompts.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./prompts"), exports);
18
- __exportStar(require("./app-router-prompts"), exports);
1
+ export * from './prompts.js';
2
+ export * from './app-router-prompts.js';
19
3
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { CfSystemChoice } from '../types';
1
+ import type { CfSystemChoice } from '../types.js';
2
2
  import { type Destinations } from '@sap-ux/btp-utils';
3
3
  /**
4
4
  * Retrieves an array of Cloud Foundry system choices.
@@ -1,13 +1,6 @@
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
- exports.getCfSystemChoices = getCfSystemChoices;
7
- exports.fetchBTPDestinations = fetchBTPDestinations;
8
- const btp_utils_1 = require("@sap-ux/btp-utils");
9
- const logger_helper_1 = __importDefault(require("../logger-helper"));
10
- const i18n_1 = require("../i18n");
1
+ import { isAppStudio, listDestinations, getDisplayName, isAbapEnvironmentOnBtp } from '@sap-ux/btp-utils';
2
+ import LoggerHelper from '../logger-helper.js';
3
+ import { t } from '../i18n.js';
11
4
  /**
12
5
  * Generates a sorted list of Cloud Foundry system destination choices from provided destinations.
13
6
  *
@@ -19,9 +12,9 @@ function createDestinationChoices(destinations = {}) {
19
12
  .filter((destination) => destination && typeof destination.Name === 'string' && typeof destination.Host === 'string')
20
13
  .sort((a, b) => a.Name.localeCompare(b.Name, undefined, { numeric: true, caseFirst: 'lower' }))
21
14
  .map((destination) => ({
22
- name: `${(0, btp_utils_1.getDisplayName)(destination) ?? 'Unknown'} - ${destination.Host}`,
15
+ name: `${getDisplayName(destination) ?? 'Unknown'} - ${destination.Host}`,
23
16
  value: destination.Name,
24
- scp: (0, btp_utils_1.isAbapEnvironmentOnBtp)(destination) || false,
17
+ scp: isAbapEnvironmentOnBtp(destination) || false,
25
18
  url: destination.Host
26
19
  }));
27
20
  }
@@ -31,7 +24,7 @@ function createDestinationChoices(destinations = {}) {
31
24
  * @param {Destinations} [destinations] - Optional destinations object retrieved from BTP.
32
25
  * @returns {Promise<CfSystemChoice[]>} - List of system choices formatted for selection prompts.
33
26
  */
34
- async function getCfSystemChoices(destinations) {
27
+ export async function getCfSystemChoices(destinations) {
35
28
  return destinations ? createDestinationChoices(destinations) : [];
36
29
  }
37
30
  /**
@@ -39,12 +32,12 @@ async function getCfSystemChoices(destinations) {
39
32
  *
40
33
  * @returns {Promise<Destinations | undefined>} - A promise resolving to a list of destinations or undefined if not in BAS.
41
34
  */
42
- async function fetchBTPDestinations() {
43
- if ((0, btp_utils_1.isAppStudio)()) {
44
- const destinations = await (0, btp_utils_1.listDestinations)({ stripS4HCApiHosts: true });
35
+ export async function fetchBTPDestinations() {
36
+ if (isAppStudio()) {
37
+ const destinations = await listDestinations({ stripS4HCApiHosts: true });
45
38
  return destinations;
46
39
  }
47
- logger_helper_1.default.logger.warn((0, i18n_1.t)('warning.btpDestinationListWarning'));
40
+ LoggerHelper.logger.warn(t('warning.btpDestinationListWarning'));
48
41
  return undefined;
49
42
  }
50
43
  //# sourceMappingURL=prompt-helpers.js.map
@@ -1,4 +1,4 @@
1
- import { type CfDeployConfigPromptOptions, type CfDeployConfigQuestions } from '../types';
1
+ import { type CfDeployConfigPromptOptions, type CfDeployConfigQuestions } from '../types.js';
2
2
  import type { Logger } from '@sap-ux/logger';
3
3
  /**
4
4
  * Retrieves a list of deployment questions based on the application root and prompt options.
@@ -1,46 +1,10 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getQuestions = getQuestions;
37
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
38
- const i18n_1 = require("../i18n");
39
- const types_1 = require("../types");
40
- const validators = __importStar(require("./validators"));
41
- const btp_utils_1 = require("@sap-ux/btp-utils");
42
- const prompt_helpers_1 = require("./prompt-helpers");
43
- const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
1
+ import { searchChoices } from '@sap-ux/inquirer-common';
2
+ import { t } from '../i18n.js';
3
+ import { RouterModuleType, promptNames } from '../types.js';
4
+ import * as validators from './validators.js';
5
+ import { isAppStudio } from '@sap-ux/btp-utils';
6
+ import { getCfSystemChoices, fetchBTPDestinations } from './prompt-helpers.js';
7
+ import { Severity } from '@sap-devx/yeoman-ui-types';
44
8
  /**
45
9
  * Retrieves the prompt configuration for selecting a Cloud Foundry destination name.
46
10
  *
@@ -67,9 +31,9 @@ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
67
31
  */
68
32
  async function getDestinationNamePrompt(destinationOptions) {
69
33
  const { hint = false, additionalChoiceList = [], defaultValue, useAutocomplete = false, addBTPDestinationList = true } = destinationOptions;
70
- const isBAS = (0, btp_utils_1.isAppStudio)();
71
- const destinations = addBTPDestinationList ? await (0, prompt_helpers_1.fetchBTPDestinations)() : {};
72
- const destinationList = [...additionalChoiceList, ...(await (0, prompt_helpers_1.getCfSystemChoices)(destinations))];
34
+ const isBAS = isAppStudio();
35
+ const destinations = addBTPDestinationList ? await fetchBTPDestinations() : {};
36
+ const destinationList = [...additionalChoiceList, ...(await getCfSystemChoices(destinations))];
73
37
  // If BAS is used or additional choices are provided, the prompt should be a list
74
38
  // If VsCode is used and additional choices are not provided, the prompt should be an input field
75
39
  // If VsCode is used and additional choices are provided, the prompt should be a list
@@ -79,16 +43,16 @@ async function getDestinationNamePrompt(destinationOptions) {
79
43
  return {
80
44
  guiOptions: {
81
45
  mandatory: !isBAS,
82
- breadcrumb: (0, i18n_1.t)('prompts.destinationNameMessage')
46
+ breadcrumb: t('prompts.destinationNameMessage')
83
47
  },
84
48
  type: promptType,
85
49
  default: () => defaultValue,
86
- name: types_1.promptNames.destinationName,
87
- message: () => (hint ? (0, i18n_1.t)('prompts.directBindingDestinationHint') : (0, i18n_1.t)('prompts.destinationNameMessage')),
50
+ name: promptNames.destinationName,
51
+ message: () => (hint ? t('prompts.directBindingDestinationHint') : t('prompts.destinationNameMessage')),
88
52
  validate: (destination) => {
89
53
  return validators.validateDestinationQuestion(destination, !destination && isBAS);
90
54
  },
91
- source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, destinationList),
55
+ source: (prevAnswers, input) => searchChoices(input, destinationList),
92
56
  choices: () => destinationList
93
57
  };
94
58
  }
@@ -104,11 +68,11 @@ async function getDestinationNamePrompt(destinationOptions) {
104
68
  function getAddManagedAppRouterPrompt() {
105
69
  return {
106
70
  type: 'confirm',
107
- name: types_1.promptNames.addManagedAppRouter,
71
+ name: promptNames.addManagedAppRouter,
108
72
  guiOptions: {
109
- breadcrumb: (0, i18n_1.t)('prompts.addApplicationRouterBreadcrumbMessage')
73
+ breadcrumb: t('prompts.addApplicationRouterBreadcrumbMessage')
110
74
  },
111
- message: () => (0, i18n_1.t)('prompts.generateManagedApplicationToRouterMessage'),
75
+ message: () => t('prompts.generateManagedApplicationToRouterMessage'),
112
76
  default: () => true
113
77
  };
114
78
  }
@@ -119,14 +83,14 @@ function getAddManagedAppRouterPrompt() {
119
83
  function getOverwritePrompt() {
120
84
  return {
121
85
  type: 'confirm',
122
- name: types_1.promptNames.overwriteCfConfig,
86
+ name: promptNames.overwriteCfConfig,
123
87
  guiOptions: {
124
- hint: (0, i18n_1.t)('prompts.overwriteHintMessage')
88
+ hint: t('prompts.overwriteHintMessage')
125
89
  },
126
90
  default: () => {
127
91
  return true;
128
92
  },
129
- message: () => (0, i18n_1.t)('prompts.overwriteMessage')
93
+ message: () => t('prompts.overwriteMessage')
130
94
  };
131
95
  }
132
96
  /**
@@ -136,26 +100,26 @@ function getOverwritePrompt() {
136
100
  function getRouterOptionsPrompt() {
137
101
  return {
138
102
  type: 'list',
139
- name: types_1.promptNames.routerType,
103
+ name: promptNames.routerType,
140
104
  guiOptions: {
141
105
  mandatory: true,
142
- breadcrumb: (0, i18n_1.t)('prompts.generateDeploymentRouterOptionsMessage')
106
+ breadcrumb: t('prompts.generateDeploymentRouterOptionsMessage')
143
107
  },
144
- default: () => types_1.RouterModuleType.Managed, // Should always be the preferred choice
145
- message: () => (0, i18n_1.t)('prompts.generateDeploymentRouterOptionsMessage'),
108
+ default: () => RouterModuleType.Managed, // Should always be the preferred choice
109
+ message: () => t('prompts.generateDeploymentRouterOptionsMessage'),
146
110
  additionalMessages: (selectedRouter) => {
147
111
  let additionalMessage;
148
- if (selectedRouter && selectedRouter === types_1.RouterModuleType.AppFront) {
112
+ if (selectedRouter && selectedRouter === RouterModuleType.AppFront) {
149
113
  additionalMessage = {
150
- message: (0, i18n_1.t)('warning.appFrontendServiceRouterChoice'),
151
- severity: yeoman_ui_types_1.Severity.warning
114
+ message: t('warning.appFrontendServiceRouterChoice'),
115
+ severity: Severity.warning
152
116
  };
153
117
  }
154
118
  return additionalMessage;
155
119
  },
156
120
  choices: [
157
- { name: (0, i18n_1.t)('prompts.routerType.managedAppRouter'), value: types_1.RouterModuleType.Managed },
158
- { name: (0, i18n_1.t)('prompts.routerType.appFrontAppService'), value: types_1.RouterModuleType.AppFront }
121
+ { name: t('prompts.routerType.managedAppRouter'), value: RouterModuleType.Managed },
122
+ { name: t('prompts.routerType.appFrontAppService'), value: RouterModuleType.AppFront }
159
123
  ]
160
124
  };
161
125
  }
@@ -166,8 +130,8 @@ function getRouterOptionsPrompt() {
166
130
  * @param {Logger} [log] - The logger instance to use for logging.
167
131
  * @returns {CfDeployConfigQuestions[]} Returns an array of questions related to cf deployment configuration.
168
132
  */
169
- async function getQuestions(promptOptions, log) {
170
- const destinationOptions = promptOptions[types_1.promptNames.destinationName];
133
+ export async function getQuestions(promptOptions, log) {
134
+ const destinationOptions = promptOptions[promptNames.destinationName];
171
135
  const addOverwriteQuestion = !promptOptions.overwriteCfConfig?.hide;
172
136
  const addManagedAppRouterQuestions = !promptOptions.addManagedAppRouter?.hide;
173
137
  const addRouterTypeQuestion = !promptOptions.routerType?.hide;
@@ -175,15 +139,15 @@ async function getQuestions(promptOptions, log) {
175
139
  // Collect questions into an array
176
140
  questions.push(await getDestinationNamePrompt(destinationOptions));
177
141
  if (addManagedAppRouterQuestions) {
178
- log?.info((0, i18n_1.t)('info.addManagedAppRouter'));
142
+ log?.info(t('info.addManagedAppRouter'));
179
143
  questions.push(getAddManagedAppRouterPrompt());
180
144
  }
181
145
  if (addOverwriteQuestion) {
182
- log?.info((0, i18n_1.t)('info.overwriteDestination'));
146
+ log?.info(t('info.overwriteDestination'));
183
147
  questions.push(getOverwritePrompt());
184
148
  }
185
149
  if (addRouterTypeQuestion) {
186
- log?.info((0, i18n_1.t)('info.routerOptions'));
150
+ log?.info(t('info.routerOptions'));
187
151
  questions.push(getRouterOptionsPrompt());
188
152
  }
189
153
  return questions;
@@ -1,4 +1,4 @@
1
- import type { CfSystemChoice, CfAppRouterDeployConfigAnswers } from '../types';
1
+ import type { CfSystemChoice, CfAppRouterDeployConfigAnswers } from '../types.js';
2
2
  import type { ErrorHandler } from '@sap-ux/inquirer-common';
3
3
  /**
4
4
  * Validates the destination name or input string. If `allowEmptyChoice` is true,
@@ -1,13 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateDestinationQuestion = validateDestinationQuestion;
4
- exports.validateMtaPath = validateMtaPath;
5
- exports.validateMtaId = validateMtaId;
6
- exports.validateAbapService = validateAbapService;
7
- const i18n_1 = require("../i18n");
8
- const node_fs_1 = require("node:fs");
9
- const node_path_1 = require("node:path");
10
- const project_input_validator_1 = require("@sap-ux/project-input-validator");
1
+ import { t } from '../i18n.js';
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { validateWindowsPathLength } from '@sap-ux/project-input-validator';
11
5
  /**
12
6
  *
13
7
  * @param input The input string to check for emptiness.
@@ -27,14 +21,14 @@ function isNotEmpty(input) {
27
21
  */
28
22
  function validateInput(input) {
29
23
  if (!isNotEmpty(input)) {
30
- return (0, i18n_1.t)('errors.emptyDestinationNameError');
24
+ return t('errors.emptyDestinationNameError');
31
25
  }
32
26
  const result = /^[a-z0-9_-]+$/i.test(input);
33
27
  if (!result) {
34
- return (0, i18n_1.t)('errors.destinationNameError');
28
+ return t('errors.destinationNameError');
35
29
  }
36
30
  if (input.length > 200) {
37
- return (0, i18n_1.t)('errors.destinationNameLengthError');
31
+ return t('errors.destinationNameLengthError');
38
32
  }
39
33
  return true;
40
34
  }
@@ -47,7 +41,7 @@ function validateInput(input) {
47
41
  * @param {boolean} allowEmptyChoice - Whether to allow an empty input as a valid choice.
48
42
  * @returns {boolean|string} `true` if the input is valid or empty choices are allowed, otherwise an error message.
49
43
  */
50
- function validateDestinationQuestion(input, allowEmptyChoice = false) {
44
+ export function validateDestinationQuestion(input, allowEmptyChoice = false) {
51
45
  if (allowEmptyChoice) {
52
46
  return true;
53
47
  }
@@ -59,9 +53,9 @@ function validateDestinationQuestion(input, allowEmptyChoice = false) {
59
53
  * @param {string} input - The input string representing the MTA path to validate.
60
54
  * @returns {boolean|string} - Returns `true` if the path is valid, or an error message if the path is invalid or does not exist.
61
55
  */
62
- function validateMtaPath(input) {
56
+ export function validateMtaPath(input) {
63
57
  const filePath = input?.trim();
64
- return (filePath && (0, node_fs_1.existsSync)(filePath)) || (0, i18n_1.t)('errors.folderDoesNotExistError', { filePath: filePath });
58
+ return (filePath && existsSync(filePath)) || t('errors.folderDoesNotExistError', { filePath: filePath });
65
59
  }
66
60
  /**
67
61
  * Validates the provided MTA ID.
@@ -75,24 +69,24 @@ function validateMtaPath(input) {
75
69
  * @param {CfAppRouterDeployConfigAnswers} previousAnswers - The previous answers, containing the MTA path.
76
70
  * @returns {boolean|string} - Returns true if the MTA ID is valid, or an error message if validation fails.
77
71
  */
78
- function validateMtaId(input, previousAnswers) {
72
+ export function validateMtaId(input, previousAnswers) {
79
73
  if (typeof input !== 'string' || !input.trim()) {
80
- return (0, i18n_1.t)('errors.noMtaIdError');
74
+ return t('errors.noMtaIdError');
81
75
  }
82
76
  if (input.length > 100) {
83
- return (0, i18n_1.t)('errors.mtaIdLengthError');
77
+ return t('errors.mtaIdLengthError');
84
78
  }
85
79
  // The MTA ID must start with a letter (a–z, A–Z). After the first character, any combination of letters, numbers, underscores (_), hyphens (-), or dots (.) is allowed.
86
80
  const idPattern = /^[a-zA-Z][a-zA-Z0-9_\-.]*$/;
87
81
  if (!idPattern.exec(input)) {
88
- return (0, i18n_1.t)('errors.invalidMtaIdError');
82
+ return t('errors.invalidMtaIdError');
89
83
  }
90
- if ((0, node_fs_1.existsSync)((0, node_path_1.join)(previousAnswers.mtaPath, input.trim()))) {
91
- return (0, i18n_1.t)('errors.mtaIdAlreadyExistError', { mtaPath: previousAnswers.mtaPath });
84
+ if (existsSync(join(previousAnswers.mtaPath, input.trim()))) {
85
+ return t('errors.mtaIdAlreadyExistError', { mtaPath: previousAnswers.mtaPath });
92
86
  }
93
87
  const mtaPath = previousAnswers.mtaPath || '';
94
88
  // Windows path length validation
95
- const winPathResult = (0, project_input_validator_1.validateWindowsPathLength)((0, node_path_1.join)(mtaPath, input), (0, i18n_1.t)('errors.windowsMtaIdPathTooLong'));
89
+ const winPathResult = validateWindowsPathLength(join(mtaPath, input), t('errors.windowsMtaIdPathTooLong'));
96
90
  if (winPathResult !== true) {
97
91
  return winPathResult;
98
92
  }
@@ -106,10 +100,10 @@ function validateMtaId(input, previousAnswers) {
106
100
  * @param {ErrorHandler} errorHandler - An instance of an error handler.
107
101
  * @returns {string | boolean} - Returns `true` if the choice is valid.
108
102
  */
109
- function validateAbapService(choice, errorHandler) {
103
+ export function validateAbapService(choice, errorHandler) {
110
104
  if (!choice) {
111
105
  const userMsg = errorHandler.getErrorMsg('', true);
112
- const checkConsoleMsg = (0, i18n_1.t)('errors.errorScpAbapSourceDiscoveryCheckLog');
106
+ const checkConsoleMsg = t('errors.errorScpAbapSourceDiscoveryCheckLog');
113
107
  return userMsg ? `${userMsg} ${checkConsoleMsg}` : false;
114
108
  }
115
109
  return true;
package/dist/types.js CHANGED
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouterModuleType = exports.appRouterPromptNames = exports.promptNames = void 0;
4
1
  /**
5
2
  * Enum defining prompt names for Cloud Foundry (CF) deployment configuration.
6
3
  *
7
4
  * N.B. as these prompts are merged with ABAP prompts (see `promptNames` in packages/abap-deploy-config-inquirer/src/types.ts),
8
5
  * ensure that the names are unique across both files.
9
6
  */
10
- var promptNames;
7
+ export var promptNames;
11
8
  (function (promptNames) {
12
9
  /** The prompt to specify the destination name for CF deployment. */
13
10
  promptNames["destinationName"] = "destinationName";
@@ -17,11 +14,11 @@ var promptNames;
17
14
  promptNames["overwriteCfConfig"] = "overwriteCfConfig";
18
15
  /** The prompt for confirming the router type. */
19
16
  promptNames["routerType"] = "routerType";
20
- })(promptNames || (exports.promptNames = promptNames = {}));
17
+ })(promptNames || (promptNames = {}));
21
18
  /**
22
19
  * Enum defining prompt names for Application Router configuration.
23
20
  */
24
- var appRouterPromptNames;
21
+ export var appRouterPromptNames;
25
22
  (function (appRouterPromptNames) {
26
23
  /* The prompt to specify the MTA path to the MTA folder. */
27
24
  appRouterPromptNames["mtaPath"] = "mtaPath";
@@ -39,11 +36,11 @@ var appRouterPromptNames;
39
36
  appRouterPromptNames["addABAPServiceBinding"] = "addABAPServiceBinding";
40
37
  /* Prompt for selecting the ABAP environments */
41
38
  appRouterPromptNames["abapServiceProvider"] = "abapServiceProvider";
42
- })(appRouterPromptNames || (exports.appRouterPromptNames = appRouterPromptNames = {}));
39
+ })(appRouterPromptNames || (appRouterPromptNames = {}));
43
40
  /**
44
41
  * Defines the types of router modules for the Application Router configuration.
45
42
  */
46
- exports.RouterModuleType = {
43
+ export const RouterModuleType = {
47
44
  Standard: 'standard',
48
45
  Managed: 'managed',
49
46
  AppFront: 'appFront'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/cf-deploy-config-inquirer",
3
3
  "description": "Prompts module that can provide prompts for cf deployment config writer",
4
- "version": "0.6.7",
4
+ "version": "1.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -10,6 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Acf-deploy-config-inquirer"
12
12
  },
13
+ "type": "module",
13
14
  "license": "Apache-2.0",
14
15
  "main": "dist/index.js",
15
16
  "files": [
@@ -21,17 +22,18 @@
21
22
  "dependencies": {
22
23
  "i18next": "25.10.10",
23
24
  "inquirer-autocomplete-prompt": "2.0.1",
24
- "@sap-ux/inquirer-common": "0.13.6",
25
- "@sap-ux/btp-utils": "1.2.1",
26
- "@sap-ux/logger": "0.9.0"
25
+ "@sap-ux/inquirer-common": "1.0.1",
26
+ "@sap-ux/btp-utils": "2.0.0",
27
+ "@sap-ux/logger": "1.0.0"
27
28
  },
28
29
  "devDependencies": {
30
+ "@jest/globals": "30.3.0",
29
31
  "@sap-devx/yeoman-ui-types": "1.25.0",
30
32
  "@types/inquirer-autocomplete-prompt": "2.0.2",
31
33
  "@types/inquirer": "8.2.6",
32
34
  "@sap/cf-tools": "3.3.1",
33
35
  "inquirer": "8.2.7",
34
- "@sap-ux/project-input-validator": "0.7.2"
36
+ "@sap-ux/project-input-validator": "1.0.1"
35
37
  },
36
38
  "engines": {
37
39
  "node": ">=22.x"
@@ -42,8 +44,8 @@
42
44
  "watch": "tsc --watch",
43
45
  "lint": "eslint",
44
46
  "lint:fix": "eslint --fix",
45
- "test": "jest --ci --forceExit --detectOpenHandles --colors",
46
- "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
47
+ "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
48
+ "test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
47
49
  "link": "pnpm link --global",
48
50
  "unlink": "pnpm unlink --global"
49
51
  }