dynamo-backend / setup /setup_frontend.sh
afnhf's picture
Deploy CORS middleware order fix to Hugging Face Space
983f705
Raw History Blame Contribute Delete
2.63 kB
#!/bin/bash
# ─────────────────────────────────────────────
# setup_frontend.sh β€” Frontend Environment Setup
# Usage: bash setup/setup_frontend.sh
# ─────────────────────────────────────────────
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
FRONTEND_DIR="$PROJECT_ROOT/frontend"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Dynamo Frontend Setup"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# ── Step 1: Node & NPM check ─────────────────
echo "[1/4] Checking Node.js and npm..."
if ! command -v node &>/dev/null; then
echo "❌ Error: Node.js is not installed or not in PATH."
exit 1
fi
if ! command -v npm &>/dev/null; then
echo "❌ Error: npm is not installed or not in PATH."
exit 1
fi
echo " βœ“ Node: $(node --version)"
echo " βœ“ npm: $(npm --version)"
echo ""
# ── Step 2: Navigate to frontend directory ───
echo "[2/4] Verifying frontend workspace..."
if [ ! -d "$FRONTEND_DIR" ]; then
echo "❌ Error: Frontend directory not found at $FRONTEND_DIR"
exit 1
fi
cd "$FRONTEND_DIR"
echo " βœ“ Working directory set to frontend"
echo ""
# ── Step 3: Environment file setup ───────────
echo "[3/4] Setting up environment configuration (.env)..."
if [ ! -f ".env" ]; then
if [ -f ".env.example" ]; then
cp .env.example .env
echo " βœ“ Created frontend/.env from frontend/.env.example"
else
echo " ⚠️ No frontend/.env.example found. Skipping .env creation."
fi
else
echo " βœ“ frontend/.env already exists"
fi
echo ""
# ── Step 4: Install NPM dependencies ─────────
echo "[4/4] Installing frontend packages..."
npm install
echo " βœ“ NPM packages installed successfully"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Frontend Setup Complete! πŸŽ‰"
echo ""
echo " To start the frontend development server:"
echo " cd frontend && npm run dev"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""