fix: pre-commit 任务容错 + gitleaks 钩子 + pnpm 构建门禁
- _tasks 的 pre-commit install 改为容错:未装时跳过而非让 copier 失败 - .pre-commit-config 增加 gitleaks 钩子(git-workflow/security 规则均已声明) - 新增 frontend/pnpm-workspace.yaml 的 allowBuilds: esbuild,解决 pnpm 11 ERR_PNPM_IGNORED_BUILDS 致 install 非零退出而中断生成的问题 端到端验证:copier 退出 0,git/uv.lock/pnpm-lock/node_modules 齐全, verify.sh 零失败。
This commit is contained in:
+5
-1
@@ -49,7 +49,11 @@ _tasks:
|
|||||||
- command: pnpm install
|
- command: pnpm install
|
||||||
working_directory: frontend
|
working_directory: frontend
|
||||||
when: "{{ include_frontend }}"
|
when: "{{ include_frontend }}"
|
||||||
- command: "pre-commit install && pre-commit install --hook-type commit-msg"
|
# 未安装 pre-commit 时跳过而非让生成失败(退出码恒 0)
|
||||||
|
- command: >-
|
||||||
|
command -v pre-commit >/dev/null 2>&1
|
||||||
|
&& pre-commit install && pre-commit install --hook-type commit-msg
|
||||||
|
|| echo '⚠ 未检测到 pre-commit,已跳过钩子安装;请先安装后手动运行:pre-commit install'
|
||||||
|
|
||||||
# ── 项目基本信息 ────────────────────────────────────────────────────────
|
# ── 项目基本信息 ────────────────────────────────────────────────────────
|
||||||
project_name:
|
project_name:
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ repos:
|
|||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: detect-private-key
|
- id: detect-private-key
|
||||||
|
|
||||||
|
# 密钥扫描(防密钥误入库,配合 detect-private-key)
|
||||||
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
|
rev: v8.21.2
|
||||||
|
hooks:
|
||||||
|
- id: gitleaks
|
||||||
|
|
||||||
# 提交信息规范(Conventional Commits)
|
# 提交信息规范(Conventional Commits)
|
||||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
- repo: https://github.com/compilerla/conventional-pre-commit
|
||||||
rev: v3.4.0
|
rev: v3.4.0
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# pnpm 10+ 默认拦截依赖的构建脚本(供应链安全)。
|
||||||
|
# allowBuilds 显式放行确需构建的包,避免 ERR_PNPM_IGNORED_BUILDS 致 install 非零退出。
|
||||||
|
# pnpm 11 用 allowBuilds 取代已废弃的 onlyBuiltDependencies。
|
||||||
|
allowBuilds:
|
||||||
|
esbuild: true
|
||||||
Reference in New Issue
Block a user