@sap-ux/generator-adp 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/generators/add-annotations-to-odata/index.js +20 -15
  2. package/generators/add-component-usages/index.js +21 -16
  3. package/generators/add-new-model/index.js +29 -24
  4. package/generators/app/extension-project/index.js +9 -6
  5. package/generators/app/index.js +135 -129
  6. package/generators/app/layer.js +8 -5
  7. package/generators/app/questions/attributes.js +65 -60
  8. package/generators/app/questions/cf-services.js +52 -48
  9. package/generators/app/questions/configuration.js +129 -125
  10. package/generators/app/questions/helper/additional-messages.js +36 -29
  11. package/generators/app/questions/helper/choices.js +25 -16
  12. package/generators/app/questions/helper/conditions.js +23 -14
  13. package/generators/app/questions/helper/default-values.js +13 -8
  14. package/generators/app/questions/helper/message.js +11 -7
  15. package/generators/app/questions/helper/tooltip.js +7 -4
  16. package/generators/app/questions/helper/validators.js +39 -29
  17. package/generators/app/questions/key-user.js +45 -40
  18. package/generators/app/questions/target-env.js +27 -22
  19. package/generators/app/types.js +16 -13
  20. package/generators/base/questions/credentials.js +18 -15
  21. package/generators/base/sub-gen-auth-base.js +30 -24
  22. package/generators/base/sub-gen-base.js +17 -11
  23. package/generators/change-data-source/index.js +13 -8
  24. package/generators/telemetry/collector.js +10 -6
  25. package/generators/telemetry/events.js +5 -2
  26. package/generators/telemetry/index.js +18 -2
  27. package/generators/types.js +5 -2
  28. package/generators/utils/appWizardCache.js +13 -7
  29. package/generators/utils/deps.d.ts +6 -0
  30. package/generators/utils/deps.js +52 -10
  31. package/generators/utils/i18n.js +20 -12
  32. package/generators/utils/logger.js +7 -4
  33. package/generators/utils/opts.js +6 -3
  34. package/generators/utils/parse-json-input.js +9 -5
  35. package/generators/utils/steps.js +48 -37
  36. package/generators/utils/subgenHelpers.js +14 -9
  37. package/generators/utils/templates.d.ts +4 -0
  38. package/generators/utils/templates.js +13 -7
  39. package/generators/utils/type-guards.js +6 -2
  40. package/generators/utils/workspace.js +13 -7
  41. package/package.json +7 -8
@@ -1,10 +1,15 @@
1
- import { getPromptsForChangeDataSource, generateChange, ChangeType } from '@sap-ux/adp-tooling';
2
- import { GeneratorTypes } from '../types.js';
3
- import SubGeneratorWithAuthBase from '../base/sub-gen-auth-base.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
7
+ const types_js_1 = require("../types.js");
8
+ const sub_gen_auth_base_js_1 = __importDefault(require("../base/sub-gen-auth-base.js"));
4
9
  /**
5
10
  * Generator for changing the data source of an OData service.
6
11
  */
