@sap-ux/generator-adp 1.0.76 → 1.1.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.
@@ -138,6 +138,10 @@ export default class extends Generator {
138
138
  end(): Promise<void>;
139
139
  /**
140
140
  * Prompts the user for the CF project path.
141
+ *
142
+ * Offers a choice between creating a new MTA project (the generator scaffolds the folder and,
143
+ * during writing, its `mta.yaml`) or reusing an existing one. For a new MTA project the selected
144
+ * folder is the parent directory and the entered MTA name becomes the project folder.
141
145
  */
142
146
  private _promptForCfProjectPath;
143
147
  /**
@@ -415,6 +415,10 @@ class default_1 extends yeoman_generator_1.default {
415
415
  }
416
416
  /**
417
417
  * Prompts the user for the CF project path.
418
+ *
419
+ * Offers a choice between creating a new MTA project (the generator scaffolds the folder and,
420
+ * during writing, its `mta.yaml`) or reusing an existing one. For a new MTA project the selected
421
+ * folder is the parent directory and the entered MTA name becomes the project folder.
418
422
  */
419
423
  async _promptForCfProjectPath() {
420
424
  if (this.isMtaYamlFound) {
@@ -423,8 +427,16 @@ class default_1 extends yeoman_generator_1.default {
423
427
  this.logger.log(`Project path information: ${path}`);
424
428
  }
425
429
  else {
426
- const pathAnswers = await this.prompt([(0, target_env_js_1.getProjectPathPrompt)(this.logger, this.vscode)]);
427
- const path = this.destinationRoot(node_fs_1.default.realpathSync(pathAnswers.projectLocation, 'utf-8'));
430
+ const pathAnswers = await this.prompt([
431
+ (0, target_env_js_1.getMtaModePrompt)(),
432
+ (0, target_env_js_1.getProjectPathPrompt)(this.logger, this.vscode, this.cfConfig),
433
+ (0, target_env_js_1.getMtaIdPrompt)()
434
+ ]);
435
+ const selectedLocation = node_fs_1.default.realpathSync(pathAnswers.projectLocation, 'utf-8');
436
+ const resolvedRoot = pathAnswers.mtaMode === types_js_1.MtaMode.New && pathAnswers.mtaId
437
+ ? (0, node_path_1.join)(selectedLocation, pathAnswers.mtaId)
438
+ : selectedLocation;
439
+ const path = this.destinationRoot(resolvedRoot);
428
440
  this.logger.log(`Project path information: ${path}`);
429
441
  }
430
442
  }
@@ -444,6 +456,7 @@ class default_1 extends yeoman_generator_1.default {
444
456
  if (this.isCfEnv) {
445
457
  telemetryData.baseAppTechnicalName = this.cfPrompter?.manifest?.['sap.app']?.id ?? '';
446
458
  telemetryData.projectType = 'cf';
459
+ telemetryData.cfServiceOffering = this.cfServicesAnswers?.serviceInstance?.service ?? '';
447
460
  }
448
461
  else {
449
462
  telemetryData.projectType =
@@ -568,8 +581,11 @@ class default_1 extends yeoman_generator_1.default {
568
581
  const serviceInstanceGuid = this.cfPrompter.serviceInstanceGuid;
569
582
  const backendUrls = this.cfPrompter.backendUrls;
570
583
  const oauthPaths = this.cfPrompter.oauthPaths;
584
+ // In new-MTA / no-existing-service modes the businessService prompt is hidden; use the
585
+ // selected live service instance name to resolve/create the service keys instead.
586
+ const businessServiceName = this.cfServicesAnswers.businessService || this.cfServicesAnswers.serviceInstance?.name || '';
571
587
  const serviceInfo = await (0, adp_tooling_1.getOrCreateServiceInstanceKeys)({
572
- names: [this.cfServicesAnswers.businessService ?? '']
588
+ names: [businessServiceName]
573
589
  }, this.logger);
574
590
  const config = (0, adp_tooling_1.getCfConfig)({
575
591
  attributeAnswers: this.attributeAnswers,
@@ -15,6 +15,10 @@ export declare class CFServicesPrompter {
15
15
  * Whether to show the solution name prompt.
16
16
  */
17
17
  private showSolutionNamePrompt;
18
+ /**
19
+ * Whether the MTA already declares an approuter module.
20
+ */
21
+ private hasExistingApprouter;
18
22
  /**
19
23
  * The type of approuter to use.
20
24
  */
@@ -23,6 +27,14 @@ export declare class CFServicesPrompter {
23
27
  * The business services available.
24
28
  */
25
29
  private businessServices;
30
+ /**
31
+ * The live CF service instances available to bind when the MTA has no service yet.
32
+ */
33
+ private serviceInstances;
34
+ /**
35
+ * Memoised live instances filtered to those FDC reports as having at least one adaptable app.
36
+ */
37
+ private adaptableInstances;
26
38
  /**
27
39
  * The info of the business service.
28
40
  */
@@ -31,6 +43,16 @@ export declare class CFServicesPrompter {
31
43
  * The base apps available.
32
44
  */
33
45
  private apps;
46
+ /**
47
+ * The MTA-declared business service that is reachable (present among the live CF service
48
+ * instances). When set, it is shown as a read-only label and no other service can be chosen.
49
+ */
50
+ private reachableBusinessService;
51
+ /**
52
+ * Result of the eager discovery performed for the reachable business service: `true` when it
53
+ * resolved and exposes apps, otherwise an error message surfaced by the read-only label.
54
+ */
55
+ private singleServiceResult;
34
56
  /**
35
57
  * The service instance GUID.
36
58
  */
@@ -90,6 +112,52 @@ export declare class CFServicesPrompter {
90
112
  * @returns {Promise<CFServicesQuestion[]>} CF services questions
91
113
  */
92
114
  getPrompts(mtaProjectPath: string, cfConfig: CfConfig, promptOptions?: CfServicesPromptOptions): Promise<CFServicesQuestion[]>;
115
+ /**
116
+ * Loads the CF state the prompts depend on before any prompt's `when`/`validate`/`choices` runs.
117
+ *
118
+ * Ordered: the reachability resolution needs both the MTA business services and the live service
119
+ * instances, so those load first; approuter detection is independent and runs last.
120
+ *
121
+ * @param {string} mtaProjectPath - MTA project path.
122
+ * @param {CfConfig} cfConfig - CF config service instance.
123
+ * @returns {Promise<void>} Resolves once all eager state has been loaded.
124
+ */
125
+ private loadCfState;
126
+ /**
127
+ * Loads the business services declared in the MTA project into `this.businessServices`.
128
+ *
129
+ * @param {string} mtaProjectPath - MTA project path.
130
+ * @returns {Promise<void>} Resolves once the business services have been loaded.
131
+ */
132
+ private loadBusinessServices;
133
+ /**
134
+ * Loads the live CF service instances up front into `this.serviceInstances`: they are both the
135
+ * reachability check for an MTA-declared business service and the fallback picker when none is reachable.
136
+ *
137
+ * @param {CfConfig} cfConfig - CF config service instance.
138
+ * @returns {Promise<void>} Resolves once the service instances have been loaded.
139
+ */
140
+ private loadServiceInstances;
141
+ /**
142
+ * Resolves the MTA-declared business service that is actually reachable (exists among the live
143
+ * service instances) and eagerly discovers its apps.
144
+ *
145
+ * Only the reachable service is shown, as a read-only label; its discovery side-effects can't be
146
+ * driven by a label's `validate`, so they are resolved here. Depends on `loadBusinessServices` and
147
+ * `loadServiceInstances` having run first.
148
+ *
149
+ * @param {CfConfig} cfConfig - CF config service instance.
150
+ * @returns {Promise<void>} Resolves once the reachable business service has been resolved.
151
+ */
152
+ private resolveReachableBusinessService;
153
+ /**
154
+ * Detects an existing approuter eagerly so `showSolutionNamePrompt` is set before any prompt's
155
+ * `when` runs. Yeoman-UI does not guarantee the approuter prompt's `when` (which used to set this
156
+ * flag) executes before the business-solution-name prompt's `when` reads it.
157
+ *
158
+ * @param {string} mtaProjectPath - MTA project path.
159
+ */
160
+ private detectExistingApprouter;
93
161
  /**
94
162
  * Prompt for business solution name.
95
163
  *
@@ -99,7 +167,6 @@ export declare class CFServicesPrompter {
99
167
  /**
100
168
  * Prompt for approuter.
101
169
  *
102
- * @param {string} mtaProjectPath - MTA project path.
103
170
  * @param {CfConfig} cfConfig - CF config service instance.
104
171
  * @returns {CFServicesQuestion} Prompt for approuter.
105
172
  */
@@ -112,11 +179,44 @@ export declare class CFServicesPrompter {
112
179
  */
113
180
  private getBaseAppPrompt;
114
181
  /**
115
- * Prompt for business services.
182
+ * Prompt for the business service declared in the MTA.
116
183
  *
117
- * @param {CfConfig} cfConfig - CF config service instance.
118
- * @returns {CFServicesQuestion} Prompt for business services.
184
+ * Rendered as a read-only label of the MTA's reachable business service (one that exists among the
185
+ * live CF service instances) the developer cannot change it. Its discovery runs eagerly in
186
+ * `getPrompts`, so this prompt only has to surface a discovery failure via `validate`.
187
+ *
188
+ * @returns {CFServicesQuestion} Prompt for the business service.
119
189
  */
120
190
  private getBusinessServicesPrompt;
191
+ /**
192
+ * Resolves a business service and discovers its base apps, populating `this.businessServiceInfo`
193
+ * and `this.apps` — the side-effects the base-app prompt and the writer depend on.
194
+ *
195
+ * @param {string} value - The business service name.
196
+ * @param {CfConfig} cfConfig - CF config service instance.
197
+ * @returns {Promise<string | true>} `true` when the service resolved and exposes apps, otherwise an error message.
198
+ */
199
+ private discoverBusinessServiceApps;
200
+ /**
201
+ * Live service instances filtered to those FDC reports as having at least one cloud-adaptable app.
202
+ * Best-effort and memoised: the FDC call runs at most once per prompter. When FDC confirms none are
203
+ * adaptable, or the lookup fails, the list is emptied so the picker shows an error rather than
204
+ * offering instances that cannot be adapted.
205
+ *
206
+ * @param {CfConfig} cfConfig - CF config service instance.
207
+ * @returns {Promise<CfServiceInstanceChoice[]>} The adaptable instances, or `[]` when none are adaptable or the lookup fails.
208
+ */
209
+ private getAdaptableInstances;
210
+ /**
211
+ * Prompt for a live CF service instance to bind, shown when the MTA has no service yet.
212
+ *
213
+ * The selected instance seeds the same discovery the business-service prompt performs
214
+ * (business service info + base apps) and is later written as an `org.cloudfoundry.existing-service`
215
+ * resource into the project's `mta.yaml`.
216
+ *
217
+ * @param {CfConfig} cfConfig - CF config service instance.
218
+ * @returns {CFServicesQuestion} Prompt for service instance.
219
+ */
220
+ private getServiceInstancePrompt;
121
221
  }
122
222
  //# sourceMappingURL=cf-services.d.ts.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CFServicesPrompter = void 0;
4
4
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
5
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
5
6
  const project_input_validator_1 = require("@sap-ux/project-input-validator");
6
7
  const i18n_js_1 = require("../../utils/i18n.js");
7
8
  const validators_js_1 = require("./helper/validators.js");
@@ -21,6 +22,10 @@ class CFServicesPrompter {
21
22
  * Whether to show the solution name prompt.
22
23
  */
23
24
  showSolutionNamePrompt = false;
25
+ /**
26
+ * Whether the MTA already declares an approuter module.
27
+ */
28
+ hasExistingApprouter = false;
24
29
  /**
25
30
  * The type of approuter to use.
26
31
  */
@@ -29,6 +34,14 @@ class CFServicesPrompter {
29
34
  * The business services available.
30
35
  */
31
36
  businessServices = [];
37
+ /**
38
+ * The live CF service instances available to bind when the MTA has no service yet.
39
+ */
40
+ serviceInstances = [];
41
+ /**
42
+ * Memoised live instances filtered to those FDC reports as having at least one adaptable app.
43
+ */
44
+ adaptableInstances;
32
45
  /**
33
46
  * The info of the business service.
34
47
  */
@@ -37,6 +50,16 @@ class CFServicesPrompter {
37
50
  * The base apps available.
38
51
  */
39
52
  apps = [];
53
+ /**
54
+ * The MTA-declared business service that is reachable (present among the live CF service
55
+ * instances). When set, it is shown as a read-only label and no other service can be chosen.
56
+ */
57
+ reachableBusinessService;
58
+ /**
59
+ * Result of the eager discovery performed for the reachable business service: `true` when it
60
+ * resolved and exposes apps, otherwise an error message surfaced by the read-only label.
61
+ */
62
+ singleServiceResult = true;
40
63
  /**
41
64
  * The service instance GUID.
42
65
  */
@@ -115,11 +138,12 @@ class CFServicesPrompter {
115
138
  */
116
139
  async getPrompts(mtaProjectPath, cfConfig, promptOptions) {
117
140
  if (this.isCfLoggedIn) {
118
- this.businessServices = await (0, adp_tooling_1.getMtaServices)(mtaProjectPath, this.logger);
141
+ await this.loadCfState(mtaProjectPath, cfConfig);
119
142
  }
120
143
  const keyedPrompts = {
121
- [adp_tooling_1.cfServicesPromptNames.approuter]: this.getAppRouterPrompt(mtaProjectPath, cfConfig),
122
- [adp_tooling_1.cfServicesPromptNames.businessService]: this.getBusinessServicesPrompt(cfConfig),
144
+ [adp_tooling_1.cfServicesPromptNames.approuter]: this.getAppRouterPrompt(cfConfig),
145
+ [adp_tooling_1.cfServicesPromptNames.businessService]: this.getBusinessServicesPrompt(),
146
+ [adp_tooling_1.cfServicesPromptNames.serviceInstance]: this.getServiceInstancePrompt(cfConfig),
123
147
  [adp_tooling_1.cfServicesPromptNames.businessSolutionName]: this.getBusinessSolutionNamePrompt(),
124
148
  [adp_tooling_1.cfServicesPromptNames.baseApp]: this.getBaseAppPrompt(cfConfig)
125
149
  };
@@ -131,6 +155,100 @@ class CFServicesPrompter {
131
155
  .map(([_, question]) => question);
132
156
  return questions;
133
157
  }
158
+ /**
159
+ * Loads the CF state the prompts depend on before any prompt's `when`/`validate`/`choices` runs.
160
+ *
161
+ * Ordered: the reachability resolution needs both the MTA business services and the live service
162
+ * instances, so those load first; approuter detection is independent and runs last.
163
+ *
164
+ * @param {string} mtaProjectPath - MTA project path.
165
+ * @param {CfConfig} cfConfig - CF config service instance.
166
+ * @returns {Promise<void>} Resolves once all eager state has been loaded.
167
+ */
168
+ async loadCfState(mtaProjectPath, cfConfig) {
169
+ await this.loadBusinessServices(mtaProjectPath);
170
+ await this.loadServiceInstances(cfConfig);
171
+ await this.resolveReachableBusinessService(cfConfig);
172
+ this.detectExistingApprouter(mtaProjectPath);
173
+ if (!this.reachableBusinessService && this.serviceInstances.length > 0) {
174
+ await this.getAdaptableInstances(cfConfig);
175
+ }
176
+ }
177
+ /**
178
+ * Loads the business services declared in the MTA project into `this.businessServices`.
179
+ *
180
+ * @param {string} mtaProjectPath - MTA project path.
181
+ * @returns {Promise<void>} Resolves once the business services have been loaded.
182
+ */
183
+ async loadBusinessServices(mtaProjectPath) {
184
+ try {
185
+ this.businessServices = await (0, adp_tooling_1.getMtaServices)(mtaProjectPath, this.logger);
186
+ }
187
+ catch (e) {
188
+ // A brand-new MTA (no mta.yaml yet) or an MTA without a service definition has no
189
+ // business services; fall back to binding a live CF service instance instead.
190
+ this.businessServices = [];
191
+ this.logger.log(`No business services found in MTA project: ${e.message}`);
192
+ }
193
+ }
194
+ /**
195
+ * Loads the live CF service instances up front into `this.serviceInstances`: they are both the
196
+ * reachability check for an MTA-declared business service and the fallback picker when none is reachable.
197
+ *
198
+ * @param {CfConfig} cfConfig - CF config service instance.
199
+ * @returns {Promise<void>} Resolves once the service instances have been loaded.
200
+ */
201
+ async loadServiceInstances(cfConfig) {
202
+ try {
203
+ this.serviceInstances = await (0, adp_tooling_1.getAdpServiceInstances)(cfConfig.space.GUID, this.logger);
204
+ }
205
+ catch (e) {
206
+ this.serviceInstances = [];
207
+ this.logger.log(`Could not load CF service instances: ${e.message}`);
208
+ }
209
+ }
210
+ /**
211
+ * Resolves the MTA-declared business service that is actually reachable (exists among the live
212
+ * service instances) and eagerly discovers its apps.
213
+ *
214
+ * Only the reachable service is shown, as a read-only label; its discovery side-effects can't be
215
+ * driven by a label's `validate`, so they are resolved here. Depends on `loadBusinessServices` and
216
+ * `loadServiceInstances` having run first.
217
+ *
218
+ * @param {CfConfig} cfConfig - CF config service instance.
219
+ * @returns {Promise<void>} Resolves once the reachable business service has been resolved.
220
+ */
221
+ async resolveReachableBusinessService(cfConfig) {
222
+ const reachable = this.businessServices.filter((service) => this.serviceInstances.some((instance) => instance.name === service));
223
+ if (reachable.length >= 1) {
224
+ this.reachableBusinessService = reachable[0];
225
+ this.singleServiceResult = await this.discoverBusinessServiceApps(reachable[0] ?? '', cfConfig);
226
+ }
227
+ }
228
+ /**
229
+ * Detects an existing approuter eagerly so `showSolutionNamePrompt` is set before any prompt's
230
+ * `when` runs. Yeoman-UI does not guarantee the approuter prompt's `when` (which used to set this
231
+ * flag) executes before the business-solution-name prompt's `when` reads it.
232
+ *
233
+ * @param {string} mtaProjectPath - MTA project path.
234
+ */
235
+ detectExistingApprouter(mtaProjectPath) {
236
+ let modules = [];
237
+ try {
238
+ modules = (0, adp_tooling_1.getModuleNames)(mtaProjectPath);
239
+ }
240
+ catch (e) {
241
+ // Brand-new MTA has no mta.yaml yet, treat it as having no modules / no existing approuter.
242
+ this.logger.log(`No mta.yaml found for approuter detection at ${mtaProjectPath}: ${e.message}`);
243
+ }
244
+ this.hasExistingApprouter = (0, adp_tooling_1.hasApprouter)(modules);
245
+ if (this.hasExistingApprouter) {
246
+ this.approuter = (0, adp_tooling_1.getApprouterType)(mtaProjectPath);
247
+ }
248
+ else {
249
+ this.showSolutionNamePrompt = true;
250
+ }
251
+ }
134
252
  /**
135
253
  * Prompt for business solution name.
136
254
  *
@@ -141,7 +259,10 @@ class CFServicesPrompter {
141
259
  type: 'input',
142
260
  name: adp_tooling_1.cfServicesPromptNames.businessSolutionName,
143
261
  message: (0, i18n_js_1.t)('prompts.businessSolutionNameLabel'),
144
- when: (answers) => (0, conditions_js_1.showBusinessSolutionNameQuestion)(answers, this.isCfLoggedIn, this.showSolutionNamePrompt, answers.businessService),
262
+ when: (answers) => (0, conditions_js_1.showBusinessSolutionNameQuestion)(answers, this.isCfLoggedIn, this.showSolutionNamePrompt, answers.businessService ||
263
+ answers.serviceInstance?.name ||
264
+ this.reachableBusinessService ||
265
+ this.serviceInstances[0]?.name),
145
266
  validate: (value) => (0, validators_js_1.validateBusinessSolutionName)(value),
146
267
  guiOptions: {
147
268
  mandatory: true,
@@ -154,30 +275,16 @@ class CFServicesPrompter {
154
275
  /**
155
276
  * Prompt for approuter.
156
277
  *
157
- * @param {string} mtaProjectPath - MTA project path.
158
278
  * @param {CfConfig} cfConfig - CF config service instance.
159
279
  * @returns {CFServicesQuestion} Prompt for approuter.
160
280
  */
161
- getAppRouterPrompt(mtaProjectPath, cfConfig) {
281
+ getAppRouterPrompt(cfConfig) {
162
282
  return {
163
283
  type: 'list',
164
284
  name: adp_tooling_1.cfServicesPromptNames.approuter,
165
285
  message: (0, i18n_js_1.t)('prompts.approuterLabel'),
166
286
  choices: (0, choices_js_1.getAppRouterChoices)(this.isInternalUsage),
167
- when: () => {
168
- const modules = (0, adp_tooling_1.getModuleNames)(mtaProjectPath);
169
- const hasRouter = (0, adp_tooling_1.hasApprouter)(modules);
170
- if (hasRouter) {
171
- this.approuter = (0, adp_tooling_1.getApprouterType)(mtaProjectPath);
172
- }
173
- if (this.isCfLoggedIn && !hasRouter) {
174
- this.showSolutionNamePrompt = true;
175
- return true;
176
- }
177
- else {
178
- return false;
179
- }
180
- },
287
+ when: () => this.isCfLoggedIn && !this.hasExistingApprouter,
181
288
  validate: async (value) => {
182
289
  this.isCfLoggedIn = await (0, adp_tooling_1.isLoggedInCf)(cfConfig, this.logger);
183
290
  if (!this.isCfLoggedIn) {
@@ -232,29 +339,153 @@ class CFServicesPrompter {
232
339
  };
233
340
  }
234
341
  /**
235
- * Prompt for business services.
342
+ * Prompt for the business service declared in the MTA.
343
+ *
344
+ * Rendered as a read-only label of the MTA's reachable business service (one that exists among the
345
+ * live CF service instances) the developer cannot change it. Its discovery runs eagerly in
346
+ * `getPrompts`, so this prompt only has to surface a discovery failure via `validate`.
347
+ *
348
+ * @returns {CFServicesQuestion} Prompt for the business service.
349
+ */
350
+ getBusinessServicesPrompt() {
351
+ return {
352
+ type: 'input',
353
+ name: adp_tooling_1.cfServicesPromptNames.businessService,
354
+ message: (0, i18n_js_1.t)('prompts.businessServiceLabel'),
355
+ default: (_) => this.reachableBusinessService ?? '',
356
+ when: (answers) => this.isCfLoggedIn && !!this.reachableBusinessService && !!(this.approuter || answers.approuter),
357
+ additionalMessages: () => this.reachableBusinessService
358
+ ? {
359
+ message: (0, i18n_js_1.t)('prompts.mtaAlreadyHasServiceInfo', {
360
+ serviceParameters: this.reachableBusinessService
361
+ }),
362
+ severity: yeoman_ui_types_1.Severity.information
363
+ }
364
+ : undefined,
365
+ validate: () => this.singleServiceResult,
366
+ guiOptions: {
367
+ type: 'label',
368
+ hint: (0, i18n_js_1.t)('prompts.businessServiceTooltip'),
369
+ breadcrumb: true
370
+ }
371
+ };
372
+ }
373
+ /**
374
+ * Resolves a business service and discovers its base apps, populating `this.businessServiceInfo`
375
+ * and `this.apps` — the side-effects the base-app prompt and the writer depend on.
376
+ *
377
+ * @param {string} value - The business service name.
378
+ * @param {CfConfig} cfConfig - CF config service instance.
379
+ * @returns {Promise<string | true>} `true` when the service resolved and exposes apps, otherwise an error message.
380
+ */
381
+ async discoverBusinessServiceApps(value, cfConfig) {
382
+ const validationResult = (0, project_input_validator_1.validateEmptyString)(value);
383
+ if (typeof validationResult === 'string') {
384
+ return (0, i18n_js_1.t)('error.businessServiceHasToBeSelected');
385
+ }
386
+ try {
387
+ this.businessServiceInfo = await (0, adp_tooling_1.getBusinessServiceInfo)(value, cfConfig, this.logger);
388
+ if (this.businessServiceInfo === null) {
389
+ return (0, i18n_js_1.t)('error.businessServiceDoesNotExist');
390
+ }
391
+ this.apps = await (0, adp_tooling_1.getCfApps)(this.businessServiceInfo.serviceKeys, cfConfig, this.logger);
392
+ this.logger?.log(`Available applications: ${JSON.stringify(this.apps)}`);
393
+ if (this.apps.length === 0) {
394
+ return (0, i18n_js_1.t)('error.noAppsFoundForBusinessService');
395
+ }
396
+ }
397
+ catch (e) {
398
+ this.apps = [];
399
+ this.logger?.error(`Failed to get available applications: ${e.message}`);
400
+ return e.message;
401
+ }
402
+ return true;
403
+ }
404
+ /**
405
+ * Live service instances filtered to those FDC reports as having at least one cloud-adaptable app.
406
+ * Best-effort and memoised: the FDC call runs at most once per prompter. When FDC confirms none are
407
+ * adaptable, or the lookup fails, the list is emptied so the picker shows an error rather than
408
+ * offering instances that cannot be adapted.
409
+ *
410
+ * @param {CfConfig} cfConfig - CF config service instance.
411
+ * @returns {Promise<CfServiceInstanceChoice[]>} The adaptable instances, or `[]` when none are adaptable or the lookup fails.
412
+ */
413
+ async getAdaptableInstances(cfConfig) {
414
+ if (this.adaptableInstances) {
415
+ return this.adaptableInstances;
416
+ }
417
+ let result = [];
418
+ try {
419
+ const resolved = await Promise.all(this.serviceInstances.map(async (instance) => {
420
+ try {
421
+ return { instance, cloudService: await (0, adp_tooling_1.getSapCloudServiceName)(instance.guid, this.logger) };
422
+ }
423
+ catch (e) {
424
+ this.logger.log(`Could not resolve sap.cloud.service for '${instance.name}': ${e.message}`);
425
+ return { instance, cloudService: undefined };
426
+ }
427
+ }));
428
+ const cloudServiceNames = resolved
429
+ .map((entry) => entry.cloudService)
430
+ .filter((name) => !!name);
431
+ const adaptable = await (0, adp_tooling_1.getAdaptableBusinessServices)(cloudServiceNames, cfConfig, this.logger);
432
+ result = resolved
433
+ .filter((entry) => !!entry.cloudService && adaptable.has(entry.cloudService))
434
+ .map((entry) => entry.instance);
435
+ if (result.length === 0) {
436
+ this.logger.log('FDC reported no adaptable service instances');
437
+ }
438
+ }
439
+ catch (e) {
440
+ this.logger.log(`Could not determine adaptable service instances: ${e.message}`);
441
+ }
442
+ this.adaptableInstances = result;
443
+ return result;
444
+ }
445
+ /**
446
+ * Prompt for a live CF service instance to bind, shown when the MTA has no service yet.
447
+ *
448
+ * The selected instance seeds the same discovery the business-service prompt performs
449
+ * (business service info + base apps) and is later written as an `org.cloudfoundry.existing-service`
450
+ * resource into the project's `mta.yaml`.
236
451
  *
237
452
  * @param {CfConfig} cfConfig - CF config service instance.
238
- * @returns {CFServicesQuestion} Prompt for business services.
453
+ * @returns {CFServicesQuestion} Prompt for service instance.
239
454
  */
240
- getBusinessServicesPrompt(cfConfig) {
455
+ getServiceInstancePrompt(cfConfig) {
241
456
  return {
242
457
  type: 'list',
243
- name: adp_tooling_1.cfServicesPromptNames.businessService,
458
+ name: adp_tooling_1.cfServicesPromptNames.serviceInstance,
244
459
  message: (0, i18n_js_1.t)('prompts.businessServiceLabel'),
245
- choices: this.businessServices,
246
- default: (_) => this.businessServices.length === 1 ? (this.businessServices[0] ?? '') : '',
247
- when: (answers) => this.isCfLoggedIn && (this.approuter || answers.approuter),
248
- validate: async (value) => {
249
- const validationResult = (0, project_input_validator_1.validateEmptyString)(value);
250
- if (typeof validationResult === 'string') {
251
- return (0, i18n_js_1.t)('error.businessServiceHasToBeSelected');
460
+ choices: async (_) => (0, choices_js_1.getServiceInstanceChoices)(await this.getAdaptableInstances(cfConfig)),
461
+ when: (answers) => this.isCfLoggedIn && !this.reachableBusinessService && !!(this.approuter || answers.approuter),
462
+ additionalMessages: () => {
463
+ if (this.serviceInstances.length === 0) {
464
+ return { message: (0, i18n_js_1.t)('error.noServiceInstancesFound'), severity: yeoman_ui_types_1.Severity.error };
465
+ }
466
+ if (this.adaptableInstances?.length === 0) {
467
+ return { message: (0, i18n_js_1.t)('error.noAdaptableServiceInstancesFound'), severity: yeoman_ui_types_1.Severity.error };
252
468
  }
469
+ return undefined;
470
+ },
471
+ validate: async (instance) => {
472
+ if (!instance) {
473
+ return (0, i18n_js_1.t)('error.serviceInstanceHasToBeSelected');
474
+ }
475
+ // Verify the instance exists and is keyable before it can be written to mta.yaml.
476
+ try {
477
+ this.businessServiceInfo = await (0, adp_tooling_1.getBusinessServiceInfo)(instance.name, cfConfig, this.logger);
478
+ }
479
+ catch (e) {
480
+ this.logger?.error(`Failed to verify service instance '${instance.name}': ${e.message}`);
481
+ return e.message;
482
+ }
483
+ if (this.businessServiceInfo === null) {
484
+ return (0, i18n_js_1.t)('error.businessServiceDoesNotExist');
485
+ }
486
+ // The picker is FDC-filtered to services with adaptable apps, so an empty app list or a
487
+ // discovery failure here is a real error: the writer needs the selected base app's manifest.
253
488
  try {
254
- this.businessServiceInfo = await (0, adp_tooling_1.getBusinessServiceInfo)(value, cfConfig, this.logger);
255
- if (this.businessServiceInfo === null) {
256
- return (0, i18n_js_1.t)('error.businessServiceDoesNotExist');
257
- }
258
489
  this.apps = await (0, adp_tooling_1.getCfApps)(this.businessServiceInfo.serviceKeys, cfConfig, this.logger);
259
490
  this.logger?.log(`Available applications: ${JSON.stringify(this.apps)}`);
260
491
  if (this.apps.length === 0) {
@@ -1,5 +1,5 @@
1
1
  import { AppRouterType } from '@sap-ux/adp-tooling';
2
- import type { CFApp, Endpoint, SourceApplication } from '@sap-ux/adp-tooling';
2
+ import type { CFApp, CfServiceInstanceChoice, Endpoint, SourceApplication } from '@sap-ux/adp-tooling';
3
3
  import { AdaptationProjectType } from '@sap-ux/axios-extension';
4
4
  import type { AdaptationDescriptor } from '@sap-ux/axios-extension';
5
5
  interface Choice {
@@ -24,6 +24,16 @@ export declare const getCFAppChoices: (apps: CFApp[]) => {
24
24
  name: string;
25
25
  value: CFApp;
26
26
  }[];
27
+ /**
28
+ * Get the choices for the service instance prompt.
29
+ *
30
+ * @param {CfServiceInstanceChoice[]} instances - The live CF service instances to offer.
31
+ * @returns {Array<{ name: string; value: CfServiceInstanceChoice }>} The formatted service instance choices.
32
+ */
33
+ export declare const getServiceInstanceChoices: (instances: CfServiceInstanceChoice[]) => {
34
+ name: string;
35
+ value: CfServiceInstanceChoice;
36
+ }[];
27
37
  /**
28
38
  * Get the choices for the approuter.
29
39
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getKeyUserSystemChoices = exports.getAdaptationChoices = exports.getProjectTypeChoices = exports.getAppRouterChoices = exports.getCFAppChoices = exports.getApplicationChoices = void 0;
3
+ exports.getKeyUserSystemChoices = exports.getAdaptationChoices = exports.getProjectTypeChoices = exports.getAppRouterChoices = exports.getServiceInstanceChoices = exports.getCFAppChoices = exports.getApplicationChoices = void 0;
4
4
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
5
5
  const axios_extension_1 = require("@sap-ux/axios-extension");
6
6
  const i18n_js_1 = require("../../../utils/i18n.js");
@@ -38,6 +38,19 @@ const getCFAppChoices = (apps) => {
38
38
  }));
39
39
  };
40
40
  exports.getCFAppChoices = getCFAppChoices;
41
+ /**
42
+ * Get the choices for the service instance prompt.
43
+ *
44
+ * @param {CfServiceInstanceChoice[]} instances - The live CF service instances to offer.
45
+ * @returns {Array<{ name: string; value: CfServiceInstanceChoice }>} The formatted service instance choices.
46
+ */
47
+ const getServiceInstanceChoices = (instances) => {
48
+ return instances.map((instance) => ({
49
+ name: instance.name,
50
+ value: instance
51
+ }));
52
+ };
53
+ exports.getServiceInstanceChoices = getServiceInstanceChoices;
41
54
  /**
42
55
  * Get the choices for the approuter.
43
56
  *
@@ -74,7 +74,10 @@ function showInternalQuestions(answers, isCustomerBase, isApplicationSupported)
74
74
  * @returns {boolean} True if the business solution name question should be shown, otherwise false.
75
75
  */
76
76
  function showBusinessSolutionNameQuestion(answers, isCFLoggedIn, showSolutionNamePrompt, businessService) {
77
- return isCFLoggedIn && answers.approuter === adp_tooling_1.AppRouterType.MANAGED && showSolutionNamePrompt && !!businessService;
77
+ return (isCFLoggedIn &&
78
+ (answers.approuter ?? adp_tooling_1.AppRouterType.MANAGED) === adp_tooling_1.AppRouterType.MANAGED &&
79
+ showSolutionNamePrompt &&
80
+ !!businessService);
78
81
  }
79
82
  /**
80
83
  * Determines if the base app prompt should be shown.
@@ -85,7 +88,7 @@ function showBusinessSolutionNameQuestion(answers, isCFLoggedIn, showSolutionNam
85
88
  * @returns {boolean} True if the base app prompt should be shown, otherwise false.
86
89
  */
87
90
  function shouldShowBaseAppPrompt(answers, isCFLoggedIn, apps) {
88
- return isCFLoggedIn && !!answers.businessService && !!apps.length;
91
+ return isCFLoggedIn && (!!answers.businessService || !!answers.serviceInstance) && !!apps.length;
89
92
  }
90
93
  /**
91
94
  * Determines if the store credentials question should be shown.
@@ -1,5 +1,6 @@
1
1
  import type { ToolsLogger } from '@sap-ux/logger';
2
2
  import type { CfConfig, SystemLookup } from '@sap-ux/adp-tooling';
3
+ import { MtaMode } from '../../types.js';
3
4
  interface JsonInputParams {
4
5
  projectName: string;
5
6
  targetFolder: string;
@@ -51,13 +52,32 @@ export declare function validateJsonInput(systemLookup: SystemLookup, isCustomer
51
52
  */
52
53
  export declare function validateEnvironment(value: string, isCFLoggedIn: boolean, cfConfig?: CfConfig): Promise<string | boolean>;
53
54
  /**
54
- * Validates the project path.
55
+ * Validates the project path for the CF Project Path page.
55
56
  *
56
- * @param {string} projectPath - The path to the project.
57
+ * In `existing` mode the path must be an existing MTA project; a missing service definition is no
58
+ * longer an error since the new service-instance dropdown lets the developer bind one. In `new`
59
+ * mode the path is the parent folder in which a new MTA project will be scaffolded, so it only has
60
+ * to exist (the MTA name/uniqueness is validated by the dedicated name prompt).
61
+ *
62
+ * @param {string} projectPath - The path to the project (existing MTA root, or parent folder for new).
57
63
  * @param {ToolsLogger} logger - The logger.
58
- * @returns {Promise<string | boolean>} Returns true if the project path is valid, otherwise returns an error message.
64
+ * @param {MtaMode} [mtaMode] - The selected MTA mode defaults to `existing`.
65
+ * @param {CfConfig} [cfConfig] - The current CF config used to block binding an MTA from a different space.
66
+ * @returns {string | boolean} Returns true if the project path is valid, otherwise returns an error message.
67
+ */
68
+ export declare function validateProjectPath(projectPath: string, logger: ToolsLogger, mtaMode?: MtaMode, cfConfig?: CfConfig): string | boolean;
69
+ /**
70
+ * Validates the MTA project name entered when creating a new MTA project.
71
+ *
72
+ * Ensures the name is non-empty, at most 20 characters, uses only allowed characters (letters,
73
+ * numbers, dots, underscores, hyphens; starting with a letter or number) and that no folder with
74
+ * that name already exists in the selected parent location.
75
+ *
76
+ * @param {string} value - The MTA project name to validate.
77
+ * @param {string} [parentPath] - The parent folder the new MTA project will be created in.
78
+ * @returns {string | boolean} Returns true if valid, otherwise an error message.
59
79
  */
60
- export declare function validateProjectPath(projectPath: string, logger: ToolsLogger): Promise<string | boolean>;
80
+ export declare function validateMtaId(value: string, parentPath?: string): string | boolean;
61
81
  /**
62
82
  * Validate business solution name.
63
83
  *
@@ -7,11 +7,14 @@ exports.validateExtensibilityExtension = validateExtensibilityExtension;
7
7
  exports.validateJsonInput = validateJsonInput;
8
8
  exports.validateEnvironment = validateEnvironment;
9
9
  exports.validateProjectPath = validateProjectPath;
10
+ exports.validateMtaId = validateMtaId;
10
11
  exports.validateBusinessSolutionName = validateBusinessSolutionName;
11
12
  const node_fs_1 = __importDefault(require("node:fs"));
13
+ const node_path_1 = require("node:path");
12
14
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
13
15
  const project_input_validator_1 = require("@sap-ux/project-input-validator");
14
16
  const i18n_js_1 = require("../../../utils/i18n.js");
17
+ const types_js_1 = require("../../types.js");
15
18
  const type_guards_js_1 = require("../../../utils/type-guards.js");
16
19
  /**
17
20
  * Validates whether the extensibility extension is available. If the extension is not found,
@@ -81,13 +84,20 @@ async function validateEnvironment(value, isCFLoggedIn, cfConfig) {
81
84
  return true;
82
85
  }
83
86
  /**
84
- * Validates the project path.
87
+ * Validates the project path for the CF Project Path page.
85
88
  *
86
- * @param {string} projectPath - The path to the project.
89
+ * In `existing` mode the path must be an existing MTA project; a missing service definition is no
90
+ * longer an error since the new service-instance dropdown lets the developer bind one. In `new`
91
+ * mode the path is the parent folder in which a new MTA project will be scaffolded, so it only has
92
+ * to exist (the MTA name/uniqueness is validated by the dedicated name prompt).
93
+ *
94
+ * @param {string} projectPath - The path to the project (existing MTA root, or parent folder for new).
87
95
  * @param {ToolsLogger} logger - The logger.
88
- * @returns {Promise<string | boolean>} Returns true if the project path is valid, otherwise returns an error message.
96
+ * @param {MtaMode} [mtaMode] - The selected MTA mode defaults to `existing`.
97
+ * @param {CfConfig} [cfConfig] - The current CF config used to block binding an MTA from a different space.
98
+ * @returns {string | boolean} Returns true if the project path is valid, otherwise returns an error message.
89
99
  */
90
- async function validateProjectPath(projectPath, logger) {
100
+ function validateProjectPath(projectPath, logger, mtaMode = types_js_1.MtaMode.Existing, cfConfig) {
91
101
  const validationResult = (0, project_input_validator_1.validateEmptyString)(projectPath);
92
102
  if (typeof validationResult === 'string') {
93
103
  return validationResult;
@@ -95,18 +105,49 @@ async function validateProjectPath(projectPath, logger) {
95
105
  if (!node_fs_1.default.existsSync(projectPath)) {
96
106
  return (0, i18n_js_1.t)('error.projectDoesNotExist');
97
107
  }
108
+ if (mtaMode === types_js_1.MtaMode.New) {
109
+ // New mode scaffolds a new MTA inside the selected folder an already-MTA folder is a conflicting
110
+ // choice (it would nest or silently reuse the MTA), so block it and point the user at Existing mode.
111
+ if ((0, adp_tooling_1.isMtaProject)(projectPath)) {
112
+ return (0, i18n_js_1.t)('error.newModeFolderAlreadyMta');
113
+ }
114
+ return true;
115
+ }
98
116
  if (!(0, adp_tooling_1.isMtaProject)(projectPath)) {
99
117
  return (0, i18n_js_1.t)('error.projectDoesNotExistMta');
100
118
  }
101
- try {
102
- const services = await (0, adp_tooling_1.getMtaServices)(projectPath, logger);
103
- if (services.length < 1) {
104
- return (0, i18n_js_1.t)('error.noAdaptableBusinessServiceFoundInMta');
105
- }
119
+ // Block reusing an MTA that was created for a different CF space than the current login. The space the
120
+ // MTA targets is persisted in its ui5.yaml an unknown space (non-CF project) is not treated as a mismatch.
121
+ const projectSpaceGuid = (0, adp_tooling_1.getCfProjectSpaceGuid)(projectPath, logger);
122
+ if (projectSpaceGuid && cfConfig && projectSpaceGuid !== cfConfig.space.GUID) {
123
+ return (0, i18n_js_1.t)('error.projectSpaceMismatch');
124
+ }
125
+ return true;
126
+ }
127
+ /**
128
+ * Validates the MTA project name entered when creating a new MTA project.
129
+ *
130
+ * Ensures the name is non-empty, at most 20 characters, uses only allowed characters (letters,
131
+ * numbers, dots, underscores, hyphens; starting with a letter or number) and that no folder with
132
+ * that name already exists in the selected parent location.
133
+ *
134
+ * @param {string} value - The MTA project name to validate.
135
+ * @param {string} [parentPath] - The parent folder the new MTA project will be created in.
136
+ * @returns {string | boolean} Returns true if valid, otherwise an error message.
137
+ */
138
+ function validateMtaId(value, parentPath) {
139
+ const validationResult = (0, project_input_validator_1.validateEmptyString)(value);
140
+ if (typeof validationResult === 'string') {
141
+ return validationResult;
142
+ }
143
+ if (value.length > 20) {
144
+ return (0, i18n_js_1.t)('error.mtaIdTooLong');
145
+ }
146
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value)) {
147
+ return (0, i18n_js_1.t)('error.mtaIdInvalid');
106
148
  }
107
- catch (e) {
108
- logger?.error(`Failed to get MTA services: ${e.message}`);
109
- return (0, i18n_js_1.t)('error.noAdaptableBusinessServiceFoundInMta');
149
+ if (parentPath && node_fs_1.default.existsSync((0, node_path_1.join)(parentPath, value))) {
150
+ return (0, i18n_js_1.t)('error.mtaIdAlreadyExists');
110
151
  }
111
152
  return true;
112
153
  }
@@ -26,13 +26,28 @@ export declare function getTargetEnvPrompt(appWizard: AppWizard, isCfInstalled:
26
26
  * @returns {object[]} The environments.
27
27
  */
28
28
  export declare function getEnvironments(appWizard: AppWizard, isCfInstalled: boolean): EnvironmentChoice[];
29
+ /**
30
+ * Returns the MTA mode prompt: create a new MTA project or use an existing one.
31
+ *
32
+ * @returns {YUIQuestion<ProjectLocationAnswers>} The MTA mode prompt.
33
+ */
34
+ export declare function getMtaModePrompt(): YUIQuestion<ProjectLocationAnswers>;
29
35
  /**
30
36
  * Returns the project path prompt.
31
37
  *
32
38
  * @param {ToolsLogger} logger - The logger.
33
39
  * @param {any} vscode - The VSCode instance.
40
+ * @param {CfConfig} [cfConfig] - The current CF config used to block reusing an MTA from a different space.
34
41
  * @returns {YUIQuestion<ProjectLocationAnswers>[]} The project path prompt.
35
42
  */
36
- export declare function getProjectPathPrompt(logger: ToolsLogger, vscode: any): YUIQuestion<ProjectLocationAnswers>;
43
+ export declare function getProjectPathPrompt(logger: ToolsLogger, vscode: any, cfConfig?: CfConfig): YUIQuestion<ProjectLocationAnswers>;
44
+ /**
45
+ * Returns the MTA project name prompt, shown only when creating a new MTA project in a folder that is
46
+ * not already an MTA project. When the selected root path already contains an `mta.yaml`, the project
47
+ * name is taken from the existing project, so the prompt is hidden.
48
+ *
49
+ * @returns {YUIQuestion<ProjectLocationAnswers>} The MTA project name prompt.
50
+ */
51
+ export declare function getMtaIdPrompt(): YUIQuestion<ProjectLocationAnswers>;
37
52
  export {};
38
53
  //# sourceMappingURL=target-env.d.ts.map
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTargetEnvPrompt = getTargetEnvPrompt;
4
4
  exports.getEnvironments = getEnvironments;
5
+ exports.getMtaModePrompt = getMtaModePrompt;
5
6
  exports.getProjectPathPrompt = getProjectPathPrompt;
7
+ exports.getMtaIdPrompt = getMtaIdPrompt;
6
8
  const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
9
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
7
10
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
8
11
  const i18n_js_1 = require("../../utils/i18n.js");
9
12
  const types_js_1 = require("../types.js");
@@ -51,14 +54,37 @@ function getEnvironments(appWizard, isCfInstalled) {
51
54
  }
52
55
  return choices;
53
56
  }
57
+ /**
58
+ * Returns the MTA mode prompt: create a new MTA project or use an existing one.
59
+ *
60
+ * @returns {YUIQuestion<ProjectLocationAnswers>} The MTA mode prompt.
61
+ */
62
+ function getMtaModePrompt() {
63
+ return {
64
+ type: 'list',
65
+ name: 'mtaMode',
66
+ message: (0, i18n_js_1.t)('prompts.mtaModeLabel'),
67
+ choices: [
68
+ { name: (0, i18n_js_1.t)('prompts.mtaModeNewLabel'), value: types_js_1.MtaMode.New },
69
+ { name: (0, i18n_js_1.t)('prompts.mtaModeExistingLabel'), value: types_js_1.MtaMode.Existing }
70
+ ],
71
+ default: types_js_1.MtaMode.New,
72
+ guiOptions: {
73
+ mandatory: true,
74
+ hint: (0, i18n_js_1.t)('prompts.mtaModeTooltip'),
75
+ breadcrumb: (0, i18n_js_1.t)('prompts.mtaModeBreadcrumb')
76
+ }
77
+ };
78
+ }
54
79
  /**
55
80
  * Returns the project path prompt.
56
81
  *
57
82
  * @param {ToolsLogger} logger - The logger.
58
83
  * @param {any} vscode - The VSCode instance.
84
+ * @param {CfConfig} [cfConfig] - The current CF config used to block reusing an MTA from a different space.
59
85
  * @returns {YUIQuestion<ProjectLocationAnswers>[]} The project path prompt.
60
86
  */
61
- function getProjectPathPrompt(logger, vscode) {
87
+ function getProjectPathPrompt(logger, vscode, cfConfig) {
62
88
  return {
63
89
  type: 'input',
64
90
  name: 'projectLocation',
@@ -69,9 +95,31 @@ function getProjectPathPrompt(logger, vscode) {
69
95
  breadcrumb: (0, i18n_js_1.t)('prompts.projectLocationBreadcrumb')
70
96
  },
71
97
  message: (0, i18n_js_1.t)('prompts.projectLocationLabel'),
72
- validate: (value) => (0, validators_js_1.validateProjectPath)(value, logger),
98
+ validate: (value, answers) => (0, validators_js_1.validateProjectPath)(value, logger, answers?.mtaMode, cfConfig),
73
99
  default: () => (0, fiori_generator_shared_1.getDefaultTargetFolder)(vscode),
74
100
  store: false
75
101
  };
76
102
  }
103
+ /**
104
+ * Returns the MTA project name prompt, shown only when creating a new MTA project in a folder that is
105
+ * not already an MTA project. When the selected root path already contains an `mta.yaml`, the project
106
+ * name is taken from the existing project, so the prompt is hidden.
107
+ *
108
+ * @returns {YUIQuestion<ProjectLocationAnswers>} The MTA project name prompt.
109
+ */
110
+ function getMtaIdPrompt() {
111
+ return {
112
+ type: 'input',
113
+ name: 'mtaId',
114
+ message: (0, i18n_js_1.t)('prompts.mtaIdLabel'),
115
+ when: (answers) => answers.mtaMode === types_js_1.MtaMode.New && !!answers.projectLocation && !(0, adp_tooling_1.isMtaProject)(answers.projectLocation),
116
+ validate: (value, answers) => (0, validators_js_1.validateMtaId)(value, answers?.projectLocation),
117
+ guiOptions: {
118
+ mandatory: true,
119
+ hint: (0, i18n_js_1.t)('prompts.mtaIdTooltip'),
120
+ breadcrumb: (0, i18n_js_1.t)('prompts.mtaIdBreadcrumb')
121
+ },
122
+ store: false
123
+ };
124
+ }
77
125
  //# sourceMappingURL=target-env.js.map
@@ -226,7 +226,27 @@ export type TargetEnvAnswers = {
226
226
  targetEnv: TargetEnv;
227
227
  };
228
228
  export type TargetEnvQuestion = YUIQuestion<TargetEnvAnswers>;
229
+ /**
230
+ * MTA project mode selected on the CF Project Path page.
231
+ * `New` scaffolds a new MTA project folder; `Existing` reuses an existing MTA project.
232
+ */
233
+ export declare const MtaMode: {
234
+ readonly New: "new";
235
+ readonly Existing: "existing";
236
+ };
237
+ export type MtaMode = (typeof MtaMode)[keyof typeof MtaMode];
229
238
  export type ProjectLocationAnswers = {
239
+ /**
240
+ * Whether to create a new MTA project or use an existing one.
241
+ */
242
+ mtaMode?: MtaMode;
243
+ /**
244
+ * The MTA project ID/name to create (new-MTA mode only).
245
+ */
246
+ mtaId?: string;
247
+ /**
248
+ * The selected folder: the parent dir (new mode) or the MTA root (existing mode).
249
+ */
230
250
  projectLocation: string;
231
251
  };
232
252
  export declare enum cfLoginPromptNames {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SystemType = exports.cfLoginPromptNames = exports.TargetEnv = exports.targetEnvPromptNames = exports.keyUserPromptNames = exports.attributePromptNames = exports.configPromptNames = void 0;
3
+ exports.SystemType = exports.cfLoginPromptNames = exports.MtaMode = exports.TargetEnv = exports.targetEnvPromptNames = exports.keyUserPromptNames = exports.attributePromptNames = exports.configPromptNames = void 0;
4
4
  /**
5
5
  * Enumeration of prompt names used in the configuration.
6
6
  */
@@ -51,6 +51,11 @@ var targetEnvPromptNames;
51
51
  targetEnvPromptNames["targetEnv"] = "targetEnv";
52
52
  })(targetEnvPromptNames || (exports.targetEnvPromptNames = targetEnvPromptNames = {}));
53
53
  exports.TargetEnv = { ABAP: 'ABAP', CF: 'CF' };
54
+ /**
55
+ * MTA project mode selected on the CF Project Path page.
56
+ * `New` scaffolds a new MTA project folder; `Existing` reuses an existing MTA project.
57
+ */
58
+ exports.MtaMode = { New: 'new', Existing: 'existing' };
54
59
  var cfLoginPromptNames;
55
60
  (function (cfLoginPromptNames) {
56
61
  cfLoginPromptNames["cfLoggedInMainMessage"] = "cfLoggedInMainMessage";
@@ -68,6 +68,16 @@
68
68
  "projectLocationLabel": "Project Root Path",
69
69
  "projectLocationTooltip": "Select the path to the root of your project.",
70
70
  "projectLocationBreadcrumb": "Project Path",
71
+ "mtaModeLabel": "MTA Project",
72
+ "mtaModeTooltip": "Choose whether to create a new MTA project or use an existing one for your Adaptation Project.",
73
+ "mtaModeBreadcrumb": "MTA Project",
74
+ "mtaModeNewLabel": "Create SAPUI5 Adaptation Project in a New MTA Project",
75
+ "mtaModeExistingLabel": "Create SAPUI5 Adaptation Project in an Existing MTA Project",
76
+ "mtaIdLabel": "MTA Project Name",
77
+ "mtaIdTooltip": "Enter the name of the new MTA project to create. It must be unique within the selected folder, be 20 characters or fewer, and use letters, numbers, dots (.), underscores (_), and hyphens (-) only.",
78
+ "mtaIdBreadcrumb": "MTA Project Name",
79
+ "serviceInstanceBreadcrumb": "Service Instance",
80
+ "mtaAlreadyHasServiceInfo": "The selected MTA project already has service definition. Proceed if you want your SAPUI5 Adaptation Project to use the same service. {{serviceParameters}}",
71
81
  "businessSolutionNameLabel": "Business Solution Name",
72
82
  "businessSolutionBreadcrumb": "Business Solution",
73
83
  "businessSolutionNameTooltip": "The business solution name must be unique and use lowercase letters, numbers, dots (.), underscores (_), and hyphens (-) only. The name must contain at least one letter or number.",
@@ -118,11 +128,19 @@
118
128
  "cfTargetMismatch": "The active Cloud Foundry session doesn't match the expected organization and space of the project.",
119
129
  "baseAppHasToBeSelected": "Base application has to be selected. Please select a base application.",
120
130
  "businessServiceHasToBeSelected": "Business service has to be selected. Please select a business service.",
131
+ "serviceInstanceHasToBeSelected": "A service instance must be selected. Please select a service instance.",
132
+ "noServiceInstancesFound": "No service instances were found in the targeted Cloud Foundry space. Please create a service instance to continue.",
133
+ "noAdaptableServiceInstancesFound": "None of the service instances in the targeted Cloud Foundry space have adaptable applications.",
134
+ "mtaIdInvalid": "Invalid MTA project name. Only letters, numbers, dots (.), underscores (_), and hyphens (-) are allowed. The name must start with a letter or number.",
135
+ "mtaIdTooLong": "MTA project name must be 20 characters or fewer.",
136
+ "mtaIdAlreadyExists": "A folder with this name already exists in the selected location. Please choose a different MTA project name.",
121
137
  "businessServiceDoesNotExist": "The service chosen does not exist in cockpit or the user is not member of the needed space.",
122
138
  "businessSolutionNameInvalid": "Invalid business solution name. Only lowercase letters, numbers, dots (.), underscores (_), and hyphens (-) are allowed. The name must contain at least one letter or number.",
123
139
  "cfLoginCannotBeDetected": "CF Login cannot be detected as an extension in Visual Studio Code. For more information, see (link not yet available).",
124
140
  "projectDoesNotExist": "The project does not exist. Please select an MTA project.",
125
141
  "projectDoesNotExistMta": "Provide the path to the MTA project where you want to have your Adaptation Project created.",
142
+ "projectSpaceMismatch": "The selected MTA project was created for a different Cloud Foundry space. Log in to that space, or choose another project.",
143
+ "newModeFolderAlreadyMta": "The selected folder is already an MTA project. Choose an empty folder to create a new MTA project, or select 'Create SAPUI5 Adaptation Project in an Existing MTA Project'.",
126
144
  "noAdaptableBusinessServiceFoundInMta": "No adaptable business service found in the MTA.",
127
145
  "noAppsFoundForBusinessService": "No applications were found for the selected business service. Please check the service configuration.",
128
146
  "fetchBaseInboundsFailed": "Fetching base application inbounds failed: {{error}}.",
@@ -29,6 +29,10 @@ export interface AdpTelemetryProperties {
29
29
  * Base app technical name (SAP app ID).
30
30
  */
31
31
  baseAppTechnicalName?: string;
32
+ /**
33
+ * The service offering of the CF service instance bound to the project (CF flow only).
34
+ */
35
+ cfServiceOffering?: string;
32
36
  /**
33
37
  * UI5 version selected by the user.
34
38
  */
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": "1.0.76",
6
+ "version": "1.1.1",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,23 +30,23 @@
30
30
  "i18next": "26.5.11",
31
31
  "yeoman-generator": "5.10.0",
32
32
  "uuid": "11.1.1",
33
- "@sap-ux/feature-toggle": "1.0.5",
33
+ "@sap-ux/adp-tooling": "1.1.1",
34
34
  "@sap-ux/btp-utils": "2.0.8",
35
- "@sap-ux/adp-tooling": "1.0.70",
36
- "@sap-ux/axios-extension": "2.1.5",
37
- "@sap-ux/inquirer-common": "1.0.51",
38
- "@sap-ux/logger": "1.0.3",
39
- "@sap-ux/project-access": "2.3.3",
35
+ "@sap-ux/feature-toggle": "1.0.5",
36
+ "@sap-ux/axios-extension": "2.1.6",
37
+ "@sap-ux/inquirer-common": "1.0.53",
38
+ "@sap-ux/project-access": "2.3.4",
40
39
  "@sap-ux/store": "2.0.8",
41
- "@sap-ux/system-access": "1.0.19",
42
- "@sap-ux/fiori-generator-shared": "1.2.25",
43
- "@sap-ux/project-input-validator": "1.0.26",
44
- "@sap-ux/odata-service-writer": "1.0.28",
45
- "@sap-ux/telemetry": "2.0.14"
40
+ "@sap-ux/logger": "1.0.3",
41
+ "@sap-ux/system-access": "1.0.20",
42
+ "@sap-ux/fiori-generator-shared": "1.2.27",
43
+ "@sap-ux/project-input-validator": "1.0.27",
44
+ "@sap-ux/odata-service-writer": "1.0.29",
45
+ "@sap-ux/telemetry": "2.0.15"
46
46
  },
47
47
  "devDependencies": {
48
- "@jest/globals": "30.4.1",
49
- "@jest/types": "30.4.1",
48
+ "@jest/globals": "30.5.2",
49
+ "@jest/types": "30.5.1",
50
50
  "@types/fs-extra": "11.0.4",
51
51
  "@types/inquirer": "8.2.6",
52
52
  "@types/vscode": "1.110.0",
@@ -58,7 +58,7 @@
58
58
  "fs-extra": "11.4.1",
59
59
  "rimraf": "6.1.3",
60
60
  "yeoman-test": "6.3.0",
61
- "@sap-ux/deploy-config-sub-generator": "1.0.86"
61
+ "@sap-ux/deploy-config-sub-generator": "1.0.89"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22.x"