chore(hooks): 引入 lefthook——pre-commit typecheck + commit-msg 规范校验
参考 enterprise-system git 体系,补齐炼境本地 git hooks: - pre-commit: pnpm typecheck(tsc --noEmit) - commit-msg: Conventional Commits 格式强校验
This commit is contained in:
parent
0552180e45
commit
bdb43a2abf
17
.lefthook/commit-msg/check-conventional.sh
Normal file
17
.lefthook/commit-msg/check-conventional.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
MSG=$(cat "$1")
|
||||||
|
|
||||||
|
# Conventional Commits: type(scope)!: description
|
||||||
|
PATTERN="^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?(!)?: .{1,}"
|
||||||
|
|
||||||
|
if ! echo "$MSG" | grep -qE "$PATTERN"; then
|
||||||
|
echo ""
|
||||||
|
echo " 提交信息不符合 Conventional Commits 规范"
|
||||||
|
echo " 正确格式: type(scope): 描述"
|
||||||
|
echo " 示例:"
|
||||||
|
echo " feat(onboarding): 新增接入包生成功能"
|
||||||
|
echo " fix(dashboard): 修复看板加载失败问题"
|
||||||
|
echo " chore: 更新依赖版本"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
11
lefthook.yml
Normal file
11
lefthook.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pre-commit:
|
||||||
|
parallel: true
|
||||||
|
commands:
|
||||||
|
typecheck:
|
||||||
|
glob: "src/**/*.{ts,tsx}"
|
||||||
|
run: pnpm typecheck
|
||||||
|
|
||||||
|
commit-msg:
|
||||||
|
scripts:
|
||||||
|
"check-conventional.sh":
|
||||||
|
runner: bash
|
||||||
@ -7,6 +7,7 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
@ -34,6 +35,7 @@
|
|||||||
"@types/react": "^19.1.8",
|
"@types/react": "^19.1.8",
|
||||||
"@types/react-dom": "^19.1.6",
|
"@types/react-dom": "^19.1.6",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
|
"lefthook": "^1.13.6",
|
||||||
"tailwindcss": "^4.2.2",
|
"tailwindcss": "^4.2.2",
|
||||||
"typescript": "~5.8.3",
|
"typescript": "~5.8.3",
|
||||||
"vite": "^7.0.4",
|
"vite": "^7.0.4",
|
||||||
|
|||||||
100
pnpm-lock.yaml
generated
100
pnpm-lock.yaml
generated
@ -69,6 +69,9 @@ importers:
|
|||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: ^4.6.0
|
specifier: ^4.6.0
|
||||||
version: 4.7.0(vite@7.3.1(jiti@2.6.1)(lightningcss@1.32.0))
|
version: 4.7.0(vite@7.3.1(jiti@2.6.1)(lightningcss@1.32.0))
|
||||||
|
lefthook:
|
||||||
|
specifier: ^1.13.6
|
||||||
|
version: 1.13.6
|
||||||
tailwindcss:
|
tailwindcss:
|
||||||
specifier: ^4.2.2
|
specifier: ^4.2.2
|
||||||
version: 4.2.2
|
version: 4.2.2
|
||||||
@ -1021,6 +1024,60 @@ packages:
|
|||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
lefthook-darwin-arm64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-m6Lb77VGc84/Qo21Lhq576pEvcgFCnvloEiP02HbAHcIXD0RTLy9u2yAInrixqZeaz13HYtdDaI7OBYAAdVt8A==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
lefthook-darwin-x64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-CoRpdzanu9RK3oXR1vbEJA5LN7iB+c7hP+sONeQJzoOXuq4PNKVtEaN84Gl1BrVtCNLHWFAvCQaZPPiiXSy8qg==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
lefthook-freebsd-arm64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-X4A7yfvAJ68CoHTqP+XvQzdKbyd935sYy0bQT6Ajz7FL1g7hFiro8dqHSdPdkwei9hs8hXeV7feyTXbYmfjKQQ==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [freebsd]
|
||||||
|
|
||||||
|
lefthook-freebsd-x64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-ai2m+Sj2kGdY46USfBrCqLKe9GYhzeq01nuyDYCrdGISePeZ6udOlD1k3lQKJGQCHb0bRz4St0r5nKDSh1x/2A==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [freebsd]
|
||||||
|
|
||||||
|
lefthook-linux-arm64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-cbo4Wtdq81GTABvikLORJsAWPKAJXE8Q5RXsICFUVznh5PHigS9dFW/4NXywo0+jfFPCT6SYds2zz4tCx6DA0Q==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
lefthook-linux-x64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-uJl9vjCIIBTBvMZkemxCE+3zrZHlRO7Oc+nZJ+o9Oea3fu+W82jwX7a7clw8jqNfaeBS+8+ZEQgiMHWCloTsGw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
lefthook-openbsd-arm64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-7r153dxrNRQ9ytRs2PmGKKkYdvZYFPre7My7XToSTiRu5jNCq++++eAKVkoyWPduk97dGIA+YWiEr5Noe0TK2A==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [openbsd]
|
||||||
|
|
||||||
|
lefthook-openbsd-x64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-Z+UhLlcg1xrXOidK3aLLpgH7KrwNyWYE3yb7ITYnzJSEV8qXnePtVu8lvMBHs/myzemjBzeIr/U/+ipjclR06g==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [openbsd]
|
||||||
|
|
||||||
|
lefthook-windows-arm64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-Uxef6qoDxCmUNQwk8eBvddYJKSBFglfwAY9Y9+NnnmiHpWTjjYiObE9gT2mvGVpEgZRJVAatBXc+Ha5oDD/OgQ==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
lefthook-windows-x64@1.13.6:
|
||||||
|
resolution: {integrity: sha512-mOZoM3FQh3o08M8PQ/b3IYuL5oo36D9ehczIw1dAgp1Ly+Tr4fJ96A+4SEJrQuYeRD4mex9bR7Ps56I73sBSZA==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
lefthook@1.13.6:
|
||||||
|
resolution: {integrity: sha512-ojj4/4IJ29Xn4drd5emqVgilegAPN3Kf0FQM2p/9+lwSTpU+SZ1v4Ig++NF+9MOa99UKY8bElmVrLhnUUNFh5g==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
lightningcss-android-arm64@1.32.0:
|
lightningcss-android-arm64@1.32.0:
|
||||||
resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==}
|
resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==}
|
||||||
engines: {node: '>= 12.0.0'}
|
engines: {node: '>= 12.0.0'}
|
||||||
@ -2342,6 +2399,49 @@ snapshots:
|
|||||||
|
|
||||||
json5@2.2.3: {}
|
json5@2.2.3: {}
|
||||||
|
|
||||||
|
lefthook-darwin-arm64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-darwin-x64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-freebsd-arm64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-freebsd-x64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-linux-arm64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-linux-x64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-openbsd-arm64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-openbsd-x64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-windows-arm64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook-windows-x64@1.13.6:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
lefthook@1.13.6:
|
||||||
|
optionalDependencies:
|
||||||
|
lefthook-darwin-arm64: 1.13.6
|
||||||
|
lefthook-darwin-x64: 1.13.6
|
||||||
|
lefthook-freebsd-arm64: 1.13.6
|
||||||
|
lefthook-freebsd-x64: 1.13.6
|
||||||
|
lefthook-linux-arm64: 1.13.6
|
||||||
|
lefthook-linux-x64: 1.13.6
|
||||||
|
lefthook-openbsd-arm64: 1.13.6
|
||||||
|
lefthook-openbsd-x64: 1.13.6
|
||||||
|
lefthook-windows-arm64: 1.13.6
|
||||||
|
lefthook-windows-x64: 1.13.6
|
||||||
|
|
||||||
lightningcss-android-arm64@1.32.0:
|
lightningcss-android-arm64@1.32.0:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user