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

echo "Doreon macOS setup starting..."

REPO_URL="https://github.com/charismaticaOSU/Doreon.git"
INSTALL_DIR="$HOME/Doreon"

if ! command -v git >/dev/null 2>&1; then
  echo "Git is required. Install it with: xcode-select --install"
  exit 1
fi

if ! command -v node >/dev/null 2>&1; then
  echo "Node.js is required. Install Node.js LTS from https://nodejs.org/ or brew install node"
  exit 1
fi

if [ ! -d "$INSTALL_DIR" ]; then
  echo "Cloning Doreon into $INSTALL_DIR ..."
  git clone "$REPO_URL" "$INSTALL_DIR"
else
  echo "Using existing folder: $INSTALL_DIR"
fi

cd "$INSTALL_DIR"
echo "Installing dependencies..."
npm install

echo "Starting Doreon desktop app (dev mode)..."
npm run dev
