498bb3a3c8
- 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
52 lines
969 B
Bash
52 lines
969 B
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "🚀 开始部署到生产环境..."
|
|
|
|
# 加载生产环境变量
|
|
export NODE_ENV=production
|
|
|
|
# 检查是否已安装依赖
|
|
if [ ! -d "node_modules" ]; then
|
|
echo "📦 安装依赖..."
|
|
npm ci --production=false
|
|
fi
|
|
|
|
# 运行测试
|
|
echo "🧪 运行测试..."
|
|
cd e2e
|
|
TEST_ENV=development npx playwright test --reporter=list
|
|
cd ..
|
|
|
|
# 构建生产版本
|
|
echo "🔨 构建生产版本..."
|
|
npm run build
|
|
|
|
# 备份当前版本(如果存在)
|
|
if [ -d "dist_backup" ]; then
|
|
rm -rf dist_backup
|
|
fi
|
|
if [ -d "dist" ]; then
|
|
echo "💾 备份当前版本..."
|
|
mv dist dist_backup
|
|
fi
|
|
|
|
# 启动生产服务器
|
|
echo "🌟 启动生产服务器..."
|
|
npm start &
|
|
|
|
# 等待服务器启动
|
|
echo "⏳ 等待服务器启动..."
|
|
sleep 10
|
|
|
|
# 健康检查
|
|
echo "🏥 健康检查..."
|
|
curl -f http://localhost:3000/api/health || {
|
|
echo "❌ 健康检查失败!"
|
|
exit 1
|
|
}
|
|
|
|
echo "✅ 部署成功!"
|
|
echo "📊 访问 http://localhost:3000"
|