#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
SOURCE_DIR="${1:-$ROOT_DIR/app/test/snapshots}"
TARGET_DIR="${2:-$ROOT_DIR/reports/snapshots/$(date +%Y%m%d-%H%M%S)}"

if [ ! -d "$SOURCE_DIR" ]; then
  echo "snapshot source directory does not exist: $SOURCE_DIR" >&2
  echo "Create widget/integration snapshot output first, then rerun this script." >&2
  exit 2
fi

mkdir -p "$TARGET_DIR"
cp -R "$SOURCE_DIR"/. "$TARGET_DIR"/
echo "saved snapshots to $TARGET_DIR"
