← back to Dw Vendor Microsites

launch-wave.sh

38 lines

#!/usr/bin/env bash
# launch-wave.sh <wave_number>
#
# Chunks a wave's PENDING vendors (from manifest.json, wave==N, build_status not yet
# BUILT/EXCLUDED) into windows of 6 and opens each via launch-window.sh.
# Recommend 2-3 windows/wave after the pilot; opens them all with a gap between.
#
# Mac2-only. Max-plan claude (= $0).
set -euo pipefail

REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WAVE="${1:?usage: launch-wave.sh <wave_number>}"
MANIFEST="$REPO/manifest.json"

# bash 3.2 (macOS) has no mapfile — read into an array via a while loop
PENDING=()
while IFS= read -r _c; do [ -n "$_c" ] && PENDING+=("$_c"); done < <(python3 -c "
import json
m=json.load(open('$MANIFEST'))
for code,v in (m.get('vendors') or {}).items():
    if str(v.get('wave'))=='$WAVE' and (v.get('build_status') or 'PENDING') not in ('BUILT','BUILT_NEEDS_RESCRAPE','EXCLUDED'):
        print(code)
")

N=${#PENDING[@]}
[ "$N" -eq 0 ] && { echo "launch-wave: no PENDING vendors in wave $WAVE" >&2; exit 0; }
echo "wave $WAVE: $N pending vendors -> $(( (N+5)/6 )) window(s) of <=6"

i=0
while [ "$i" -lt "$N" ]; do
  chunk=("${PENDING[@]:$i:6}")
  echo "  window: ${chunk[*]}"
  bash "$REPO/launch-window.sh" "${chunk[@]}"
  i=$(( i + 6 ))
  [ "$i" -lt "$N" ] && sleep 3
done
echo "launch-wave $WAVE: launched all windows."