@sap-ux/adp-flp-config-sub-generator 0.2.10 → 1.0.0

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.
@@ -1,4 +1,4 @@
1
- import type { FlpConfigOptions } from './types';
1
+ import type { FlpConfigOptions } from './types.js';
2
2
  import Generator from 'yeoman-generator';
3
3
  /**
4
4
  * Generator for adding a FLP configuration to an adaptation project.
@@ -1,29 +1,24 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
7
- const node_path_1 = require("node:path");
8
- const axios_extension_1 = require("@sap-ux/axios-extension");
9
- const adp_tooling_1 = require("@sap-ux/adp-tooling");
10
- const logger_1 = require("@sap-ux/logger");
11
- const telemetryEvents_1 = require("../telemetryEvents");
12
- const flp_config_inquirer_1 = require("@sap-ux/flp-config-inquirer");
13
- const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
14
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
15
- const feature_toggle_1 = require("@sap-ux/feature-toggle");
16
- const project_access_1 = require("@sap-ux/project-access");
17
- const utils_1 = require("../utils");
18
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
19
- const btp_utils_1 = require("@sap-ux/btp-utils");
20
- const appWizardCache_1 = require("../utils/appWizardCache");
1
+ import Generator from 'yeoman-generator';
2
+ import { join, basename } from 'node:path';
3
+ import { isAxiosError, AdaptationProjectType } from '@sap-ux/axios-extension';
4
+ import { getVariant, getAdpConfig, isCFEnvironment, generateInboundConfig, flpConfigurationExists, SystemLookup, getBaseAppInbounds, getCfBaseAppInbounds, loadCfConfig, isLoggedInCf, getAppParamsFromUI5Yaml, getExistingAdpProjectType } from '@sap-ux/adp-tooling';
5
+ import { ToolsLogger } from '@sap-ux/logger';
6
+ import { EventName } from '../telemetryEvents/index.js';
7
+ import { getPrompts, getAdpFlpConfigPromptOptions, getAdpFlpInboundsWriterConfig, getTileSettingsQuestions, tilePromptNames, tileActions } from '@sap-ux/flp-config-inquirer';
8
+ import { AppWizard, Prompts, MessageType } from '@sap-devx/yeoman-ui-types';
9
+ import { DefaultLogger, TelemetryHelper, sendTelemetry, isCli, setYeomanEnvConflicterForce } from '@sap-ux/fiori-generator-shared';
10
+ import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
11
+ import { FileName, getAppType } from '@sap-ux/project-access';
12
+ import { AdpFlpConfigLogger, t, initI18n, getAbapServiceProvider } from '../utils/index.js';
13
+ import { ErrorHandler, getCredentialsPrompts } from '@sap-ux/inquirer-common';
14
+ import { isAppStudio } from '@sap-ux/btp-utils';
15
+ import { initAppWizardCache, addToCache, getFromCache, deleteCache } from '../utils/appWizardCache.js';
21
16
  /**
22
17
  * Generator for adding a FLP configuration to an adaptation project.
23
18
  *
24
19
  * @extends Generator
25
20
  */
