From ccd8bf52f5d9558feac523496b2aeb163a5a0fc7 Mon Sep 17 00:00:00 2001 From: Jinma Yamashita <9401060+jinmayamashita@users.noreply.github.com> Date: Fri, 23 Aug 2024 04:53:05 +0000 Subject: [PATCH 1/2] fix: remove JSON.stringify Co-authored-by: Patrick Dan Lacuna --- .../src/helpers/prompt-clack.ts | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/packages/start-frontend/src/helpers/prompt-clack.ts b/packages/start-frontend/src/helpers/prompt-clack.ts index 835829f61..651b8cc75 100644 --- a/packages/start-frontend/src/helpers/prompt-clack.ts +++ b/packages/start-frontend/src/helpers/prompt-clack.ts @@ -44,23 +44,38 @@ const t = gradient("#53575a", "#ffff00"); export async function propmtClackDir() { intro(`${g("ꮙ START-")}${t("FRONTEND")}`); - const result = await text({ - message: color.blue("Where Would You like to Create Your Application?"), - placeholder: "./my-app", - initialValue: "./my-app", - validate: (value) => { - if (!value) { - return "Please provide a location path"; - } - // regular expression that text start from ./ - const Reg = new RegExp("^\\./"); - if (!Reg.test(value)) { - return "Please input a valid location path"; - } + const { dir } = await group( + { + dir: () => + text({ + message: color.blue( + "Where Would You like to Create Your Application?" + ), + placeholder: "./my-app", + initialValue: "./my-app", + validate: (value) => { + if (!value) { + return "Please provide a location path"; + } + // regular expression that text start from ./ + const Reg = new RegExp("^\\./"); + if (!Reg.test(value)) { + return "Please input a valid location path"; + } + }, + }), }, - }); + { + // On Cancel callback that wraps the group + // So if the user cancels one of the prompts in the group this function will be called + onCancel: () => { + cancel("Operation cancelled."); + process.exit(0); + }, + } + ); - return JSON.stringify(result); + return dir; } export async function promptClack() { From dff61e6a8930d4be74f27401141da132f90f2bda Mon Sep 17 00:00:00 2001 From: Jinma Yamashita <9401060+jinmayamashita@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:55:27 +0900 Subject: [PATCH 2/2] Create wet-snails-flash.md --- .changeset/wet-snails-flash.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wet-snails-flash.md diff --git a/.changeset/wet-snails-flash.md b/.changeset/wet-snails-flash.md new file mode 100644 index 000000000..5a35ab254 --- /dev/null +++ b/.changeset/wet-snails-flash.md @@ -0,0 +1,5 @@ +--- +"start-frontend": patch +--- + +fix: remove JSON.stringify by @ptrkdan @jinmayamashita