create-lve 0.4.21 → 0.4.22

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/config.js CHANGED
@@ -7,40 +7,6 @@ import { execSync, spawn } from 'node:child_process'
7
7
 
8
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
9
 
10
- const getReactAppTemplate = (isUno) => {
11
- const logoClass = isUno
12
- ? 'animate-spin animate-duration-20s animate-linear animate-infinite'
13
- : 'animate-[spin_20s_linear_infinite]'
14
-
15
- return `
16
- import { useState } from 'react'
17
- import reactLogo from './assets/react.svg'
18
-
19
- export function App() {
20
- const [count, setCount] = useState(0)
21
-
22
- return (
23
- <div className="max-w-7xl mx-auto p-8 text-center font-sans antialiased text-[#213547] dark:text-zinc-200 min-h-dvh flex flex-col justify-center items-center">
24
- <div className="flex justify-center gap-12 mb-12">
25
- <a href="https://viteplus.dev" target="_blank" rel="noreferrer" className="transition-all duration-300 hover:drop-shadow-[0_0_2em_#646cffaa]">
26
- <img src="/favicon.svg" className="h-24 p-6" alt="VitePlus logo" />
27
- </a>
28
- <a href="https://react.dev" target="_blank" rel="noreferrer" className="transition-all duration-300 hover:drop-shadow-[0_0_2em_#61dafbaa]">
29
- <img src={reactLogo} className="h-24 p-6 ${logoClass}" alt="React logo" />
30
- </a>
31
- </div>
32
- <h1 className="text-5xl font-bold leading-[1.1] mb-8">VitePlus + React</h1>
33
- <div className="p-8 space-y-4 flex flex-col items-center">
34
- <button onClick={() => setCount((count) => count + 1)} className="rounded-lg border border-transparent px-5 py-2.5 text-base font-medium bg-[#f9f9f9] dark:bg-zinc-800 cursor-pointer transition-colors hover:border-[#646cff] outline-none">
35
- count is {count}
36
- </button>
37
- </div>
38
- </div>
39
- )
40
- }
41
- `.trim()
42
- }
43
-
44
10
  const FRAMEWORK_CONFIG = {
45
11
  next: {
46
12
  deps: (isUno) => ({
@@ -64,11 +30,9 @@ const FRAMEWORK_CONFIG = {
64
30
  : { tailwindcss: 'latest', '@tailwindcss/vite': 'latest' }),
65
31
  },
66
32
 
67
- pnpm: {
68
- overrides: {
69
- vite: 'npm:@voidzero-dev/vite-plus-core@latest',
70
- vitest: 'npm:@voidzero-dev/vite-plus-test@latest',
71
- },
33
+ overrides: {
34
+ vite: 'npm:@voidzero-dev/vite-plus-core@latest',
35
+ vitest: 'npm:@voidzero-dev/vite-plus-test@latest',
72
36
  },
73
37
  }),
74
38
  },
@@ -199,7 +163,9 @@ async function runTask(command, args, cwd) {
199
163
  reject(err)
200
164
  })
201
165
 
202
- child.on('close', (code) => (code === 0 ? resolve() : reject()))
166
+ child.on('close', (code) =>
167
+ code === 0 ? resolve() : reject(new Error(`${command} exited with code ${code}`)),
168
+ )
203
169
  })
204
170
  }
205
171
 
