create-lzcli 1.0.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.html +12 -0
- package/index.js +104 -0
- package/package.json +30 -0
- package/readme.md +1 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/.env +2 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/.prettierrc +10 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/eslint.config.ts +80 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/index.html +26 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/package-lock.json +2936 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/package.json +44 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/src/App.vue +19 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/src/main.ts +13 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/src/store/index.ts +11 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/src/styles/index.css +1 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/src/vite-env.d.ts +10 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/tsconfig.json +43 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/tsconfig.node.json +18 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia/vite.config.ts +27 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/.env +2 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/.prettierrc +10 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/eslint.config.ts +80 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/index.html +26 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/package-lock.json +3309 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/package.json +45 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/App.vue +26 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/main.ts +14 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/router/index.ts +19 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/store/index.ts +11 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/styles/index.css +1 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/view/HomeView.vue +7 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/src/vite-env.d.ts +10 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/tsconfig.json +43 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/tsconfig.node.json +18 -0
- package/template/vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter/vite.config.ts +27 -0
- package/template/vue_ts_prettieric_pinia/.env +2 -0
- package/template/vue_ts_prettieric_pinia/.prettierrc +11 -0
- package/template/vue_ts_prettieric_pinia/index.html +26 -0
- package/template/vue_ts_prettieric_pinia/package-lock.json +1371 -0
- package/template/vue_ts_prettieric_pinia/package.json +36 -0
- package/template/vue_ts_prettieric_pinia/pnpm-lock.yaml +883 -0
- package/template/vue_ts_prettieric_pinia/src/App.vue +56 -0
- package/template/vue_ts_prettieric_pinia/src/main.ts +11 -0
- package/template/vue_ts_prettieric_pinia/src/store/counter.ts +12 -0
- package/template/vue_ts_prettieric_pinia/src/styles/index.css +1 -0
- package/template/vue_ts_prettieric_pinia/src/vite-env.d.ts +10 -0
- package/template/vue_ts_prettieric_pinia/tsconfig.json +42 -0
- package/template/vue_ts_prettieric_pinia/tsconfig.node.json +13 -0
- package/template/vue_ts_prettieric_pinia/vite.config.ts +25 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/.env +2 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/.prettierrc +11 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/index.html +26 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/package-lock.json +1661 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/package.json +39 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/src/App.vue +16 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/src/main.ts +10 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/src/store/counter.ts +14 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/src/styles/index.css +1 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/src/vite-env.d.ts +10 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/tsconfig.json +43 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/tsconfig.node.json +13 -0
- package/template/vue_ts_prettieric_tailwindcss_pinia/vite.config.ts +27 -0
package/index.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>My App</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
</body>
|
|
11
|
+
<script src="/src/main.ts"></script>
|
|
12
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { spawn } from "child_process"; // 新增:用于执行终端命令
|
|
6
|
+
|
|
7
|
+
// 1. 交互选择
|
|
8
|
+
(async () => {
|
|
9
|
+
try {
|
|
10
|
+
let answer = await inquirer.prompt([
|
|
11
|
+
{
|
|
12
|
+
type: "input",
|
|
13
|
+
name: "name",
|
|
14
|
+
message: "请输入项目名称:",
|
|
15
|
+
default: "my-project",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "list",
|
|
19
|
+
name: "type",
|
|
20
|
+
message: "请选择项目模板:",
|
|
21
|
+
choices: [
|
|
22
|
+
{
|
|
23
|
+
name: "Vue3 + TS + Pinia + eslint + tailwindcss",
|
|
24
|
+
value: "vue_ts_eslint_prettieric_tailwindcss_pinia",
|
|
25
|
+
},
|
|
26
|
+
{ name: "Vue3 + TS + pinia", value: "vue_ts_prettieric_pinia" },
|
|
27
|
+
{
|
|
28
|
+
name: "Vue3 + TS + pinia + tailwindcss ",
|
|
29
|
+
value: "vue_ts_prettieric_tailwindcss_pinia",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Vue3 + TS + pinia + tailwindcss + eslint + tailwindcss + vueRouter",
|
|
33
|
+
value: "vue_ts_eslint_prettieric_tailwindcss_pinia_vueRouter",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
// 2. 定义路径
|
|
40
|
+
let projectName = answer.name;
|
|
41
|
+
let templateName = answer.type;
|
|
42
|
+
|
|
43
|
+
// 目标项目路径
|
|
44
|
+
let targetDir = path.resolve(process.cwd(), projectName);
|
|
45
|
+
// 模板路径(必须用 __dirname 保证绝对路径正确!)
|
|
46
|
+
let templateDir = path.resolve(`./template/${templateName}`);
|
|
47
|
+
|
|
48
|
+
// 3. 检查目标目录是否已存在
|
|
49
|
+
if (await fs.pathExists(targetDir)) {
|
|
50
|
+
console.error("\n❌ 错误:项目目录已存在!");
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 4. 复制模板
|
|
55
|
+
await fs.copy(templateDir, targetDir);
|
|
56
|
+
console.log("\n✅ 项目创建成功!");
|
|
57
|
+
|
|
58
|
+
// 5. 询问是否安装依赖 + 打开项目
|
|
59
|
+
const answer2 = await inquirer.prompt([
|
|
60
|
+
{
|
|
61
|
+
type: "confirm",
|
|
62
|
+
name: "isOpen",
|
|
63
|
+
message: "是否安装依赖并打开项目?",
|
|
64
|
+
default: true,
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
if (answer2.isOpen) {
|
|
69
|
+
console.log("\n📦 正在安装依赖...");
|
|
70
|
+
// 切换工作目录
|
|
71
|
+
process.chdir(targetDir);
|
|
72
|
+
|
|
73
|
+
// 执行 npm install
|
|
74
|
+
const install = spawn("npm", ["install"], {
|
|
75
|
+
cwd: targetDir,
|
|
76
|
+
stdio: "inherit", // 让终端输出日志
|
|
77
|
+
shell: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
install.on("close", (code) => {
|
|
81
|
+
if (code === 0) {
|
|
82
|
+
console.log("\n✅ 依赖安装成功!");
|
|
83
|
+
console.log("\n🚀 启动项目:npm run dev");
|
|
84
|
+
// 自动启动项目
|
|
85
|
+
spawn("npm", ["run", "dev"], {
|
|
86
|
+
cwd: targetDir,
|
|
87
|
+
stdio: "inherit",
|
|
88
|
+
shell: true,
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
console.error("\n❌ 依赖安装失败!");
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
console.log("\n👉 请手动执行以下命令:");
|
|
96
|
+
console.log(`cd ${projectName}`);
|
|
97
|
+
console.log("npm install");
|
|
98
|
+
console.log("npm run dev");
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error("\n❌ 创建失败:", error.message);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-lzcli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "自定义Vue项目脚手架",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-vue_mine_components": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"fs-extra": "^11.3.4",
|
|
13
|
+
"inquirer": "^9.3.8"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vue",
|
|
17
|
+
"cli",
|
|
18
|
+
"template",
|
|
19
|
+
"vue-router",
|
|
20
|
+
"sass",
|
|
21
|
+
"less",
|
|
22
|
+
"typescript",
|
|
23
|
+
"eslint",
|
|
24
|
+
"prettier",
|
|
25
|
+
"tailwindcss",
|
|
26
|
+
"vite"
|
|
27
|
+
],
|
|
28
|
+
"author": "a15173636319",
|
|
29
|
+
"license": "MIT"
|
|
30
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# 这是我打包的项目模板,方便快速构建项目
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
import pluginVue from 'eslint-plugin-vue'
|
|
5
|
+
import { defineConfig } from 'eslint/config'
|
|
6
|
+
import ts from 'typescript'
|
|
7
|
+
|
|
8
|
+
export default defineConfig(
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{js,mjs,cjs,ts,mts,cts,vue}',
|
|
13
|
+
],
|
|
14
|
+
ignores: [
|
|
15
|
+
'node_modules/**',
|
|
16
|
+
'dist/**',
|
|
17
|
+
'*.config.{js,ts}',
|
|
18
|
+
'*.d.ts',
|
|
19
|
+
'*.css',
|
|
20
|
+
'*.scss',
|
|
21
|
+
'*.less',
|
|
22
|
+
'*.json',
|
|
23
|
+
'*.md',
|
|
24
|
+
'*.sass',
|
|
25
|
+
],
|
|
26
|
+
extends: [
|
|
27
|
+
'js/recommended',
|
|
28
|
+
],
|
|
29
|
+
languageOptions: {
|
|
30
|
+
globals: globals.browser,
|
|
31
|
+
},
|
|
32
|
+
rules: {
|
|
33
|
+
// 代码风格与错误检查
|
|
34
|
+
'no-console': 'warn', // 禁止 console,仅警告
|
|
35
|
+
'no-unused-vars': 'error', // 未使用变量报错
|
|
36
|
+
'prefer-const': 'error', // 优先使用 const
|
|
37
|
+
'no-var': 'error', // 禁止使用 var
|
|
38
|
+
'no-undef': 'warn', // 禁止使用未定义的变量
|
|
39
|
+
'no-debugger': 'warn', // 禁止使用 debugger,仅警告
|
|
40
|
+
'no-empty': 'warn', // 禁止空块,仅警告
|
|
41
|
+
'no-empty-function': 'warn', // 禁止空函数,仅警告
|
|
42
|
+
'no-multi-spaces': 'warn', // 禁止多余的空格,仅警告
|
|
43
|
+
'no-trailing-spaces': 'warn', // 禁止行尾空格,仅警告
|
|
44
|
+
'eol-last': [
|
|
45
|
+
'warn',
|
|
46
|
+
'always',
|
|
47
|
+
], // 文件末尾必须有换行符,仅警告
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
// 对于ts文件和vue文件,关闭 any 检查
|
|
51
|
+
{
|
|
52
|
+
files: [
|
|
53
|
+
'**/*.{ts,tsx,vue}',
|
|
54
|
+
],
|
|
55
|
+
rules: {
|
|
56
|
+
'@typescript-eslint/no-explicit-any': 'off', // 关闭 any 检查
|
|
57
|
+
'@typescript-eslint/no-unused-vars': 'warn', // 未使用变量报错
|
|
58
|
+
'@typescript-eslint/no-non-null-assertion': 'warn', // 关闭非空断言检查
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
tseslint
|
|
62
|
+
.configs
|
|
63
|
+
.recommended,
|
|
64
|
+
pluginVue
|
|
65
|
+
.configs[
|
|
66
|
+
'flat/essential'
|
|
67
|
+
],
|
|
68
|
+
// 针对vue文件,关闭组件命名规则检查
|
|
69
|
+
{
|
|
70
|
+
files: [
|
|
71
|
+
'**/*.vue',
|
|
72
|
+
],
|
|
73
|
+
rules: {
|
|
74
|
+
'vue/multi-word-component-names': 'warn', // 组件命名规则检查,警告级别
|
|
75
|
+
'vue/no-unused-components': 'warn', // 未使用组件检查,警告级别
|
|
76
|
+
'vue/no-unused-vars': 'warn', // 未使用变量检查,警告级别
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html
|
|
3
|
+
lang="en"
|
|
4
|
+
>
|
|
5
|
+
<head>
|
|
6
|
+
<meta
|
|
7
|
+
charset="UTF-8"
|
|
8
|
+
/>
|
|
9
|
+
<meta
|
|
10
|
+
name="viewport"
|
|
11
|
+
content="width=device-width, initial-scale=1.0"
|
|
12
|
+
/>
|
|
13
|
+
<title>
|
|
14
|
+
%VITE_PROJECT_NAME%
|
|
15
|
+
</title>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div
|
|
19
|
+
id="app"
|
|
20
|
+
></div>
|
|
21
|
+
</body>
|
|
22
|
+
<script
|
|
23
|
+
type="module"
|
|
24
|
+
src="/src/main.ts"
|
|
25
|
+
></script>
|
|
26
|
+
</html>
|