@sap-ux/ui5-library-inquirer 0.2.5 → 0.2.7

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/i18n.js CHANGED
@@ -21,17 +21,7 @@ const ui5LibI18nNamespace = 'ui5-library-inquirer';
21
21
  */
22
22
  function initI18n() {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- yield i18next_1.default.init({
25
- resources: {
26
- en: {
27
- [ui5LibI18nNamespace]: ui5_library_inquirer_i18n_json_1.default
28
- }
29
- },
30
- lng: 'en',
31
- fallbackLng: 'en',
32
- defaultNS: ui5LibI18nNamespace,
33
- ns: [ui5LibI18nNamespace]
34
- });
24
+ yield i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', ui5LibI18nNamespace, ui5_library_inquirer_i18n_json_1.default));
35
25
  });
36
26
  }
37
27
  exports.initI18n = initI18n;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { type InquirerAdapter } from '@sap-ux/inquirer-common';
1
2
  import { type Question } from 'inquirer';
2
- import type { InquirerAdapter, UI5LibraryAnswers, UI5LibraryPromptOptions } from './types';
3
+ import type { UI5LibraryAnswers, UI5LibraryPromptOptions } from './types';
3
4
  /**
4
5
  * Get the inquirer prompts for ui5 library inquirer.
5
6
  *
@@ -15,5 +16,5 @@ declare function getPrompts(promptOptions?: UI5LibraryPromptOptions): Promise<Qu
15
16
  * @returns the prompt answers
16
17
  */
17
18
  declare function prompt(promptOptions?: UI5LibraryPromptOptions, adapter?: InquirerAdapter): Promise<UI5LibraryAnswers>;
18
- export { getPrompts, prompt, type UI5LibraryPromptOptions, type UI5LibraryAnswers };
19
+ export { getPrompts, prompt, type UI5LibraryPromptOptions, type UI5LibraryAnswers, type InquirerAdapter };
19
20
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ function prompt(promptOptions, adapter) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
51
  const ui5LibPrompts = yield exports.getPrompts(promptOptions);
52
52
  const pm = adapter ? adapter.promptModule : inquirer_1.default;
