55 lines
1.3 KiB
Bash
55 lines
1.3 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
set -e
|
||
|
|
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||
|
|
cd "$SCRIPT_DIR"
|
||
|
|
|
||
|
|
# --- Check Node.js ---
|
||
|
|
if ! command -v node &>/dev/null; then
|
||
|
|
echo "❌ Node.js is not installed."
|
||
|
|
echo " Install it from https://nodejs.org (LTS recommended)"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "✅ Node.js $(node -v)"
|
||
|
|
|
||
|
|
# --- Check .env ---
|
||
|
|
if [ ! -f .env ]; then
|
||
|
|
if [ -f env.example ]; then
|
||
|
|
cp env.example .env
|
||
|
|
echo "⚠️ Created .env from template. Please edit it with your API keys, then re-run this script."
|
||
|
|
exit 1
|
||
|
|
else
|
||
|
|
echo "⚠️ No .env or env.example found. Continuing without environment config."
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
|
||
|
|
# --- Install web dependencies ---
|
||
|
|
if [ ! -d web/node_modules ]; then
|
||
|
|
echo "📦 Installing dependencies..."
|
||
|
|
cd web && npm install && cd ..
|
||
|
|
fi
|
||
|
|
|
||
|
|
# --- Launch ---
|
||
|
|
echo ""
|
||
|
|
echo "🔥 Starting Forge Console..."
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Open browser after a short delay
|
||
|
|
(sleep 2 && {
|
||
|
|
URL="http://localhost:${PORT:-3000}"
|
||
|
|
if command -v xdg-open &>/dev/null; then
|
||
|
|
xdg-open "$URL" 2>/dev/null
|
||
|
|
elif command -v open &>/dev/null; then
|
||
|
|
open "$URL"
|
||
|
|
elif command -v start &>/dev/null; then
|
||
|
|
start "$URL"
|
||
|
|
else
|
||
|
|
echo " Open $URL in your browser"
|
||
|
|
fi
|
||
|
|
}) &
|
||
|
|
|
||
|
|
# Run server (trap for clean exit)
|
||
|
|
trap 'echo ""; echo "👋 Shutting down..."; kill %1 2>/dev/null; exit 0' INT TERM
|
||
|
|
cd web && node server.js
|