#!/usr/bin/env bash
# RN 0.72.x：boost tarball 镜像/校验和修复（CocoaPods 常见失败）
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BOOST_POD="$ROOT/node_modules/react-native/third-party-podspecs/boost.podspec"

if [[ ! -f "$BOOST_POD" ]]; then
  echo "skip: boost.podspec not found"
  exit 0
fi

if grep -q 'archives.boost.io' "$BOOST_POD"; then
  exit 0
fi

echo "==> patch RN 0.72 boost.podspec"
perl -i -pe '
  s|https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2|https://archives.boost.io/release/1.76.0/source/boost_1_76_0.tar.bz2|g;
' "$BOOST_POD"
