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

HOST="${HOST:-pr@192.168.2.19}"
TARGET="${TARGET:-/opt/rental-system}"

rsync -az --delete \
  --exclude ".git" \
  --exclude ".env" \
  --exclude ".env.local" \
  --exclude "node_modules" \
  --exclude ".next" \
  --exclude "dist" \
  "${PWD}/" "${HOST}:${TARGET}"

ssh "${HOST}" "cd ${TARGET} && npm install && npm run build && npm run db:migrate --workspace @rental/api"
