From 16ca2044207d1a7a20a39092d09feab83108ac03 Mon Sep 17 00:00:00 2001 From: Vladimir Vagaytsev <10628074+vvagaytsev@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:17:23 +0100 Subject: [PATCH] fix: fix user prompt function (#6613) That has been broken since the major version update of inquirer library on 0.13.43. --- core/src/commands/base.ts | 3 +-- core/src/commands/cloud/helpers.ts | 5 ++--- core/src/commands/create/create-project.ts | 1 - core/src/util/util.ts | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/core/src/commands/base.ts b/core/src/commands/base.ts index dae6436a4c..acf17d3fda 100644 --- a/core/src/commands/base.ts +++ b/core/src/commands/base.ts @@ -590,7 +590,6 @@ export abstract class Command< `) const answer = await userPrompt({ - name: "continue", message: defaultMessage, type: "confirm", default: false, @@ -598,7 +597,7 @@ export abstract class Command< log.info("") - return answer.continue + return answer } return true diff --git a/core/src/commands/cloud/helpers.ts b/core/src/commands/cloud/helpers.ts index d39e4c58cd..0edf207b65 100644 --- a/core/src/commands/cloud/helpers.ts +++ b/core/src/commands/cloud/helpers.ts @@ -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({ diff --git a/core/src/commands/create/create-project.ts b/core/src/commands/create/create-project.ts index 989b0a1022..762e2bd87a 100644 --- a/core/src/commands/create/create-project.ts +++ b/core/src/commands/create/create-project.ts @@ -132,7 +132,6 @@ export class CreateProjectCommand extends Command { - const inquirer = await import("inquirer") - return inquirer.prompt(params) +export async function userPrompt(params: { message: string; type: "confirm" | "input"; default?: any }): Promise { + 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 } /**