#!/usr/bin/env bash
# Bootstrap the backend dev environment on Linux/macOS.
# Usage:  bash scripts/bootstrap.sh

set -euo pipefail
cd "$(dirname "$0")/.."

if [ ! -d ".venv" ]; then
    echo "Creating virtualenv .venv ..."
    python3 -m venv .venv
fi

# shellcheck disable=SC1091
source .venv/bin/activate

echo "Installing dev requirements ..."
python -m pip install --upgrade pip
pip install -r requirements/dev.txt

if [ ! -f ".env" ]; then
    cp .env.example .env
    echo "Created .env from .env.example"
fi

echo "Applying migrations ..."
python manage.py migrate

echo
echo "Backend ready. Run:  python manage.py runserver"
