#!/usr/bin/env bash # Synchronises the vendored copy of the whynot-design system from a pinned # upstream commit. Source: ~/whynot-design (worktree) or a clone from gitea. # # Usage: ./scripts/sync-whynot-design.sh [] # Default: reads .whynot-design-ref from the vendor directory. # # See workplans/WP-0017-whynot-design-tokens.md for the adoption strategy. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" VENDOR_DIR="$ROOT/static/src/vendor/whynot-design" REF_FILE="$VENDOR_DIR/.whynot-design-ref" SRC_REPO="${WHYNOT_DESIGN_SRC:-$HOME/whynot-design}" REF="${1:-}" if [[ -z "$REF" && -f "$REF_FILE" ]]; then REF="$(cat "$REF_FILE")" fi if [[ -z "$REF" ]]; then echo "Usage: $0 (or write a ref to $REF_FILE)" >&2 exit 2 fi if [[ ! -d "$SRC_REPO/.git" ]]; then echo "Source not found: $SRC_REPO" >&2 echo "Set WHYNOT_DESIGN_SRC or clone gitea:whynot/whynot-design there." >&2 exit 1 fi mkdir -p "$VENDOR_DIR/tokens" git -C "$SRC_REPO" show "$REF:src/styles/colors_and_type.css" \ > "$VENDOR_DIR/colors_and_type.css" for f in colors.json type.json spacing.json index.json; do git -C "$SRC_REPO" show "$REF:tokens/$f" > "$VENDOR_DIR/tokens/$f" done git -C "$SRC_REPO" rev-parse "$REF" > "$REF_FILE" echo "Vendor synced → $VENDOR_DIR (ref: $(cat "$REF_FILE"))"