chore: 提交和推送前增加前端 TypeScript 检查

与 Docker 构建的 tsc -b 对齐,避免类型错误在服务器构建才暴露。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-10 11:45:35 +08:00
co-authored by Cursor
parent c1f4e7c7ae
commit 874a95dd6f
7 changed files with 92 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# 与 Docker 构建第一步对齐:tsc -b。失败则阻止提交/推送。
set -euo pipefail
ROOT="$(git rev-parse --show-toplevel)"
FRONTEND="$ROOT/web/frontend"
if ! command -v npm >/dev/null 2>&1; then
echo "[git-hook] 未找到 npm,无法做前端 TypeScript 检查。"
echo "请安装 Node.js,或紧急用 git push --no-verify 绕过。"
exit 1
fi
cd "$FRONTEND"
if [ ! -x node_modules/.bin/tsc ]; then
echo "[git-hook] 前端依赖缺失,正在 npm ci..."
npm ci
fi
echo "[git-hook] 检查前端 TypeScript..."
npm exec -- tsc -b --pretty false
echo "[git-hook] TypeScript 通过"