7
- class OdataServiceGenerator extends SubGeneratorWithAuthBase {
12
+ class OdataServiceGenerator extends sub_gen_auth_base_js_1.default {
8
13
  /**
9
14
  * The answers for the generator.
10
15
  */
@@ -20,7 +25,7 @@ class OdataServiceGenerator extends SubGeneratorWithAuthBase {
20
25
  * @param {GeneratorOpts} opts - The options for the generator.
21
26
  */
22
27
  constructor(args, opts) {
23
- super(args, opts, GeneratorTypes.CHANGE_DATA_SOURCE);
28
+ super(args, opts, types_js_1.GeneratorTypes.CHANGE_DATA_SOURCE);
24
29
  }
25
30
  async initializing() {
26
31
  await this.onInit();
@@ -29,7 +34,7 @@ class OdataServiceGenerator extends SubGeneratorWithAuthBase {
29
34
  try {
30
35
  const manifest = await this.getManifest();
31
36
  this.dataSources = manifest?.['sap.app']?.dataSources ?? {};
32
- this.answers = await this.prompt(getPromptsForChangeDataSource(this.dataSources));
37
+ this.answers = await this.prompt((0, adp_tooling_1.getPromptsForChangeDataSource)(this.dataSources));
33
38
  this.logger.log(`Current OData services\n${JSON.stringify(this.answers, null, 2)}`);
34
39
  }
35
40
  catch (error) {
@@ -37,7 +42,7 @@ class OdataServiceGenerator extends SubGeneratorWithAuthBase {
37
42
  }
38
43
  }
39
44
  async writing() {
40
- await generateChange(this.projectPath, ChangeType.CHANGE_DATA_SOURCE, {
45
+ await (0, adp_tooling_1.generateChange)(this.projectPath, adp_tooling_1.ChangeType.CHANGE_DATA_SOURCE, {
41
46
  variant: this.variant,
42
47
  dataSources: this.dataSources,
43
48
  service: this.answers
@@ -48,5 +53,5 @@ class OdataServiceGenerator extends SubGeneratorWithAuthBase {
48
53
  this.logger.log('Successfully created OData Change!');
49
54
  }
50
55
  }
51
- export default OdataServiceGenerator;
56
+ exports.default = OdataServiceGenerator;
52
57
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,7 @@
1
- import { PerformanceMeasurementAPI } from '@sap-ux/telemetry';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TelemetryCollector = void 0;
4
+ const telemetry_1 = require("@sap-ux/telemetry");
2
5
  const DEFAULT_DATA = {
3
6
  wasExtProjectGenerated: false,
4
7
  wasFlpConfigDone: false,
@@ -8,7 +11,7 @@ const DEFAULT_DATA = {
8
11
  /**
9
12
  * Telemetry collector for ADP generator. Tracks telemetry data throughout the generation process.
10
13
  */
11
- export class TelemetryCollector {
14
+ class TelemetryCollector {
12
15
  /**
13
16
  * Map of timing mark names.
14
17
  */
@@ -39,7 +42,7 @@ export class TelemetryCollector {
39
42
  * @param {keyof AdpTelemetryTimerProperties} key - The timer property name that will store the duration (e.g., 'applicationListLoadingTime').
40
43
  */
41
44
  startTiming(key) {
42
- const markName = PerformanceMeasurementAPI.startMark(key);
45
+ const markName = telemetry_1.PerformanceMeasurementAPI.startMark(key);
43
46
  this.timingMarkNames.set(key, markName);
44
47
  }
45
48
  /**
@@ -50,12 +53,13 @@ export class TelemetryCollector {
50
53
  endTiming(key) {
51
54
  const markName = this.timingMarkNames.get(key);
52
55
  if (markName !== undefined) {
53
- PerformanceMeasurementAPI.endMark(markName);
54
- PerformanceMeasurementAPI.measure(markName);
55
- const duration = PerformanceMeasurementAPI.getMeasurementDuration(markName);
56
+ telemetry_1.PerformanceMeasurementAPI.endMark(markName);
57
+ telemetry_1.PerformanceMeasurementAPI.measure(markName);
58
+ const duration = telemetry_1.PerformanceMeasurementAPI.getMeasurementDuration(markName);
56
59
  this.setBatch({ [key]: duration });
57
60
  this.timingMarkNames.delete(key);
58
61
  }
59
62
  }
60
63
  }
64
+ exports.TelemetryCollector = TelemetryCollector;
61
65
  //# sourceMappingURL=collector.js.map
@@ -1,8 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventName = void 0;
1
4
  /**
2
5
  * Event names for telemetry for the adaptation project fiori launchpad configuration generator
3
6
  */
4
- export var EventName;
7
+ var EventName;
5
8
  (function (EventName) {
6
9
  EventName["ADAPTATION_PROJECT_CREATED"] = "ADAPTATION_PROJECT_CREATED";
7
- })(EventName || (EventName = {}));
10
+ })(EventName || (exports.EventName = EventName = {}));
8
11
  //# sourceMappingURL=events.js.map
@@ -1,3 +1,19 @@
1
- export * from './collector.js';
2
- export * from './events.js';
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("./collector.js"), exports);
18
+ __exportStar(require("./events.js"), exports);
3
19
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,11 @@
1
- export var GeneratorTypes;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeneratorTypes = void 0;
4
+ var GeneratorTypes;
2
5
  (function (GeneratorTypes) {
3
6
  GeneratorTypes["ADD_ANNOTATIONS_TO_DATA"] = "Add Local Annotation File";
4
7
  GeneratorTypes["ADD_COMPONENT_USAGES"] = "Add SAPUI5 Component Usages";
5
8
  GeneratorTypes["ADD_NEW_MODEL"] = "Add Data Source and SAPUI5 Model";
6
9
  GeneratorTypes["CHANGE_DATA_SOURCE"] = "Replace OData Service";
7
- })(GeneratorTypes || (GeneratorTypes = {}));
10
+ })(GeneratorTypes || (exports.GeneratorTypes = GeneratorTypes = {}));
8
11
  //# sourceMappingURL=types.js.map
@@ -1,4 +1,10 @@
1
- import { getHostEnvironment, hostEnvironment } from '@sap-ux/fiori-generator-shared';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initCache = initCache;
4
+ exports.cachePut = cachePut;
5
+ exports.cacheGet = cacheGet;
6
+ exports.cacheClear = cacheClear;
7
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
2
8
  const ADP_CACHE_KEY = '$adp-generator-cache';
3
9
  /**
4
10
  * Initializes the internal cache store on the AppWizard instance if it doesn't exist.
@@ -8,7 +14,7 @@ const ADP_CACHE_KEY = '$adp-generator-cache';
8
14
  * @param {AppWizardWithCache} [wizard] - The AppWizard instance to augment with cache storage.
9
15
  * @returns {void}
10
16
  */
11
- export function initCache(logger, wizard) {
17
+ function initCache(logger, wizard) {
12
18
  if (wizard && !wizard[ADP_CACHE_KEY]) {
13
19
  wizard[ADP_CACHE_KEY] = {};
14
20
  logger.debug('ADP-wizard cache initialised.');
@@ -22,7 +28,7 @@ export function initCache(logger, wizard) {
22
28
  * @param {ILogWrapper} logger - Logger instance for diagnostics.
23
29
  * @returns {void}
24
30
  */
25
- export function cachePut(wizard, state, logger) {
31
+ function cachePut(wizard, state, logger) {
26
32
  ensureCache(logger, wizard);
27
33
  if (wizard?.[ADP_CACHE_KEY]) {
28
34
  Object.assign(wizard[ADP_CACHE_KEY], state);
@@ -37,7 +43,7 @@ export function cachePut(wizard, state, logger) {
37
43
  * @param {ILogWrapper} logger - Logger instance used for diagnostics.
38
44
  * @returns {T | undefined} - The cached value if present, otherwise `undefined`.
39
45
  */
40
- export function cacheGet(wizard, key, logger) {
46
+ function cacheGet(wizard, key, logger) {
41
47
  ensureCache(logger, wizard);
42
48
  return wizard?.[ADP_CACHE_KEY]?.[key];
43
49
  }
@@ -48,7 +54,7 @@ export function cacheGet(wizard, key, logger) {
48
54
  * @param {ILogWrapper} logger - Logger instance for diagnostics.
49
55
  * @returns {void}
50
56
  */
51
- export function cacheClear(wizard, logger) {
57
+ function cacheClear(wizard, logger) {
52
58
  ensureCache(logger, wizard);
53
59
  if (wizard?.[ADP_CACHE_KEY]) {
54
60
  delete wizard[ADP_CACHE_KEY];
@@ -63,8 +69,8 @@ export function cacheClear(wizard, logger) {
63
69
  * @returns {void}
64
70
  */
65
71
  function ensureCache(logger, wizard) {
66
- const hostEnv = getHostEnvironment();
67
- if (hostEnv === hostEnvironment.vscode && !wizard?.[ADP_CACHE_KEY]) {
72
+ const hostEnv = (0, fiori_generator_shared_1.getHostEnvironment)();
73
+ if (hostEnv === fiori_generator_shared_1.hostEnvironment.vscode && !wizard?.[ADP_CACHE_KEY]) {
68
74
  logger.info('Warning: caching is not supported');
69
75
  }
70
76
  }
@@ -2,6 +2,12 @@ import type { Package } from '@sap-ux/project-access';
2
2
  /**
3
3
  * Reads the package.json of the current package.
4
4
  *
5
+ * Uses Node's CJS `__dirname` global at runtime (the package compiles to
6
+ * CommonJS — see tsconfig.json). Under ts-jest's ESM test transform
7
+ * `__dirname` is undefined and we fall back to `process.cwd()`, which
8
+ * jest sets to the package root — so the upward walk to `package.json`
9
+ * still lands on the right file.
10
+ *
5
11
  * @returns {Package} Package.json of the current package.
6
12
  */
7
13
  export declare function getPackageInfo(): Package;
@@ -1,24 +1,66 @@
1
- import { dirname, join } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import * as util from 'node:util';
4
- import { readFileSync } from 'node:fs';
5
- import { exec } from 'node:child_process';
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getPackageInfo = getPackageInfo;
37
+ exports.installDependencies = installDependencies;
38
+ const node_path_1 = require("node:path");
39
+ const util = __importStar(require("node:util"));
40
+ const node_fs_1 = require("node:fs");
41
+ const node_child_process_1 = require("node:child_process");
7
42
  /**
8
43
  * Reads the package.json of the current package.
9
44
  *
45
+ * Uses Node's CJS `__dirname` global at runtime (the package compiles to
46
+ * CommonJS — see tsconfig.json). Under ts-jest's ESM test transform
47
+ * `__dirname` is undefined and we fall back to `process.cwd()`, which
48
+ * jest sets to the package root — so the upward walk to `package.json`
49
+ * still lands on the right file.
50
+ *
10
51
  * @returns {Package} Package.json of the current package.
11
52
  */
12
- export function getPackageInfo() {
13
- return JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
53
+ function getPackageInfo() {
54
+ const moduleDir = typeof __dirname === 'undefined' ? process.cwd() : __dirname;
55
+ return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(moduleDir, '../../package.json'), 'utf-8'));
14
56
  }
15
57
  /**
16
58
  * Installs dependencies in the project directory.
17
59
  *
18
60
  * @param {string} projectPath - The project directory.
19
61
  */
20
- export async function installDependencies(projectPath) {
21
- const execAsync = util.promisify(exec);
62
+ async function installDependencies(projectPath) {
63
+ const execAsync = util.promisify(node_child_process_1.exec);
22
64
  try {
23
65
  await execAsync(`cd ${projectPath} && npm i`);
24
66
  }
@@ -1,21 +1,29 @@
1
- import i18next from 'i18next';
2
- import { addi18nResourceBundle as addInquirerCommonResourceBundle } from '@sap-ux/inquirer-common';
3
- import { addi18nResourceBundle as addProjectInputValidatorBundle } from '@sap-ux/project-input-validator';
4
- import translations from '../translations/generator-adp.i18n.json' with { type: 'json' };
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 inquirer_common_1 = require("@sap-ux/inquirer-common");
11
+ const project_input_validator_1 = require("@sap-ux/project-input-validator");
12
+ const generator_adp_i18n_json_1 = __importDefault(require("../translations/generator-adp.i18n.json"));
5
13
  const adpGeneratorI18nNamespace = 'generator-adp';
6
- export const i18n = i18next.createInstance();
14
+ exports.i18n = i18next_1.default.createInstance();
7
15
  /**
8
16
  * Initialize i18next with the translations for this module.
9
17
  */
10
- export async function initI18n() {
11
- await i18n.init({
18
+ async function initI18n() {
19
+ await exports.i18n.init({
12
20
  lng: 'en',
13
21
  fallbackLng: 'en',
14
22
  showSupportNotice: false
15
23
  });
16
- i18n.addResourceBundle('en', adpGeneratorI18nNamespace, translations);
17
- addInquirerCommonResourceBundle();
18
- addProjectInputValidatorBundle();
24
+ exports.i18n.addResourceBundle('en', adpGeneratorI18nNamespace, generator_adp_i18n_json_1.default);
25
+ (0, inquirer_common_1.addi18nResourceBundle)();
26
+ (0, project_input_validator_1.addi18nResourceBundle)();
19
27
  }
20
28
  /**
21
29
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -24,11 +32,11 @@ export async function initI18n() {
24
32
  * @param options additional options
25
33
  * @returns {string} localized string stored for the given key
26
34
  */
27
- export function t(key, options) {
35
+ function t(key, options) {
28
36
  if (!options?.ns) {
29
37
  options = Object.assign(options ?? {}, { ns: adpGeneratorI18nNamespace });
30
38
  }
31
- return i18n.t(key, options);
39
+ return exports.i18n.t(key, options);
32
40
  }
33
41
  void initI18n().catch(() => undefined);
34
42
  //# sourceMappingURL=i18n.js.map
@@ -1,9 +1,11 @@
1
- import { DefaultLogger, LogWrapper } from '@sap-ux/fiori-generator-shared';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
2
4
  /**
3
5
  * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
4
6
  */
5
- export default class AdpGeneratorLogger {
6
- static _logger = DefaultLogger;
7
+ class AdpGeneratorLogger {
8
+ static _logger = fiori_generator_shared_1.DefaultLogger;
7
9
  /**
8
10
  * Get the logger.
9
11
  *
@@ -31,8 +33,9 @@ export default class AdpGeneratorLogger {
31
33
  * @param logWrapper - log wrapper instance
32
34
  */
33
35
  static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel, logWrapper) {
34
- const logger = logWrapper ?? new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
36
+ const logger = logWrapper ?? new fiori_generator_shared_1.LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
35
37
  AdpGeneratorLogger.logger = logger;
36
38
  }
37
39
  }
40
+ exports.default = AdpGeneratorLogger;
38
41
  //# sourceMappingURL=logger.js.map
@@ -1,4 +1,7 @@
1
- import { getPackageInfo } from './deps.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setHeaderTitle = setHeaderTitle;
4
+ const deps_js_1 = require("./deps.js");
2
5
  /**
3
6
  * Sets a custom header title in the AppWizard UI, if the `setHeaderTitle` method is available.
4
7
  * This allows generators to specify their own display name while keeping the version information.
@@ -7,10 +10,10 @@ import { getPackageInfo } from './deps.js';
7
10
  * @param {ToolsLogger} logger - Logger instance used for logging any errors that occur during execution.
8
11
  * @param {string} customTitle - Optional custom title to display instead of the package name.
9
12
  */
10
- export function setHeaderTitle(opts, logger, customTitle) {
13
+ function setHeaderTitle(opts, logger, customTitle) {
11
14
  try {
12
15
  if (typeof opts?.appWizard?.setHeaderTitle === 'function') {
13
- const { name = '', version = '', displayName = '' } = getPackageInfo();
16
+ const { name = '', version = '', displayName = '' } = (0, deps_js_1.getPackageInfo)();
14
17
  if (name && version) {
15
18
  const headerTitle = customTitle ?? (displayName || name);
16
19
  opts.appWizard.setHeaderTitle(headerTitle, `${name}@${version}`);
@@ -1,4 +1,8 @@
1
- import { isJsonInput, isString } from './type-guards.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFirstArgAsString = getFirstArgAsString;
4
+ exports.parseJsonInput = parseJsonInput;
5
+ const type_guards_js_1 = require("./type-guards.js");
2
6
  /**
3
7
  * Returns the first argument from a list of CLI arguments. If the first argument
4
8
  * is not a string returns empty string.
@@ -6,8 +10,8 @@ import { isJsonInput, isString } from './type-guards.js';
6
10
  * @param {string | string[]} args - The list of CLI command arguments.
7
11
  * @returns {string} The first parameter in the argument's list as string.
8
12
  */
9
- export function getFirstArgAsString(args) {
10
- if (isString(args)) {
13
+ function getFirstArgAsString(args) {
14
+ if ((0, type_guards_js_1.isString)(args)) {
11
15
  return args;
12
16
  }
13
17
  if (Array.isArray(args) && args.length) {
@@ -23,10 +27,10 @@ export function getFirstArgAsString(args) {
23
27
  * @returns {JsonInput | undefined} The parsed json object, in case of an error or
24
28
  * if the object does not match the above interface - returns undefined.
25
29
  */
26
- export function parseJsonInput(jsonString, logger) {
30
+ function parseJsonInput(jsonString, logger) {
27
31
  try {
28
32
  const parsed = JSON.parse(jsonString);
29
- if (!isJsonInput(parsed)) {
33
+ if (!(0, type_guards_js_1.isJsonInput)(parsed)) {
30
34
  return undefined;
31
35
  }
32
36
  return parsed;
@@ -1,21 +1,32 @@
1
- import { t } from './i18n.js';
2
- import { GeneratorTypes } from '../types.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWizardPages = getWizardPages;
4
+ exports.updateCfWizardSteps = updateCfWizardSteps;
5
+ exports.getFlpPages = getFlpPages;
6
+ exports.updateFlpWizardSteps = updateFlpWizardSteps;
7
+ exports.getDeployPage = getDeployPage;
8
+ exports.getKeyUserImportPage = getKeyUserImportPage;
9
+ exports.updateWizardSteps = updateWizardSteps;
10
+ exports.getSubGenErrorPage = getSubGenErrorPage;
11
+ exports.getSubGenAuthPages = getSubGenAuthPages;
12
+ const i18n_js_1 = require("./i18n.js");
13
+ const types_js_1 = require("../types.js");
3
14
  /**
4
15
  * Returns the list of base wizard pages used in the Adaptation Project.
5
16
  *
6
17
  * @param {boolean} shouldShowTargetEnv - Whether to show the target environment page.
7
18
  * @returns {IPrompt[]} The list of static wizard steps to show initially.
8
19
  */
9
- export function getWizardPages(shouldShowTargetEnv) {
20
+ function getWizardPages(shouldShowTargetEnv) {
10
21
  return [
11
22
  ...(shouldShowTargetEnv ? [{ name: 'Target Environment', description: '' }] : []),
12
23
  {
13
- name: t('yuiNavSteps.configurationName'),
14
- description: t('yuiNavSteps.configurationDescr')
24
+ name: (0, i18n_js_1.t)('yuiNavSteps.configurationName'),
25
+ description: (0, i18n_js_1.t)('yuiNavSteps.configurationDescr')
15
26
  },
16
27
  {
17
- name: t('yuiNavSteps.projectAttributesName'),
18
- description: t('yuiNavSteps.projectAttributesDescr')
28
+ name: (0, i18n_js_1.t)('yuiNavSteps.projectAttributesName'),
29
+ description: (0, i18n_js_1.t)('yuiNavSteps.projectAttributesDescr')
19
30
  }
20
31
  ];
21
32
  }
@@ -25,13 +36,13 @@ export function getWizardPages(shouldShowTargetEnv) {
25
36
  * @param {boolean} isCFEnv - Whether the target environment is Cloud Foundry.
26
37
  * @param {YeomanUiSteps} prompts - The Yeoman UI Prompts container object.
27
38
  */
28
- export function updateCfWizardSteps(isCFEnv, prompts) {
39
+ function updateCfWizardSteps(isCFEnv, prompts) {
29
40
  if (isCFEnv) {
30
41
  prompts.splice(1, prompts['items'].length - 1, [
31
42
  { name: 'Project Path', description: 'Provide path to MTA project.' },
32
43
  {
33
- name: t('yuiNavSteps.projectAttributesName'),
34
- description: t('yuiNavSteps.projectAttributesDescr')
44
+ name: (0, i18n_js_1.t)('yuiNavSteps.projectAttributesName'),
45
+ description: (0, i18n_js_1.t)('yuiNavSteps.projectAttributesDescr')
35
46
  },
36
47
  { name: 'Application Details', description: 'Setup application details.' }
37
48
  ]);
@@ -44,17 +55,17 @@ export function updateCfWizardSteps(isCFEnv, prompts) {
44
55
  * @param {string} projectName - The name of the project.
45
56
  * @returns {IPrompt} The FLP configuration wizard page.
46
57
  */
47
- export function getFlpPages(showTileSettingsPage, projectName) {
58
+ function getFlpPages(showTileSettingsPage, projectName) {
48
59
  const pages = [
49
60
  {
50
- name: t('yuiNavSteps.flpConfigName'),
61
+ name: (0, i18n_js_1.t)('yuiNavSteps.flpConfigName'),
51
62
  description: ''
52
63
  }
53
64
  ];
54
65
  if (showTileSettingsPage) {
55
66
  pages.unshift({
56
- name: t('yuiNavSteps.tileSettingsName'),
57
- description: t('yuiNavSteps.tileSettingsDescr', { projectName })
67
+ name: (0, i18n_js_1.t)('yuiNavSteps.tileSettingsName'),
68
+ description: (0, i18n_js_1.t)('yuiNavSteps.tileSettingsDescr', { projectName })
58
69
  });
59
70
  }
60
71
  return pages;
@@ -67,30 +78,30 @@ export function getFlpPages(showTileSettingsPage, projectName) {
67
78
  * @param {string} projectName - The name of the project.
68
79
  * @param {boolean} shouldAdd - Whether to add (`true`) or remove (`false`) the steps.
69
80
  */
70
- export function updateFlpWizardSteps(hasBaseAppInbound, prompts, projectName, shouldAdd) {
81
+ function updateFlpWizardSteps(hasBaseAppInbound, prompts, projectName, shouldAdd) {
71
82
  const pages = getFlpPages(hasBaseAppInbound, projectName);
72
83
  if (pages.length === 2) {
73
- updateWizardSteps(prompts, pages[0], t('yuiNavSteps.deployConfigName'), shouldAdd);
74
- updateWizardSteps(prompts, pages[1], t('yuiNavSteps.tileSettingsName'), shouldAdd);
84
+ updateWizardSteps(prompts, pages[0], (0, i18n_js_1.t)('yuiNavSteps.deployConfigName'), shouldAdd);
85
+ updateWizardSteps(prompts, pages[1], (0, i18n_js_1.t)('yuiNavSteps.tileSettingsName'), shouldAdd);
75
86
  return;
76
87
  }
77
- updateWizardSteps(prompts, pages[0], t('yuiNavSteps.deployConfigName'), shouldAdd);
88
+ updateWizardSteps(prompts, pages[0], (0, i18n_js_1.t)('yuiNavSteps.deployConfigName'), shouldAdd);
78
89
  }
79
90
  /**
80
91
  * Returns the deploy configuration page step.
81
92
  *
82
93
  * @returns {IPrompt} The deployment configuration wizard page.
83
94
  */
84
- export function getDeployPage() {
85
- return { name: t('yuiNavSteps.deployConfigName'), description: t('yuiNavSteps.deployConfigDescr') };
95
+ function getDeployPage() {
96
+ return { name: (0, i18n_js_1.t)('yuiNavSteps.deployConfigName'), description: (0, i18n_js_1.t)('yuiNavSteps.deployConfigDescr') };
86
97
  }
87
98
  /**
88
99
  * Returns the key user import page step.
89
100
  *
90
101
  * @returns {IPrompt} The key user import wizard page.
91
102
  */
92
- export function getKeyUserImportPage() {
93
- return { name: t('yuiNavSteps.keyUserImportName'), description: t('yuiNavSteps.keyUserImportDescr') };
103
+ function getKeyUserImportPage() {
104
+ return { name: (0, i18n_js_1.t)('yuiNavSteps.keyUserImportName'), description: (0, i18n_js_1.t)('yuiNavSteps.keyUserImportDescr') };
94
105
  }
95
106
  /**
96
107
  * Dynamically adds or removes a step in the Yeoman UI wizard.
@@ -107,7 +118,7 @@ export function getKeyUserImportPage() {
107
118
  * @param {string} [insertAfter] - Optional name of the step after which to insert.
108
119
  * @param {boolean} [shouldAdd] - Whether to add (`true`) or remove (`false`) the step.
109
120
  */
110
- export function updateWizardSteps(prompts, step, insertAfter = '', shouldAdd = true) {
121
+ function updateWizardSteps(prompts, step, insertAfter = '', shouldAdd = true) {
111
122
  const pages = prompts['items'];
112
123
  const existingIdx = pages.findIndex((p) => p.name === step.name);
113
124
  if (shouldAdd) {
@@ -139,12 +150,12 @@ export function updateWizardSteps(prompts, step, insertAfter = '', shouldAdd = t
139
150
  * @param {GeneratorTypes} subGenType - The type of sub generator.
140
151
  * @returns {IPrompt[]} The error page for the given sub generator type.
141
152
  */
142
- export function getSubGenErrorPage(subGenType) {
153
+ function getSubGenErrorPage(subGenType) {
143
154
  switch (subGenType) {
144
- case GeneratorTypes.ADD_ANNOTATIONS_TO_DATA:
145
- return [{ name: t('yuiNavSteps.addLocalAnnotationFileName'), description: '' }];
146
- case GeneratorTypes.CHANGE_DATA_SOURCE:
147
- return [{ name: t('yuiNavSteps.replaceODataServiceName'), description: '' }];
155
+ case types_js_1.GeneratorTypes.ADD_ANNOTATIONS_TO_DATA:
156
+ return [{ name: (0, i18n_js_1.t)('yuiNavSteps.addLocalAnnotationFileName'), description: '' }];
157
+ case types_js_1.GeneratorTypes.CHANGE_DATA_SOURCE:
158
+ return [{ name: (0, i18n_js_1.t)('yuiNavSteps.replaceODataServiceName'), description: '' }];
148
159
  default:
149
160
  return [];
150
161
  }
@@ -159,26 +170,26 @@ export function getSubGenErrorPage(subGenType) {
159
170
  * @param {string} destination - ID of the destination system (used only for UI text).
160
171
  * @returns {IPrompt[]} The page definitions consumed by Yeoman-UI <Prompts>.
161
172
  */
162
- export function getSubGenAuthPages(type, destination) {
173
+ function getSubGenAuthPages(type, destination) {
163
174
  const getCredentialsPageProps = (nameBase) => ({
164
175
  name: `${nameBase} - Credentials`,
165
176
  description: `Enter credentials for your adaptation project's system (${destination})`
166
177
  });
167
178
  switch (type) {
168
- case GeneratorTypes.ADD_ANNOTATIONS_TO_DATA:
179
+ case types_js_1.GeneratorTypes.ADD_ANNOTATIONS_TO_DATA:
169
180
  return [
170
- getCredentialsPageProps(t('yuiNavSteps.addLocalAnnotationFileName')),
181
+ getCredentialsPageProps((0, i18n_js_1.t)('yuiNavSteps.addLocalAnnotationFileName')),
171
182
  {
172
- name: t('yuiNavSteps.addLocalAnnotationFileName'),
173
- description: t('yuiNavSteps.addLocalAnnotationFileDescr')
183
+ name: (0, i18n_js_1.t)('yuiNavSteps.addLocalAnnotationFileName'),
184
+ description: (0, i18n_js_1.t)('yuiNavSteps.addLocalAnnotationFileDescr')
174
185
  }
175
186
  ];
176
- case GeneratorTypes.CHANGE_DATA_SOURCE:
187
+ case types_js_1.GeneratorTypes.CHANGE_DATA_SOURCE:
177
188
  return [
178
- getCredentialsPageProps(t('yuiNavSteps.replaceODataServiceName')),
189
+ getCredentialsPageProps((0, i18n_js_1.t)('yuiNavSteps.replaceODataServiceName')),
179
190
  {
180
- name: t('yuiNavSteps.replaceODataServiceName'),
181
- description: t('yuiNavSteps.replaceODataServiceDescr')
191
+ name: (0, i18n_js_1.t)('yuiNavSteps.replaceODataServiceName'),
192
+ description: (0, i18n_js_1.t)('yuiNavSteps.replaceODataServiceDescr')
182
193
  }
183
194
  ];
184
195
  default: