#!/usr/bin/env bash
set -euo pipefail

VPS="ordinarthur@10.10.0.13"
APP_DIR="/var/www/html/rebours"

echo "🚀 Deploying rebours..."

# 1. Sync source code
rsync -avz --delete \
  --exclude node_modules \
  --exclude .env \
  --exclude dist \
  --exclude .git \
  ./ "$VPS:$APP_DIR/"

# 2. Install deps, migrate, build, restart
ssh "$VPS" "cd $APP_DIR && \
  pnpm install --frozen-lockfile && \
  pnpm prisma migrate deploy && \
  pnpm build && \
  sudo systemctl restart rebours"

echo "✅ Live → https://rebours.studio"
