create-vite-vue 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +55 -6
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -242,6 +242,11 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
|
242
242
|
if(extraPlugins.includes('vueuse')) optionalDeps['@vueuse/core'] = '^14.2.1'
|
|
243
243
|
if(extraPlugins.includes('dayjs')) optionalDeps['dayjs'] = '^1.11.19'
|
|
244
244
|
if(extraPlugins.includes('lodash')) optionalDeps['lodash'] = '^4.17.23'
|
|
245
|
+
if(extraPlugins.includes('tailwind')) {
|
|
246
|
+
optionalDeps['tailwindcss'] = '^4.2.1'
|
|
247
|
+
optionalDeps['@tailwindcss/postcss'] = '^4.2.1'
|
|
248
|
+
optionalDeps['postcss'] = '^8.5.8'
|
|
249
|
+
}
|
|
245
250
|
if(autoRoute) optionalDeps['vite-plugin-pages'] = '^0.33.3'
|
|
246
251
|
|
|
247
252
|
let depsStr = ''
|
|
@@ -360,19 +365,63 @@ export default createRouter({
|
|
|
360
365
|
|
|
361
366
|
// 1️⃣0️⃣ 安装依赖
|
|
362
367
|
console.log('📦 安装依赖中...')
|
|
363
|
-
let installCmd = 'npm install'
|
|
364
368
|
|
|
365
|
-
|
|
366
|
-
|
|
369
|
+
const pkgManager = detectPackageManager()
|
|
370
|
+
|
|
371
|
+
let installCmd = ''
|
|
372
|
+
|
|
373
|
+
if(pkgManager === 'pnpm') {
|
|
374
|
+
installCmd = 'pnpm install'
|
|
375
|
+
} else if(pkgManager === 'yarn') {
|
|
376
|
+
installCmd = 'yarn'
|
|
377
|
+
} else {
|
|
378
|
+
installCmd = 'npm install'
|
|
367
379
|
}
|
|
368
380
|
|
|
369
381
|
execSync(installCmd, { cwd: targetDir, stdio: 'inherit' })
|
|
370
382
|
|
|
383
|
+
const pkgCommands = {
|
|
384
|
+
npm: {
|
|
385
|
+
install: 'npm install',
|
|
386
|
+
dev: 'npm run dev'
|
|
387
|
+
},
|
|
388
|
+
yarn: {
|
|
389
|
+
install: 'yarn',
|
|
390
|
+
dev: 'yarn dev'
|
|
391
|
+
},
|
|
392
|
+
pnpm: {
|
|
393
|
+
install: 'pnpm install',
|
|
394
|
+
dev: 'pnpm dev'
|
|
395
|
+
},
|
|
396
|
+
bun: {
|
|
397
|
+
install: 'bun install',
|
|
398
|
+
dev: 'bun run dev'
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
371
402
|
// 1️⃣1️⃣ 运行 dev
|
|
372
403
|
if(runDev) {
|
|
373
404
|
console.log('🚀 启动开发服务器...')
|
|
374
|
-
execSync(
|
|
405
|
+
execSync(pkgCommands[pkgManager].dev, {
|
|
406
|
+
cwd: targetDir,
|
|
407
|
+
stdio: 'inherit'
|
|
408
|
+
})
|
|
375
409
|
} else {
|
|
376
|
-
console.log(`\n✅
|
|
410
|
+
console.log(`\n✅ 项目创建完成`)
|
|
411
|
+
console.log(`👉 cd ${projectName}`)
|
|
412
|
+
console.log(`👉 ${pkgCommands[pkgManager].dev}\n`)
|
|
377
413
|
}
|
|
378
|
-
})()
|
|
414
|
+
})()
|
|
415
|
+
|
|
416
|
+
function detectPackageManager () {
|
|
417
|
+
const userAgent = process.env.npm_config_user_agent || ''
|
|
418
|
+
|
|
419
|
+
if(userAgent.startsWith('pnpm')) return 'pnpm'
|
|
420
|
+
if(userAgent.startsWith('yarn')) return 'yarn'
|
|
421
|
+
if(userAgent.startsWith('npm')) return 'npm'
|
|
422
|
+
|
|
423
|
+
if(fs.existsSync('pnpm-lock.yaml')) return 'pnpm'
|
|
424
|
+
if(fs.existsSync('yarn.lock')) return 'yarn'
|
|
425
|
+
|
|
426
|
+
return 'npm'
|
|
427
|
+
}
|