#!/usr/bin/env bash
# Create a fresh sandbox copy of the fixture project and generate its logs/.
# Usage: sandbox <scenario> <dest>
set -euo pipefail

SCENARIO="${1:?usage: sandbox <scenario> <dest>}"
DEST="${2:?usage: sandbox <scenario> <dest>}"

EVAL_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
FIXTURE="$EVAL_ROOT/fixture/project"

[ -d "$FIXTURE" ] || { echo "fixture missing: $FIXTURE" >&2; exit 2; }
[ -e "$DEST" ] && { echo "refusing to overwrite existing sandbox: $DEST" >&2; exit 2; }

mkdir -p "$(dirname "$DEST")"
cp -r "$FIXTURE" "$DEST"
ruby "$DEST/bin/gen-logs" "$DEST" >/dev/null
echo "$DEST"
