create-vue3-enterprise 1.0.35 → 1.0.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vue3-enterprise",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Vue3 + TypeScript + Vite 企业级项目脚手架",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,23 +13,7 @@ if ! npx commitlint --edit ${1}; then
13
13
  echo ""
14
14
  echo "❌ Commit message validation FAILED"
15
15
  echo ""
16
- echo "📖 Correct format:"
17
- echo " <type>: <subject>"
18
- echo " OR"
19
- echo " <type>(<scope>): <subject>"
20
- echo ""
21
- echo " Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
22
- echo ""
23
- echo " Examples:"
24
- echo " • feat: add user login button"
25
- echo " • fix: resolve memory leak in component"
26
- echo " • docs: update API documentation"
27
- echo " • feat(auth): add login API"
28
- echo ""
29
- echo " ⚠️ Note: Use a SPACE after the colon!"
30
- echo " ❌ feat:test -> ✅ feat: test"
31
- echo ""
32
- echo " Run 'npm run commit' for interactive commit"
16
+ echo "Please refer to the commit specification guide in .husky/pre-commit.md for modifications."
33
17
  echo ""
34
18
  exit 1
35
19
  fi
@@ -1,28 +1,19 @@
1
1
  #!/usr/bin/env sh
2
- # ============================================
3
- # 🧹 Pre-commit Checks
4
- # - Code formatting (Prettier)
5
- # - Type checking (vue-tsc)
6
- # - Linting (ESLint)
7
- # ============================================
2
+ # Pre-commit checks - concise output
8
3
 
9
- echo ""
10
- echo "🔍 Running pre-commit checks..."
11
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
4
+ # Run lint-staged and capture output
5
+ OUTPUT=$(npx lint-staged 2>&1)
6
+ EXIT_CODE=$?
12
7
 
13
- # Run lint-staged
14
- if ! npx lint-staged; then
8
+ if [ $EXIT_CODE -eq 0 ]; then
9
+ echo "✅ Code validation passed!"
10
+ exit 0
11
+ else
12
+ echo "❌ Code validation failed!"
15
13
  echo ""
16
- echo "❌ Pre-commit checks FAILED"
17
- echo ""
18
- echo "📖 Fix suggestions:"
19
- echo " • Run 'npm run format' to fix formatting"
20
- echo " • Run 'npm run lint' to fix linting errors"
21
- echo " • Fix TypeScript errors manually"
14
+ # Extract file paths and line numbers from eslint output
15
+ echo "$OUTPUT" | grep -E ':\d+:\d+' | sed 's/^/ /'
22
16
  echo ""
17
+ echo "fixed: npm run lint -- --fix"
23
18
  exit 1
24
19
  fi