53
- if (promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.useAutocomplete) {
53
+ if (pm && (promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.useAutocomplete)) {
54
54
  pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
55
55
  }
56
56
  return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
@@ -1,6 +1,6 @@
1
+ import type { UI5Version } from '@sap-ux/ui5-info';
1
2
  import type { Question } from 'inquirer';
2
3
  import type { UI5LibraryAnswers, UI5LibraryPromptOptions } from '../types';
3
- import type { UI5Version } from '@sap-ux/ui5-info';
4
4
  /**
5
5
  * Get the prompts for UI5 library generation.
6
6
  *
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getQuestions = void 0;
4
- const i18n_1 = require("../i18n");
5
- const utility_1 = require("./utility");
4
+ const inquirer_common_1 = require("@sap-ux/inquirer-common");
6
5
  const project_input_validator_1 = require("@sap-ux/project-input-validator");
6
+ const i18n_1 = require("../i18n");
7
7
  /**
8
8
  * Get the prompts for UI5 library generation.
9
9
  *
@@ -13,7 +13,7 @@ const project_input_validator_1 = require("@sap-ux/project-input-validator");
13
13
  */
14
14
  function getQuestions(ui5Versions, options) {
15
15
  var _a;
16
- const ui5VersionChoices = (0, utility_1.ui5VersionsGrouped)(ui5Versions, options === null || options === void 0 ? void 0 : options.includeSeparators);
16
+ const ui5VersionChoices = (0, inquirer_common_1.ui5VersionsGrouped)(ui5Versions, options === null || options === void 0 ? void 0 : options.includeSeparators);
17
17
  return [
18
18
  {
19
19
  type: 'input',
@@ -60,7 +60,7 @@ function getQuestions(ui5Versions, options) {
60
60
  breadcrumb: true
61
61
  },
62
62
  choices: () => ui5VersionChoices,
63
- source: (prevAnswers, input) => (0, utility_1.searchChoices)(input, ui5VersionChoices)
63
+ source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, ui5VersionChoices)
64
64
  },
65
65
  {
66
66
  type: 'confirm',
@@ -9,11 +9,5 @@
9
9
  "libraryEnableTypeScriptLabel": "Enable TypeScript (Experimental)",
10
10
  "libraryFolderLabel": "Library folder path",
11
11
  "libraryFolderTooltip": "The generated library's folder will be a combination of the library's namespace and module name"
12
- },
13
- "ui5VersionLabels": {
14
- "maintained": "Maintained",
15
- "outOfMaintenance": "Out of maintenance",
16
- "version_one": "version",
17
- "version_other": "versions"
18
12
  }
19
13
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { ConfirmQuestion as BaseConfirmQuestion, InputQuestion as BaseInputQuestion, ListQuestion as BaseListQuestion, Answers, ListChoiceOptions, PromptFunction, PromptModule } from 'inquirer';
2
1
  export interface UI5LibraryAnswers {
3
2
  libraryName?: string;
4
3
  namespace?: string;
@@ -20,33 +19,4 @@ export interface UI5LibraryPromptOptions {
20
19
  */
21
20
  useAutocomplete?: boolean;
22
21
  }
23
- export interface UI5VersionChoice extends ListChoiceOptions {
24
- value: string;
25
- }
26
- export interface InquirerAdapter {
27
- prompt: PromptFunction;
28
- promptModule: PromptModule;
29
- }
30
- /**
31
- *
32
- * Remove when YUI specific types are available from `"@sap-devx/yeoman-ui-types`
33
- *
34
- */
35
- export interface GuiOptions {
36
- hint?: string;
37
- applyDefaultWhenDirty?: boolean;
38
- breadcrumb?: boolean | string;
39
- }
40
- export interface ConfirmQuestion<A extends Answers = Answers> extends BaseConfirmQuestion<A> {
41
- guiOptions?: GuiOptions;
42
- }
43
- export interface InputQuestion<A extends Answers = Answers> extends BaseInputQuestion<A> {
44
- guiOptions?: GuiOptions;
45
- }
46
- export interface ListQuestion<A extends Answers = Answers> extends BaseListQuestion<A> {
47
- guiOptions?: GuiOptions;
48
- }
49
- export interface FileBrowserQuestion<A extends Answers = Answers> extends InputQuestion<A> {
50
- guiType: 'file-browser' | 'folder-browser';
51
- }
52
22
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-library-inquirer",
3
3
  "description": "Prompts module that can provide prompts for UI5 library writer",
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -20,14 +20,14 @@
20
20
  "!dist/**/*.map"
21
21
  ],
22
22
  "dependencies": {
23
- "fuzzy": "0.1.3",
24
23
  "i18next": "23.5.1",
25
- "inquirer": "8.2.6",
26
24
  "inquirer-autocomplete-prompt": "2.0.1",
27
- "@sap-ux/project-input-validator": "0.2.2",
25
+ "@sap-ux/inquirer-common": "0.2.1",
26
+ "@sap-ux/project-input-validator": "0.2.3",
28
27
  "@sap-ux/ui5-info": "0.3.2"
29
28
  },
30
29
  "devDependencies": {
30
+ "inquirer": "8.2.6",
31
31
  "@types/inquirer-autocomplete-prompt": "2.0.1",
32
32
  "@types/inquirer": "8.2.6"
33
33
  },
@@ -1,21 +0,0 @@
1
- import { Separator, type ListChoiceOptions } from 'inquirer';
2
- import type { UI5Version } from '@sap-ux/ui5-info';
3
- import type { UI5VersionChoice } from '../types';
4
- /**
5
- * Finds the search value in the provided list using `fuzzy` search.
6
- *
7
- * @param searchVal - the string to search for
8
- * @param searchList - the list in which to search by fuzzy matching the choice name
9
- * @returns Inquirer choices filtered by the search value
10
- */
11
- export declare function searchChoices(searchVal: string, searchList: ListChoiceOptions[]): ListChoiceOptions[];
12
- /**
13
- * Creates a list of UI5 Versions prompt choices, adding additional maintenance info for use in prompts
14
- * and grouping according to maintenance status.
15
- *
16
- * @param versions ui5Versions
17
- * @param includeSeparators Include a separator to visually identify groupings, if false then grouping info is included in each entry as additional name text
18
- * @returns Array of ui5 version choices and separators if applicable, grouped by maintenance state
19
- */
20
- export declare function ui5VersionsGrouped(versions: UI5Version[], includeSeparators?: boolean): (UI5VersionChoice | Separator)[];
21
- //# sourceMappingURL=utility.d.ts.map
@@ -1,85 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ui5VersionsGrouped = exports.searchChoices = void 0;
27
- const inquirer_1 = require("inquirer");
28
- const fuzzy = __importStar(require("fuzzy"));
29
- const i18n_1 = require("../i18n");
30
- /**
31
- * Finds the search value in the provided list using `fuzzy` search.
32
- *
33
- * @param searchVal - the string to search for
34
- * @param searchList - the list in which to search by fuzzy matching the choice name
35
- * @returns Inquirer choices filtered by the search value
36
- */
37
- function searchChoices(searchVal, searchList) {
38
- return searchVal && searchList
39
- ? fuzzy
40
- .filter(searchVal, searchList, {
41
- // Only `choice.name` searching is supported, as this is what is presented to the user by Inquirer
42
- extract: (choice) => { var _a; return (_a = choice.name) !== null && _a !== void 0 ? _a : ''; }
43
- })
44
- .map((el) => el.original)
45
- : searchList;
46
- }
47
- exports.searchChoices = searchChoices;
48
- /**
49
- * Creates a list of UI5 Versions prompt choices, adding additional maintenance info for use in prompts
50
- * and grouping according to maintenance status.
51
- *
52
- * @param versions ui5Versions
53
- * @param includeSeparators Include a separator to visually identify groupings, if false then grouping info is included in each entry as additional name text
54
- * @returns Array of ui5 version choices and separators if applicable, grouped by maintenance state
55
- */
56
- function ui5VersionsGrouped(versions, includeSeparators = false) {
57
- if (!versions || (Array.isArray(versions) && versions.length === 0)) {
58
- return [];
59
- }
60
- const maintChoices = versions
61
- .filter((v) => v.maintained === true)
62
- .map((mainV) => ({
63
- name: !includeSeparators
64
- ? `${mainV.version} - (${(0, i18n_1.t)('ui5VersionLabels.maintained')} ${(0, i18n_1.t)('ui5VersionLabels.version', {
65
- count: 1
66
- })})`
67
- : mainV.version,
68
- value: mainV.version
69
- }));
70
- const notMaintChoices = versions
71
- .filter((v) => v.maintained === false)
72
- .map((mainV) => ({
73
- name: !includeSeparators
74
- ? `${mainV.version} - (${(0, i18n_1.t)('ui5VersionLabels.outOfMaintenance')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 1 })})`
75
- : mainV.version,
76
- value: mainV.version
77
- }));
78
- if (includeSeparators) {
79
- maintChoices.unshift(new inquirer_1.Separator(`${(0, i18n_1.t)('ui5VersionLabels.maintained')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 0 })}`));
80
- notMaintChoices.unshift(new inquirer_1.Separator(`${(0, i18n_1.t)('ui5VersionLabels.outOfMaintenance')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 0 })}`));
81
- }
82
- return [...maintChoices, ...notMaintChoices];
83
- }
84
- exports.ui5VersionsGrouped = ui5VersionsGrouped;
85
- //# sourceMappingURL=utility.js.map