#!/bin/bash
# Render every mockup HTML to PNG at its declared html,body size using
# mockup-studio shot.sh (chrome-headless-shell). Output: _renders/<name>.png
set -u
cd "$(dirname "$0")/.."
SH="$HOME/.claude/skills/mockup-studio/scripts/shot.sh"
mkdir -p _renders
fail=0
for f in os-renders/*/*.html; do
  base=$(basename "$f" .html)
  [ "$base" = "alpha-test" ] && continue
  size=$(grep -oE 'width:\s*[0-9]+px;\s*height:\s*[0-9]+px' "$f" | head -1 | grep -oE '[0-9]+' | paste -sd x -)
  if [ -z "$size" ]; then echo "SKIP (no size): $f"; fail=1; continue; fi
  bash "$SH" "$f" "_renders/$base.png" "$size" >/dev/null 2>&1
  if [ -s "_renders/$base.png" ]; then echo "OK  $base  $size"; else echo "FAIL $base"; fail=1; fi
done
exit $fail
