diff --git a/src/schema/integrate.schema.json b/src/schema/integrate.schema.json index bc99186..a3ea3a4 100644 --- a/src/schema/integrate.schema.json +++ b/src/schema/integrate.schema.json @@ -1166,6 +1166,58 @@ "type" ], "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "initialValue": { + "$ref": "#/definitions/OptionValue" + }, + "maxItems": { + "type": "number" + }, + "name": { + "type": "string" + }, + "options": { + "items": { + "additionalProperties": false, + "properties": { + "hint": { + "type": "string" + }, + "label": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/OptionValue" + } + }, + "required": [ + "value" + ], + "type": "object" + }, + "type": "array" + }, + "text": { + "type": "string" + }, + "type": { + "const": "select", + "type": "string" + }, + "when": { + "$ref": "#/definitions/AnyObject" + } + }, + "required": [ + "name", + "options", + "text", + "type" + ], + "type": "object" } ] }, diff --git a/src/schema/upgrade.schema.json b/src/schema/upgrade.schema.json index 3d9e95b..ebb39bc 100644 --- a/src/schema/upgrade.schema.json +++ b/src/schema/upgrade.schema.json @@ -1166,6 +1166,58 @@ "type" ], "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "initialValue": { + "$ref": "#/definitions/OptionValue" + }, + "maxItems": { + "type": "number" + }, + "name": { + "type": "string" + }, + "options": { + "items": { + "additionalProperties": false, + "properties": { + "hint": { + "type": "string" + }, + "label": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/OptionValue" + } + }, + "required": [ + "value" + ], + "type": "object" + }, + "type": "array" + }, + "text": { + "type": "string" + }, + "type": { + "const": "select", + "type": "string" + }, + "when": { + "$ref": "#/definitions/AnyObject" + } + }, + "required": [ + "name", + "options", + "text", + "type" + ], + "type": "object" } ] }, diff --git a/src/types/mod.types.ts b/src/types/mod.types.ts index 24dd7fe..d845904 100644 --- a/src/types/mod.types.ts +++ b/src/types/mod.types.ts @@ -1,6 +1,7 @@ import { ConfirmPromptArgs, MultiselectPromptArgs, + SelectPromptArgs, TextPromptArgs, } from './prompt.types'; @@ -448,11 +449,14 @@ export type ConfirmPrompt = ConfirmPromptArgs & { export type MultiselectPrompt = MultiselectPromptArgs & { type: 'multiselect'; }; +export type SelectPrompt = SelectPromptArgs & { + type: 'select'; +}; export type Prompt = { name: string; text: string; -} & (TextPrompt | ConfirmPrompt | MultiselectPrompt); +} & (TextPrompt | ConfirmPrompt | MultiselectPrompt | SelectPrompt); /** * @TJS-additionalProperties true diff --git a/src/utils/runPrompt.ts b/src/utils/runPrompt.ts index 2ca2126..5e4f78c 100644 --- a/src/utils/runPrompt.ts +++ b/src/utils/runPrompt.ts @@ -1,4 +1,4 @@ -import { confirm, multiselect, text } from '../prompter'; +import { confirm, multiselect, select, text } from '../prompter'; import { Prompt, ValidationType } from '../types/mod.types'; import { transformTextInObject, variables } from '../variables'; import { handlePackageUpgradeInput } from './getPackageUpgradeInput'; @@ -19,6 +19,9 @@ export async function runPrompt( case 'multiselect': inputValue = await multiselect(prompt.text, prompt); break; + case 'select': + inputValue = await select(prompt.text, prompt); + break; default: inputValue = await text(prompt.text, { placeholder: prompt.placeholder,