From cafe3c570ca939cdb5b95ac03689334cc6da199c Mon Sep 17 00:00:00 2001 From: zichen0116 Date: Mon, 25 May 2026 07:17:54 +0800 Subject: [PATCH] fix(@typegpu/cli): remove default name suggestion, leave just placeholder Remove from text prompts in getProjectDirectory and getPackageName so that only the placeholder (grey hint text) is shown, rather than pre-filling the input with a default value. When the user submits an empty input, the default value is used as a fallback, preserving the original behavior while giving users a cleaner prompt experience. Fixes #2542 --- packages/typegpu-cli/src/utils/inputs.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/typegpu-cli/src/utils/inputs.ts b/packages/typegpu-cli/src/utils/inputs.ts index dd3b263561..5765bd2620 100644 --- a/packages/typegpu-cli/src/utils/inputs.ts +++ b/packages/typegpu-cli/src/utils/inputs.ts @@ -9,11 +9,10 @@ function isValidPackageName(packageName: string) { return /^(?:@[a-z\d][a-z\d\-._]*\/)?[a-z\d][a-z\d\-._]*$/.test(packageName.trim()); } -export async function getProjectDirectory(initialValue: string) { +export async function getProjectDirectory(defaultValue: string) { let projectDir = await p.text({ message: 'Project directory:', - placeholder: initialValue, - initialValue, + placeholder: defaultValue, validate: (value) => { return value && !isValidProjectDirectory(value) ? 'Invalid project directory.' : undefined; }, @@ -23,17 +22,16 @@ export async function getProjectDirectory(initialValue: string) { cancelExit(); } - projectDir ??= '.'; - return projectDir.trim(); + projectDir = projectDir?.trim() || defaultValue; + return projectDir; } -export async function getPackageName(initialValue: string) { +export async function getPackageName(defaultValue: string) { const packageName = await p.text({ message: 'Package name:', - placeholder: initialValue, - initialValue, + placeholder: defaultValue, validate: (value) => { - return !value || !isValidPackageName(value) ? 'Invalid package name.' : undefined; + return value && !isValidPackageName(value) ? 'Invalid package name.' : undefined; }, }); @@ -41,5 +39,5 @@ export async function getPackageName(initialValue: string) { cancelExit(); } - return packageName.trim(); + return packageName?.trim() || defaultValue; }