create-lve 0.1.0

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 ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as p from '@clack/prompts';
4
+ import pc from 'picocolors';
5
+ import fs from 'fs-extra';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+
11
+ async function main() {
12
+ console.clear();
13
+
14
+ p.intro(`${pc.bgCyan(pc.black(' LVE-CLI '))}`);
15
+
16
+ // 1. 交互收集信息
17
+ const project = await p.group(
18
+ {
19
+ path: () =>
20
+ p.text({
21
+ message: '项目名称(或路径)?',
22
+ placeholder: './lve-app',
23
+ validate: (value) => {
24
+ if (value.length === 0) return '路径不能为空';
25
+ }
26
+ }),
27
+ },
28
+ {
29
+ onCancel: () => {
30
+ p.cancel('已取消操作');
31
+ process.exit(0);
32
+ },
33
+ }
34
+ );
35
+
36
+ const targetDir = path.resolve(process.cwd(), project.path);
37
+ const templateDir = path.resolve(__dirname, 'template');
38
+
39
+ const s = p.spinner();
40
+ s.start('🚀 正在初始化项目模板...');
41
+
42
+ try {
43
+ if (!fs.existsSync(targetDir)) {
44
+ await fs.ensureDir(targetDir);
45
+ }
46
+
47
+ await fs.copy(templateDir, targetDir);
48
+
49
+ const renameList = [
50
+ ['_package.json', 'package.json'],
51
+ ['_gitignore', '.gitignore']
52
+ ];
53
+
54
+ for (const [oldName, newName] of renameList) {
55
+ const oldPath = path.join(targetDir, oldName);
56
+ const newPath = path.join(targetDir, newName);
57
+ if (fs.existsSync(oldPath)) {
58
+ await fs.move(oldPath, newPath, { overwrite: true });
59
+ }
60
+ }
61
+
62
+ const pkgPath = path.join(targetDir, 'package.json');
63
+ if (fs.existsSync(pkgPath)) {
64
+ const pkg = await fs.readJson(pkgPath);
65
+ pkg.name = path.basename(targetDir);
66
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
67
+ }
68
+
69
+ const lockFile = path.join(targetDir, 'pnpm-lock.yaml');
70
+ if (fs.existsSync(lockFile)) {
71
+ await fs.remove(lockFile);
72
+ }
73
+
74
+ s.stop('项目初始化成功!');
75
+
76
+ const cdPath = path.relative(process.cwd(), targetDir);
77
+
78
+ p.note(
79
+ pc.cyan(`cd ${cdPath}\npnpm install\npnpm dev`),
80
+ '快速开始'
81
+ );
82
+
83
+ p.outro(`✨ 祝你开发愉快!如有问题请反馈。`);
84
+
85
+ } catch (err) {
86
+ s.stop('初始化失败');
87
+ console.error(pc.red(err));
88
+ process.exit(1);
89
+ }
90
+ }
91
+
92
+ main();
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "create-lve",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "create-lve": "index.js"
7
+ },
8
+ "files": [
9
+ "index.js",
10
+ "template",
11
+ "dist"
12
+ ],
13
+ "devDependencies": {
14
+ "@clack/prompts": "^1.1.0",
15
+ "picocolors": "^1.1.1",
16
+ "fs-extra": "^11.2.0"
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "semi": false,
4
+ "singleQuote": true
5
+ }
@@ -0,0 +1,24 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>react-project</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "react-project",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "build-only": "vite build",
10
+ "lint": "eslint .",
11
+ "preview": "vite preview",
12
+ "format": "oxfmt src/",
13
+ "format:check": "oxfmt --check"
14
+ },
15
+ "dependencies": {
16
+ "@tailwindcss/vite": "^4.2.1",
17
+ "react": "^19.2.0",
18
+ "react-dom": "^19.2.0",
19
+ "tailwindcss": "^4.2.1"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^24.10.1",
23
+ "@types/react": "^19.2.7",
24
+ "@types/react-dom": "^19.2.3",
25
+ "@vitejs/plugin-react": "^5.1.1",
26
+ "globals": "^16.5.0",
27
+ "oxfmt": "^0.36.0",
28
+ "oxlint": "^1.52.0",
29
+ "typescript": "~5.9.3",
30
+ "vite": "^8.0.0-beta.18"
31
+ }
32
+ }