@sap-ux/ui5-library-reference-inquirer 0.2.20 → 0.2.22

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 { promptNames, UI5LibraryReferencePromptOptions, UI5LibraryReferenceQuestion } from '../types';
1
+ import type { UI5LibraryReferencePromptOptions, UI5LibraryReferenceQuestion, promptNames } from '../types';
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.
@@ -8,12 +8,4 @@ import type { promptNames, UI5LibraryReferencePromptOptions, UI5LibraryReference
8
8
  * @returns the updated questions
9
9
  */
10
10
  export declare function hidePrompts(prompts: Record<promptNames, UI5LibraryReferenceQuestion>, promptOptions?: UI5LibraryReferencePromptOptions): UI5LibraryReferenceQuestion[];
11
- /**
12
- * Updates questions with extensions for specific properties. Only `validate`, `default` and `additionalMessages` are currently supported.
13
- *
14
- * @param questions - array of prompts to be extended
15
- * @param promptOptions - the prompt options possibly containing function extensions
16
- * @returns - the extended questions
17
- */
18
- export declare function extendWithOptions(questions: UI5LibraryReferenceQuestion[], promptOptions: UI5LibraryReferencePromptOptions): UI5LibraryReferenceQuestion[];
19
11
  //# sourceMappingURL=helpers.d.ts.map
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendWithOptions = exports.hidePrompts = void 0;
4
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
3
+ exports.hidePrompts = void 0;
5
4
  /**
6
5
  * Will remove prompts from the specified prompts based on prompt options
7
6
  * Removing prompts is preferable to using `when()` to prevent continuous re-evaluation.
@@ -27,63 +26,4 @@ function hidePrompts(prompts, promptOptions) {
27
26
  return questions;
28
27
  }
29
28
  exports.hidePrompts = hidePrompts;
30
- /**
31
- * Extends a validate function.
32
- *
33
- * @param question - the question to which the validate function will be applied
34
- * @param validateFunc - the validate function which will be applied to the question
35
- * @returns the extended validate function
36
- */
37
- function extendValidate(question, validateFunc) {
38
- const validate = question.validate;
39
- return (value, previousAnswers) => {
40
- const extVal = validateFunc(value, previousAnswers);
41
- if (extVal !== true) {
42
- return extVal;
43
- }
44
- return typeof validate === 'function' ? validate(value, previousAnswers) : true;
45
- };
46
- }
47
- /**
48
- * Extend the existing prompt property function with the one specified in prompt options or add as new.
49
- *
50
- * @param question - the question to which the extending function will be applied
51
- * @param promptOption - prompt options, containing extending functions
52
- * @param funcName - the question property (function) name to extend
53
- * @returns the extended question
54
- */
55
- function applyExtensionFunction(question, promptOption, funcName) {
56
- let extendedFunc;
57
- if (funcName === 'validate' && promptOption.validate) {
58
- extendedFunc = extendValidate(question, promptOption.validate);
59
- }
60
- if (funcName === 'additionalMessages' && promptOption.additionalMessages) {
61
- extendedFunc = (0, inquirer_common_1.extendAdditionalMessages)(question, promptOption.additionalMessages);
62
- }
63
- question = Object.assign(question, { [funcName]: extendedFunc });
64
- return question;
65
- }
66
- /**
67
- * Updates questions with extensions for specific properties. Only `validate`, `default` and `additionalMessages` are currently supported.
68
- *
69
- * @param questions - array of prompts to be extended
70
- * @param promptOptions - the prompt options possibly containing function extensions
71
- * @returns - the extended questions
72
- */
73
- function extendWithOptions(questions, promptOptions) {
74
- questions.forEach((question) => {
75
- const promptOptKey = question.name;
76
- const promptOpt = promptOptions[promptOptKey];
77
- if (promptOpt) {
78
- const propsToExtend = Object.keys(promptOpt);
79
- for (const extProp of propsToExtend) {
80
- if (extProp === 'validate' || extProp === 'additionalMessages') {
81
- question = applyExtensionFunction(question, promptOpt, extProp);
82
- }
83
- }
84
- }
85
- });
86
- return questions;
87
- }
88
- exports.extendWithOptions = extendWithOptions;
89
29
  //# sourceMappingURL=helpers.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getQuestions = void 0;
4
4
  const i18n_1 = require("../i18n");
5
5
  const project_access_1 = require("@sap-ux/project-access");
6
+ const inquirer_common_1 = require("@sap-ux/inquirer-common");
6
7
  const types_1 = require("../types");
7
8
  const helpers_1 = require("./helpers");
8
9
  const constants_1 = require("./constants");
@@ -25,7 +26,7 @@ function getQuestions(projectChoices, reuseLibs, promptOptions) {
25
26
  let questions = (0, helpers_1.hidePrompts)(keyedPrompts, promptOptions);
26
27
  // Apply extended `validate`, `additionalMessages` or override `default` prompt properties
27
28
  if (promptOptions) {
28
- questions = (0, helpers_1.extendWithOptions)(questions, promptOptions);
29
+ questions = (0, inquirer_common_1.extendWithOptions)(questions, promptOptions);
29
30
  }
30
31
  return questions;
31
32
  }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { PromptSeverityMessage, validate, YUIQuestion } from '@sap-ux/inquirer-common';
1
+ import type { PromptSeverityMessage, YUIQuestion } from '@sap-ux/inquirer-common';
2
2
  import type { ReuseLib } from '@sap-ux/project-access';
3
- import type { ListChoiceOptions } from 'inquirer';
3
+ import type { ListChoiceOptions, Validator } from 'inquirer';
4
4
  /**
5
5
  * Enumeration of prompt names used by UI5LibraryReferencePromptOptions
6
6
  *
@@ -26,7 +26,7 @@ type stringValuePrompts = stringValuePromptType[keyof stringValuePromptType];
26
26
  */
27
27
  export type CommonPromptOptions = {
28
28
  hide?: boolean;
29
- validate?: validate<UI5LibraryReferenceAnswers>;
29
+ validate?: Validator<UI5LibraryReferenceAnswers>;
30
30
  additionalMessages?: PromptSeverityMessage;
31
31
  };
32
32
  /**
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.2.20",
4
+ "version": "0.2.22",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "i18next": "23.5.1",
23
- "@sap-ux/inquirer-common": "0.2.6",
23
+ "@sap-ux/inquirer-common": "0.2.8",
24
24
  "@sap-ux/project-access": "1.19.14"
25
25
  },
26
26
  "devDependencies": {