#!/bin/bash # Refresh the bundled fallback dump (FuelBoardDump dataset) from the GitHub # mirror — run before a Release build so the IPA carries the freshest REAL # snapshot (the app's no-network last resort). Idempotent: skips when the # bundled dump already carries the mirror's data_updated stamp. set -euo pipefail cd "$(dirname "$0")/.." TARGET="FuelBoard/Assets.xcassets/FuelBoardDump.dataset/fuelboard_dump.json" RAW="https://raw.githubusercontent.com/aptonline/fuelboard-data/main" LATEST="$(curl -fsSL "$RAW/latest.json")" DAY="$(printf '%s' "$LATEST" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("available_to") or d.get("date") or "")')" UPD="$(printf '%s' "$LATEST" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("data_updated") or "")')" if [ -z "$DAY" ]; then echo "no snapshot day in latest.json" >&2; exit 1; fi if [ -f "$TARGET" ] && grep -q "\"data_updated\": \"$UPD\"" "$TARGET"; then echo "bundled dump already current ($DAY, $UPD)" exit 0 fi echo "fetching history/$DAY.json ($UPD)…" curl -fsSL "$RAW/history/$DAY.json" -o "$TARGET" echo "updated $TARGET — $DAY"