create-lve 0.4.29 → 0.4.31

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/index.js CHANGED
@@ -7,6 +7,10 @@ import path from 'node:path'
7
7
  import { execSync } from 'node:child_process'
8
8
  import { __dirname, applyProjectTransform, cleanupTemplate, installDependencies } from './config.js'
9
9
 
10
+ const version = JSON.parse(
11
+ fs.readFileSync(new URL('./package.json', import.meta.url), 'utf-8'),
12
+ ).version
13
+
10
14
  function parseArgs() {
11
15
  const args = process.argv.slice(2)
12
16
  const flags = {}
@@ -23,59 +27,70 @@ function randomName() {
23
27
  return `vite-app-${hash}`
24
28
  }
25
29
 
30
+ function onCancel() {
31
+ p.cancel('操作取消')
32
+ process.exit(0)
33
+ }
34
+
26
35
  async function main() {
27
36
  const { flags, positional } = parseArgs()
28
37
  process.stdout.write('\u001b[3J\u001b[2J\u001b[1J')
29
38
  console.clear()
30
39
  const logo = `
31
40
  ${pc.cyan('█ █ █ █▀▀▀')}
32
- ${pc.cyan('█ █ █ █▀▀ ')}
41
+ ${pc.cyan('█ █ █ █▀▀ ')}
33
42
  ${pc.cyan('█▄▄▄ ▀▄▀ █▄▄▄')} ${pc.gray('THE ULTRA-FAST FRONTEND STACK')}
34
43
  `
35
44
  console.log(logo)
36
- p.intro(`${pc.bgCyan(pc.black(' LVE-CLI '))}`)
37
-
38
- const defaultName = positional[0] || randomName()
39
-
40
- const project = await p.group(
41
- {
42
- path: () =>
43
- flags.default
44
- ? defaultName
45
- : p.text({
46
- message: '项目名称',
47
- placeholder: 'your-project-name',
48
- defaultValue: randomName(),
49
- validate: (value) => {
50
- if (!value || value.length === 0) return
51
- if (value.match(/[<>:"|?*]/)) return '路径包含非法字符'
52
- },
53
- }),
54
-
55
- shouldOverwrite: ({ results }) => {
56
- const targetDir = path.resolve(process.cwd(), results.path)
57
- if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
58
- return p.confirm({ message: `目录已存在,是否清空?`, initialValue: false })
59
- }
60
- },
61
-
62
- framework: () =>
63
- flags.default
64
- ? 'react'
65
- : p.select({
66
- message: '选择框架',
67
- options: [
68
- { value: 'react', label: 'React 19', hint: '' },
69
- { value: 'vue', label: 'Vue 3', hint: '' },
70
- { value: 'next', label: 'Next.js 16', hint: '' },
71
- ],
72
- }),
73
-
74
- cssEngine: ({ results }) =>
75
- results.framework === 'next'
76
- ? p.note('Next.js 已内置 Tailwind,无需选择')
77
- : flags.default
78
- ? 'tailwind'
45
+ p.intro(`${pc.bgCyan(pc.black(` LVE-CLI v${version} `))}`)
46
+
47
+ let project
48
+
49
+ if (flags.default) {
50
+ // --default: React + Tailwind,跳过所有 prompt
51
+ const name = positional[0] || randomName()
52
+ const targetDir = path.resolve(process.cwd(), name)
53
+ let shouldOverwrite = false
54
+ if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
55
+ shouldOverwrite = await p.confirm({ message: `目录已存在,是否清空?`, initialValue: false })
56
+ if (p.isCancel(shouldOverwrite)) onCancel()
57
+ }
58
+ project = { path: name, framework: 'react', cssEngine: 'tailwind', shouldOverwrite }
59
+ } else {
60
+ // 交互模式
61
+ project = await p.group(
62
+ {
63
+ path: () =>
64
+ p.text({
65
+ message: '项目名称',
66
+ placeholder: 'your-project-name',
67
+ defaultValue: randomName(),
68
+ validate: (value) => {
69
+ if (!value || value.length === 0) return
70
+ if (value.match(/[<>:"|?*]/)) return '路径包含非法字符'
71
+ },
72
+ }),
73
+
74
+ shouldOverwrite: ({ results }) => {
75
+ const targetDir = path.resolve(process.cwd(), results.path)
76
+ if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
77
+ return p.confirm({ message: `目录已存在,是否清空?`, initialValue: false })
78
+ }
79
+ },
80
+
81
+ framework: () =>
82
+ p.select({
83
+ message: '选择框架',
84
+ options: [
85
+ { value: 'react', label: 'React 19', hint: '' },
86
+ { value: 'vue', label: 'Vue 3', hint: '' },
87
+ { value: 'next', label: 'Next.js 16', hint: '' },
88
+ ],
89
+ }),
90
+
91
+ cssEngine: ({ results }) =>
92
+ results.framework === 'next'
93
+ ? p.note('Next.js 已内置 Tailwind,无需选择')
79
94
  : p.select({
80
95
  message: '选择 CSS',
81
96
  options: [
@@ -83,14 +98,10 @@ async function main() {
83
98
  { value: 'unocss', label: 'UnoCSS' },
84
99
  ],
85
100
  }),
86
- },
87
- {
88
- onCancel: () => {
89
- p.cancel('操作取消')
90
- process.exit(0)
91
101
  },
92
- },
93
- )
102
+ { onCancel },
103
+ )
104
+ }
94
105
 
95
106
  const ctx = {
96
107
  name: project.path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.4.29",
3
+ "version": "0.4.31",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },
@@ -31,12 +31,14 @@ export default defineConfig({
31
31
  output: {
32
32
  manualChunks(id) {
33
33
  if (!id.includes('node_modules')) return
34
- if (id.includes('react') && !id.includes('react-router')) return 'vendor-react'
35
- if (id.includes('react-dom')) return 'vendor-react-dom'
36
- if (id.includes('react-router')) return 'vendor-router'
34
+ const pkg = id.match(/node_modules\/(?:@[^/]+\/)?([^/]+)/)?.[1]
35
+ if (pkg === 'react') return 'vendor-react'
36
+ if (pkg === 'react-dom') return 'vendor-react-dom'
37
+ if (pkg === 'react-router' || pkg === 'react-router-dom')
38
+ return 'vendor-router'
37
39
  if (id.includes('@tanstack')) return 'vendor-query'
38
- if (id.includes('zustand')) return 'vendor-state'
39
- if (id.includes('jotai')) return 'vendor-atom'
40
+ if (pkg === 'zustand') return 'vendor-state'
41
+ if (pkg === 'jotai') return 'vendor-atom'
40
42
  return 'vendor'
41
43
  },
42
44
  },