Files
image-workbench-desktop/scripts/preflight.sh
T
qiqi 30cf375ea0
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
docs+tooling: 工程流程优化约定(preflight 体检 / diag-tail 日志过滤)
2026-12-02 06:54:16 +08:00

25 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 发版/构建前的统一体检(只读)。
set -uo pipefail
cd "$(dirname "$0")/.."
fail=0
ok() { printf " ok %s\n" "$1"; }
bad() { printf " FAIL %s\n" "$1"; fail=1; }
echo "== 1. 工作区"
dirty=$(git status --porcelain | grep -v -E '^(\?\? (PLUGIN-API-GOVERNANCE-ISSUE|docs/ISSUE-REPLIES|icon\.png))' || true)
if [ -z "$dirty" ]; then ok "无未提交改动(长期未跟踪文件除外)"; else bad "存在未提交改动"; printf "%s\n" "$dirty" | sed 's/^/ /'; fi
echo "== 2. 版本号三处一致"
v1=$(node -p 'require("./package.json").version' 2>/dev/null)
v2=$(node -p 'require("./src-tauri/tauri.conf.json").version' 2>/dev/null)
v3=$(grep -m1 '^version = ' src-tauri/Cargo.toml | cut -d'"' -f2)
if [ "$v1" = "$v2" ] && [ "$v1" = "$v3" ]; then ok "版本 $v1"; else bad "版本不一致 pkg=$v1 tauri=$v2 cargo=$v3"; fi
echo "== 3. 构建单实例"
if pgrep -f 'tauri build|cargo build --bins' >/dev/null 2>&1; then bad "已有构建在跑(等它结束,避免抢锁)"; else ok "无并行构建"; fi
echo "== 4. 插件两仓一致"
if node scripts/check-plugins-sync.js >/dev/null 2>&1; then ok "plugins/ 与源仓一致"; else bad "插件两仓不一致(跑 sync-plugins-from-repo.js)"; fi
echo "== 5. 设计 token 快照"
if npm run -s tokens:check >/dev/null 2>&1; then ok "tokens 无漂移"; else bad "tokens 漂移(npm run tokens:check 看详情)"; fi
echo
if [ "$fail" = "0" ]; then echo "preflight: 通过"; else echo "preflight: 有问题,见上"; fi
exit "$fail"