#!/bin/bash

# TimeSafari Electron Development Script
# This script builds the web app and runs it in Electron

set -e

echo "🔧 Starting Electron development workflow..."

# Navigate to project root
cd /home/noone/projects/timesafari/crowd-master

# Build for Capacitor
echo "📦 Building for Capacitor..."
npm run build:capacitor

# Create electron/app directory if it doesn't exist
echo "📁 Preparing Electron app directory..."
mkdir -p electron/app

# Copy built files to Electron
echo "📋 Copying web assets to Electron..."
cp -r dist/* electron/app/

# Ensure capacitor config is valid JSON (remove any comments)
echo "🔧 Validating Capacitor configuration..."
cp capacitor.config.json electron/capacitor.config.json

# Navigate to electron directory
cd electron

# Build Electron
echo "🔨 Building Electron..."
npm run build

# Start Electron
echo "🚀 Starting Electron app..."
npm run electron:start

echo "✅ Electron development workflow complete!" 