25
-
26
- echo ""
27
- echo "✅ Pre-commit checks passed!"
28
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@@ -0,0 +1,57 @@
1
+ # 代码检查
2
+
3
+ ## 功能事项:
4
+ 1. 模板文件 (template/)
5
+
6
+ - .husky/pre-commit - pre-commit hook,运行 lint-staged 检查格式和类型
7
+ - .husky/commit-msg - commit-msg hook,验证 conventional commits 格式
8
+ - lint-staged.config.js - 配置 prettier + vue-tsc 检查
9
+ - commitlint.config.js - conventional commits 配置
10
+
11
+ 2. 脚手架逻辑 (src/index.ts)
12
+
13
+ - 添加 husky, lint-staged, @commitlint/cli 依赖
14
+ - 添加 prepare 和 lint-staged 脚本
15
+ - 项目创建时自动初始化 git + husky
16
+ - 输出 Git Hooks 配置提示
17
+
18
+ ## 工作流程:
19
+ 1. 用户选择 "ESLint + Prettier" 功能
20
+ 2. npm install 后自动运行 npm run prepare 安装 husky hooks
21
+ 3. 提交代码时:
22
+ - pre-commit: 自动检查格式(Prettier) + 类型(vue-tsc)
23
+ - commit-msg: 验证提交信息符合 conventional commits 格式
24
+
25
+ ## 友好提示示例:
26
+ 📖 正确格式:
27
+ ```
28
+ <type>: <subject>
29
+ OR
30
+ <type>(<scope>): <subject>
31
+ ```
32
+
33
+ ## 提交类型:
34
+ > Types: feat, fix, docs, style, refactor, perf, test, build, revert
35
+
36
+ | 提交类型 | 英文标识 | 适用场景(举例) |
37
+ | --------- | -------- | --------------------------------------------------------------- |
38
+ | 功能新增 | feat | 新增功能、新接口、新页面、新模块 |
39
+ | 修复 Bug | fix | 修复代码错误、逻辑问题、兼容性问题 |
40
+ | 文档修改 | docs | 仅修改文档(注释、README、API 文档等) |
41
+ | 代码格式 | style | 仅调整代码格式(空格、缩进、换行、命名规范),无逻辑变更 |
42
+ | 重构 | refactor | 代码重构(既不新增功能也不修复 Bug),比如提取函数、优化结构 |
43
+ | 性能优化 | perf | 优化性能(减少耗时、降低内存占用、提升响应速度) |
44
+ | 测试 | test | 添加/修改测试用例(单元测试、集成测试等) |
45
+ | 构建/部署 | build | 构建脚本、依赖包、CI/CD 配置变更(如 package.json、Dockerfile) |
46
+ | 工程配置 | chore | 其他不影响代码逻辑的变更(如.gitignore、编辑器配置) |
47
+ | 回滚 | revert | 回滚之前的提交 |
48
+
49
+ ## 例子:
50
+ - feat: add user login button"
51
+ - fix: resolve memory leak in component"
52
+ - docs: update API documentation"
53
+ - feat(auth): add login API"
54
+
55
+ ⚠️ **注意**: 冒号后加空格!
56
+
57
+ ❌ feat:test -> ✅ feat: test"
@@ -0,0 +1,30 @@
1
+ # 代码检查提示词
2
+
3
+ ## 代码检查:
4
+ 1. 代码格式化检查
5
+ 2. ts类型检查
6
+ 3. 提交代码规范检查
7
+ create-vue3-enterprise 脚手架在 git 代码提交时自动触发上面3个检查,给出友好修复提示,无需单元测试检查
8
+
9
+ ## 功能完善:
10
+ ```
11
+ 在create-vue3-enterprise脚手架创建的项目中,vue和ts文件故意搞乱格式,git提交代码时并没有检测出来代码格式化问题
12
+ ```
13
+
14
+ ```
15
+ 添加一下判断,用create-vue3-enterprise脚手架创建项目时,选择模板有3个选项:
16
+ 如果用户选择“Vue3 + TypeScript + Vite (推荐)”这个选项,后面询问“添加 Vue Router?”和“添加 Pinia (状态管理)?”
17
+ 如果用户选择“Vue3 + TypeScript + Vite + Pinia”这个选项,后面询问“添加 Vue Router?”,不询问“添加 Pinia (状态管理)?”
18
+ 如果用户选择“Vue3 + TypeScript + Vite + Pinia + Vue Router”这个选项,后面不询问“添加 Vue Router?”,也不询问“添加 Pinia (状态管理)?”
19
+ ```
20
+
21
+ ```
22
+ 上述修改没有符合要求,现在状态是选择3个选项都是询问Router,我要的状态是:
23
+ 选择 "Vue3 + TypeScript + Vite (推荐)" → 询问 Router 和 Pinia
24
+ 选择 "Vue3 + TypeScript + Vite + Pinia" → 只询问 Router
25
+ 选择 "Vue3 + TypeScript + Vite + Pinia + Vue Router" → 都不询问
26
+ ```
27
+
28
+ ```
29
+ git提交代码触发pre-commit checks,如果代码检查成功,只打印代码检查成功提示,如果代码检查失败去除多余日志,只保留错误代码文件名和错误代码行数
30
+ ```
@@ -1,4 +1,13 @@
1
1
  module.exports = {
2
+ // TypeScript and Vue files - lint with quiet mode (errors only, no warnings)
3
+ '*.ts': ['eslint --quiet --fix'],
4
+ '*.tsx': ['eslint --quiet --fix'],
5
+ '*.vue': ['eslint --quiet --fix'],
6
+ // Format only (fast)
7
+ '*.{js,jsx,json,css,html,md}': ['prettier --write'],
8
+ // Vue and TS files - format only (skip type check for speed)
9
+ '*.{ts,tsx,vue}': ['prettier --write'],
10
+ };
2
11
  // TypeScript and Vue files - lint only (skip slow type check in pre-commit)
3
12
  '*.ts': ['eslint --fix'],
4
13
  '*.tsx': ['eslint --fix'],