Skip to content

Commit

Permalink
fix: fix user prompt function (#6613)
Browse files Browse the repository at this point in the history
That has been broken since the major version update of inquirer library on 0.13.43.
  • Loading branch information
vvagaytsev authored Nov 1, 2024
1 parent e3280b5 commit 16ca204
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
3 changes: 1 addition & 2 deletions core/src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,14 @@ export abstract class Command<
`)
const answer = await userPrompt({
name: "continue",
message: defaultMessage,
type: "confirm",
default: false,
})

log.info("")

return answer.continue
return answer
}

return true
Expand Down
5 changes: 2 additions & 3 deletions core/src/commands/cloud/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ export async function confirmDelete(resource: string, count: number) {
Are you sure you want to continue? (run the command with the "--yes" flag to skip this check).
`)

const answer: any = await userPrompt({
name: "continue",
const answer = await userPrompt({
message: msg,
type: "confirm",
default: false,
})

return answer.continue
return answer
}

export async function readInputKeyValueResources({
Expand Down
1 change: 0 additions & 1 deletion core/src/commands/create/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export class CreateProjectCommand extends Command<CreateProjectArgs, CreateProje

if (opts.interactive && !opts.name) {
const answer = await userPrompt({
name: "name",
message: "Project name:",
type: "input",
default: name,
Expand Down
20 changes: 10 additions & 10 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,16 +762,16 @@ export function removeSlice(array: any[], slice: any[]) {
*
* Note: Wrapping inquirer here and requiring inline because it is surprisingly slow to import on load.
*/
export async function userPrompt(params: {
name: string
message: string
type: "confirm" | "list" | "input"
default?: any
choices?: string[]
pageSize?: number
}): Promise<any> {
const inquirer = await import("inquirer")
return inquirer.prompt(params)
export async function userPrompt(params: { message: string; type: "confirm" | "input"; default?: any }): Promise<any> {
const { confirm, input } = await import("@inquirer/prompts")
const { message, type, default: _default } = params
if (type === "confirm") {
return confirm({ message, default: _default })
}
if (type === "input") {
return input({ message, default: _default })
}
return type satisfies never
}

/**
Expand Down

0 comments on commit 16ca204

Please sign in to comment.