@sap-ux/ui5-library-reference-inquirer 0.5.7 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/choices.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AllAppResults, ReuseLib } from '@sap-ux/project-access';
2
2
  import type { ListChoiceOptions } from 'inquirer';
3
- import type { ReuseLibChoice } from './types';
3
+ import type { ReuseLibChoice } from './types.js';
4
4
  /**
5
5
  * Creates the project choice options.
6
6
  *
package/dist/choices.js CHANGED
@@ -1,31 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLibraryChoices = exports.getProjectChoices = void 0;
4
- const node_path_1 = require("node:path");
1
+ import { basename } from 'node:path';
5
2
  /**
6
3
  * Creates the project choice options.
7
4
  *
8
5
  * @param apps array of applications found in the workspace folders.
9
6
  * @returns list of projects
10
7
  */
11
- const getProjectChoices = async (apps) => {
8
+ export const getProjectChoices = async (apps) => {
12
9
  const projectChoices = [];
13
10
  if (apps) {
14
11
  for (const app of apps) {
15
- const name = (0, node_path_1.basename)(app.appRoot);
12
+ const name = basename(app.appRoot);
16
13
  projectChoices.push({ name, value: app.appRoot });
17
14
  }
18
15
  }
19
16
  return projectChoices;
20
17
  };
21
- exports.getProjectChoices = getProjectChoices;
22
18
  /**
23
19
  * Creates the library choice options.
24
20
  *
25
21
  * @param libs - array of libraries found in the workspace folders.
26
22
  * @returns list of libraries
27
23
  */
28
- const getLibraryChoices = async (libs) => {
24
+ export const getLibraryChoices = async (libs) => {
29
25
  const libraryChoices = [];
30
26
  if (libs) {
31
27
  for (const lib of libs) {
@@ -35,5 +31,4 @@ const getLibraryChoices = async (libs) => {
35
31
  }
36
32
  return libraryChoices;
37
33
  };
38
- exports.getLibraryChoices = getLibraryChoices;
39
34
  //# sourceMappingURL=choices.js.map
package/dist/i18n.js CHANGED
@@ -1,25 +1,17 @@
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 ui5_library_reference_inquirer_i18n_json_1 = __importDefault(require("./translations/ui5-library-reference-inquirer.i18n.json"));
1
+ import i18next from 'i18next';
2
+ import translations from './translations/ui5-library-reference-inquirer.i18n.json' with { type: 'json' };
11
3
  const ui5LibI18nNamespace = 'ui5-library-reference-inquirer';
12
- exports.i18n = i18next_1.default.createInstance();
4
+ export const i18n = i18next.createInstance();
13
5
  /**
14
6
  * Initialize i18next with the translations for this module.
15
7
  */
16
- async function initI18n() {
17
- await exports.i18n.init({
8
+ export async function initI18n() {
9
+ await i18n.init({
18
10
  lng: 'en',
19
11
  fallbackLng: 'en',
20
12
  showSupportNotice: false
21
13
  });
22
- exports.i18n.addResourceBundle('en', ui5LibI18nNamespace, ui5_library_reference_inquirer_i18n_json_1.default);
14
+ i18n.addResourceBundle('en', ui5LibI18nNamespace, translations);
23
15
  }
24
16
  /**
25
17
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -28,13 +20,11 @@ async function initI18n() {
28
20
  * @param options additional options
29
21
  * @returns {string} localized string stored for the given key
30
22
  */
31
- function t(key, options) {
23
+ export function t(key, options) {
32
24
  if (!options?.ns) {
33
25
  options = Object.assign(options ?? {}, { ns: ui5LibI18nNamespace });
34
26
  }
35
- return exports.i18n.t(key, options);
27
+ return i18n.t(key, options);
36
28
  }
37
- initI18n().catch(() => {
38
- // Needed for lint
39
- });
29
+ void initI18n().catch(() => undefined);
40
30
  //# sourceMappingURL=i18n.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type InquirerAdapter } from '@sap-ux/inquirer-common';
2
2
  import { type Question } from 'inquirer';
3
- import type { UI5LibraryReferenceAnswers, UI5LibraryReferencePromptOptions } from './types';
3
+ import type { UI5LibraryReferenceAnswers, UI5LibraryReferencePromptOptions } from './types.js';
4
4
  import { type WorkspaceFolder } from '@sap-ux/project-access';
5
5
  /**
6
6
  * Get the inquirer prompts for ui5 library inquirer.
package/dist/index.js CHANGED
@@ -1,14 +1,7 @@
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.getPrompts = getPrompts;
7
- exports.prompt = prompt;
8
- const inquirer_1 = __importDefault(require("inquirer"));
9
- const prompts_1 = require("./prompts");
10
- const project_access_1 = require("@sap-ux/project-access");
11
- const choices_1 = require("./choices");
1
+ import inquirer from 'inquirer';
2
+ import { getQuestions } from './prompts/index.js';
3
+ import { getReuseLibs, findFioriArtifacts } from '@sap-ux/project-access';
4
+ import { getProjectChoices, getLibraryChoices } from './choices.js';
12
5
  /**
13
6
  * Get the inquirer prompts for ui5 library inquirer.
14
7
  *
@@ -21,11 +14,11 @@ async function getPrompts(wsFolders, promptOptions) {
21
14
  wsFolders: wsFolders,
22
15
  artifacts: ['applications', 'libraries']
23
16
  };
24
- const fioriArtifacts = await (0, project_access_1.findFioriArtifacts)(options);
25
- const reuseLibs = await (0, project_access_1.getReuseLibs)(fioriArtifacts?.libraries);
26
- const projectChoices = await (0, choices_1.getProjectChoices)(fioriArtifacts?.applications);
27
- const libraryChoices = await (0, choices_1.getLibraryChoices)(reuseLibs);
28
- return (0, prompts_1.getQuestions)(projectChoices, libraryChoices, promptOptions);
17
+ const fioriArtifacts = await findFioriArtifacts(options);
18
+ const reuseLibs = await getReuseLibs(fioriArtifacts?.libraries);
19
+ const projectChoices = await getProjectChoices(fioriArtifacts?.applications);
20
+ const libraryChoices = await getLibraryChoices(reuseLibs);
21
+ return getQuestions(projectChoices, libraryChoices, promptOptions);
29
22
  }
30
23
  /**
31
24
  * Prompt for ui5 library generation inputs.
@@ -36,7 +29,8 @@ async function getPrompts(wsFolders, promptOptions) {
36
29
  * @returns the prompt answers
37
30
  */
38
31
  async function prompt(wsFolders, adapter, promptOptions) {
39
- const ui5LibPrompts = await exports.getPrompts(wsFolders, promptOptions);
40
- return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
32
+ const ui5LibPrompts = await getPrompts(wsFolders ?? [], promptOptions);
33
+ return adapter ? adapter.prompt(ui5LibPrompts) : inquirer.prompt(ui5LibPrompts);
41
34
  }
35
+ export { getPrompts, prompt };
42
36
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SourceType = void 0;
4
- var SourceType;
1
+ export var SourceType;
5
2
  (function (SourceType) {
6
3
  SourceType["Workspace"] = "Workspace";
7
- })(SourceType || (exports.SourceType = SourceType = {}));
4
+ })(SourceType || (SourceType = {}));
8
5
  //# sourceMappingURL=constants.js.map
@@ -1,4 +1,4 @@
1
- import type { UI5LibraryReferencePromptOptions, UI5LibraryReferenceQuestion, promptNames } from '../types';
1
+ import type { UI5LibraryReferencePromptOptions, UI5LibraryReferenceQuestion, promptNames } from '../types.js';
2
2
  /**
3
3
  * Will remove prompts from the specified prompts based on prompt options
4
4
  * Removing prompts is preferable to using `when()` to prevent continuous re-evaluation.
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hidePrompts = hidePrompts;
4
1
  /**
5
2
  * Will remove prompts from the specified prompts based on prompt options
6
3
  * Removing prompts is preferable to using `when()` to prevent continuous re-evaluation.
@@ -9,7 +6,7 @@ exports.hidePrompts = hidePrompts;
9
6
  * @param promptOptions prompt options
10
7
  * @returns the updated questions
11
8
  */
12
- function hidePrompts(prompts, promptOptions) {
9
+ export function hidePrompts(prompts, promptOptions) {
13
10
  const questions = [];
14
11
  if (promptOptions) {
15
12
  Object.keys(prompts).forEach((key) => {
@@ -1,2 +1,2 @@
1
- export * from './prompts';
1
+ export * from './prompts.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./prompts"), exports);
1
+ export * from './prompts.js';
18
2
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ListChoiceOptions } from 'inquirer';
2
- import { type UI5LibraryReferenceQuestion, type ReuseLibChoice, type UI5LibraryReferencePromptOptions } from '../types';
2
+ import { type UI5LibraryReferenceQuestion, type ReuseLibChoice, type UI5LibraryReferencePromptOptions } from '../types.js';
3
3
  /**
4
4
  * Get the prompts for the UI5 library reference writing.
5
5
  *
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQuestions = getQuestions;
4
- const i18n_1 = require("../i18n");
5
- const project_access_1 = require("@sap-ux/project-access");
6
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
7
- const types_1 = require("../types");
8
- const helpers_1 = require("./helpers");
9
- const constants_1 = require("./constants");
10
- const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
1
+ import { t } from '../i18n.js';
2
+ import { checkDependencies } from '@sap-ux/project-access';
3
+ import { extendWithOptions } from '@sap-ux/inquirer-common';
4
+ import { promptNames } from '../types.js';
5
+ import { hidePrompts } from './helpers.js';
6
+ import { SourceType } from './constants.js';
7
+ import { Severity } from '@sap-devx/yeoman-ui-types';
11
8
  /**
12
9
  * Get the prompts for the UI5 library reference writing.
13
10
  *
@@ -16,17 +13,17 @@ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
16
13
  * @param promptOptions - optional inputs used to pre-populate some prompt choices, default values and other prompting options
17
14
  * @returns the prompts
18
15
  */
19
- function getQuestions(projectChoices, reuseLibs, promptOptions) {
16
+ export function getQuestions(projectChoices, reuseLibs, promptOptions) {
20
17
  const keyedPrompts = {
21
- [types_1.promptNames.targetProjectFolder]: getTargetProjectFolderPrompt(projectChoices),
22
- [types_1.promptNames.source]: getSourcePrompt(),
23
- [types_1.promptNames.referenceLibraries]: getReferenceLibrariesPrompt(reuseLibs)
18
+ [promptNames.targetProjectFolder]: getTargetProjectFolderPrompt(projectChoices),
19
+ [promptNames.source]: getSourcePrompt(),
20
+ [promptNames.referenceLibraries]: getReferenceLibrariesPrompt(reuseLibs)
24
21
  };
25
22
  // Hide not applicable prompts based on passed options
26
- let questions = (0, helpers_1.hidePrompts)(keyedPrompts, promptOptions);
23
+ let questions = hidePrompts(keyedPrompts, promptOptions);
27
24
  // Apply extended `validate`, `additionalMessages` or override `default` prompt properties
28
25
  if (promptOptions) {
29
- questions = (0, inquirer_common_1.extendWithOptions)(questions, promptOptions);
26
+ questions = extendWithOptions(questions, promptOptions);
30
27
  }
31
28
  return questions;
32
29
  }
@@ -42,14 +39,14 @@ function getTargetProjectFolderPrompt(projectChoices) {
42
39
  guiOptions: {
43
40
  breadcrumb: true
44
41
  },
45
- name: types_1.promptNames.targetProjectFolder,
46
- message: (0, i18n_1.t)('prompts.targetProjectFolderLabel'),
42
+ name: promptNames.targetProjectFolder,
43
+ message: t('prompts.targetProjectFolderLabel'),
47
44
  choices: projectChoices,
48
45
  default: () => {
49
46
  return projectChoices?.length ? 0 : undefined;
50
47
  },
51
48
  validate: () => {
52
- return !projectChoices?.length ? (0, i18n_1.t)('error.noProjectsFound') : true;
49
+ return !projectChoices?.length ? t('error.noProjectsFound') : true;
53
50
  }
54
51
  };
55
52
  }
@@ -64,9 +61,9 @@ function getSourcePrompt() {
64
61
  guiOptions: {
65
62
  breadcrumb: true
66
63
  },
67
- name: types_1.promptNames.source,
68
- message: (0, i18n_1.t)('prompts.sourceLabel'),
69
- choices: [{ name: (0, i18n_1.t)('choices.workspace'), value: constants_1.SourceType.Workspace }],
64
+ name: promptNames.source,
65
+ message: t('prompts.sourceLabel'),
66
+ choices: [{ name: t('choices.workspace'), value: SourceType.Workspace }],
70
67
  default: 0
71
68
  };
72
69
  }
@@ -80,28 +77,28 @@ function getReferenceLibrariesPrompt(reuseLibs) {
80
77
  let missingDeps;
81
78
  return {
82
79
  type: 'checkbox',
83
- name: types_1.promptNames.referenceLibraries,
84
- message: (0, i18n_1.t)('prompts.referenceLibrariesLabel'),
80
+ name: promptNames.referenceLibraries,
81
+ message: t('prompts.referenceLibrariesLabel'),
85
82
  guiOptions: {
86
83
  breadcrumb: true
87
84
  },
88
85
  choices: reuseLibs,
89
86
  additionalMessages: () => {
90
87
  const msg = {
91
- message: (0, i18n_1.t)('addtionalMsgs.missingDeps', { dependencies: missingDeps }),
92
- severity: yeoman_ui_types_1.Severity.warning
88
+ message: t('addtionalMsgs.missingDeps', { dependencies: missingDeps }),
89
+ severity: Severity.warning
93
90
  };
94
91
  return missingDeps ? msg : undefined;
95
92
  },
96
93
  validate: (answer) => {
97
94
  if (!reuseLibs?.length) {
98
- return (0, i18n_1.t)('error.noLibsFound');
95
+ return t('error.noLibsFound');
99
96
  }
100
97
  else if (answer?.length < 1) {
101
- return (0, i18n_1.t)('error.noLibSelected');
98
+ return t('error.noLibSelected');
102
99
  }
103
100
  else if (answer?.length) {
104
- missingDeps = (0, project_access_1.checkDependencies)(answer, reuseLibs.map((libs) => libs.value));
101
+ missingDeps = checkDependencies(answer, reuseLibs.map((libs) => libs.value));
105
102
  }
106
103
  return true;
107
104
  }
package/dist/types.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptNames = void 0;
4
1
  /**
5
2
  * Enumeration of prompt names used by UI5LibraryReferencePromptOptions
6
3
  *
7
4
  */
8
- var promptNames;
5
+ export var promptNames;
9
6
  (function (promptNames) {
10
7
  /**
11
8
  * Target project folder
@@ -19,5 +16,5 @@ var promptNames;
19
16
  * Libraries to reference
20
17
  */
21
18
  promptNames["referenceLibraries"] = "referenceLibraries";
22
- })(promptNames || (exports.promptNames = promptNames = {}));
19
+ })(promptNames || (promptNames = {}));
23
20
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-library-reference-inquirer",
3
3
  "description": "Prompts module that can provide prompts for UI5 library writer",
4
- "version": "0.5.7",
4
+ "version": "1.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -10,6 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-library-reference-inquirer"
12
12
  },
13
+ "type": "module",
13
14
  "license": "Apache-2.0",
14
15
  "main": "dist/index.js",
15
16
  "files": [
@@ -20,10 +21,11 @@
20
21
  ],
21
22
  "dependencies": {
22
23
  "i18next": "25.10.10",
23
- "@sap-ux/inquirer-common": "0.13.6",
24
- "@sap-ux/project-access": "1.38.1"
24
+ "@sap-ux/inquirer-common": "1.0.1",
25
+ "@sap-ux/project-access": "2.0.1"
25
26
  },
26
27
  "devDependencies": {
28
+ "@jest/globals": "30.3.0",
27
29
  "inquirer": "8.2.7",
28
30
  "@sap-devx/yeoman-ui-types": "1.25.0",
29
31
  "@types/inquirer": "8.2.6"
@@ -37,8 +39,8 @@
37
39
  "watch": "tsc --watch",
38
40
  "lint": "eslint",
39
41
  "lint:fix": "eslint --fix",
40
- "test": "jest --ci --forceExit --detectOpenHandles --colors",
41
- "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
42
+ "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
43
+ "test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
42
44
  "link": "pnpm link --global",
43
45
  "unlink": "pnpm unlink --global"
44
46
  }