From 93cd5873507ecde010fb9e33965d95fa30387879 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 20 Sep 2025 21:51:40 +0800 Subject: [PATCH 1/6] feat: add `needsAutomaticalllyInstallDependencies` option --- index.ts | 38 +++++++++++++++++++++++++++++++++----- locales/en-US.json | 3 +++ locales/fr-FR.json | 3 +++ locales/tr-TR.json | 3 +++ locales/zh-Hans.json | 3 +++ locales/zh-Hant.json | 3 +++ utils/getLanguage.ts | 1 + 7 files changed, 49 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index 4d77d0904..76a173403 100755 --- a/index.ts +++ b/index.ts @@ -101,6 +101,7 @@ type PromptResult = { e2eFramework?: 'cypress' | 'nightwatch' | 'playwright' experimentFeatures?: (typeof EXPERIMENTAL_FEATURE_OPTIONS)[number]['value'][] needsBareboneTemplates?: boolean + needsAutomaticalllyInstallDependencies?: boolean } function isValidPackageName(projectName) { @@ -255,6 +256,8 @@ async function init() { // TODO: default to true sometime in the future needsBareboneTemplates: false, + // TODO: default to false sometime in the future + needsAutomaticalllyInstallDependencies: false, } intro( @@ -680,12 +683,22 @@ async function init() { }), ) + result.needsAutomaticalllyInstallDependencies = await unwrapPrompt( + confirm({ + message: language.needsAutomaticalllyInstallDependencies.message, + // TODO: default to true sometime in the future + initialValue: false, + }), + ) + let outroMessage = `${language.infos.done}\n\n` if (root !== cwd) { const cdProjectName = path.relative(cwd, root) outroMessage += ` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}\n` } - outroMessage += ` ${bold(green(getCommand(packageManager, 'install')))}\n` + if (!result.needsAutomaticalllyInstallDependencies) { + outroMessage += ` ${bold(green(getCommand(packageManager, 'install')))}\n` + } if (needsPrettier) { outroMessage += ` ${bold(green(getCommand(packageManager, 'format')))}\n` } @@ -693,12 +706,27 @@ async function init() { if (!dotGitDirectoryState.hasDotGitDirectory) { outroMessage += ` -${dim('|')} ${language.infos.optionalGitCommand} - - ${bold(green('git init && git add -A && git commit -m "initial commit"'))}` + ${dim('|')} ${language.infos.optionalGitCommand} + ${bold(green('git init && git add -A && git commit -m "initial commit"'))}` + } + + if (!result.needsAutomaticalllyInstallDependencies) { + outro(outroMessage) + return } - outro(outroMessage) + console.log(`\n\nstarting installation...\n`) + const { spawn } = await import('node:child_process') + const installArgs = ['install'] + const child = spawn('pnpm', installArgs, { + cwd: root, + stdio: 'inherit', + shell: process.platform === 'win32', + }) + + child.on('close', () => { + console.log(outroMessage) + }) } init().catch((e) => { diff --git a/locales/en-US.json b/locales/en-US.json index 10a91068f..87568f815 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -69,6 +69,9 @@ "message": "Select experimental features to include in your project:", "hint": "(↑/↓ to navigate, space to select, a to toggle all, enter to confirm)" }, + "needsAutomaticalllyInstallDependencies": { + "message": "Automatically install dependencies?" + }, "needsRolldownVite": { "message": "rolldown-vite (experimental)" }, diff --git a/locales/fr-FR.json b/locales/fr-FR.json index 1e2ff6895..975eebcbb 100644 --- a/locales/fr-FR.json +++ b/locales/fr-FR.json @@ -75,6 +75,9 @@ "needsBareboneTemplates": { "message": "Ignorer tout le code d'exemple et commencer avec un projet Vue vierge\u00a0?" }, + "needsAutomaticalllyInstallDependencies": { + "message": "Installer automatiquement les dépendances\u00a0?" + }, "errors": { "operationCancelled": "Operation annulée" }, diff --git a/locales/tr-TR.json b/locales/tr-TR.json index 550cdcedd..2e477a907 100644 --- a/locales/tr-TR.json +++ b/locales/tr-TR.json @@ -75,6 +75,9 @@ "needsBareboneTemplates": { "message": "Tüm örnek kodları atlayıp boş bir Vue projesi ile başlansın mı?" }, + "needsAutomaticalllyInstallDependencies": { + "message": "Bağımlılıklar otomatik olarak yüklensin mi?" + }, "errors": { "operationCancelled": "İşlem iptal edildi" }, diff --git a/locales/zh-Hans.json b/locales/zh-Hans.json index 3f46cf5d5..9ef7dc228 100644 --- a/locales/zh-Hans.json +++ b/locales/zh-Hans.json @@ -75,6 +75,9 @@ "needsBareboneTemplates": { "message": "跳过所有示例代码,创建一个空白的 Vue 项目?" }, + "needsAutomaticalllyInstallDependencies": { + "message": "是否自动安装依赖?" + }, "errors": { "operationCancelled": "操作取消" }, diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 98cc63b2d..f70fb79b8 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -75,6 +75,9 @@ "needsBareboneTemplates": { "message": "跳過所有範例程式碼,建立一個空白的 Vue 專案?" }, + "needsAutomaticalllyInstallDependencies": { + "message": "是否自動安裝相依套件?" + }, "errors": { "operationCancelled": "操作取消" }, diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 5d81d2a00..6b0b9bd19 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -42,6 +42,7 @@ interface Language { needsOxlint: LanguageItem needsRolldownVite: LanguageItem needsBareboneTemplates: LanguageItem + needsAutomaticalllyInstallDependencies: LanguageItem errors: { operationCancelled: string } From 758623f1c2fd136517663e0209ed62df9e7f95ec Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 20 Sep 2025 21:59:33 +0800 Subject: [PATCH 2/6] fix: update --- locales/fr-FR.json | 6 +++--- locales/tr-TR.json | 6 +++--- locales/zh-Hans.json | 6 +++--- locales/zh-Hant.json | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/locales/fr-FR.json b/locales/fr-FR.json index 975eebcbb..4df9f2992 100644 --- a/locales/fr-FR.json +++ b/locales/fr-FR.json @@ -69,15 +69,15 @@ "message": "Sélectionnez les fonctionnalités expérimentales à inclure\u00a0:", "hint": "(↑/↓ pour naviguer, espace pour sélectionner, a pour tout sélectionner, entrée pour confirmer)" }, + "needsAutomaticalllyInstallDependencies": { + "message": "Installer automatiquement les dépendances\u00a0?" + }, "needsRolldownVite": { "message": "rolldown-vite (expérimental)" }, "needsBareboneTemplates": { "message": "Ignorer tout le code d'exemple et commencer avec un projet Vue vierge\u00a0?" }, - "needsAutomaticalllyInstallDependencies": { - "message": "Installer automatiquement les dépendances\u00a0?" - }, "errors": { "operationCancelled": "Operation annulée" }, diff --git a/locales/tr-TR.json b/locales/tr-TR.json index 2e477a907..1f1124bd9 100644 --- a/locales/tr-TR.json +++ b/locales/tr-TR.json @@ -69,15 +69,15 @@ "message": "Dahil edilecek deneysel özellikleri seçin:", "hint": "(↑/↓ gezinmek için, boşluk seçmek için, a tümünü seçmek için, enter onaylamak için)" }, + "needsAutomaticalllyInstallDependencies": { + "message": "Bağımlılıklar otomatik olarak yüklensin mi?" + }, "needsRolldownVite": { "message": "rolldown-vite (deneysel)" }, "needsBareboneTemplates": { "message": "Tüm örnek kodları atlayıp boş bir Vue projesi ile başlansın mı?" }, - "needsAutomaticalllyInstallDependencies": { - "message": "Bağımlılıklar otomatik olarak yüklensin mi?" - }, "errors": { "operationCancelled": "İşlem iptal edildi" }, diff --git a/locales/zh-Hans.json b/locales/zh-Hans.json index 9ef7dc228..447a2e3d9 100644 --- a/locales/zh-Hans.json +++ b/locales/zh-Hans.json @@ -69,15 +69,15 @@ "message": "选择要包含的试验特性:", "hint": "(↑/↓ 切换,空格选择,a 全选,回车确认)" }, + "needsAutomaticalllyInstallDependencies": { + "message": "是否自动安装依赖?" + }, "needsRolldownVite": { "message": "rolldown-vite(试验阶段)" }, "needsBareboneTemplates": { "message": "跳过所有示例代码,创建一个空白的 Vue 项目?" }, - "needsAutomaticalllyInstallDependencies": { - "message": "是否自动安装依赖?" - }, "errors": { "operationCancelled": "操作取消" }, diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index f70fb79b8..482975e8f 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -69,15 +69,15 @@ "message": "請選擇要包含的試驗特性:", "hint": "(↑/↓ 切換,空格選擇,a 全選,enter 確認)" }, + "needsAutomaticalllyInstallDependencies": { + "message": "是否自動安裝相依套件?" + }, "needsRolldownVite": { "message": "rolldown-vite(試驗性功能)" }, "needsBareboneTemplates": { "message": "跳過所有範例程式碼,建立一個空白的 Vue 專案?" }, - "needsAutomaticalllyInstallDependencies": { - "message": "是否自動安裝相依套件?" - }, "errors": { "operationCancelled": "操作取消" }, From bc750969740f5bebdc056e4895d3dd662885a7c6 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 20 Sep 2025 22:07:25 +0800 Subject: [PATCH 3/6] fix: typo --- index.ts | 12 ++++++------ locales/en-US.json | 2 +- locales/fr-FR.json | 2 +- locales/tr-TR.json | 2 +- locales/zh-Hans.json | 2 +- locales/zh-Hant.json | 2 +- utils/getLanguage.ts | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/index.ts b/index.ts index 76a173403..a69f69040 100755 --- a/index.ts +++ b/index.ts @@ -101,7 +101,7 @@ type PromptResult = { e2eFramework?: 'cypress' | 'nightwatch' | 'playwright' experimentFeatures?: (typeof EXPERIMENTAL_FEATURE_OPTIONS)[number]['value'][] needsBareboneTemplates?: boolean - needsAutomaticalllyInstallDependencies?: boolean + needsAutomaticallyInstallDependencies?: boolean } function isValidPackageName(projectName) { @@ -257,7 +257,7 @@ async function init() { // TODO: default to true sometime in the future needsBareboneTemplates: false, // TODO: default to false sometime in the future - needsAutomaticalllyInstallDependencies: false, + needsAutomaticallyInstallDependencies: false, } intro( @@ -683,9 +683,9 @@ async function init() { }), ) - result.needsAutomaticalllyInstallDependencies = await unwrapPrompt( + result.needsAutomaticallyInstallDependencies = await unwrapPrompt( confirm({ - message: language.needsAutomaticalllyInstallDependencies.message, + message: language.needsAutomaticallyInstallDependencies.message, // TODO: default to true sometime in the future initialValue: false, }), @@ -696,7 +696,7 @@ async function init() { const cdProjectName = path.relative(cwd, root) outroMessage += ` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}\n` } - if (!result.needsAutomaticalllyInstallDependencies) { + if (!result.needsAutomaticallyInstallDependencies) { outroMessage += ` ${bold(green(getCommand(packageManager, 'install')))}\n` } if (needsPrettier) { @@ -710,7 +710,7 @@ async function init() { ${bold(green('git init && git add -A && git commit -m "initial commit"'))}` } - if (!result.needsAutomaticalllyInstallDependencies) { + if (!result.needsAutomaticallyInstallDependencies) { outro(outroMessage) return } diff --git a/locales/en-US.json b/locales/en-US.json index 87568f815..79cb13e27 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -69,7 +69,7 @@ "message": "Select experimental features to include in your project:", "hint": "(↑/↓ to navigate, space to select, a to toggle all, enter to confirm)" }, - "needsAutomaticalllyInstallDependencies": { + "needsAutomaticallyInstallDependencies": { "message": "Automatically install dependencies?" }, "needsRolldownVite": { diff --git a/locales/fr-FR.json b/locales/fr-FR.json index 4df9f2992..12e34a9b1 100644 --- a/locales/fr-FR.json +++ b/locales/fr-FR.json @@ -69,7 +69,7 @@ "message": "Sélectionnez les fonctionnalités expérimentales à inclure\u00a0:", "hint": "(↑/↓ pour naviguer, espace pour sélectionner, a pour tout sélectionner, entrée pour confirmer)" }, - "needsAutomaticalllyInstallDependencies": { + "needsAutomaticallyInstallDependencies": { "message": "Installer automatiquement les dépendances\u00a0?" }, "needsRolldownVite": { diff --git a/locales/tr-TR.json b/locales/tr-TR.json index 1f1124bd9..9db5335c5 100644 --- a/locales/tr-TR.json +++ b/locales/tr-TR.json @@ -69,7 +69,7 @@ "message": "Dahil edilecek deneysel özellikleri seçin:", "hint": "(↑/↓ gezinmek için, boşluk seçmek için, a tümünü seçmek için, enter onaylamak için)" }, - "needsAutomaticalllyInstallDependencies": { + "needsAutomaticallyInstallDependencies": { "message": "Bağımlılıklar otomatik olarak yüklensin mi?" }, "needsRolldownVite": { diff --git a/locales/zh-Hans.json b/locales/zh-Hans.json index 447a2e3d9..9fe5b3c87 100644 --- a/locales/zh-Hans.json +++ b/locales/zh-Hans.json @@ -69,7 +69,7 @@ "message": "选择要包含的试验特性:", "hint": "(↑/↓ 切换,空格选择,a 全选,回车确认)" }, - "needsAutomaticalllyInstallDependencies": { + "needsAutomaticallyInstallDependencies": { "message": "是否自动安装依赖?" }, "needsRolldownVite": { diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 482975e8f..15a32e6e2 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -69,7 +69,7 @@ "message": "請選擇要包含的試驗特性:", "hint": "(↑/↓ 切換,空格選擇,a 全選,enter 確認)" }, - "needsAutomaticalllyInstallDependencies": { + "needsAutomaticallyInstallDependencies": { "message": "是否自動安裝相依套件?" }, "needsRolldownVite": { diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 6b0b9bd19..1fccdaa7c 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -42,7 +42,7 @@ interface Language { needsOxlint: LanguageItem needsRolldownVite: LanguageItem needsBareboneTemplates: LanguageItem - needsAutomaticalllyInstallDependencies: LanguageItem + needsAutomaticallyInstallDependencies: LanguageItem errors: { operationCancelled: string } From f08fc2a56d7ac49c2ce757ee7c9a17690bef13e2 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 20 Sep 2025 22:08:18 +0800 Subject: [PATCH 4/6] fix: update --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index a69f69040..1c985d25b 100755 --- a/index.ts +++ b/index.ts @@ -718,7 +718,7 @@ async function init() { console.log(`\n\nstarting installation...\n`) const { spawn } = await import('node:child_process') const installArgs = ['install'] - const child = spawn('pnpm', installArgs, { + const child = spawn(packageManager, installArgs, { cwd: root, stdio: 'inherit', shell: process.platform === 'win32', From ffad94edbfa05193fb4ff15fda6648ee98e46599 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sun, 21 Sep 2025 10:17:58 +0800 Subject: [PATCH 5/6] fix: update --- index.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 1c985d25b..4402a1957 100755 --- a/index.ts +++ b/index.ts @@ -724,8 +724,21 @@ async function init() { shell: process.platform === 'win32', }) - child.on('close', () => { - console.log(outroMessage) + child.on('close', (code) => { + if (code === 0) { + console.log(outroMessage) + } else { + console.error( + red(`\n${bold('Error:')} Dependency installation failed with exit code ${code}.`), + ) + console.error( + red( + 'Please check the output above for details and try running the install command manually:', + ), + ) + console.error(bold(green(getCommand(packageManager, 'install')))) + process.exit(code) + } }) } From 4176fe8b36aca5f0b98cb3687bc5b9f3b842f193 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 22 Sep 2025 08:20:55 +0800 Subject: [PATCH 6/6] fix: update --- index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index 4402a1957..e7c44df34 100755 --- a/index.ts +++ b/index.ts @@ -683,13 +683,16 @@ async function init() { }), ) - result.needsAutomaticallyInstallDependencies = await unwrapPrompt( - confirm({ - message: language.needsAutomaticallyInstallDependencies.message, - // TODO: default to true sometime in the future - initialValue: false, - }), - ) + if (!args.length) { + // skip snapshot pending prompts + result.needsAutomaticallyInstallDependencies = await unwrapPrompt( + confirm({ + message: language.needsAutomaticallyInstallDependencies.message, + // TODO: default to true sometime in the future + initialValue: false, + }), + ) + } let outroMessage = `${language.infos.done}\n\n` if (root !== cwd) {