Skip to content

Commit 93cd587

Browse files
committed
feat: add needsAutomaticalllyInstallDependencies option
1 parent 0b1d1d4 commit 93cd587

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

index.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type PromptResult = {
101101
e2eFramework?: 'cypress' | 'nightwatch' | 'playwright'
102102
experimentFeatures?: (typeof EXPERIMENTAL_FEATURE_OPTIONS)[number]['value'][]
103103
needsBareboneTemplates?: boolean
104+
needsAutomaticalllyInstallDependencies?: boolean
104105
}
105106

106107
function isValidPackageName(projectName) {
@@ -255,6 +256,8 @@ async function init() {
255256

256257
// TODO: default to true sometime in the future
257258
needsBareboneTemplates: false,
259+
// TODO: default to false sometime in the future
260+
needsAutomaticalllyInstallDependencies: false,
258261
}
259262

260263
intro(
@@ -680,25 +683,50 @@ async function init() {
680683
}),
681684
)
682685

686+
result.needsAutomaticalllyInstallDependencies = await unwrapPrompt(
687+
confirm({
688+
message: language.needsAutomaticalllyInstallDependencies.message,
689+
// TODO: default to true sometime in the future
690+
initialValue: false,
691+
}),
692+
)
693+
683694
let outroMessage = `${language.infos.done}\n\n`
684695
if (root !== cwd) {
685696
const cdProjectName = path.relative(cwd, root)
686697
outroMessage += ` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}\n`
687698
}
688-
outroMessage += ` ${bold(green(getCommand(packageManager, 'install')))}\n`
699+
if (!result.needsAutomaticalllyInstallDependencies) {
700+
outroMessage += ` ${bold(green(getCommand(packageManager, 'install')))}\n`
701+
}
689702
if (needsPrettier) {
690703
outroMessage += ` ${bold(green(getCommand(packageManager, 'format')))}\n`
691704
}
692705
outroMessage += ` ${bold(green(getCommand(packageManager, 'dev')))}\n`
693706

694707
if (!dotGitDirectoryState.hasDotGitDirectory) {
695708
outroMessage += `
696-
${dim('|')} ${language.infos.optionalGitCommand}
697-
698-
${bold(green('git init && git add -A && git commit -m "initial commit"'))}`
709+
${dim('|')} ${language.infos.optionalGitCommand}
710+
${bold(green('git init && git add -A && git commit -m "initial commit"'))}`
711+
}
712+
713+
if (!result.needsAutomaticalllyInstallDependencies) {
714+
outro(outroMessage)
715+
return
699716
}
700717

701-
outro(outroMessage)
718+
console.log(`\n\nstarting installation...\n`)
719+
const { spawn } = await import('node:child_process')
720+
const installArgs = ['install']
721+
const child = spawn('pnpm', installArgs, {
722+
cwd: root,
723+
stdio: 'inherit',
724+
shell: process.platform === 'win32',
725+
})
726+
727+
child.on('close', () => {
728+
console.log(outroMessage)
729+
})
702730
}
703731

704732
init().catch((e) => {

locales/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"message": "Select experimental features to include in your project:",
7070
"hint": "(↑/↓ to navigate, space to select, a to toggle all, enter to confirm)"
7171
},
72+
"needsAutomaticalllyInstallDependencies": {
73+
"message": "Automatically install dependencies?"
74+
},
7275
"needsRolldownVite": {
7376
"message": "rolldown-vite (experimental)"
7477
},

locales/fr-FR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"needsBareboneTemplates": {
7676
"message": "Ignorer tout le code d'exemple et commencer avec un projet Vue vierge\u00a0?"
7777
},
78+
"needsAutomaticalllyInstallDependencies": {
79+
"message": "Installer automatiquement les dépendances\u00a0?"
80+
},
7881
"errors": {
7982
"operationCancelled": "Operation annulée"
8083
},

locales/tr-TR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"needsBareboneTemplates": {
7676
"message": "Tüm örnek kodları atlayıp boş bir Vue projesi ile başlansın mı?"
7777
},
78+
"needsAutomaticalllyInstallDependencies": {
79+
"message": "Bağımlılıklar otomatik olarak yüklensin mi?"
80+
},
7881
"errors": {
7982
"operationCancelled": "İşlem iptal edildi"
8083
},

locales/zh-Hans.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"needsBareboneTemplates": {
7676
"message": "跳过所有示例代码,创建一个空白的 Vue 项目?"
7777
},
78+
"needsAutomaticalllyInstallDependencies": {
79+
"message": "是否自动安装依赖?"
80+
},
7881
"errors": {
7982
"operationCancelled": "操作取消"
8083
},

locales/zh-Hant.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"needsBareboneTemplates": {
7676
"message": "跳過所有範例程式碼,建立一個空白的 Vue 專案?"
7777
},
78+
"needsAutomaticalllyInstallDependencies": {
79+
"message": "是否自動安裝相依套件?"
80+
},
7881
"errors": {
7982
"operationCancelled": "操作取消"
8083
},

utils/getLanguage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface Language {
4242
needsOxlint: LanguageItem
4343
needsRolldownVite: LanguageItem
4444
needsBareboneTemplates: LanguageItem
45+
needsAutomaticalllyInstallDependencies: LanguageItem
4546
errors: {
4647
operationCancelled: string
4748
}

0 commit comments

Comments
 (0)