← back to Dw Contact Us Pages
scripts/cohort-flip.sh
39 lines
#!/usr/bin/env bash
# cohort-flip.sh — run the proven TK-11925 contact-us (quote-only) mechanism for ONE cohort. TK-11669.
# bash scripts/cohort-flip.sh maharam # DRY-RUN of every step (no writes anywhere)
# bash scripts/cohort-flip.sh maharam --apply # LIVE — customer-facing; Steve-gated
# Steps: 0 prereq guard · 1 fresh enumerate · 2 freeze restore map · 3 Boost-card vendor list ·
# 4 harden canary (1 variant) · 5 harden all · 6 templateSuffix contact-us · 7 unpublish
# G&YT/Shop/Buy Button · 8 verify. Every write step ledgers its preimage BEFORE writing and has
# a --rollback; undo everything with: bash scripts/cohort-rollback.sh <cohort> --apply
set -euo pipefail
COHORT="${1:?usage: cohort-flip.sh <cohort> [--apply]}"; shift || true
APPLY=""; [[ "${1:-}" == "--apply" ]] && APPLY="--apply"
cd "$(dirname "$0")/.."
C="--cohort $COHORT"
GUARD="$HOME/Projects/Designer-Wallcoverings/shopify/scripts/cadence/stock-2026-guard.js"
step(){ printf '\n\033[1;36m== %s ==\033[0m\n' "$*"; }
step "0 prereq: stock-2026-guard must skip contact-us products (else it re-stamps on_hand 2026 every 6h)"
if grep -q "templateSuffix === 'contact-us'" "$GUARD"; then echo " OK: guard patch present"
else
echo " MISSING: apply cohorts/maharam-stock-2026-guard-contact-us-skip.patch first:"
echo " cd ~/Projects/Designer-Wallcoverings/shopify && git apply -p1 ~/Projects/dw-contact-us-pages/cohorts/maharam-stock-2026-guard-contact-us-skip.patch"
if [[ -n "$APPLY" && "${ALLOW_NO_GUARD:-}" != "1" ]]; then echo " REFUSED (set ALLOW_NO_GUARD=1 to override)"; exit 2; fi
fi
step "1 enumerate (READ ONLY, fresh preimage)"; node scripts/enumerate.mjs $C | tail -25
if [[ -n "$APPLY" ]]; then step "2 freeze restore map (local file)"; node scripts/restore-map.mjs $C --freeze
else step "2 freeze restore map — skipped in dry-run (runs first thing on --apply)"; fi
step "3 Boost card vendor list"; node scripts/set-contact-us-vendors.mjs $C $APPLY
if [[ -n "$APPLY" ]]; then
step "4 harden CANARY (1 variant)"; node scripts/harden-variants.mjs $C --apply --limit 1
fi
step "5 harden sellable variants"; node scripts/harden-variants.mjs $C $APPLY
step "6 templateSuffix contact-us"; node scripts/assign-template.mjs $C $APPLY
step "7 unpublish G&YT / Shop / Buy Button"; node scripts/unpublish-channels.mjs $C $APPLY
if [[ -n "$APPLY" ]]; then step "8 verify"; node scripts/verify.mjs $C --n 10 || true
step "8b restore-map diff (expect diffs ONLY on suffix/policy/tracked/qty/channels)"; node scripts/restore-map.mjs $C --check || true
fi
echo; echo "cohort-flip $COHORT ${APPLY:-DRY-RUN} complete."