← back to Dw Photo Capture
scripts/refresh-color-index.sh
27 lines
#!/usr/bin/env bash
# refresh-color-index.sh — rebuild the PDP "Colors In This Pattern" index from
# LIVE truth (dw_unified.shopify_products: active + online_store_published) and
# ship it to the Kamatera endpoint. The /apps/color-index server hot-reloads the
# file on mtime change, so no pm2 restart is needed.
#
# Safe to run nightly: idempotent, $0 (local PG read + one small rsync).
# Build runs HERE (Mac3) because the canonical dw_unified mirror lives here.
set -euo pipefail
cd "$(dirname "$0")/.."
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
echo "[$(date '+%F %T')] building color-index from shopify_products…"
node scripts/build-color-index.cjs
echo "[$(date '+%F %T')] building color-dots (ΔE-collapsed shop-by-color wheel swatches)…"
node scripts/build-color-dots.cjs
echo "[$(date '+%F %T')] shipping color-index.json + color-dots.json → Kamatera (hot-reload on mtime)…"
rsync -az data/color-index.json \
root@45.61.58.125:/root/public-projects/dwphoto/data/color-index.json
rsync -az data/color-dots.json \
root@45.61.58.125:/root/public-projects/dwphoto/data/color-dots.json
echo "[$(date '+%F %T')] color-index + color-dots refreshed + shipped."