@sap-ux/ui5-application-inquirer 0.13.0 → 0.14.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.
- package/dist/index.js +2 -13
- package/dist/prompts/prompt-helpers.js +9 -2
- package/dist/types.d.ts +6 -25
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -51,7 +51,7 @@ async function prompt(adapter, promptOptions, capCdsInfo, isYUI = false) {
|
|
|
51
51
|
const answers = await adapter.prompt(ui5AppPrompts);
|
|
52
52
|
// Apply default values to prompts in case they have not been executed
|
|
53
53
|
if (promptOptions) {
|
|
54
|
-
const defaultAnswers = applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions
|
|
54
|
+
const defaultAnswers = applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions);
|
|
55
55
|
Object.assign(answers, defaultAnswers);
|
|
56
56
|
}
|
|
57
57
|
return answers;
|
|
@@ -63,10 +63,9 @@ async function prompt(adapter, promptOptions, capCdsInfo, isYUI = false) {
|
|
|
63
63
|
* @param answers the answers from previous prompting, only answers without a value will be considered for defaulting
|
|
64
64
|
* @param ui5AppPrompts the prompts that were used to prompt the user, will be used to apply default values if not answered or no default provided
|
|
65
65
|
* @param promptOptions the prompt options which may provide default values or functions
|
|
66
|
-
* @param capCdsInfo will be passed as additional answer to default functions that depend on it to determine the default value
|
|
67
66
|
* @returns the default values for the unanswered prompts, based on the prompt options
|
|
68
67
|
*/
|
|
69
|
-
function applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions
|
|
68
|
+
function applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions) {
|
|
70
69
|
const defaultAnswers = {};
|
|
71
70
|
Object.entries(promptOptions).forEach(([key, promptOpt]) => {
|
|
72
71
|
const promptKey = key;
|
|
@@ -80,16 +79,6 @@ function applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions, capCds
|
|
|
80
79
|
if (promptKey === types_1.promptNames.ui5Theme) {
|
|
81
80
|
defaultValue = (0, ui5_info_1.getDefaultUI5Theme)(answers.ui5Version);
|
|
82
81
|
}
|
|
83
|
-
else if (promptKey === types_1.promptNames.enableTypeScript) {
|
|
84
|
-
// TypeScript default value is dependent on the CdsUi5PluginInfo
|
|
85
|
-
const enableTypeScriptOpts = promptOpt;
|
|
86
|
-
// If an enableTypeScript default function is provided, use it to determine the default value
|
|
87
|
-
// otherwise override with the provided default value
|
|
88
|
-
defaultValue =
|
|
89
|
-
typeof enableTypeScriptOpts?.default === 'function'
|
|
90
|
-
? enableTypeScriptOpts.default({ ...answers, capCdsInfo })
|
|
91
|
-
: defaultValueOrFunc;
|
|
92
|
-
}
|
|
93
82
|
else if (defaultValueOrFunc !== undefined) {
|
|
94
83
|
defaultValue = getDefaultValue(answers, defaultValueOrFunc);
|
|
95
84
|
}
|
|
@@ -64,12 +64,19 @@ function isVersionIncluded(version, minVersion) {
|
|
|
64
64
|
* @param isCapProject if we are generating into a CAP project certain prompts may be removed
|
|
65
65
|
* @returns the updated questions
|
|
66
66
|
*/
|
|
67
|
-
function hidePrompts(prompts, promptOptions, isCapProject) {
|
|
67
|
+
function hidePrompts(prompts, promptOptions, isCapProject = false) {
|
|
68
68
|
const questions = [];
|
|
69
69
|
if (promptOptions ?? isCapProject) {
|
|
70
70
|
Object.keys(prompts).forEach((key) => {
|
|
71
71
|
const promptKey = key;
|
|
72
|
-
|
|
72
|
+
// Narrow the type as we are only dealing with `hide` options
|
|
73
|
+
const promptOpt = promptOptions?.[promptKey];
|
|
74
|
+
let hidePrompt = false;
|
|
75
|
+
if (typeof promptOpt?.hide === 'function') {
|
|
76
|
+
hidePrompt = promptOpt.hide(isCapProject);
|
|
77
|
+
}
|
|
78
|
+
if (!hidePrompt &&
|
|
79
|
+
!promptOpt?.hide &&
|
|
73
80
|
// Target directory is determined by the CAP project. `enableEsLint` and `targetFolder` are not available for CAP projects
|
|
74
81
|
!([types_1.promptNames.targetFolder, types_1.promptNames.enableEslint].includes(types_1.promptNames[promptKey]) && isCapProject)) {
|
|
75
82
|
questions.push(prompts[promptKey]);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CdsUi5PluginInfo } from '@sap-ux/project-access';
|
|
2
1
|
import type { CommonPromptOptions, PromptDefaultValue, UI5VersionChoice, YUIQuestion } from '@sap-ux/inquirer-common';
|
|
3
2
|
import type { AutocompleteQuestionOptions } from 'inquirer-autocomplete-prompt';
|
|
4
3
|
export interface UI5ApplicationAnswers {
|
|
@@ -80,19 +79,6 @@ type UI5VersionPromptOptions = {
|
|
|
80
79
|
*/
|
|
81
80
|
defaultChoice?: UI5VersionChoice;
|
|
82
81
|
};
|
|
83
|
-
/**
|
|
84
|
-
* Options for the enable TypeScript prompt. This allows for a default value to be determined based on the answers provided
|
|
85
|
-
* and additonal runtime cds information if available. This effectively constains the prompt options for the enable TypeScript prompt
|
|
86
|
-
* to be a function that returns a boolean value since enable TypeScript prompt default is conditional.
|
|
87
|
-
*/
|
|
88
|
-
type EnableTypeScriptPromptOptions = Omit<PromptDefaultValue<boolean>, 'default'> & {
|
|
89
|
-
/**
|
|
90
|
-
* Callback function to determine the default value for TypeScript
|
|
91
|
-
*/
|
|
92
|
-
default?: (answers: UI5ApplicationAnswers & {
|
|
93
|
-
capCdsInfo?: CdsUi5PluginInfo;
|
|
94
|
-
}) => boolean;
|
|
95
|
-
};
|
|
96
82
|
type TargetFolderPromptOptions = {
|
|
97
83
|
/**
|
|
98
84
|
* The default target folder path to be used in combination with the prompt default function and the name prompt validation.
|
|
@@ -122,6 +108,9 @@ type NamePromptOptions = {
|
|
|
122
108
|
*/
|
|
123
109
|
defaultValue?: string;
|
|
124
110
|
};
|
|
111
|
+
export type AddDeployPromptOptions = Omit<UI5ApplicationCommonPromptOptions, 'hide'> & {
|
|
112
|
+
hide?: boolean | ((isCap: boolean) => boolean);
|
|
113
|
+
};
|
|
125
114
|
/**
|
|
126
115
|
* These are boolean value prompt option keys
|
|
127
116
|
*/
|
|
@@ -131,7 +120,7 @@ type stringValuePrompts = stringValuePromptType[keyof stringValuePromptType];
|
|
|
131
120
|
type booleanValuePromptType = Pick<typeof promptNames, booleanPromptKeys>;
|
|
132
121
|
type booleanValuePrompts = booleanValuePromptType[keyof booleanValuePromptType];
|
|
133
122
|
type DefaultValueInputPrompts = promptNames.name | promptNames.description | promptNames.namespace | promptNames.ui5Version | promptNames.targetFolder;
|
|
134
|
-
type DefaultValueConfirmPrompts = promptNames.enableCodeAssist | promptNames.enableEslint | promptNames.skipAnnotations;
|
|
123
|
+
type DefaultValueConfirmPrompts = promptNames.enableTypeScript | promptNames.enableCodeAssist | promptNames.enableEslint | promptNames.skipAnnotations | promptNames.addDeployConfig;
|
|
135
124
|
/**
|
|
136
125
|
* Defines prompt/question default values and/or whether or not they should be shown.
|
|
137
126
|
*/
|
|
@@ -147,17 +136,9 @@ type stringValuePromptOptions = Record<stringValuePrompts, UI5ApplicationCommonP
|
|
|
147
136
|
* Provide the correct type checking for boolean value prompts and validator callback options
|
|
148
137
|
*
|
|
149
138
|
*/
|
|
150
|
-
type booleanValuePromptOtions = Record<booleanValuePrompts, {
|
|
151
|
-
/**
|
|
152
|
-
* Callback function can be provided which will be executed on input validation.
|
|
153
|
-
* This may be used, for example, to trigger conditional steps in Yeoman UI.
|
|
154
|
-
*
|
|
155
|
-
* @param answer
|
|
156
|
-
* @param promptName
|
|
157
|
-
* @returns
|
|
158
|
-
*/
|
|
139
|
+
type booleanValuePromptOtions = Record<Exclude<booleanValuePrompts, typeof promptNames.addDeployConfig>, UI5ApplicationCommonPromptOptions> & Record<booleanValuePrompts, {
|
|
159
140
|
validatorCallback?: (answer: boolean, promptName: string) => void;
|
|
160
|
-
}
|
|
141
|
+
}> & Record<DefaultValueConfirmPrompts, PromptDefaultValue<boolean>> & Record<promptNames.addDeployConfig, AddDeployPromptOptions>;
|
|
161
142
|
export type UI5ApplicationQuestion = YUIQuestion<UI5ApplicationAnswers> & Partial<Pick<AutocompleteQuestionOptions, 'source'>>;
|
|
162
143
|
export type UI5ApplicationPromptOptions = Partial<stringValuePromptOptions & booleanValuePromptOtions>;
|
|
163
144
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-application-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for UI5 application writing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"inquirer-autocomplete-prompt": "2.0.1",
|
|
24
24
|
"lodash": "4.17.21",
|
|
25
25
|
"semver": "7.5.4",
|
|
26
|
-
"@sap-ux/inquirer-common": "0.7.
|
|
27
|
-
"@sap-ux/project-access": "1.30.
|
|
28
|
-
"@sap-ux/project-input-validator": "0.6.
|
|
26
|
+
"@sap-ux/inquirer-common": "0.7.1",
|
|
27
|
+
"@sap-ux/project-access": "1.30.1",
|
|
28
|
+
"@sap-ux/project-input-validator": "0.6.1",
|
|
29
29
|
"@sap-ux/ui5-info": "0.11.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/lodash": "4.14.202",
|
|
36
36
|
"@types/semver": "7.5.4",
|
|
37
37
|
"inquirer": "8.2.6",
|
|
38
|
-
"@sap-ux/cap-config-writer": "0.10.
|
|
38
|
+
"@sap-ux/cap-config-writer": "0.10.1"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=20.x"
|