#!/bin/bash
set -e

REMOTE_SERVER="archipelago@192.168.1.228"

echo "╔════════════════════════════════════════════════════════════════╗"
echo "║  Deploying Indeedhub + Updated Archipelago UI                 ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""

# Step 1: Deploy Indeedhub container
echo "📦 Step 1: Deploying Indeedhub container..."
cd "/Users/dorian/Projects/Indeedhub Prototype"
./deploy-to-archipelago.sh

# Step 2: Deploy updated frontend
echo ""
echo "📦 Step 2: Deploying updated Archipelago frontend..."
cd /Users/dorian/Projects/archy

echo "   Syncing frontend to server..."
rsync -avz --delete \
  -e "ssh -o PreferredAuthentications=keyboard-interactive,password" \
  web/dist/neode-ui/ "$REMOTE_SERVER:/opt/archipelago/web-ui/"

echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║   ✅ DEPLOYMENT COMPLETE!                                     ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
echo "🎬 Indeedhub:   http://192.168.1.228:7777"
echo "🏠 Archipelago: https://192.168.1.228"
echo ""
echo "   Indeedhub is now visible in the Archipelago app store!"
echo ""
