#!/usr/bin/env bash
# Runs on box as user: playwright system-deps list + GC cron
set -uo pipefail
export PATH="$HOME/.local/bin:$PATH"
eval "$("$HOME/.local/bin/mise" env -s bash)"

mkdir -p ~/pw-probe && cd ~/pw-probe
[ -f package.json ] || echo '{"name":"pw-probe","private":true}' > package.json
pnpm add -D playwright >/dev/null 2>&1
pnpm exec playwright install-deps --dry-run 2>/dev/null | grep -E '^\s*(apt-get|sudo)' | sed 's/sudo //' > ~/pw-apt-cmd.txt || true
echo "---PW-APT---"
cat ~/pw-apt-cmd.txt

( crontab -l 2>/dev/null | grep -v 'rb-mirror-gc' ; echo '17 4 * * * find $HOME/builds -mindepth 1 -maxdepth 1 -type d -mtime +14 -exec rm -rf {} + # rb-mirror-gc' ) | crontab -
echo "---CRON---"
crontab -l | tail -1
