create-lve 0.4.28 → 0.4.29

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.
Files changed (2) hide show
  1. package/index.js +44 -24
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -7,12 +7,24 @@ 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
+ function parseArgs() {
11
+ const args = process.argv.slice(2)
12
+ const flags = {}
13
+ const positional = []
14
+ for (const arg of args) {
15
+ if (arg === '--default') flags.default = true
16
+ else if (!arg.startsWith('-')) positional.push(arg)
17
+ }
18
+ return { flags, positional }
19
+ }
20
+
10
21
  function randomName() {
11
22
  const hash = Math.random().toString(36).slice(2, 6)
12
23
  return `vite-app-${hash}`
13
24
  }
14
25
 
15
26
  async function main() {
27
+ const { flags, positional } = parseArgs()
16
28
  process.stdout.write('\u001b[3J\u001b[2J\u001b[1J')
17
29
  console.clear()
18
30
  const logo = `
@@ -23,18 +35,22 @@ async function main() {
23
35
  console.log(logo)
24
36
  p.intro(`${pc.bgCyan(pc.black(' LVE-CLI '))}`)
25
37
 
38
+ const defaultName = positional[0] || randomName()
39
+
26
40
  const project = await p.group(
27
41
  {
28
42
  path: () =>
29
- p.text({
30
- message: '项目名称',
31
- placeholder: 'your-project-name',
32
- defaultValue: randomName(),
33
- validate: (value) => {
34
- if (!value || value.length === 0) return
35
- if (value.match(/[<>:"|?*]/)) return '路径包含非法字符'
36
- },
37
- }),
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
+ }),
38
54
 
39
55
  shouldOverwrite: ({ results }) => {
40
56
  const targetDir = path.resolve(process.cwd(), results.path)
@@ -44,25 +60,29 @@ async function main() {
44
60
  },
45
61
 
46
62
  framework: () =>
47
- p.select({
48
- message: '选择框架',
49
- options: [
50
- { value: 'react', label: 'React 19', hint: '' },
51
- { value: 'vue', label: 'Vue 3', hint: '' },
52
- { value: 'next', label: 'Next.js 16', hint: '' },
53
- ],
54
- }),
55
-
56
- cssEngine: ({ results }) =>
57
- results.framework === 'next'
58
- ? p.note('Next.js 已内置 Tailwind,无需选择')
63
+ flags.default
64
+ ? 'react'
59
65
  : p.select({
60
- message: '选择 CSS',
66
+ message: '选择框架',
61
67
  options: [
62
- { value: 'tailwind', label: 'Tailwind v4' },
63
- { value: 'unocss', label: 'UnoCSS' },
68
+ { value: 'react', label: 'React 19', hint: '' },
69
+ { value: 'vue', label: 'Vue 3', hint: '' },
70
+ { value: 'next', label: 'Next.js 16', hint: '' },
64
71
  ],
65
72
  }),
73
+
74
+ cssEngine: ({ results }) =>
75
+ results.framework === 'next'
76
+ ? p.note('Next.js 已内置 Tailwind,无需选择')
77
+ : flags.default
78
+ ? 'tailwind'
79
+ : p.select({
80
+ message: '选择 CSS',
81
+ options: [
82
+ { value: 'tailwind', label: 'Tailwind v4' },
83
+ { value: 'unocss', label: 'UnoCSS' },
84
+ ],
85
+ }),
66
86
  },
67
87
  {
68
88
  onCancel: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },