#!/bin/bash
# dev.sh — run the JARO Ops platform locally.
#   ./dev.sh          -> serves the repo at http://localhost:8080/ops/
#   PORT=9000 ./dev.sh
set -e
cd "$(dirname "$0")"

if ! command -v php >/dev/null 2>&1; then
  echo "PHP is not installed. On macOS:  brew install php"
  exit 1
fi

if [ ! -f private/airtable-config.php ]; then
  echo "Missing private/airtable-config.php"
  echo "  cp private/airtable-config.php.example private/airtable-config.php"
  echo "  ...then fill in your Airtable token, base id, and Anthropic key."
  exit 1
fi

mkdir -p ops/uploads

PORT="${PORT:-8080}"
echo "JARO Ops dev server -> http://localhost:${PORT}/ops/"
echo "(errors show in this terminal; Ctrl+C stops)"
php -d display_errors=1 -d error_reporting=E_ALL -d upload_max_filesize=20M \
    -d post_max_size=25M -d max_execution_time=900 \
    -S "localhost:${PORT}" -t .
