refactor: reorganize project structure and improve code quality

- Move CI/CD configs to config/ci/ directory
- Reorganize scripts into categorized directories (deployment, monitoring, testing, utils)
- Consolidate documentation into docs/ directory with proper structure
- Update linting and testing configurations
- Remove obsolete test reports and performance summaries
- Add new documentation for code quality tools and contact form security
- Improve project organization and maintainability
- Fix lint-staged config to only lint JS/TS files
- Disable react/react-in-jsx-scope rule for Next.js compatibility
- Ignore scripts and test config directories in ESLint
This commit is contained in:
张翔
2026-03-24 13:38:58 +08:00
parent c06ac08510
commit 498bb3a3c8
62 changed files with 5473 additions and 6498 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
echo "🧪 测试Contact页面HMR错误"
echo "=========================="
echo ""
# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查开发服务器是否运行
if ! lsof -ti:3000 > /dev/null 2>&1; then
echo -e "${RED}❌ 开发服务器未运行${NC}"
echo "请先运行: npm run dev"
exit 1
fi
echo -e "${GREEN}✅ 开发服务器正在运行${NC}"
echo ""
# 测试contact页面
echo "测试Contact页面..."
echo "访问: http://localhost:3000/contact"
echo ""
# 使用curl测试页面
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/contact)
if [ "$response" -eq 200 ]; then
echo -e "${GREEN}✅ Contact页面响应正常 (HTTP $response)${NC}"
else
echo -e "${RED}❌ Contact页面响应异常 (HTTP $response)${NC}"
fi
echo ""
echo "📋 请在浏览器中访问 http://localhost:3000/contact 并检查控制台"
echo "如果仍然看到HMR错误,请尝试以下方案:"
echo ""
echo "1. 清除浏览器缓存"
echo "2. 使用无痕模式打开"
echo "3. 运行: ./scripts/fix-dev-server.sh --deep"
echo "4. 考虑使用生产模式: npm run build && npm run start"
echo ""
echo "如果问题持续,建议:"
echo "- 升级Next.js到15.x: npm install next@^15.0.0"
echo "- 或降级React到18.x: npm install react@^18.3.0 react-dom@^18.3.0"
+164
View File
@@ -0,0 +1,164 @@
#!/bin/bash
echo "🚀 分层测试系统验证"
echo "=========================="
echo ""
# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 验证计数器
TOTAL_CHECKS=0
PASSED_CHECKS=0
FAILED_CHECKS=0
# 验证函数
check_file() {
local file=$1
local description=$2
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
if [ -f "$file" ]; then
echo -e "${GREEN}${NC} $description: $file"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
return 0
else
echo -e "${RED}${NC} $description: $file (文件不存在)"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 1
fi
}
check_dir() {
local dir=$1
local description=$2
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
if [ -d "$dir" ]; then
echo -e "${GREEN}${NC} $description: $dir"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
return 0
else
echo -e "${RED}${NC} $description: $dir (目录不存在)"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 1
fi
}
check_script() {
local script=$1
local description=$2
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
if [ -f "$script" ] && [ -x "$script" ]; then
echo -e "${GREEN}${NC} $description: $script"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
return 0
else
echo -e "${RED}${NC} $description: $script (文件不存在或不可执行)"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 1
fi
}
check_npm_script() {
local script_name=$1
local description=$2
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
if npm run | grep -q "$script_name"; then
echo -e "${GREEN}${NC} $description: npm run $script_name"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
return 0
else
echo -e "${RED}${NC} $description: npm run $script_name (脚本不存在)"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 1
fi
}
echo "📁 检查配置文件"
echo "-------------------"
check_file "e2e/src/config/test-tiers.ts" "测试层级配置"
check_file "e2e/src/config/test-tags.ts" "测试标记配置"
check_file "e2e/playwright.config.tiered.ts" "分层测试Playwright配置"
check_file ".woodpecker/test-tiered.yml" "Woodpecker CI配置"
check_file ".woodpecker/test-tiered-simple.yml" "简化版Woodpecker CI配置"
echo ""
echo "🔧 检查工具文件"
echo "-------------------"
check_file "e2e/src/utils/test-history.ts" "测试历史管理器"
check_file "e2e/src/utils/test-scheduler.ts" "智能测试调度器"
check_file "e2e/src/utils/test-reporter.ts" "测试报告生成器"
check_file "e2e/src/utils/test-monitor.ts" "测试监控器"
check_file "e2e/src/utils/test-alert.ts" "测试告警管理器"
check_file "e2e/src/utils/test-optimizer.ts" "测试性能优化器"
echo ""
echo "📝 检查脚本文件"
echo "-------------------"
check_file "e2e/global-setup.ts" "全局设置脚本"
check_file "e2e/global-teardown.ts" "全局清理脚本"
check_file "e2e/scripts/generate-report.js" "CI报告生成脚本"
check_file "scripts/validate-woodpecker-config.js" "Woodpecker配置验证脚本"
echo ""
echo "📚 检查文档文件"
echo "-------------------"
check_file "README-TIERED-TESTING.md" "快速入门指南"
check_file "docs/test-optimization-guide.md" "测试优化指南"
check_file "docs/test-tiering-best-practices.md" "最佳实践文档"
echo ""
echo "🎯 检查NPM脚本"
echo "-------------------"
check_npm_script "test:tier:fast" "快速层测试脚本"
check_npm_script "test:tier:standard" "标准层测试脚本"
check_npm_script "test:tier:deep" "深度层测试脚本"
check_npm_script "test:tier:all" "所有层级测试脚本"
check_npm_script "test:tier:ci" "CI测试脚本"
echo ""
echo "📊 检查测试文件"
echo "-------------------"
check_dir "e2e/src/tests/smoke" "冒烟测试目录"
check_dir "e2e/src/tests/api" "API测试目录"
check_dir "e2e/src/tests/admin" "管理后台测试目录"
echo ""
echo "🔍 验证TypeScript编译"
echo "-------------------"
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
if cd e2e && npx tsc --noEmit src/config/test-tiers.ts src/config/test-tags.ts src/utils/*.ts 2>/dev/null; then
echo -e "${GREEN}${NC} TypeScript编译通过"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
else
echo -e "${RED}${NC} TypeScript编译失败"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi
cd ..
echo ""
echo "📈 生成验证报告"
echo "=========================="
echo ""
echo "总检查项: $TOTAL_CHECKS"
echo -e "${GREEN}通过: $PASSED_CHECKS${NC}"
echo -e "${RED}失败: $FAILED_CHECKS${NC}"
echo ""
if [ $FAILED_CHECKS -eq 0 ]; then
echo -e "${GREEN}🎉 所有验证通过!分层测试系统已就绪。${NC}"
exit 0
else
echo -e "${YELLOW}⚠️ 发现 $FAILED_CHECKS 个问题,请检查并修复。${NC}"
exit 1
fi