#!/usr/bin/env bash set -euo pipefail echo "[setup] Ensuring ./data/uploads exists..." mkdir -p ./data/uploads mkdir -p ./data/uploads/challenges mkdir -p ./data/uploads/challenges/.staging mkdir -p ./data/uploads/icons echo "[setup] Installing root dependencies..." npm ci --no-audit --no-fund || npm install --no-audit --no-fund echo "[setup] Rebuilding better-sqlite3 native binding (guarantees DB drivers work)" npm rebuild better-sqlite3 --build-from-source || npm rebuild better-sqlite3 echo "[setup] Building Angular frontend..." npm --workspace frontend run build echo "[setup] Building NestJS backend..." npm --workspace backend run build echo "[setup] Done. Start with: npm start (dev mode: npm run dev)"