[moz] docs: §18 API 聚合重构 + 工具链 Tab 设计文档
- 18-api-refactor-and-toolchain-tab.md: 主设计(9章+实施约束) - 后端拆分方案 B(task_routes + task_relation_routes + shared) - expand 细粒度聚合(comments/events 带 limit+total_count) - 任务列表搜索参数 q - 工具链 Tab 设计(仿 MailPanel + 搜索栏) - GATE 门控 + 委派原则 + wiki 查询规则 - 司马懿已审(mail-1781415763066) - 18-test-design.md: 测试用例详细设计(34 个用例 + CI 集成) - tests/scripts/verify_api_compat.sh: 路由兼容性验证脚本
This commit is contained in:
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# verify_api_compat.sh — 验证 API 拆分前后路由清单完全一致
|
||||
#
|
||||
# 用法:
|
||||
# bash tests/scripts/verify_api_compat.sh
|
||||
#
|
||||
# 前置:
|
||||
# - 当前在开发目录(sanguo_moziplus_v2/)
|
||||
# - git working tree 有拆分改动
|
||||
# - main 分支是拆分前的基准
|
||||
#
|
||||
# 输出:
|
||||
# ✅ 路由完全一致(exit 0)
|
||||
# ❌ 路由有差异(exit 1,打印 diff)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BEFORE_FILE="/tmp/routes_before_$$.txt"
|
||||
AFTER_FILE="/tmp/routes_after_$$.txt"
|
||||
|
||||
echo "=== 提取拆分前路由清单(main 分支)==="
|
||||
|
||||
# stash 当前改动(如果有 untracked 新文件,--include-untracked)
|
||||
STASHED=0
|
||||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||
git stash --include-untracked
|
||||
STASHED=1
|
||||
fi
|
||||
|
||||
python3 -c "
|
||||
from src.main import app
|
||||
for route in app.routes:
|
||||
if hasattr(route, 'methods') and hasattr(route, 'path'):
|
||||
for m in sorted(route.methods):
|
||||
if m in ('GET','POST','PATCH','DELETE','PUT'):
|
||||
print(f'{m} {route.path}')
|
||||
" | sort > "$BEFORE_FILE"
|
||||
|
||||
echo "Routes before: $(wc -l < "$BEFORE_FILE")"
|
||||
|
||||
# 恢复改动
|
||||
if [ "$STASHED" = "1" ]; then
|
||||
git stash pop
|
||||
fi
|
||||
|
||||
echo "=== 提取拆分后路由清单(当前 working tree)==="
|
||||
|
||||
python3 -c "
|
||||
from src.main import app
|
||||
for route in app.routes:
|
||||
if hasattr(route, 'methods') and hasattr(route, 'path'):
|
||||
for m in sorted(route.methods):
|
||||
if m in ('GET','POST','PATCH','DELETE','PUT'):
|
||||
print(f'{m} {route.path}')
|
||||
" | sort > "$AFTER_FILE"
|
||||
|
||||
echo "Routes after: $(wc -l < "$AFTER_FILE")"
|
||||
|
||||
echo ""
|
||||
echo "=== Diff ==="
|
||||
|
||||
if diff "$BEFORE_FILE" "$AFTER_FILE"; then
|
||||
echo "✅ 路由完全一致"
|
||||
rm -f "$BEFORE_FILE" "$AFTER_FILE"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ 路由有差异"
|
||||
rm -f "$BEFORE_FILE" "$AFTER_FILE"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user