lins-vue3-base 1.0.0 → 1.0.1
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/cli.js +129 -0
- package/package.json +63 -84
- package/.npmignore +0 -37
- package/.prettierrc +0 -10
- package/postcss.config.js +0 -6
- package/tailwind.config.js +0 -8
package/bin/cli.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const templateDir = path.join(__dirname, '..');
|
|
10
|
+
const excludeDirs = ['node_modules', 'bin', 'test-project', '.git'];
|
|
11
|
+
const excludeFiles = ['.gitignore', 'package-lock.json'];
|
|
12
|
+
|
|
13
|
+
const program = new Command();
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.name('lins-vue3-base')
|
|
17
|
+
.description('Vue 3 + TypeScript + Vite project template')
|
|
18
|
+
.version('1.0.0');
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command('create <project-name>')
|
|
22
|
+
.description('Create a new Vue 3 project')
|
|
23
|
+
.action(async (projectName) => {
|
|
24
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
25
|
+
|
|
26
|
+
// 检查目标目录是否存在
|
|
27
|
+
if (fs.existsSync(targetDir)) {
|
|
28
|
+
console.error(`Error: Directory ${projectName} already exists`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
console.log(`Creating project ${projectName}...`);
|
|
34
|
+
|
|
35
|
+
// 创建目标目录
|
|
36
|
+
await fs.mkdirp(targetDir);
|
|
37
|
+
|
|
38
|
+
// 自定义复制函数,排除不需要的目录和文件
|
|
39
|
+
async function copyTemplate(src, dest) {
|
|
40
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
41
|
+
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const srcPath = path.join(src, entry.name);
|
|
44
|
+
const destPath = path.join(dest, entry.name);
|
|
45
|
+
|
|
46
|
+
// 排除不需要的目录
|
|
47
|
+
if (entry.isDirectory()) {
|
|
48
|
+
if (!excludeDirs.includes(entry.name)) {
|
|
49
|
+
await fs.mkdirp(destPath);
|
|
50
|
+
await copyTemplate(srcPath, destPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// 排除不需要的文件
|
|
54
|
+
else if (!excludeFiles.includes(entry.name)) {
|
|
55
|
+
await fs.copyFile(srcPath, destPath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 复制模板文件
|
|
61
|
+
await copyTemplate(templateDir, targetDir);
|
|
62
|
+
|
|
63
|
+
// 修改创建的项目的 package.json 文件
|
|
64
|
+
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
65
|
+
let packageJsonContent = await fs.readFile(packageJsonPath, 'utf8');
|
|
66
|
+
|
|
67
|
+
// 修改 package.json 中的配置
|
|
68
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
69
|
+
packageJson.name = projectName;
|
|
70
|
+
packageJson.private = true;
|
|
71
|
+
packageJson.version = '0.0.0';
|
|
72
|
+
delete packageJson.bin;
|
|
73
|
+
delete packageJson.files;
|
|
74
|
+
delete packageJson.dependencies.commander;
|
|
75
|
+
delete packageJson.dependencies['fs-extra'];
|
|
76
|
+
|
|
77
|
+
// 写回修改后的 package.json
|
|
78
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
79
|
+
|
|
80
|
+
// 创建 .gitignore 文件
|
|
81
|
+
const gitignoreContent = `# Logs
|
|
82
|
+
logs
|
|
83
|
+
*.log
|
|
84
|
+
npm-debug.log*
|
|
85
|
+
yarn-debug.log*
|
|
86
|
+
yarn-error.log*
|
|
87
|
+
pnpm-debug.log*
|
|
88
|
+
lerna-debug.log*
|
|
89
|
+
|
|
90
|
+
node_modules
|
|
91
|
+
dist
|
|
92
|
+
dist-ssr
|
|
93
|
+
*.local
|
|
94
|
+
|
|
95
|
+
# Editor directories and files
|
|
96
|
+
.vscode/*
|
|
97
|
+
!.vscode/extensions.json
|
|
98
|
+
.idea
|
|
99
|
+
.DS_Store
|
|
100
|
+
*.suo
|
|
101
|
+
*.ntvs*
|
|
102
|
+
*.njsproj
|
|
103
|
+
*.sln
|
|
104
|
+
*.sw?
|
|
105
|
+
`;
|
|
106
|
+
await fs.writeFile(path.join(targetDir, '.gitignore'), gitignoreContent);
|
|
107
|
+
|
|
108
|
+
console.log(`Project ${projectName} created successfully!`);
|
|
109
|
+
console.log('');
|
|
110
|
+
console.log('To get started:');
|
|
111
|
+
console.log(` cd ${projectName}`);
|
|
112
|
+
console.log(' npm install');
|
|
113
|
+
console.log(' npm run dev');
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error('Error creating project:', error);
|
|
116
|
+
// 清理创建的目录
|
|
117
|
+
if (fs.existsSync(targetDir)) {
|
|
118
|
+
await fs.remove(targetDir);
|
|
119
|
+
}
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 如果没有参数,显示帮助信息
|
|
125
|
+
if (process.argv.length === 2) {
|
|
126
|
+
program.help();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,84 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lins-vue3-base",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
".
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"sass-embedded": "^1.97.3",
|
|
65
|
-
"tailwindcss": "^3.4.19",
|
|
66
|
-
"typescript": "~5.9.3",
|
|
67
|
-
"vite": "npm:rolldown-vite@7.2.5",
|
|
68
|
-
"vue-eslint-parser": "^10.2.0",
|
|
69
|
-
"vue-tsc": "^3.1.4"
|
|
70
|
-
},
|
|
71
|
-
"overrides": {
|
|
72
|
-
"vite": "npm:rolldown-vite@7.2.5"
|
|
73
|
-
},
|
|
74
|
-
"keywords": [
|
|
75
|
-
"vue3",
|
|
76
|
-
"base",
|
|
77
|
-
"ant-design-vue",
|
|
78
|
-
"axios",
|
|
79
|
-
"pinia",
|
|
80
|
-
"vue-router",
|
|
81
|
-
"scss",
|
|
82
|
-
"base"
|
|
83
|
-
]
|
|
84
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "lins-vue3-base",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lins-vue3-base": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"public",
|
|
12
|
+
"src",
|
|
13
|
+
".gitignore",
|
|
14
|
+
"eslint.config.js",
|
|
15
|
+
"index.html",
|
|
16
|
+
"package.json",
|
|
17
|
+
"tsconfig.app.json",
|
|
18
|
+
"tsconfig.json",
|
|
19
|
+
"tsconfig.node.json",
|
|
20
|
+
"vite.config.ts"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "vite",
|
|
24
|
+
"build": "vue-tsc -b && vite build",
|
|
25
|
+
"preview": "vite preview",
|
|
26
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.json",
|
|
27
|
+
"format": "prettier --write \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts,vue,json}\""
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"ant-design-vue": "^4.2.6",
|
|
31
|
+
"axios": "^1.13.3",
|
|
32
|
+
"commander": "^14.0.0",
|
|
33
|
+
"fs-extra": "^11.0.0",
|
|
34
|
+
"pinia": "^3.0.4",
|
|
35
|
+
"reset-css": "^5.0.2",
|
|
36
|
+
"vue": "^3.5.24",
|
|
37
|
+
"vue-router": "^4.6.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^9.39.2",
|
|
41
|
+
"@types/node": "^24.10.1",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
43
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
44
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
45
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
46
|
+
"@vue/tsconfig": "^0.8.1",
|
|
47
|
+
"autoprefixer": "^10.4.23",
|
|
48
|
+
"eslint": "^9.39.2",
|
|
49
|
+
"eslint-plugin-vue": "^10.7.0",
|
|
50
|
+
"jsonc-eslint-parser": "^2.4.2",
|
|
51
|
+
"postcss": "^8.5.6",
|
|
52
|
+
"prettier": "^3.8.1",
|
|
53
|
+
"sass-embedded": "^1.97.3",
|
|
54
|
+
"tailwindcss": "^3.4.19",
|
|
55
|
+
"typescript": "~5.9.3",
|
|
56
|
+
"vite": "npm:rolldown-vite@7.2.5",
|
|
57
|
+
"vue-eslint-parser": "^10.2.0",
|
|
58
|
+
"vue-tsc": "^3.1.4"
|
|
59
|
+
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/.npmignore
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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-ssr
|
|
12
|
-
*.local
|
|
13
|
-
|
|
14
|
-
# Editor directories and files
|
|
15
|
-
.vscode/*
|
|
16
|
-
!.vscode/extensions.json
|
|
17
|
-
.idea
|
|
18
|
-
.DS_Store
|
|
19
|
-
*.suo
|
|
20
|
-
*.ntvs*
|
|
21
|
-
*.njsproj
|
|
22
|
-
*.sln
|
|
23
|
-
*.sw?
|
|
24
|
-
|
|
25
|
-
# Build artifacts
|
|
26
|
-
node_modules/
|
|
27
|
-
|
|
28
|
-
# Environment variables
|
|
29
|
-
.env
|
|
30
|
-
.env.local
|
|
31
|
-
.env.*.local
|
|
32
|
-
|
|
33
|
-
# Test files
|
|
34
|
-
__tests__/
|
|
35
|
-
test/
|
|
36
|
-
*.spec.*
|
|
37
|
-
*.test.*
|
package/.prettierrc
DELETED
package/postcss.config.js
DELETED