Skip to content

Commit

Permalink
fix: added select to prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat Mehmet committed Jul 16, 2024
1 parent 605fb37 commit d539f8f
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
52 changes: 52 additions & 0 deletions src/schema/integrate.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
},
Expand Down
52 changes: 52 additions & 0 deletions src/schema/upgrade.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion src/types/mod.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ConfirmPromptArgs,
MultiselectPromptArgs,
SelectPromptArgs,
TextPromptArgs,
} from './prompt.types';

Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/utils/runPrompt.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down

0 comments on commit d539f8f

Please sign in to comment.