#!/usr/bin/env bash
set -euo pipefail
# Place this file and github-fixture.py in a new evidence directory.
# Run from a checkout after vp i; install pr-partial-word.e2e.ts in scripts/scenarios/.
fixture_dir=$(cd -- "$(dirname -- "$0")" && pwd)
mkdir -p "$fixture_dir/bin"
cat > "$fixture_dir/bin/gh" <<'GH'
#!/bin/sh
case "$*" in
 'config get http_unix_socket') echo "$PR_SEARCH_FIXTURE_DIR/github.sock";;
 'auth token'*) echo synthetic-scenario-token;;
 'auth status'*) echo '{"hosts":{"github.com":[{"state":"success","active":true,"host":"github.com","login":"scenario","tokenSource":"GH_TOKEN"}]}}';;
 '--version') echo 'gh version 2.80.0';;
 *) exit 1;;
esac
GH
chmod +x "$fixture_dir/bin/gh"
python3 "$fixture_dir/github-fixture.py" &
fixture_pid=$!
trap 'kill "$fixture_pid"' EXIT
export PR_SEARCH_FIXTURE_DIR="$fixture_dir"
export PATH="$fixture_dir/bin:$PATH"
export GH_TOKEN=synthetic-scenario-token T3CODE_DEV_SEED=0
cd scripts
vp exec -- e2e run scenarios/pr-partial-word.e2e.ts --target web --output ".e2e/evidence-$(date +%s)"
