#!/bin/bash
# 服务器端部署（SSH进去后直接运行）
# 用法: bash deploy.sh
set -e
cd /data/ai/audio_codebuddy

echo "=== 1. 拉取 ==="
git fetch origin master
git reset --hard origin/master
echo "当前: $(git log --oneline -1)"

echo "=== 2. Prisma ==="
cd server
npx prisma generate

echo "=== 3. 构建 ==="
rm -rf dist
npm run build
mkdir -p dist/config
cp src/config/models.json dist/config/models.json

echo "=== 4. 重启 ==="
pm2 reload server

echo "=== 完成 ==="
pm2 status | grep server
