@sap-ux/adp-flp-config-sub-generator 0.1.28 → 0.1.30

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.
@@ -5,7 +5,7 @@ import Generator from 'yeoman-generator';
5
5
  *
6
6
  * @extends Generator
7
7
  */
8
- export default class extends Generator {
8
+ export default class AdpFlpConfigGenerator extends Generator {
9
9
  setPromptsCallback: (fn: object) => void;
10
10
  private prompts;
11
11
  private readonly launchAsSubGen;
@@ -13,14 +13,17 @@ export default class extends Generator {
13
13
  private readonly vscode;
14
14
  private readonly toolsLogger;
15
15
  private readonly projectRootPath;
16
- private manifest;
17
16
  private answers;
18
17
  private logger;
19
18
  private authenticationRequired;
20
19
  private abort;
21
- private configuredSystem;
22
20
  private ui5Yaml;
23
21
  private credentials;
22
+ private inbounds?;
23
+ private appId;
24
+ private variant;
25
+ private tileSettingsAnswers?;
26
+ private provider;
24
27
  /**
25
28
  * Creates an instance of the generator.
26
29
  *
@@ -32,12 +35,6 @@ export default class extends Generator {
32
35
  prompting(): Promise<void>;
33
36
  writing(): Promise<void>;
34
37
  end(): void;
35
- /**
36
- * Retrieves the merged manifest for the project.
37
- *
38
- * @returns {Promise<Manifest>} The project manifest.
39
- */
40
- private _getManifest;
41
38
  /**
42
39
  * Prompts the user for authentication credentials.
43
40
  *
@@ -57,14 +54,14 @@ export default class extends Generator {
57
54
  /**
58
55
  * Sets up the prompts for the generator.
59
56
  */
60
- private _setupPrompts;
57
+ private _setupFLPConfigPrompts;
61
58
  /**
62
59
  * Finds the configured system based on the provided target in ui5.yaml configuration.
63
60
  *
64
61
  * @param {AbapTarget} target - The target ABAP system.
65
62
  * @returns {Promise<string>} The configured system.
66
63
  */
67
- private _findConfiguredSystem;
64
+ private _findSystemName;
68
65
  /**
69
66
  * Shows an error notification with the provided message and aborts the generator execution.
70
67
  *
@@ -89,6 +86,35 @@ export default class extends Generator {
89
86
  * Configures logging for the generator.
90
87
  */
91
88
  private _setupLogging;
89
+ /**
90
+ * Prompts the user for tile actions and returns the answers.
91
+ *
92
+ * @returns {Promise<(TileSettingsAnswers & FLPConfigAnswers) | undefined>} The answers from the tile actions prompt, or undefined.
93
+ */
94
+ private _promptTileActions;
95
+ /**
96
+ * Sets the tile settings prompts based on the current state of the generator.
97
+ */
98
+ private _setTileSettingsPrompts;
99
+ /**
100
+ * Validates the project type and cloud readiness.
101
+ *
102
+ * @throws {Error} If the project is not supported or not cloud ready.
103
+ */
104
+ private _validateProject;
105
+ /**
106
+ * Initializes the generator when launched as a standalone generator.
107
+ *
108
+ * @returns {Promise<void>} A promise that resolves when the initialization is complete.
109
+ */
110
+ private _initializeStandAloneGenerator;
111
+ /**
112
+ * Initializes the AbapServiceProvider for the generator. If the generator is launched as a sub-generator, the provider is taken from the options.
113
+ * If the provider is cached in the app wizard, it is retrieved from the cache, otherwise, a new AbapServiceProvider is created using the ui5.yaml configuration.
114
+ *
115
+ * @returns {Promise<void>} A promise that resolves when the AbapServiceProvider is initialized.
116
+ */
117
+ private _initAbapServiceProvider;
92
118
  }
93
119
  export type { FlpConfigOptions };
94
120
  //# sourceMappingURL=index.d.ts.map
@@ -47,17 +47,16 @@ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
47
47
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
48
48
  const feature_toggle_1 = require("@sap-ux/feature-toggle");
49
49
  const project_access_1 = require("@sap-ux/project-access");
50
- const logger_2 = __importDefault(require("../utils/logger"));
51
- const i18n_1 = require("../utils/i18n");
50
+ const utils_1 = require("../utils");
52
51
  const inquirer_common_1 = require("@sap-ux/inquirer-common");
53
- const system_access_1 = require("@sap-ux/system-access");
54
52
  const btp_utils_1 = require("@sap-ux/btp-utils");
53
+ const appWizardCache_1 = require("../utils/appWizardCache");
55
54
  /**
56
55
  * Generator for adding a FLP configuration to an adaptation project.
57
56
  *
58
57
  * @extends Generator
59
58
  */
60
- class default_1 extends yeoman_generator_1.default {
59
+ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
61
60
  setPromptsCallback;
62
61
  prompts;
63
62
  // Flag to determine if the generator was launched as a sub-generator or standalone
@@ -66,15 +65,18 @@ class default_1 extends yeoman_generator_1.default {
66
65
  vscode;
67
66
  toolsLogger;
68
67
  projectRootPath = '';
69
- manifest;
70
68
  answers;
71
69
  logger;
72
70
  authenticationRequired = false;
73
71
  // Flag to determine if the generator was aborted
74
72
  abort = false;
75
- configuredSystem;
76
73
  ui5Yaml;
77
74
  credentials;
75
+ inbounds;
76
+ appId;
77
+ variant;
78
+ tileSettingsAnswers;
79
+ provider;
78
80
  /**
79
81
  * Creates an instance of the generator.
80
82
  *
@@ -85,46 +87,27 @@ class default_1 extends yeoman_generator_1.default {
85
87
  super(args, opts);
86
88
  this.appWizard = opts.appWizard ?? yeoman_ui_types_1.AppWizard.create(opts);
87
89
  this.launchAsSubGen = !!opts.launchAsSubGen;
88
- this.configuredSystem = opts.system;
89
- this.manifest = opts.manifest;
90
90
  this.toolsLogger = new logger_1.ToolsLogger();
91
+ this.logger = opts.logger ?? fiori_generator_shared_1.DefaultLogger;
91
92
  this.projectRootPath = opts.data?.projectRootPath ?? this.destinationRoot();
92
93
  this.options = opts;
93
94
  this.vscode = opts.vscode;
94
- this._setupPrompts();
95
+ this.inbounds = opts.inbounds;
96
+ (0, appWizardCache_1.initAppWizardCache)(this.logger, this.appWizard);
97
+ this._setupFLPConfigPrompts();
95
98
  this._setupLogging();
96
99
  }
97
100
  async initializing() {
98
- await (0, i18n_1.initI18n)();
99
- // Check if the project is supported
100
- if (!this.launchAsSubGen) {
101
- const isFioriAdaptation = (await (0, project_access_1.getAppType)(this.projectRootPath)) === 'Fiori Adaptation';
102
- if (!isFioriAdaptation || (0, adp_tooling_1.isCFEnvironment)(this.projectRootPath)) {
103
- throw new Error((0, i18n_1.t)('error.projectNotSupported'));
104
- }
105
- }
101
+ await (0, utils_1.initI18n)();
106
102
  // Force the generator to overwrite existing files without additional prompting
107
103
  if (this.env.conflicter) {
108
104
  this.env.conflicter.force = this.options.force ?? true;
109
105
  }
110
106
  this._setupFLPConfigPage();
111
107
  if (!this.launchAsSubGen) {
112
- this.ui5Yaml = await (0, adp_tooling_1.getAdpConfig)(this.projectRootPath, (0, path_1.join)(this.projectRootPath, project_access_1.FileName.Ui5Yaml));
113
- this.configuredSystem ??= await this._findConfiguredSystem(this.ui5Yaml.target);
114
- }
115
- if (!this.configuredSystem) {
116
- return;
117
- }
118
- if (!this.manifest) {
119
- try {
120
- this.manifest = await this._getManifest();
121
- }
122
- catch (error) {
123
- this.authenticationRequired = this._checkAuthRequired(error);
124
- if (this.authenticationRequired) {
125
- return;
126
- }
127
- this._handleFetchingError(error);
108
+ await this._initializeStandAloneGenerator();
109
+ if (this.abort || this.authenticationRequired) {
110
+ return;
128
111
  }
129
112
  }
130
113
  // Add telemetry to be sent once adp-flp-config is generated
@@ -144,13 +127,14 @@ class default_1 extends yeoman_generator_1.default {
144
127
  if (this.abort) {
145
128
  return;
146
129
  }
147
- const inbounds = (0, adp_tooling_1.getInboundsFromManifest)(this.manifest);
148
- const appId = (0, adp_tooling_1.getRegistrationIdFromManifest)(this.manifest);
149
- const prompts = await (0, flp_config_inquirer_1.getPrompts)(inbounds, appId, {
150
- overwrite: { hide: true },
151
- createAnotherInbound: { hide: true },
152
- emptyInboundsInfo: { hide: (0, fiori_generator_shared_1.isCli)() }
153
- });
130
+ if (!this.launchAsSubGen) {
131
+ await this._validateProject();
132
+ if (this.abort) {
133
+ return;
134
+ }
135
+ }
136
+ this.tileSettingsAnswers = await this._promptTileActions();
137
+ const prompts = await (0, flp_config_inquirer_1.getPrompts)(this.inbounds, (0, flp_config_inquirer_1.getAdpFlpConfigPromptOptions)(this.tileSettingsAnswers, this.inbounds, this.variant));
154
138
  this.answers = await this.prompt(prompts);
155
139
  }
156
140
  async writing() {
@@ -158,19 +142,21 @@ class default_1 extends yeoman_generator_1.default {
158
142
  return;
159
143
  }
160
144
  try {
161
- await (0, adp_tooling_1.generateInboundConfig)(this.projectRootPath, this.answers, this.fs);
145
+ const config = (0, flp_config_inquirer_1.getAdpFlpInboundsWriterConfig)(this.answers, this.tileSettingsAnswers);
146
+ await (0, adp_tooling_1.generateInboundConfig)(this.projectRootPath, config, this.fs);
162
147
  }
163
148
  catch (error) {
164
149
  this.logger.error(`Writing phase failed: ${error}`);
165
- throw new Error((0, i18n_1.t)('error.updatingApp'));
150
+ throw new Error((0, utils_1.t)('error.updatingApp'));
166
151
  }
167
152
  }
168
153
  end() {
154
+ (0, appWizardCache_1.deleteCache)(this.appWizard, this.logger);
169
155
  if (this.abort) {
170
156
  return;
171
157
  }
172
158
  if (!this.launchAsSubGen) {
173
- this.appWizard?.showInformation((0, i18n_1.t)('info.flpConfigAdded'), yeoman_ui_types_1.MessageType.notification);
159
+ this.appWizard?.showInformation((0, utils_1.t)('info.flpConfigAdded'), yeoman_ui_types_1.MessageType.notification);
174
160
  }
175
161
  const telemetryData = fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
176
162
  appType: 'adp-flp-config',
@@ -178,26 +164,10 @@ class default_1 extends yeoman_generator_1.default {
178
164
  }) ?? {};
179
165
  if (telemetryData) {
180
166
  (0, fiori_generator_shared_1.sendTelemetry)(telemetryEvents_1.EventName.ADP_FLP_CONFIG_ADDED, telemetryData, this.projectRootPath).catch((error) => {
181
- this.logger.error((0, i18n_1.t)('error.telemetry', { error }));
167
+ this.logger.error((0, utils_1.t)('error.telemetry', { error }));
182
168
  });
183
169
  }
184
170
  }
185
- /**
186
- * Retrieves the merged manifest for the project.
187
- *
188
- * @returns {Promise<Manifest>} The project manifest.
189
- */
190
- async _getManifest() {
191
- const { target, ignoreCertErrors = false } = this.ui5Yaml;
192
- const requestOptions = { ignoreCertErrors };
193
- if (this.credentials) {
194
- requestOptions['auth'] = { username: this.credentials.username, password: this.credentials.password };
195
- }
196
- const provider = await (0, system_access_1.createAbapServiceProvider)(target, requestOptions, false, this.toolsLogger);
197
- const variant = await (0, adp_tooling_1.getVariant)(this.projectRootPath);
198
- const manifestService = await adp_tooling_1.ManifestService.initMergedManifest(provider, this.projectRootPath, variant, this.toolsLogger);
199
- return manifestService.getManifest();
200
- }
201
171
  /**
202
172
  * Prompts the user for authentication credentials.
203
173
  *
@@ -207,25 +177,31 @@ class default_1 extends yeoman_generator_1.default {
207
177
  const prompts = await (0, inquirer_common_1.getCredentialsPrompts)(async (credentials) => {
208
178
  this.credentials = credentials;
209
179
  try {
210
- this.manifest = await this._getManifest();
180
+ this.provider = await (0, utils_1.getAbapServiceProvider)(this.ui5Yaml, this.toolsLogger, this.credentials);
181
+ this.inbounds = await (0, adp_tooling_1.getBaseAppInbounds)(this.appId, this.provider);
182
+ (0, appWizardCache_1.addToCache)(this.appWizard, { provider: this.provider }, this.logger);
211
183
  }
212
184
  catch (error) {
213
185
  if (!(0, axios_extension_1.isAxiosError)(error)) {
214
- this.logger.error(`Manifest fetching failed: ${error}`);
215
- throw new Error((0, i18n_1.t)('error.fetchingManifest'));
186
+ this.logger.error(`Base application inbounds fetching failed: ${error}`);
187
+ throw new Error((0, utils_1.t)('error.baseAppInboundsFetching'));
216
188
  }
217
189
  this.authenticationRequired = this._checkAuthRequired(error);
218
190
  if (this.authenticationRequired) {
219
- return (0, i18n_1.t)('error.authenticationFailed');
191
+ return (0, utils_1.t)('error.authenticationFailed');
220
192
  }
221
193
  return this._getErrorHandlerMessage(error) ?? false;
222
194
  }
223
195
  return true;
224
196
  });
197
+ const systemName = await this._findSystemName(this.ui5Yaml.target);
198
+ if (!systemName) {
199
+ return;
200
+ }
225
201
  this.prompts.splice(0, 0, [
226
202
  {
227
- name: (0, i18n_1.t)('yuiNavSteps.flpCredentialsName'),
228
- description: (0, i18n_1.t)('yuiNavSteps.flpCredentialsDesc', { system: this.configuredSystem })
203
+ name: (0, utils_1.t)('yuiNavSteps.flpCredentialsName'),
204
+ description: (0, utils_1.t)('yuiNavSteps.flpCredentialsDesc', { system: systemName })
229
205
  }
230
206
  ]);
231
207
  await this.prompt(prompts);
@@ -237,7 +213,7 @@ class default_1 extends yeoman_generator_1.default {
237
213
  */
238
214
  _handleFetchingError(error) {
239
215
  if ((0, axios_extension_1.isAxiosError)(error)) {
240
- this.logger.error(`Manifest fetching failed: ${error}. Status: ${error.response?.status}. URI: ${error.request?.path}`);
216
+ this.logger.error(`Base application inbounds fetching failed: ${error}. Status: ${error.response?.status}. URI: ${error.request?.path}`);
241
217
  const errorHelp = this._getErrorHandlerMessage(error);
242
218
  if (errorHelp) {
243
219
  this._abortExecution(typeof errorHelp === 'string'
@@ -246,8 +222,8 @@ class default_1 extends yeoman_generator_1.default {
246
222
  }
247
223
  return;
248
224
  }
249
- this.logger.error(`Manifest fetching failed: ${error}`);
250
- throw new Error((0, i18n_1.t)('error.fetchingManifest'));
225
+ this.logger.error(`Base application inbounds fetching failed: ${error}`);
226
+ throw new Error((0, utils_1.t)('error.baseAppInboundsFetching'));
251
227
  }
252
228
  /**
253
229
  * Adds navigations steps and callback function for the generator prompts.
@@ -257,8 +233,8 @@ class default_1 extends yeoman_generator_1.default {
257
233
  if (!this.launchAsSubGen) {
258
234
  this.prompts.splice(0, 0, [
259
235
  {
260
- name: (0, i18n_1.t)('yuiNavSteps.flpConfigName'),
261
- description: (0, i18n_1.t)('yuiNavSteps.flpConfigDesc', { projectName: path_1.default.basename(this.projectRootPath) })
236
+ name: (0, utils_1.t)('yuiNavSteps.flpConfigName', { projectName: path_1.default.basename(this.projectRootPath) }),
237
+ description: ''
262
238
  }
263
239
  ]);
264
240
  }
@@ -266,7 +242,7 @@ class default_1 extends yeoman_generator_1.default {
266
242
  /**
267
243
  * Sets up the prompts for the generator.
268
244
  */
269
- _setupPrompts() {
245
+ _setupFLPConfigPrompts() {
270
246
  // If launched as a sub-generator, the prompts will be set by the parent generator
271
247
  if (!this.launchAsSubGen) {
272
248
  this.prompts = new yeoman_ui_types_1.Prompts([]);
@@ -283,33 +259,16 @@ class default_1 extends yeoman_generator_1.default {
283
259
  * @param {AbapTarget} target - The target ABAP system.
284
260
  * @returns {Promise<string>} The configured system.
285
261
  */
286
- async _findConfiguredSystem(target) {
287
- let configuredSystem;
288
- if ((0, btp_utils_1.isAppStudio)()) {
289
- configuredSystem = target?.destination;
290
- if (!configuredSystem) {
291
- this._abortExecution((0, i18n_1.t)('error.destinationNotFound'));
292
- return;
293
- }
294
- const destinations = await (0, btp_utils_1.listDestinations)();
295
- if (!(configuredSystem in destinations)) {
296
- this._abortExecution((0, i18n_1.t)('error.destinationNotFoundInStore', { destination: configuredSystem }));
297
- return;
298
- }
262
+ async _findSystemName(target) {
263
+ const systemLookup = new adp_tooling_1.SystemLookup(this.toolsLogger);
264
+ const isBas = (0, btp_utils_1.isAppStudio)();
265
+ const endpoint = await systemLookup.getSystemByName((isBas ? target.destination : target.url));
266
+ if (!endpoint?.Name) {
267
+ const message = isBas ? (0, utils_1.t)('error.destinationNotFound') : (0, utils_1.t)('error.systemNotFoundInStore');
268
+ this._abortExecution(message);
269
+ return undefined;
299
270
  }
300
- else {
301
- const url = target?.url;
302
- if (!url) {
303
- this._abortExecution((0, i18n_1.t)('error.systemNotFound'));
304
- return;
305
- }
306
- configuredSystem = (await (0, system_access_1.getCredentialsFromStore)(target, this.toolsLogger))?.name;
307
- if (!configuredSystem) {
308
- this._abortExecution((0, i18n_1.t)('error.systemNotFoundInStore', { systemUrl: url }));
309
- return;
310
- }
311
- }
312
- return configuredSystem;
271
+ return endpoint.Name;
313
272
  }
314
273
  /**
315
274
  * Shows an error notification with the provided message and aborts the generator execution.
@@ -353,9 +312,97 @@ class default_1 extends yeoman_generator_1.default {
353
312
  * Configures logging for the generator.
354
313
  */
355
314
  _setupLogging() {
356
- logger_2.default.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
357
- this.logger = logger_2.default.logger;
315
+ utils_1.AdpFlpConfigLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
316
+ this.logger = utils_1.AdpFlpConfigLogger.logger;
317
+ }
318
+ /**
319
+ * Prompts the user for tile actions and returns the answers.
320
+ *
321
+ * @returns {Promise<(TileSettingsAnswers & FLPConfigAnswers) | undefined>} The answers from the tile actions prompt, or undefined.
322
+ */
323
+ async _promptTileActions() {
324
+ if (!this.inbounds) {
325
+ return undefined;
326
+ }
327
+ this._setTileSettingsPrompts();
328
+ const existingFlpConfig = !this.launchAsSubGen && (0, adp_tooling_1.flpConfigurationExists)(this.variant);
329
+ const promptOptions = {
330
+ existingFlpConfigInfo: {
331
+ hide: !existingFlpConfig
332
+ }
333
+ };
334
+ const tileSettingsPrompts = (0, flp_config_inquirer_1.getTileSettingsQuestions)(promptOptions);
335
+ return this.prompt(tileSettingsPrompts);
336
+ }
337
+ /**
338
+ * Sets the tile settings prompts based on the current state of the generator.
339
+ */
340
+ _setTileSettingsPrompts() {
341
+ if (this.launchAsSubGen) {
342
+ return;
343
+ }
344
+ const promptsIndex = this.prompts.size() === 1 ? 0 : 1;
345
+ this.prompts.splice(promptsIndex, 0, [
346
+ {
347
+ name: (0, utils_1.t)('yuiNavSteps.tileSettingsName', {
348
+ projectName: path_1.default.basename(this.projectRootPath)
349
+ }),
350
+ description: ''
351
+ }
352
+ ]);
353
+ }
354
+ /**
355
+ * Validates the project type and cloud readiness.
356
+ *
357
+ * @throws {Error} If the project is not supported or not cloud ready.
358
+ */
359
+ async _validateProject() {
360
+ const isFioriAdaptation = (await (0, project_access_1.getAppType)(this.projectRootPath)) === 'Fiori Adaptation';
361
+ if (!isFioriAdaptation || (0, adp_tooling_1.isCFEnvironment)(this.projectRootPath)) {
362
+ this._abortExecution((0, utils_1.t)('error.projectNotSupported'));
363
+ return;
364
+ }
365
+ const isCloud = await this.provider.isAbapCloud();
366
+ if (!isCloud) {
367
+ this._abortExecution((0, utils_1.t)('error.projectNotCloudReady'));
368
+ }
369
+ }
370
+ /**
371
+ * Initializes the generator when launched as a standalone generator.
372
+ *
373
+ * @returns {Promise<void>} A promise that resolves when the initialization is complete.
374
+ */
375
+ async _initializeStandAloneGenerator() {
376
+ this.ui5Yaml = await (0, adp_tooling_1.getAdpConfig)(this.projectRootPath, (0, path_1.join)(this.projectRootPath, project_access_1.FileName.Ui5Yaml));
377
+ this.variant = await (0, adp_tooling_1.getVariant)(this.projectRootPath, this.fs);
378
+ this.appId = this.variant.reference;
379
+ await this._initAbapServiceProvider();
380
+ try {
381
+ this.inbounds = this.inbounds ?? (await (0, adp_tooling_1.getBaseAppInbounds)(this.appId, this.provider));
382
+ }
383
+ catch (error) {
384
+ this.authenticationRequired = this._checkAuthRequired(error);
385
+ if (this.authenticationRequired) {
386
+ return;
387
+ }
388
+ this._handleFetchingError(error);
389
+ }
390
+ }
391
+ /**
392
+ * Initializes the AbapServiceProvider for the generator. If the generator is launched as a sub-generator, the provider is taken from the options.
393
+ * If the provider is cached in the app wizard, it is retrieved from the cache, otherwise, a new AbapServiceProvider is created using the ui5.yaml configuration.
394
+ *
395
+ * @returns {Promise<void>} A promise that resolves when the AbapServiceProvider is initialized.
396
+ */
397
+ async _initAbapServiceProvider() {
398
+ const cachedProvider = (0, appWizardCache_1.getFromCache)(this.appWizard, 'provider', this.logger);
399
+ if (cachedProvider) {
400
+ this.provider = cachedProvider;
401
+ return;
402
+ }
403
+ this.provider = await (0, utils_1.getAbapServiceProvider)(this.ui5Yaml, this.toolsLogger);
404
+ (0, appWizardCache_1.addToCache)(this.appWizard, { provider: this.provider }, this.logger);
358
405
  }
359
406
  }
360
- exports.default = default_1;
407
+ exports.default = AdpFlpConfigGenerator;
361
408
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,8 @@
1
1
  import type { AppWizard } from '@sap-devx/yeoman-ui-types';
2
- import type { Manifest } from '@sap-ux/project-access';
3
2
  import type Generator from 'yeoman-generator';
4
3
  import type { TelemetryData } from '@sap-ux/fiori-generator-shared';
4
+ import type { AbapServiceProvider } from '@sap-ux/axios-extension';
5
+ import type { ManifestNamespace } from '@sap-ux/project-access';
5
6
  export interface FlpConfigOptions extends Generator.GeneratorOptions {
6
7
  /**
7
8
  * VSCode instance
@@ -20,9 +21,9 @@ export interface FlpConfigOptions extends Generator.GeneratorOptions {
20
21
  */
21
22
  launchAsSubGen?: boolean;
22
23
  /**
23
- * The manifest of the base application
24
+ * Application ID (refference ID) of the base application
24
25
  */
25
- manifest: Manifest;
26
+ appId?: string;
26
27
  /**
27
28
  * Telemetry data to be send after deployment configuration has been added
28
29
  */
@@ -30,8 +31,12 @@ export interface FlpConfigOptions extends Generator.GeneratorOptions {
30
31
  /**
31
32
  * Additional data for the generator
32
33
  */
34
+ inbounds: ManifestNamespace.Inbound;
33
35
  data?: {
34
36
  projectRootPath: string;
35
37
  };
36
38
  }
39
+ export interface State {
40
+ provider?: AbapServiceProvider;
41
+ }
37
42
  //# sourceMappingURL=types.d.ts.map
@@ -3,15 +3,16 @@
3
3
  "flpCredentialsName": "FLP Configuration - Credentials",
4
4
  "flpCredentialsDesc": "Enter credentials for your adaptation project's system ({{- system}})",
5
5
  "sysConfirmDesc": "Validates connection to configured system",
6
- "flpConfigName": "FLP Configuration",
7
- "flpConfigDesc": "FLP Configuration for {{- projectName}}"
6
+ "flpConfigName": "Fiori Launchpad Configuration",
7
+ "tileSettingsName": "Fiori Launchpad Configuration - Tile Settings for {{- projectName}}"
8
8
  },
9
9
  "info": {
10
10
  "flpConfigAdded": "FLP Configuration added successfully"
11
11
  },
12
12
  "error": {
13
13
  "projectNotSupported": "Unable to find a supported adaptation project",
14
- "fetchingManifest": "Error fetching merged manifest for base application",
14
+ "projectNotCloudReady": "FLP Configuration is supported for Cloud Ready adaptation projects only",
15
+ "baseAppInboundsFetching": "Error while fetching base application inbounds",
15
16
  "destinationNotFound": "Missing destination configuration in ui5.yaml",
16
17
  "destinationNotInSubaccount": "Destination not found in the subaccount: {{- destination}}",
17
18
  "systemNotFound": "Missing system configuration in ui5.yaml",
@@ -19,6 +20,7 @@
19
20
  "writingPhase": "Error in writing phase of the adaptation project FLP configuration",
20
21
  "telemetry": "Error sending telemetry data: {{- error}}",
21
22
  "updatingApp": "Error updating app with FLP configuration. Inspect the logs for full error.",
22
- "authenticationFailed": "Authentication failed."
23
+ "authenticationFailed": "Authentication failed.",
24
+ "warningCachingNotSupported": "Warning: caching is not supported"
23
25
  }
24
26
  }
@@ -0,0 +1,40 @@
1
+ import { type ILogWrapper } from '@sap-ux/fiori-generator-shared';
2
+ import type { State } from '../app/types';
3
+ import type { AppWizard } from '@sap-devx/yeoman-ui-types';
4
+ declare const ADP_FLP_CONFIG_CACHE = "$adp-flp-config-cache";
5
+ export type AppWizardCache = AppWizard & {
6
+ [ADP_FLP_CONFIG_CACHE]?: State;
7
+ };
8
+ /**
9
+ * Initialize the cache object in the appWizard object. N.B. this will update the passed reference.
10
+ *
11
+ * @param logger - Logger to log messages.
12
+ * @param appWizard - AppWizard object to initialize the cache in.
13
+ */
14
+ export declare function initAppWizardCache(logger: ILogWrapper, appWizard?: AppWizardCache): void;
15
+ /**
16
+ * Adds the specificed partial state to the app wizard cache. N.B. this will update the passed app wizard reference.
17
+ *
18
+ * @param appWizard - AppWizard object.
19
+ * @param state - Partial state to add to the cache.
20
+ * @param logger - Logger to log messages.
21
+ */
22
+ export declare function addToCache(appWizard: AppWizardCache | undefined, state: Partial<State>, logger: ILogWrapper): void;
23
+ /**
24
+ * Gets the cached state from the app wizard object based on the specified key where the key is a propert of the State type.
25
+ *
26
+ * @param appWizard - AppWizard object with the cache object.
27
+ * @param cacheKey - Key of the AdpAppWizardCache object to retrieve.
28
+ * @param logger - Logger to log messages.
29
+ * @returns The cached state of the specified key or undefined if not found.
30
+ */
31
+ export declare function getFromCache<T>(appWizard: AppWizardCache | undefined, cacheKey: keyof State, logger: ILogWrapper): T | undefined;
32
+ /**
33
+ * Deletes the cache object from the app wizard object. N.B. this will update the passed app wizard reference.
34
+ *
35
+ * @param appWizard - AppWizard object with the cache object.
36
+ * @param logger - Logger to log messages.
37
+ */
38
+ export declare function deleteCache(appWizard: AppWizardCache | undefined, logger: ILogWrapper): void;
39
+ export {};
40
+ //# sourceMappingURL=appWizardCache.d.ts.map
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initAppWizardCache = initAppWizardCache;
4
+ exports.addToCache = addToCache;
5
+ exports.getFromCache = getFromCache;
6
+ exports.deleteCache = deleteCache;
7
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
8
+ const i18n_1 = require("../utils/i18n");
9
+ const ADP_FLP_CONFIG_CACHE = '$adp-flp-config-cache';
10
+ const hostEnv = (0, fiori_generator_shared_1.getHostEnvironment)();
11
+ /**
12
+ * Initialize the cache object in the appWizard object. N.B. this will update the passed reference.
13
+ *
14
+ * @param logger - Logger to log messages.
15
+ * @param appWizard - AppWizard object to initialize the cache in.
16
+ */
17
+ function initAppWizardCache(logger, appWizard) {
18
+ if (appWizard && !appWizard[ADP_FLP_CONFIG_CACHE]) {
19
+ appWizard[ADP_FLP_CONFIG_CACHE] = {};
20
+ logger.debug('AppWizard based cache initialized.');
21
+ }
22
+ }
23
+ /**
24
+ * Adds the specificed partial state to the app wizard cache. N.B. this will update the passed app wizard reference.
25
+ *
26
+ * @param appWizard - AppWizard object.
27
+ * @param state - Partial state to add to the cache.
28
+ * @param logger - Logger to log messages.
29
+ */
30
+ function addToCache(appWizard, state, logger) {
31
+ logIfCacheMissing(appWizard, logger);
32
+ if (appWizard?.[ADP_FLP_CONFIG_CACHE]) {
33
+ Object.assign(appWizard[ADP_FLP_CONFIG_CACHE], state);
34
+ }
35
+ }
36
+ /**
37
+ * Gets the cached state from the app wizard object based on the specified key where the key is a propert of the State type.
38
+ *
39
+ * @param appWizard - AppWizard object with the cache object.
40
+ * @param cacheKey - Key of the AdpAppWizardCache object to retrieve.
41
+ * @param logger - Logger to log messages.
42
+ * @returns The cached state of the specified key or undefined if not found.
43
+ */
44
+ function getFromCache(appWizard, cacheKey, logger) {
45
+ logIfCacheMissing(appWizard, logger);
46
+ return appWizard?.[ADP_FLP_CONFIG_CACHE]?.[cacheKey];
47
+ }
48
+ /**
49
+ * Deletes the cache object from the app wizard object. N.B. this will update the passed app wizard reference.
50
+ *
51
+ * @param appWizard - AppWizard object with the cache object.
52
+ * @param logger - Logger to log messages.
53
+ */
54
+ function deleteCache(appWizard, logger) {
55
+ logIfCacheMissing(appWizard, logger);
56
+ if (appWizard?.[ADP_FLP_CONFIG_CACHE]) {
57
+ delete appWizard[ADP_FLP_CONFIG_CACHE];
58
+ }
59
+ }
60
+ /**
61
+ * Logs a warning message if the cache object is missing from the app wizard object.
62
+ *
63
+ * @param appWizard - AppWizard object with the cache object.
64
+ * @param logger - Logger to log messages.
65
+ */
66
+ function logIfCacheMissing(appWizard, logger) {
67
+ if (hostEnv === fiori_generator_shared_1.hostEnvironment.vscode && !appWizard?.[ADP_FLP_CONFIG_CACHE]) {
68
+ logger.info((0, i18n_1.t)('logMessages.warningCachingNotSupported'));
69
+ }
70
+ }
71
+ //# sourceMappingURL=appWizardCache.js.map
@@ -8,6 +8,7 @@ exports.t = t;
8
8
  const i18next_1 = __importDefault(require("i18next"));
9
9
  const adp_flp_config_sub_generator_i18n_json_1 = __importDefault(require("../translations/adp-flp-config-sub-generator.i18n.json"));
10
10
  const inquirer_common_1 = require("@sap-ux/inquirer-common");
11
+ const flp_config_inquirer_1 = require("@sap-ux/flp-config-inquirer");
11
12
  const adpFlpConfigI18nNamespace = 'adp-flp-config-sub-generator';
12
13
  /**
13
14
  * Initialize i18next with the translations for this module.
@@ -15,6 +16,7 @@ const adpFlpConfigI18nNamespace = 'adp-flp-config-sub-generator';
15
16
  async function initI18n() {
16
17
  await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', adpFlpConfigI18nNamespace, adp_flp_config_sub_generator_i18n_json_1.default));
17
18
  (0, inquirer_common_1.addi18nResourceBundle)();
19
+ (0, flp_config_inquirer_1.addi18nResourceBundle)();
18
20
  }
19
21
  /**
20
22
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -0,0 +1,5 @@
1
+ export * from './provider';
2
+ export * from './logger';
3
+ export * from './appWizardCache';
4
+ export * from './i18n';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
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("./provider"), exports);
18
+ __exportStar(require("./logger"), exports);
19
+ __exportStar(require("./appWizardCache"), exports);
20
+ __exportStar(require("./i18n"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -4,7 +4,7 @@ import type { IVSCodeExtLogger, LogLevel } from '@vscode-logging/logger';
4
4
  /**
5
5
  * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
6
  */
7
- export default class AdpFlpConfigLogger {
7
+ export declare class AdpFlpConfigLogger {
8
8
  private static _logger;
9
9
  /**
10
10
  * Get the logger.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdpFlpConfigLogger = void 0;
3
4
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
4
5
  /**
5
6
  * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
@@ -37,5 +38,5 @@ class AdpFlpConfigLogger {
37
38
  AdpFlpConfigLogger.logger = logger;
38
39
  }
39
40
  }
40
- exports.default = AdpFlpConfigLogger;
41
+ exports.AdpFlpConfigLogger = AdpFlpConfigLogger;
41
42
  //# sourceMappingURL=logger.js.map
@@ -0,0 +1,14 @@
1
+ import { type AbapServiceProvider } from '@sap-ux/axios-extension';
2
+ import { type AdpPreviewConfig } from '@sap-ux/adp-tooling';
3
+ import { type CredentialsAnswers } from '@sap-ux/inquirer-common';
4
+ import type { ToolsLogger } from '@sap-ux/logger';
5
+ /**
6
+ * Creates and returns an instance of AbapServiceProvider using the current UI5 YAML configuration and credentials.
7
+ *
8
+ * @param {AdpPreviewConfig} ui5Yaml - The UI5 YAML configuration containing the target ABAP system details.
9
+ * @param {ToolsLogger} logger - The logger instance for logging messages.
10
+ * @param {CredentialsAnswers} [credentials] - Optional credentials for authentication against the ABAP system.
11
+ * @returns {Promise<AbapServiceProvider>} The ABAP service provider instance.
12
+ */
13
+ export declare function getAbapServiceProvider(ui5Yaml: AdpPreviewConfig, logger: ToolsLogger, credentials?: CredentialsAnswers): Promise<AbapServiceProvider>;
14
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAbapServiceProvider = getAbapServiceProvider;
4
+ const system_access_1 = require("@sap-ux/system-access");
5
+ /**
6
+ * Creates and returns an instance of AbapServiceProvider using the current UI5 YAML configuration and credentials.
7
+ *
8
+ * @param {AdpPreviewConfig} ui5Yaml - The UI5 YAML configuration containing the target ABAP system details.
9
+ * @param {ToolsLogger} logger - The logger instance for logging messages.
10
+ * @param {CredentialsAnswers} [credentials] - Optional credentials for authentication against the ABAP system.
11
+ * @returns {Promise<AbapServiceProvider>} The ABAP service provider instance.
12
+ */
13
+ async function getAbapServiceProvider(ui5Yaml, logger, credentials) {
14
+ const { target, ignoreCertErrors = false } = ui5Yaml;
15
+ const requestOptions = { ignoreCertErrors };
16
+ if (credentials) {
17
+ requestOptions['auth'] = { username: credentials.username, password: credentials.password };
18
+ }
19
+ return (0, system_access_1.createAbapServiceProvider)(target, requestOptions, false, logger);
20
+ }
21
+ //# sourceMappingURL=provider.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/adp-flp-config-sub-generator",
3
3
  "description": "Generator for adding FLP configuration to an Adaptation Project",
4
- "version": "0.1.28",
4
+ "version": "0.1.30",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -22,17 +22,17 @@
22
22
  "@sap-devx/yeoman-ui-types": "1.14.4",
23
23
  "i18next": "23.5.1",
24
24
  "yeoman-generator": "5.10.0",
25
- "@sap-ux/adp-tooling": "0.14.28",
26
- "@sap-ux/axios-extension": "1.22.2",
25
+ "@sap-ux/adp-tooling": "0.14.30",
26
+ "@sap-ux/axios-extension": "1.22.3",
27
27
  "@sap-ux/btp-utils": "1.1.0",
28
28
  "@sap-ux/feature-toggle": "0.3.0",
29
- "@sap-ux/fiori-generator-shared": "0.12.8",
30
- "@sap-ux/flp-config-inquirer": "0.3.28",
31
- "@sap-ux/inquirer-common": "0.7.13",
29
+ "@sap-ux/fiori-generator-shared": "0.12.10",
30
+ "@sap-ux/flp-config-inquirer": "0.3.30",
31
+ "@sap-ux/inquirer-common": "0.7.15",
32
32
  "@sap-ux/logger": "0.7.0",
33
- "@sap-ux/project-access": "1.30.2",
33
+ "@sap-ux/project-access": "1.30.3",
34
34
  "@sap-ux/store": "1.1.0",
35
- "@sap-ux/system-access": "0.6.7"
35
+ "@sap-ux/system-access": "0.6.8"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/types": "29.6.3",