feat(diag): 可保留调试日志+版本可追溯机制(阶段0.5止血增强)
解决 EQD-6838 排查时硬编码版本号 v20260729a 散落3处、无法按需开关、
看不到实际加载缓存戳的问题。
层1 运行时开关(核心):
- HtmlUtil.cs 新增 GitCommit(读 AssemblyInformationalVersion,零新依赖)
- _MainLayout.cshtml 注入 window.ylotc.__diag(jsVersion+git+built)
- main.js 顶部新增 otcDebug 工具(banner+log),debug 默认 false 生产零输出
- swapTradeEdit.js / fastVue.base.js 硬编码标记改为 otcDebug.banner
- 开启方式:URL ?otcdebug=1(会话)或 localStorage.setItem('otcdebug','1')(持久)
层2 构建守卫:
- pre-commit 新增第三块 bundle 版本一致性检查(rebuild-bundles.py --verify)
- 修复 Windows python3 Store stub 不可用问题(优先用 python)
- 注:bundle 头部不注入 git sha(会随 commit 变化导致 verify 永久失败),
版本可追溯完全由运行时 __diag(后端注入)覆盖
层3 单测预防:
- 新增 diag.test.js(213测试之一),用 console spy 守卫开关行为
- 断言不再含硬编码 v20260729a + 防止第二套调试开关回归
验证:11 suites/213 tests 全绿,--verify 通过,C# 编译0错误
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
# =============================================================================
|
||||
# pre-commit — 提交前自动守卫
|
||||
# =============================================================================
|
||||
# 做两件事(任一失败即阻断提交):
|
||||
# 做三件事(任一失败即阻断提交):
|
||||
# 1. guard_arch.js — 扫描新增/修改行,禁止在 Vue 组件里内联金额计算
|
||||
# 2. jest — 跑前端单测,确保不引入回归
|
||||
# 3. bundle 校验 — rebuild-bundles.py --verify,拦截"改源文件忘重新打 bundle"
|
||||
#
|
||||
# 安装方式(开发者只需执行一次):
|
||||
# cd <repo-root>
|
||||
@@ -85,5 +86,37 @@ else
|
||||
echo -e "${YELLOW} 建议:cd YLErpWeb/fe-tests && npm install${NC}"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 3. bundle 版本一致性 — 拦截"改了源文件却忘重新打 bundle"
|
||||
# -----------------------------------------------------------------------------
|
||||
# EQD-6838 踩坑:8 次提交只为解决"改源文件没生效"。本检查在提交前用
|
||||
# rebuild-bundles.py --verify 逐字节比对产物与源文件,不同步则阻断。
|
||||
# 仅在有 bundle 相关改动时跑(Scripts 源文件 或 bundles 产物 任一改动)。
|
||||
if command -v python &>/dev/null || command -v python3 &>/dev/null; then
|
||||
# 选可用的 python:优先 python(Windows 上 python3 可能是微软 Store 的 stub,不可用)
|
||||
if command -v python &>/dev/null && python -c 'print(1)' &>/dev/null; then
|
||||
PY=python
|
||||
else
|
||||
PY=python3
|
||||
fi
|
||||
BUNDLE_SRC_CHANGED=$(git diff --cached --name-only --diff-filter=ACM -- "*.js" | grep "wwwroot/Scripts/" || true)
|
||||
BUNDLE_OUT_CHANGED=$(git diff --cached --name-only --diff-filter=ACM -- "YLErpWeb/wwwroot/Statics/bundles/" || true)
|
||||
if [ -n "$BUNDLE_SRC_CHANGED" ] || [ -n "$BUNDLE_OUT_CHANGED" ]; then
|
||||
echo -e "${YELLOW}[pre-commit] ③ bundle 版本一致性 (rebuild-bundles.py --verify)...${NC}"
|
||||
if ($PY "$REPO_ROOT/YLErpWeb/rebuild-bundles.py" --verify 2>&1); then
|
||||
echo -e "${GREEN}[pre-commit] ✅ bundle 产物与源文件同步${NC}"
|
||||
else
|
||||
echo -e "${RED}[pre-commit] ❌ bundle 产物与源文件不同步,提交被阻断${NC}"
|
||||
echo -e "${YELLOW} 请运行:python YLErpWeb/rebuild-bundles.py 重建并提交产物${NC}"
|
||||
echo -e "${YELLOW} 或用 git commit --no-verify 跳过(不推荐)${NC}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}[pre-commit] ⏭️ 无 bundle 相关改动,跳过 bundle 校验${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}[pre-commit] ⚠️ 未找到 python,跳过 bundle 校验${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}[pre-commit] ✅ 所有守卫检查通过,继续提交${NC}"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user