#!/bin/bash

# EchoMeet Deployment Script for HostArmada Subdomain
# This script builds the EchoMeet site and prepares it for subdomain deployment

echo "🎯 Starting EchoMeet deployment process..."

# Check if we're in the right directory
if [ ! -f "package.json" ]; then
    echo "❌ Error: package.json not found. Please run this script from the echomeet directory."
    exit 1
fi

# Install dependencies
echo "📦 Installing dependencies..."
npm ci

# Build the project
echo "🔨 Building EchoMeet site..."
npm run build

# Check if build was successful
if [ $? -eq 0 ]; then
    echo "✅ EchoMeet build completed successfully!"
    echo "📁 Built files are in the 'dist' directory"
    echo ""
    echo "📋 Deployment Instructions for HostArmada Subdomain:"
    echo "1. Create subdomain 'echomeet' in your HostArmada control panel"
    echo "2. Upload all contents of the 'dist' folder to public_html/echomeet/"
    echo "3. Make sure the index.html file is in the root of the echomeet folder"
    echo "4. Your EchoMeet site will be live at echomeet.yourdomain.com!"
    echo ""
    echo "📂 Files to upload to public_html/echomeet/:"
    ls -la dist/
else
    echo "❌ Build failed! Please check the errors above."
    exit 1
fi
