#!/bin/bash
# Mirrors sites/ to ~/sites/ on the FastComet host. Run from anywhere;
# LOCAL_DIR is resolved relative to this script's own location.
#
# Usage:
#   ./deploy.sh            sync for real
#   ./deploy.sh --dry-run  preview what would change, nothing is touched

set -euo pipefail

HOST="dpkpnm.com"
PORT="22"
USER="dpkpnmc1"
REMOTE_DIR="~/sites/"
LOCAL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"

DRY_RUN=""
if [ "${1:-}" = "--dry-run" ]; then
  DRY_RUN="--dry-run"
  echo "Dry run — nothing will actually be uploaded or deleted."
fi

echo "Syncing $LOCAL_DIR -> $USER@$HOST:$REMOTE_DIR (port $PORT)"

rsync -avz --delete $DRY_RUN \
  -e "ssh -p $PORT" \
  --exclude='.git' \
  --exclude='.DS_Store' \
  --exclude='._*' \
  --exclude='node_modules/' \
  --exclude='__pycache__/' \
  --exclude='*.py[cod]' \
  --exclude='.venv/' \
  --exclude='venv/' \
  --exclude='env/' \
  --exclude='.env' \
  --exclude='.claude/' \
  --exclude='dpkpnm/tmp/' \
  "$LOCAL_DIR" "$USER@$HOST:$REMOTE_DIR"

echo "Sync complete!"