26
- class AdpFlpConfigGenerator extends yeoman_generator_1.default {
21
+ export default class AdpFlpConfigGenerator extends Generator {
27
22
  setPromptsCallback;
28
23
  prompts;
29
24
  // Flag to determine if the generator was launched as a sub-generator or standalone
@@ -54,24 +49,24 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
54
49
  */
55
50
  constructor(args, opts) {
56
51
  super(args, opts);
57
- this.appWizard = opts.appWizard ?? yeoman_ui_types_1.AppWizard.create(opts);
52
+ this.appWizard = opts.appWizard ?? AppWizard.create(opts);
58
53
  this.launchAsSubGen = !!opts.launchAsSubGen;
59
- this.toolsLogger = new logger_1.ToolsLogger();
60
- this.logger = opts.logger ?? fiori_generator_shared_1.DefaultLogger;
54
+ this.toolsLogger = new ToolsLogger();
55
+ this.logger = opts.logger ?? DefaultLogger;
61
56
  this.projectRootPath = opts.data?.projectRootPath ?? this.destinationRoot();
62
57
  this.options = opts;
63
58
  this.vscode = opts.vscode;
64
59
  this.inbounds = opts.inbounds;
65
60
  this.layer = opts.layer;
66
61
  this.isCfProject = !!opts.isCfProject;
67
- (0, appWizardCache_1.initAppWizardCache)(this.logger, this.appWizard);
62
+ initAppWizardCache(this.logger, this.appWizard);
68
63
  this._setupFLPConfigPrompts();
69
64
  this._setupLogging();
70
65
  }
71
66
  async initializing() {
72
- await (0, utils_1.initI18n)();
67
+ await initI18n();
73
68
  // Force the generator to overwrite existing files without additional prompting
74
- (0, fiori_generator_shared_1.setYeomanEnvConflicterForce)(this.env, this.options.force);
69
+ setYeomanEnvConflicterForce(this.env, this.options.force);
75
70
  this._setupFLPConfigPage();
76
71
  if (!this.launchAsSubGen) {
77
72
  await this._initializeStandAloneGenerator();
@@ -80,18 +75,18 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
80
75
  }
81
76
  }
82
77
  // Add telemetry to be sent once adp-flp-config is generated
83
- await fiori_generator_shared_1.TelemetryHelper.initTelemetrySettings({
78
+ await TelemetryHelper.initTelemetrySettings({
84
79
  consumerModule: {
85
80
  name: '@sap/generator-fiori-deployment:adp-flp-config',
86
81
  version: this.rootGeneratorVersion()
87
82
  },
88
- internalFeature: (0, feature_toggle_1.isInternalFeaturesSettingEnabled)(),
83
+ internalFeature: isInternalFeaturesSettingEnabled(),
89
84
  watchTelemetrySettingStore: false
90
85
  });
91
86
  }
92
87
  async prompting() {
93
88
  // If authentication was already prompted it should not be skipped as this leads to issues with Yeoman UI navigation
94
- const credentialsPrompted = (0, appWizardCache_1.getFromCache)(this.appWizard, 'credentialsPrompted', this.logger);
89
+ const credentialsPrompted = getFromCache(this.appWizard, 'credentialsPrompted', this.logger);
95
90
  if (this.authenticationRequired || credentialsPrompted) {
96
91
  await this._promptAuthentication();
97
92
  }
@@ -105,10 +100,10 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
105
100
  }
106
101
  }
107
102
  this.tileSettingsAnswers = await this._promptTileActions();
108
- if (this.tileSettingsAnswers?.[flp_config_inquirer_1.tilePromptNames.tileHandlingAction] === flp_config_inquirer_1.tileActions.REPLACE) {
103
+ if (this.tileSettingsAnswers?.[tilePromptNames.tileHandlingAction] === tileActions.REPLACE) {
109
104
  this._setupReplacePage();
110
105
  }
111
- const prompts = await (0, flp_config_inquirer_1.getPrompts)(this.inbounds, (0, flp_config_inquirer_1.getAdpFlpConfigPromptOptions)(this.tileSettingsAnswers, this.inbounds, this.variant, this.isCfProject));
106
+ const prompts = await getPrompts(this.inbounds, getAdpFlpConfigPromptOptions(this.tileSettingsAnswers, this.inbounds, this.variant, this.isCfProject));
112
107
  this.answers = await this.prompt(prompts);
113
108
  }
114
109
  async writing() {
@@ -116,29 +111,29 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
116
111
  return;
117
112
  }
118
113
  try {
119
- const config = (0, flp_config_inquirer_1.getAdpFlpInboundsWriterConfig)(this.answers, this.layer, this.tileSettingsAnswers, this.inbounds);
120
- await (0, adp_tooling_1.generateInboundConfig)(this.projectRootPath, config, this.fs);
114
+ const config = getAdpFlpInboundsWriterConfig(this.answers, this.layer, this.tileSettingsAnswers, this.inbounds);
115
+ await generateInboundConfig(this.projectRootPath, config, this.fs);
121
116
  }
122
117
  catch (error) {
123
118
  this.logger.error(`Writing phase failed: ${error}`);
124
- throw new Error((0, utils_1.t)('error.updatingApp'));
119
+ throw new Error(t('error.updatingApp'));
125
120
  }
126
121
  }
127
122
  end() {
128
- (0, appWizardCache_1.deleteCache)(this.appWizard, this.logger);
123
+ deleteCache(this.appWizard, this.logger);
129
124
  if (this.abort) {
130
125
  return;
131
126
  }
132
127
  if (!this.launchAsSubGen) {
133
- this.appWizard?.showInformation((0, utils_1.t)('info.flpConfigAdded'), yeoman_ui_types_1.MessageType.notification);
128
+ this.appWizard?.showInformation(t('info.flpConfigAdded'), MessageType.notification);
134
129
  }
135
- const telemetryData = fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
130
+ const telemetryData = TelemetryHelper.createTelemetryData({
136
131
  appType: 'adp-flp-config',
137
132
  ...this.options.telemetryData
138
133
  }) ?? {};
139
134
  if (telemetryData) {
140
- (0, fiori_generator_shared_1.sendTelemetry)(telemetryEvents_1.EventName.ADP_FLP_CONFIG_ADDED, telemetryData, this.projectRootPath).catch((error) => {
141
- this.logger.error((0, utils_1.t)('error.telemetry', { error }));
135
+ sendTelemetry(EventName.ADP_FLP_CONFIG_ADDED, telemetryData, this.projectRootPath).catch((error) => {
136
+ this.logger.error(t('error.telemetry', { error }));
142
137
  });
143
138
  }
144
139
  }
@@ -148,21 +143,21 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
148
143
  * @returns {void}
149
144
  */
150
145
  async _promptAuthentication() {
151
- const prompts = await (0, inquirer_common_1.getCredentialsPrompts)(async (credentials) => {
146
+ const prompts = await getCredentialsPrompts(async (credentials) => {
152
147
  this.credentials = credentials;
153
148
  try {
154
- this.provider = await (0, utils_1.getAbapServiceProvider)(this.ui5Yaml, this.toolsLogger, this.credentials);
155
- this.inbounds = await (0, adp_tooling_1.getBaseAppInbounds)(this.appId, this.provider);
156
- (0, appWizardCache_1.addToCache)(this.appWizard, { provider: this.provider, credentialsPrompted: true }, this.logger);
149
+ this.provider = await getAbapServiceProvider(this.ui5Yaml, this.toolsLogger, this.credentials);
150
+ this.inbounds = await getBaseAppInbounds(this.appId, this.provider);
151
+ addToCache(this.appWizard, { provider: this.provider, credentialsPrompted: true }, this.logger);
157
152
  }
158
153
  catch (error) {
159
- if (!(0, axios_extension_1.isAxiosError)(error)) {
154
+ if (!isAxiosError(error)) {
160
155
  this.logger.error(`Base application inbounds fetching failed: ${error}`);
161
- throw new Error((0, utils_1.t)('error.baseAppInboundsFetching'));
156
+ throw new Error(t('error.baseAppInboundsFetching'));
162
157
  }
163
158
  this.authenticationRequired = this._checkAuthRequired(error);
164
159
  if (this.authenticationRequired) {
165
- return (0, utils_1.t)('error.authenticationFailed');
160
+ return t('error.authenticationFailed');
166
161
  }
167
162
  return this._getErrorHandlerMessage(error) ?? false;
168
163
  }
@@ -174,8 +169,8 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
174
169
  }
175
170
  this.prompts.splice(0, 0, [
176
171
  {
177
- name: (0, utils_1.t)('yuiNavSteps.flpCredentialsName'),
178
- description: (0, utils_1.t)('yuiNavSteps.flpCredentialsDesc', { system: systemName })
172
+ name: t('yuiNavSteps.flpCredentialsName'),
173
+ description: t('yuiNavSteps.flpCredentialsDesc', { system: systemName })
179
174
  }
180
175
  ]);
181
176
  await this.prompt(prompts);
@@ -186,7 +181,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
186
181
  * @param {Error | AxiosError} error - The error that occurred.
187
182
  */
188
183
  _handleFetchingError(error) {
189
- if ((0, axios_extension_1.isAxiosError)(error)) {
184
+ if (isAxiosError(error)) {
190
185
  this.logger.error(`Base application inbounds fetching failed: ${error}. Status: ${error.response?.status}. URI: ${error.request?.path}`);
191
186
  const errorHelp = this._getErrorHandlerMessage(error);
192
187
  if (errorHelp) {
@@ -197,7 +192,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
197
192
  return;
198
193
  }
199
194
  this.logger.error(`Base application inbounds fetching failed: ${error}`);
200
- throw new Error((0, utils_1.t)('error.baseAppInboundsFetching'));
195
+ throw new Error(t('error.baseAppInboundsFetching'));
201
196
  }
202
197
  /**
203
198
  * Adds navigations steps and callback function for the generator prompts.
@@ -207,7 +202,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
207
202
  if (!this.launchAsSubGen) {
208
203
  this.prompts.splice(0, 0, [
209
204
  {
210
- name: (0, utils_1.t)('yuiNavSteps.flpConfigName'),
205
+ name: t('yuiNavSteps.flpConfigName'),
211
206
  description: ''
212
207
  }
213
208
  ]);
@@ -221,15 +216,15 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
221
216
  ? Object.values(this.inbounds).map((inboundData) => {
222
217
  const title = inboundData.title ?? '';
223
218
  const navigationIntent = `${inboundData.semanticObject}-${inboundData.action}`;
224
- return (0, utils_1.t)('yuiNavSteps.flpConfigReplaceTile', { navigationIntent, title });
219
+ return t('yuiNavSteps.flpConfigReplaceTile', { navigationIntent, title });
225
220
  })
226
221
  : [];
227
222
  const pages = this.prompts['items'];
228
- const flpConfigPageIndex = pages.findIndex((p) => p.name === (0, utils_1.t)('yuiNavSteps.flpConfigName'));
223
+ const flpConfigPageIndex = pages.findIndex((p) => p.name === t('yuiNavSteps.flpConfigName'));
229
224
  this.prompts.splice(flpConfigPageIndex, 1, [
230
225
  {
231
- name: (0, utils_1.t)('yuiNavSteps.flpConfigName'),
232
- description: (0, utils_1.t)('yuiNavSteps.flpConfigReplaceCurrentTiles', { currentTiles: tileEntries.join('\n') })
226
+ name: t('yuiNavSteps.flpConfigName'),
227
+ description: t('yuiNavSteps.flpConfigReplaceCurrentTiles', { currentTiles: tileEntries.join('\n') })
233
228
  }
234
229
  ]);
235
230
  }
@@ -239,7 +234,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
239
234
  _setupFLPConfigPrompts() {
240
235
  // If launched as a sub-generator, the prompts will be set by the parent generator
241
236
  if (!this.launchAsSubGen) {
242
- this.prompts = new yeoman_ui_types_1.Prompts([]);
237
+ this.prompts = new Prompts([]);
243
238
  this.setPromptsCallback = (fn) => {
244
239
  if (this.prompts) {
245
240
  this.prompts.setCallback(fn);
@@ -257,12 +252,12 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
257
252
  return;
258
253
  }
259
254
  const pages = this.prompts['items'];
260
- const credentialsPageIndex = pages.findIndex((p) => p.name === (0, utils_1.t)('yuiNavSteps.flpCredentialsName'));
255
+ const credentialsPageIndex = pages.findIndex((p) => p.name === t('yuiNavSteps.flpCredentialsName'));
261
256
  this.prompts.splice(credentialsPageIndex + 1, 0, [
262
257
  {
263
- name: (0, utils_1.t)('yuiNavSteps.tileSettingsName'),
264
- description: (0, utils_1.t)('yuiNavSteps.tileSettingsDescr', {
265
- projectName: (0, node_path_1.basename)(this.projectRootPath)
258
+ name: t('yuiNavSteps.tileSettingsName'),
259
+ description: t('yuiNavSteps.tileSettingsDescr', {
260
+ projectName: basename(this.projectRootPath)
266
261
  })
267
262
  }
268
263
  ]);
@@ -274,11 +269,11 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
274
269
  * @returns {Promise<string>} The configured system.
275
270
  */
276
271
  async _findSystemName(target) {
277
- const systemLookup = new adp_tooling_1.SystemLookup(this.toolsLogger);
278
- const isBas = (0, btp_utils_1.isAppStudio)();
272
+ const systemLookup = new SystemLookup(this.toolsLogger);
273
+ const isBas = isAppStudio();
279
274
  const endpoint = await systemLookup.getSystemByName((isBas ? target.destination : target.url));
280
275
  if (!endpoint?.Name) {
281
- const message = isBas ? (0, utils_1.t)('error.destinationNotFound') : (0, utils_1.t)('error.systemNotFoundInStore');
276
+ const message = isBas ? t('error.destinationNotFound') : t('error.systemNotFoundInStore');
282
277
  this._abortExecution(message);
283
278
  return undefined;
284
279
  }
@@ -290,7 +285,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
290
285
  * @param {string} message - The error message to display.
291
286
  */
292
287
  _abortExecution(message) {
293
- if ((0, fiori_generator_shared_1.isCli)()) {
288
+ if (isCli()) {
294
289
  this.toolsLogger.error(message);
295
290
  }
296
291
  else {
@@ -308,9 +303,9 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
308
303
  // If `system_info` endpoint returns 404, the system is not cloud ready
309
304
  // `system_info` endpoint needs to be called before `isAbapCloud`, because `isAbapCloud` silently catches the errors
310
305
  if (error.status === 404) {
311
- return (0, utils_1.t)('error.projectNotCloudReady');
306
+ return t('error.projectNotCloudReady');
312
307
  }
313
- const errorHandler = new inquirer_common_1.ErrorHandler(undefined, undefined, '@sap-ux/adp-flp-config');
308
+ const errorHandler = new ErrorHandler(undefined, undefined, '@sap-ux/adp-flp-config');
314
309
  return errorHandler.getValidationErrorHelp(error);
315
310
  }
316
311
  /**
@@ -320,7 +315,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
320
315
  * @returns {boolean} True if authentication is required, false otherwise.
321
316
  */
322
317
  _checkAuthRequired(error) {
323
- if ((0, axios_extension_1.isAxiosError)(error)) {
318
+ if (isAxiosError(error)) {
324
319
  if (error.response?.status === 401) {
325
320
  return true;
326
321
  }
@@ -331,8 +326,8 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
331
326
  * Configures logging for the generator.
332
327
  */
333
328
  _setupLogging() {
334
- utils_1.AdpFlpConfigLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
335
- this.logger = utils_1.AdpFlpConfigLogger.logger;
329
+ AdpFlpConfigLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
330
+ this.logger = AdpFlpConfigLogger.logger;
336
331
  }
337
332
  /**
338
333
  * Prompts the user for tile actions and returns the answers.
@@ -344,13 +339,13 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
344
339
  return undefined;
345
340
  }
346
341
  this._setTileSettingsPrompts();
347
- const existingFlpConfig = !this.launchAsSubGen && (0, adp_tooling_1.flpConfigurationExists)(this.variant);
342
+ const existingFlpConfig = !this.launchAsSubGen && flpConfigurationExists(this.variant);
348
343
  const promptOptions = {
349
344
  existingFlpConfigInfo: {
350
345
  hide: !existingFlpConfig
351
346
  }
352
347
  };
353
- const tileSettingsPrompts = (0, flp_config_inquirer_1.getTileSettingsQuestions)(promptOptions);
348
+ const tileSettingsPrompts = getTileSettingsQuestions(promptOptions);
354
349
  return this.prompt(tileSettingsPrompts);
355
350
  }
356
351
  /**
@@ -359,12 +354,12 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
359
354
  * @throws {Error} If the project is not supported or not cloud ready.
360
355
  */
361
356
  async _validateProjectType() {
362
- const isFioriAdaptation = (await (0, project_access_1.getAppType)(this.projectRootPath)) === 'Fiori Adaptation';
357
+ const isFioriAdaptation = (await getAppType(this.projectRootPath)) === 'Fiori Adaptation';
363
358
  if (!isFioriAdaptation) {
364
- this._abortExecution((0, utils_1.t)('error.projectNotSupported'));
359
+ this._abortExecution(t('error.projectNotSupported'));
365
360
  return;
366
361
  }
367
- this.isCfProject = await (0, adp_tooling_1.isCFEnvironment)(this.projectRootPath);
362
+ this.isCfProject = await isCFEnvironment(this.projectRootPath);
368
363
  }
369
364
  /**
370
365
  * Validates the project is cloud ready.
@@ -372,9 +367,9 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
372
367
  * @throws {Error} If the project is not supported or not cloud ready.
373
368
  */
374
369
  async _validateCloudProject() {
375
- const projectType = await (0, adp_tooling_1.getExistingAdpProjectType)(this.projectRootPath);
376
- if (projectType !== axios_extension_1.AdaptationProjectType.CLOUD_READY) {
377
- this._abortExecution((0, utils_1.t)('error.projectNotCloudReady'));
370
+ const projectType = await getExistingAdpProjectType(this.projectRootPath);
371
+ if (projectType !== AdaptationProjectType.CLOUD_READY) {
372
+ this._abortExecution(t('error.projectNotCloudReady'));
378
373
  }
379
374
  }
380
375
  /**
@@ -387,7 +382,7 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
387
382
  if (this.abort) {
388
383
  return;
389
384
  }
390
- this.variant = await (0, adp_tooling_1.getVariant)(this.projectRootPath, this.fs);
385
+ this.variant = await getVariant(this.projectRootPath, this.fs);
391
386
  this.appId = this.variant.reference;
392
387
  this.layer = this.variant.layer;
393
388
  if (this.isCfProject) {
@@ -403,10 +398,10 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
403
398
  * @returns {Promise<void>} A promise that resolves when initialization is complete.
404
399
  */
405
400
  async _initializeAbapGenerator() {
406
- this.ui5Yaml = await (0, adp_tooling_1.getAdpConfig)(this.projectRootPath, (0, node_path_1.join)(this.projectRootPath, project_access_1.FileName.Ui5Yaml));
401
+ this.ui5Yaml = await getAdpConfig(this.projectRootPath, join(this.projectRootPath, FileName.Ui5Yaml));
407
402
  await this._initAbapServiceProvider();
408
403
  try {
409
- this.inbounds = this.inbounds ?? (await (0, adp_tooling_1.getBaseAppInbounds)(this.appId, this.provider));
404
+ this.inbounds = this.inbounds ?? (await getBaseAppInbounds(this.appId, this.provider));
410
405
  }
411
406
  catch (error) {
412
407
  this.authenticationRequired = this._checkAuthRequired(error);
@@ -422,24 +417,24 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
422
417
  * @returns {Promise<void>} A promise that resolves when initialization is complete.
423
418
  */
424
419
  async _initializeCfGenerator() {
425
- const cfConfig = (0, adp_tooling_1.loadCfConfig)(this.toolsLogger);
426
- if (!(await (0, adp_tooling_1.isLoggedInCf)(cfConfig, this.toolsLogger))) {
427
- this._abortExecution((0, utils_1.t)('error.cfLoginRequired'));
420
+ const cfConfig = loadCfConfig(this.toolsLogger);
421
+ if (!(await isLoggedInCf(cfConfig, this.toolsLogger))) {
422
+ this._abortExecution(t('error.cfLoginRequired'));
428
423
  return;
429
424
  }
430
- const appParams = (0, adp_tooling_1.getAppParamsFromUI5Yaml)(this.projectRootPath);
425
+ const appParams = getAppParamsFromUI5Yaml(this.projectRootPath);
431
426
  if (!appParams.appHostId) {
432
- this._abortExecution((0, utils_1.t)('error.cfAppHostIdMissing'));
427
+ this._abortExecution(t('error.cfAppHostIdMissing'));
433
428
  return;
434
429
  }
435
430
  try {
436
431
  this.inbounds =
437
432
  this.inbounds ??
438
- (await (0, adp_tooling_1.getCfBaseAppInbounds)(this.appId, appParams.appHostId, cfConfig, this.toolsLogger));
433
+ (await getCfBaseAppInbounds(this.appId, appParams.appHostId, cfConfig, this.toolsLogger));
439
434
  }
440
435
  catch (e) {
441
436
  this.toolsLogger.error(`CF inbounds fetching failed: ${e}`);
442
- this._abortExecution((0, utils_1.t)('error.cfInboundsFetchFailed', { error: e.message }));
437
+ this._abortExecution(t('error.cfInboundsFetchFailed', { error: e.message }));
443
438
  }
444
439
  }
445
440
  /**
@@ -449,14 +444,13 @@ class AdpFlpConfigGenerator extends yeoman_generator_1.default {
449
444
  * @returns {Promise<void>} A promise that resolves when the AbapServiceProvider is initialized.
450
445
  */
451
446
  async _initAbapServiceProvider() {
452
- const cachedProvider = (0, appWizardCache_1.getFromCache)(this.appWizard, 'provider', this.logger);
447
+ const cachedProvider = getFromCache(this.appWizard, 'provider', this.logger);
453
448
  if (cachedProvider) {
454
449
  this.provider = cachedProvider;
455
450
  return;
456
451
  }
457
- this.provider = await (0, utils_1.getAbapServiceProvider)(this.ui5Yaml, this.toolsLogger);
458
- (0, appWizardCache_1.addToCache)(this.appWizard, { provider: this.provider }, this.logger);
452
+ this.provider = await getAbapServiceProvider(this.ui5Yaml, this.toolsLogger);
453
+ addToCache(this.appWizard, { provider: this.provider }, this.logger);
459
454
  }
460
455
  }
461
- exports.default = AdpFlpConfigGenerator;
462
456
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventName = void 0;
4
1
  /**
5
2
  * Event names for telemetry for the adaptation project fiori launchpad configuration generator
6
3
  */
7
- var EventName;
4
+ export var EventName;
8
5
  (function (EventName) {
9
6
  EventName["ADP_FLP_CONFIG_ADDED"] = "ADP_FLP_CONFIG_ADDED";
10
- })(EventName || (exports.EventName = EventName = {}));
7
+ })(EventName || (EventName = {}));
11
8
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { type ILogWrapper } from '@sap-ux/fiori-generator-shared';
2
- import type { State } from '../app/types';
2
+ import type { State } from '../app/types.js';
3
3
  import type { AppWizard } from '@sap-devx/yeoman-ui-types';
4
4
  declare const ADP_FLP_CONFIG_CACHE = "$adp-flp-config-cache";
5
5
  export type AppWizardCache = AppWizard & {
@@ -1,20 +1,14 @@
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");
1
+ import { getHostEnvironment, hostEnvironment } from '@sap-ux/fiori-generator-shared';
2
+ import { t } from '../utils/i18n.js';
9
3
  const ADP_FLP_CONFIG_CACHE = '$adp-flp-config-cache';
10
- const hostEnv = (0, fiori_generator_shared_1.getHostEnvironment)();
4
+ const hostEnv = getHostEnvironment();
11
5
  /**
12
6
  * Initialize the cache object in the appWizard object. N.B. this will update the passed reference.
13
7
  *
14
8
  * @param logger - Logger to log messages.
15
9
  * @param appWizard - AppWizard object to initialize the cache in.
16
10
  */
17
- function initAppWizardCache(logger, appWizard) {
11
+ export function initAppWizardCache(logger, appWizard) {
18
12
  if (appWizard && !appWizard[ADP_FLP_CONFIG_CACHE]) {
19
13
  appWizard[ADP_FLP_CONFIG_CACHE] = { credentialsPrompted: false };
20
14
  logger.debug('AppWizard based cache initialized.');
@@ -27,7 +21,7 @@ function initAppWizardCache(logger, appWizard) {
27
21
  * @param state - Partial state to add to the cache.
28
22
  * @param logger - Logger to log messages.
29
23
  */
30
- function addToCache(appWizard, state, logger) {
24
+ export function addToCache(appWizard, state, logger) {
31
25
  logIfCacheMissing(appWizard, logger);
32
26
  if (appWizard?.[ADP_FLP_CONFIG_CACHE]) {
33
27
  Object.assign(appWizard[ADP_FLP_CONFIG_CACHE], state);
@@ -41,7 +35,7 @@ function addToCache(appWizard, state, logger) {
41
35
  * @param logger - Logger to log messages.
42
36
  * @returns The cached state of the specified key or undefined if not found.
43
37
  */
44
- function getFromCache(appWizard, cacheKey, logger) {
38
+ export function getFromCache(appWizard, cacheKey, logger) {
45
39
  logIfCacheMissing(appWizard, logger);
46
40
  return appWizard?.[ADP_FLP_CONFIG_CACHE]?.[cacheKey];
47
41
  }
@@ -51,7 +45,7 @@ function getFromCache(appWizard, cacheKey, logger) {
51
45
  * @param appWizard - AppWizard object with the cache object.
52
46
  * @param logger - Logger to log messages.
53
47
  */
54
- function deleteCache(appWizard, logger) {
48
+ export function deleteCache(appWizard, logger) {
55
49
  logIfCacheMissing(appWizard, logger);
56
50
  if (appWizard?.[ADP_FLP_CONFIG_CACHE]) {
57
51
  delete appWizard[ADP_FLP_CONFIG_CACHE];
@@ -64,8 +58,8 @@ function deleteCache(appWizard, logger) {
64
58
  * @param logger - Logger to log messages.
65
59
  */
66
60
  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'));
61
+ if (hostEnv === hostEnvironment.vscode && !appWizard?.[ADP_FLP_CONFIG_CACHE]) {
62
+ logger.info(t('logMessages.warningCachingNotSupported'));
69
63
  }
70
64
  }
71
65
  //# sourceMappingURL=appWizardCache.js.map
@@ -1,29 +1,21 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.i18n = void 0;
7
- exports.initI18n = initI18n;
8
- exports.t = t;
9
- const i18next_1 = __importDefault(require("i18next"));
10
- const adp_flp_config_sub_generator_i18n_json_1 = __importDefault(require("../translations/adp-flp-config-sub-generator.i18n.json"));
11
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
12
- const flp_config_inquirer_1 = require("@sap-ux/flp-config-inquirer");
1
+ import i18next from 'i18next';
2
+ import translations from '../translations/adp-flp-config-sub-generator.i18n.json' with { type: 'json' };
3
+ import { addi18nResourceBundle as addInquirerCommonResourceBundle } from '@sap-ux/inquirer-common';
4
+ import { addi18nResourceBundle as addFlpConfigInquirerResourceBundler } from '@sap-ux/flp-config-inquirer';
13
5
  const adpFlpConfigI18nNamespace = 'adp-flp-config-sub-generator';
14
- exports.i18n = i18next_1.default.createInstance();
6
+ export const i18n = i18next.createInstance();
15
7
  /**
16
8
  * Initialize i18next with the translations for this module.
17
9
  */
18
- async function initI18n() {
19
- await exports.i18n.init({
10
+ export async function initI18n() {
11
+ await i18n.init({
20
12
  lng: 'en',
21
13
  fallbackLng: 'en',
22
14
  showSupportNotice: false
23
15
  });
24
- exports.i18n.addResourceBundle('en', adpFlpConfigI18nNamespace, adp_flp_config_sub_generator_i18n_json_1.default);
25
- (0, inquirer_common_1.addi18nResourceBundle)();
26
- (0, flp_config_inquirer_1.addi18nResourceBundle)();
16
+ i18n.addResourceBundle('en', adpFlpConfigI18nNamespace, translations);
17
+ addInquirerCommonResourceBundle();
18
+ addFlpConfigInquirerResourceBundler();
27
19
  }
28
20
  /**
29
21
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -32,13 +24,11 @@ async function initI18n() {
32
24
  * @param options additional options
33
25
  * @returns {string} localized string stored for the given key
34
26
  */
35
- function t(key, options) {
27
+ export function t(key, options) {
36
28
  if (!options?.ns) {
37
29
  options = Object.assign(options ?? {}, { ns: adpFlpConfigI18nNamespace });
38
30
  }
39
- return exports.i18n.t(key, options);
31
+ return i18n.t(key, options);
40
32
  }
41
- initI18n().catch(() => {
42
- // Needed for lint
43
- });
33
+ void initI18n().catch(() => undefined);
44
34
  //# sourceMappingURL=i18n.js.map
@@ -1,5 +1,5 @@
1
- export * from './provider';
2
- export * from './logger';
3
- export * from './appWizardCache';
4
- export * from './i18n';
1
+ export * from './provider.js';
2
+ export * from './logger.js';
3
+ export * from './appWizardCache.js';
4
+ export * from './i18n.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,21 +1,5 @@
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);
1
+ export * from './provider.js';
2
+ export * from './logger.js';
3
+ export * from './appWizardCache.js';
4
+ export * from './i18n.js';
21
5
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdpFlpConfigLogger = void 0;
4
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
1
+ import { DefaultLogger, LogWrapper } from '@sap-ux/fiori-generator-shared';
5
2
  /**
6
3
  * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
7
4
  */
8
- class AdpFlpConfigLogger {
9
- static _logger = fiori_generator_shared_1.DefaultLogger;
5
+ export class AdpFlpConfigLogger {
6
+ static _logger = DefaultLogger;
10
7
  /**
11
8
  * Get the logger.
12
9
  *
@@ -34,9 +31,8 @@ class AdpFlpConfigLogger {
34
31
  * @param logWrapper - log wrapper instance
35
32
  */
36
33
  static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel, logWrapper) {
37
- const logger = logWrapper ?? new fiori_generator_shared_1.LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
34
+ const logger = logWrapper ?? new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
38
35
  AdpFlpConfigLogger.logger = logger;
39
36
  }
40
37
  }
41
- exports.AdpFlpConfigLogger = AdpFlpConfigLogger;
42
38
  //# sourceMappingURL=logger.js.map
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAbapServiceProvider = getAbapServiceProvider;
4
- const system_access_1 = require("@sap-ux/system-access");
1
+ import { createAbapServiceProvider } from '@sap-ux/system-access';
5
2
  /**
6
3
  * Creates and returns an instance of AbapServiceProvider using the current UI5 YAML configuration and credentials.
7
4
  *
@@ -10,12 +7,12 @@ const system_access_1 = require("@sap-ux/system-access");
10
7
  * @param {CredentialsAnswers} [credentials] - Optional credentials for authentication against the ABAP system.
11
8
  * @returns {Promise<AbapServiceProvider>} The ABAP service provider instance.
12
9
  */
13
- async function getAbapServiceProvider(ui5Yaml, logger, credentials) {
10
+ export async function getAbapServiceProvider(ui5Yaml, logger, credentials) {
14
11
  const { target, ignoreCertErrors = false } = ui5Yaml;
15
12
  const requestOptions = { ignoreCertErrors };
16
13
  if (credentials) {
17
14
  requestOptions['auth'] = { username: credentials.username, password: credentials.password };
18
15
  }
19
- return (0, system_access_1.createAbapServiceProvider)(target, requestOptions, false, logger);
16
+ return createAbapServiceProvider(target, requestOptions, false, logger);
20
17
  }
21
18
  //# sourceMappingURL=provider.js.map
package/package.json CHANGED
@@ -1,12 +1,13 @@
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.2.10",
4
+ "version": "1.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
8
8
  "directory": "packages/adp-flp-config-sub-generator"
9
9
  },
10
+ "type": "module",
10
11
  "bugs": {
11
12
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
12
13
  },
@@ -22,19 +23,20 @@
22
23
  "@sap-devx/yeoman-ui-types": "1.25.0",
23
24
  "i18next": "25.10.10",
24
25
  "yeoman-generator": "5.10.0",
25
- "@sap-ux/adp-tooling": "0.19.10",
26
- "@sap-ux/axios-extension": "1.26.1",
27
- "@sap-ux/btp-utils": "1.2.1",
28
- "@sap-ux/feature-toggle": "0.4.0",
29
- "@sap-ux/fiori-generator-shared": "0.15.6",
30
- "@sap-ux/flp-config-inquirer": "0.5.10",
31
- "@sap-ux/inquirer-common": "0.13.5",
32
- "@sap-ux/logger": "0.9.0",
33
- "@sap-ux/project-access": "1.38.1",
34
- "@sap-ux/store": "1.6.1",
35
- "@sap-ux/system-access": "0.8.2"
26
+ "@sap-ux/adp-tooling": "1.0.0",
27
+ "@sap-ux/axios-extension": "2.0.0",
28
+ "@sap-ux/btp-utils": "2.0.0",
29
+ "@sap-ux/feature-toggle": "1.0.0",
30
+ "@sap-ux/fiori-generator-shared": "1.0.0",
31
+ "@sap-ux/flp-config-inquirer": "1.0.0",
32
+ "@sap-ux/inquirer-common": "1.0.0",
33
+ "@sap-ux/logger": "1.0.0",
34
+ "@sap-ux/project-access": "2.0.0",
35
+ "@sap-ux/store": "2.0.0",
36
+ "@sap-ux/system-access": "1.0.0"
36
37
  },
37
38
  "devDependencies": {
39
+ "@jest/globals": "30.3.0",
38
40
  "@jest/types": "30.3.0",
39
41
  "@types/fs-extra": "11.0.4",
40
42
  "@types/inquirer": "8.2.6",
@@ -56,8 +58,8 @@
56
58
  "watch": "tsc --watch",
57
59
  "lint": "eslint",
58
60
  "lint:fix": "eslint --fix",
59
- "test": "jest --ci --forceExit --detectOpenHandles --colors",
60
- "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
61
+ "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
62
+ "test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
61
63
  "link": "pnpm link --global",
62
64
  "unlink": "pnpm unlink --global"
63
65
  }