@@ -213,7 +179,11 @@ async function applyProjectTransform(ctx) {
213
179
  const extraConfig = config.deps(isUno)
214
180
  pkg.dependencies = { ...pkg.dependencies, ...extraConfig.dependencies }
215
181
  pkg.devDependencies = { ...pkg.devDependencies, ...extraConfig.devDependencies }
216
- if (extraConfig.pnpm) pkg.pnpm = { ...pkg.pnpm, ...extraConfig.pnpm }
182
+ if (extraConfig.overrides) pkg.overrides = { ...pkg.overrides, ...extraConfig.overrides }
183
+ try {
184
+ const version = execSync('pnpm --version', { encoding: 'utf-8', timeout: 5000 }).trim()
185
+ pkg.packageManager = `pnpm@${version}`
186
+ } catch {}
217
187
  await fs.writeJson(pkgPath, pkg, { spaces: 2 })
218
188
 
219
189
  await resolveLatestVersions(pkgPath)
@@ -225,11 +195,6 @@ async function applyProjectTransform(ctx) {
225
195
  const paths = {
226
196
  main: path.join(targetDir, isVue ? 'src/main.ts' : 'src/main.tsx'),
227
197
  vite: path.join(targetDir, 'vite.config.ts'),
228
- app: path.join(targetDir, isVue ? 'src/App.vue' : 'src/App.tsx'),
229
- }
230
-
231
- if (framework === 'react') {
232
- await fs.writeFile(paths.app, getReactAppTemplate(isUno))
233
198
  }
234
199
 
235
200
  let viteContent = await fs.readFile(paths.vite, 'utf-8')
package/index.js CHANGED
@@ -7,6 +7,11 @@ 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 randomName() {
11
+ const hash = Math.random().toString(36).slice(2, 6)
12
+ return `vite-app-${hash}`
13
+ }
14
+
10
15
  async function main() {
11
16
  process.stdout.write('\u001b[3J\u001b[2J\u001b[1J')
12
17
  console.clear()
@@ -23,8 +28,8 @@ async function main() {
23
28
  path: () =>
24
29
  p.text({
25
30
  message: '项目名称',
26
- placeholder: 'react-app',
27
- defaultValue: 'react-app',
31
+ placeholder: 'your-project-name',
32
+ defaultValue: randomName(),
28
33
  validate: (value) => {
29
34
  if (!value || value.length === 0) return
30
35
  if (value.match(/[<>:"|?*]/)) return '路径包含非法字符'
@@ -106,7 +111,7 @@ async function main() {
106
111
  s.start('Installing dependencies')
107
112
  await installDependencies(ctx)
108
113
  s.stop()
109
- console.log(pc.green(`→ Next: cd ${ctx.name} && ${ctx.devCmd.replace(' ', ' run ')}`))
114
+ console.log(pc.green(`→ Next: cd ${ctx.name} && ${ctx.devCmd}`))
110
115
  } catch (err) {
111
116
  s.stop(pc.red('Failed'))
112
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },
@@ -10,24 +10,23 @@
10
10
  "prepare": "vp config"
11
11
  },
12
12
  "dependencies": {
13
+ "@tanstack/react-query": "latest",
14
+ "jotai": "latest",
13
15
  "react": "latest",
14
- "react-dom": "latest"
16
+ "react-dom": "latest",
17
+ "react-router": "latest",
18
+ "zustand": "latest"
15
19
  },
16
20
  "devDependencies": {
21
+ "@tailwindcss/vite": "latest",
17
22
  "@types/node": "latest",
18
23
  "@types/react": "latest",
19
24
  "@types/react-dom": "latest",
20
25
  "@vitejs/plugin-react": "latest",
21
26
  "babel-plugin-react-compiler": "latest",
27
+ "tailwindcss": "latest",
22
28
  "typescript": "latest",
23
29
  "vite": "latest",
24
30
  "vite-plus": "latest"
25
- },
26
- "packageManager": "pnpm@10.32.1",
27
- "pnpm": {
28
- "overrides": {
29
- "vite": "npm:@voidzero-dev/vite-plus-core@latest",
30
- "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
31
- }
32
31
  }
33
32
  }
@@ -0,0 +1,9 @@
1
+ import { Outlet } from 'react-router'
2
+
3
+ export default function RootLayout() {
4
+ return (
5
+ <div className="min-h-dvh">
6
+ <Outlet />
7
+ </div>
8
+ )
9
+ }
@@ -0,0 +1,19 @@
1
+ import { StrictMode } from 'react'
2
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
+
4
+ const queryClient = new QueryClient({
5
+ defaultOptions: {
6
+ queries: {
7
+ staleTime: 5 * 60 * 1000,
8
+ retry: 1,
9
+ },
10
+ },
11
+ })
12
+
13
+ export function Providers({ children }: { children: React.ReactNode }) {
14
+ return (
15
+ <StrictMode>
16
+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
17
+ </StrictMode>
18
+ )
19
+ }
@@ -0,0 +1,11 @@
1
+ import { createBrowserRouter } from 'react-router'
2
+ import RootLayout from './layouts/root'
3
+ import HomePage from '@/features/home/pages'
4
+
5
+ export const router = createBrowserRouter([
6
+ {
7
+ path: '/',
8
+ element: <RootLayout />,
9
+ children: [{ index: true, element: <HomePage /> }],
10
+ },
11
+ ])
@@ -0,0 +1,7 @@
1
+ export default function HomePage() {
2
+ return (
3
+ <div className="flex min-h-dvh items-center justify-center">
4
+ <h1 className="text-4xl font-bold">Welcome</h1>
5
+ </div>
6
+ )
7
+ }
File without changes
@@ -1,9 +1,11 @@
1
- import { StrictMode } from 'react'
2
1
  import { createRoot } from 'react-dom/client'
3
- import { App } from './App.tsx'
2
+ import { Providers } from './app/providers'
3
+ import { router } from './app/router'
4
+ import { RouterProvider } from 'react-router'
5
+ import './style.css'
4
6
 
5
7
  createRoot(document.getElementById('root')!).render(
6
- <StrictMode>
7
- <App />
8
- </StrictMode>,
8
+ <Providers>
9
+ <RouterProvider router={router} />
10
+ </Providers>,
9
11
  )
@@ -0,0 +1 @@
1
+ @import 'tailwindcss';
@@ -1,6 +1,5 @@
1
1
  import { defineConfig, loadEnv, lazyPlugins } from 'vite-plus'
2
2
  import react, { reactCompilerPreset } from '@vitejs/plugin-react'
3
- // import { fileURLToPath, URL } from 'node:url'
4
3
 
5
4
  const mode = process.env.NODE_ENV || 'development'
6
5
  const env = loadEnv(mode, process.cwd(), '')
@@ -25,11 +24,24 @@ export default defineConfig({
25
24
  }),
26
25
  ],
27
26
  resolve: {
28
- // alias: {
29
- // '@': fileURLToPath(new URL('./src', import.meta.url)),
30
- // },
31
27
  tsconfigPaths: true,
32
28
  },
29
+ build: {
30
+ rolldownOptions: {
31
+ output: {
32
+ manualChunks(id) {
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'
37
+ if (id.includes('@tanstack')) return 'vendor-query'
38
+ if (id.includes('zustand')) return 'vendor-state'
39
+ if (id.includes('jotai')) return 'vendor-atom'
40
+ return 'vendor'
41
+ },
42
+ },
43
+ },
44
+ },
33
45
  server: {
34
46
  proxy: {
35
47
  '/api': {
@@ -10,22 +10,20 @@
10
10
  "prepare": "vp config"
11
11
  },
12
12
  "dependencies": {
13
- "vue": "latest"
13
+ "@vueuse/core": "latest",
14
+ "pinia": "latest",
15
+ "vue": "latest",
16
+ "vue-router": "latest"
14
17
  },
15
18
  "devDependencies": {
16
- "@types/node": "^24.12.2",
17
- "@vitejs/plugin-vue": "^6.0.5",
18
- "@vue/tsconfig": "^0.9.1",
19
- "typescript": "~6.0.2",
20
- "vite": "npm:@voidzero-dev/vite-plus-core@latest",
19
+ "@tailwindcss/vite": "latest",
20
+ "@types/node": "latest",
21
+ "@vitejs/plugin-vue": "latest",
22
+ "@vue/tsconfig": "latest",
23
+ "tailwindcss": "latest",
24
+ "typescript": "latest",
25
+ "vite": "latest",
21
26
  "vite-plus": "latest",
22
- "vue-tsc": "^3.2.6"
23
- },
24
- "packageManager": "pnpm@10.33.0",
25
- "pnpm": {
26
- "overrides": {
27
- "vite": "npm:@voidzero-dev/vite-plus-core@latest",
28
- "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
29
- }
27
+ "vue-tsc": "latest"
30
28
  }
31
29
  }
@@ -1,61 +1,5 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue'
3
-
4
- const count = ref(0)
5
- </script>
1
+ <script setup lang="ts"></script>
6
2
 
7
3
  <template>
8
- <div
9
- class="max-w-7xl mx-auto p-8 text-center font-sans antialiased text-[#213547] dark:text-zinc-200 min-h-dvh flex flex-col justify-center"
10
- >
11
- <div class="flex justify-center gap-12 mb-12">
12
- <a
13
- href="https://viteplus.dev"
14
- target="_blank"
15
- class="transition-filter duration-300 hover:drop-shadow-[0_0_2em_#646cffaa]"
16
- >
17
- <img src="/favicon.svg" class="h-24 p-6" alt="VitePlus logo" />
18
- </a>
19
- <a
20
- href="https://vuejs.org/"
21
- target="_blank"
22
- class="transition-filter duration-300 hover:drop-shadow-[0_0_2em_#42b883aa]"
23
- >
24
- <img src="./assets/vue.svg" class="h-24 p-6" alt="Vue logo" />
25
- </a>
26
- </div>
27
-
28
- <h1 class="text-5xl font-bold leading-[1.1] mb-8">VitePlus + Vue</h1>
29
-
30
- <div class="p-8 space-y-4">
31
- <button
32
- type="button"
33
- @click="count++"
34
- class="rounded-lg border border-transparent px-5 py-2.5 text-base font-medium bg-[#f9f9f9] dark:bg-zinc-800 cursor-pointer transition-colors hover:border-[#646cff] outline-none"
35
- >
36
- count is {{ count }}
37
- </button>
38
- <p class="text-zinc-500">
39
- Edit
40
- <code class="bg-[#f1f1f1] dark:bg-zinc-800 px-1.5 py-0.5 rounded font-mono"
41
- >src/App.vue</code
42
- >
43
- to test HMR
44
- </p>
45
- </div>
46
-
47
- <p class="text-[#888] mt-8">
48
- Check out
49
- <a
50
- href="https://github.com/voidzero-dev/vite-plus"
51
- target="_blank"
52
- class="font-medium text-[#646cff] hover:text-[#535bf2]"
53
- >VitePlus</a
54
- >, the unified toolchain for the web.
55
- </p>
56
-
57
- <p class="text-[#888] mt-4 text-sm">Click on the VitePlus and Vue logos to learn more</p>
58
- </div>
4
+ <RouterView />
59
5
  </template>
60
-
61
- <style scoped></style>
@@ -1,4 +1,12 @@
1
1
  import { createApp } from 'vue'
2
+ import { createPinia } from 'pinia'
2
3
  import App from './App.vue'
4
+ import router from './router'
5
+ import './style.css'
3
6
 
4
- createApp(App).mount('#app')
7
+ const app = createApp(App)
8
+
9
+ app.use(createPinia())
10
+ app.use(router)
11
+
12
+ app.mount('#app')
@@ -0,0 +1,16 @@
1
+ import { createRouter, createWebHistory } from 'vue-router'
2
+ import RootLayout from '@/views/RootLayout.vue'
3
+ import HomeView from '@/views/HomeView.vue'
4
+
5
+ const router = createRouter({
6
+ history: createWebHistory(),
7
+ routes: [
8
+ {
9
+ path: '/',
10
+ component: RootLayout,
11
+ children: [{ path: '', name: 'home', component: HomeView }],
12
+ },
13
+ ],
14
+ })
15
+
16
+ export default router
@@ -0,0 +1 @@
1
+ @import 'tailwindcss';
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="flex min-h-dvh items-center justify-center">
3
+ <h1 class="text-4xl font-bold">Welcome</h1>
4
+ </div>
5
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="min-h-dvh">
3
+ <RouterView />
4
+ </div>
5
+ </template>
@@ -1,4 +1,9 @@
1
1
  {
2
2
  "files": [],
3
- "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
3
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
4
+ "compilerOptions": {
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ }
4
9
  }
@@ -1,6 +1,5 @@
1
1
  import { defineConfig, loadEnv } from 'vite-plus'
2
2
  import vue from '@vitejs/plugin-vue'
3
- import { fileURLToPath, URL } from 'node:url'
4
3
 
5
4
  const mode = process.env.NODE_ENV || 'development'
6
5
  const env = loadEnv(mode, process.cwd(), '')
@@ -17,8 +16,21 @@ export default defineConfig({
17
16
  vue(),
18
17
  ],
19
18
  resolve: {
20
- alias: {
21
- '@': fileURLToPath(new URL('./src', import.meta.url)),
19
+ tsconfigPaths: true,
20
+ },
21
+ build: {
22
+ rolldownOptions: {
23
+ output: {
24
+ manualChunks(id) {
25
+ if (!id.includes('node_modules')) return
26
+ if (id.includes('vue') && !id.includes('vue-router'))
27
+ return 'vendor-vue'
28
+ if (id.includes('vue-router')) return 'vendor-router'
29
+ if (id.includes('pinia')) return 'vendor-pinia'
30
+ if (id.includes('@vueuse')) return 'vendor-vueuse'
31
+ return 'vendor'
32
+ },
33
+ },
22
34
  },
23
35
  },
24
36
  server: {
@@ -1,68 +0,0 @@
1
- import { useState } from 'react'
2
- import reactLogo from './assets/react.svg'
3
-
4
- export function App() {
5
- const [count, setCount] = useState(0)
6
-
7
- return (
8
- <div className="max-w-7xl mx-auto p-8 text-center font-sans antialiased text-[#213547] dark:text-zinc-200 min-h-dvh flex flex-col justify-center items-center">
9
- <div className="flex justify-center gap-12 mb-12">
10
- <a
11
- href="https://viteplus.dev"
12
- target="_blank"
13
- rel="noreferrer"
14
- className="transition-all duration-300 hover:drop-shadow-[0_0_2em_#646cffaa]"
15
- >
16
- <img src="/favicon.svg" className="h-24 p-6" alt="VitePlus logo" />
17
- </a>
18
- <a
19
- href="https://react.dev"
20
- target="_blank"
21
- rel="noreferrer"
22
- className="transition-all duration-300 hover:drop-shadow-[0_0_2em_#61dafbaa]"
23
- >
24
- <img
25
- src={reactLogo}
26
- className="h-24 p-6 animate-[spin_20s_linear_infinite]"
27
- alt="React logo"
28
- />
29
- </a>
30
- </div>
31
-
32
- <h1 className="text-5xl font-bold leading-[1.1] mb-8">VitePlus + React</h1>
33
-
34
- <div className="p-8 space-y-4 flex flex-col items-center">
35
- <button
36
- onClick={() => setCount((count) => count + 1)}
37
- className="rounded-lg border border-transparent px-5 py-2.5 text-base font-medium bg-[#f9f9f9] dark:bg-zinc-800 cursor-pointer transition-colors hover:border-[#646cff] outline-none"
38
- >
39
- count is {count}
40
- </button>
41
- <p className="text-zinc-500">
42
- Edit{' '}
43
- <code className="bg-[#f1f1f1] dark:bg-zinc-800 px-1.5 py-0.5 rounded font-mono">
44
- src/App.tsx
45
- </code>{' '}
46
- to test HMR
47
- </p>
48
- </div>
49
-
50
- <p className="text-[#888] mt-8">
51
- Check out{' '}
52
- <a
53
- href="https://github.com/voidzero-dev/vite-plus"
54
- target="_blank"
55
- rel="noreferrer"
56
- className="font-medium text-[#646cff] hover:text-[#535bf2]"
57
- >
58
- VitePlus
59
- </a>
60
- , the unified toolchain for the web.
61
- </p>
62
-
63
- <p className="text-[#888] mt-4 text-sm">
64
- Click on the VitePlus and React logos to learn more
65
- </p>
66
- </div>
67
- )
68
- }