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

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

echo "=== Building Rust ==="
cargo build --manifest-path "$PROJECT_ROOT/Cargo.toml"

if [ -d "$PROJECT_ROOT/frontend" ]; then
  echo "=== Building frontend ==="
  cd "$PROJECT_ROOT/frontend"
  npm install
  npm run build
else
  echo "Skipping frontend build (no frontend directory)"
fi
