#!/bin/bash

# This script updates documentation with the deployed URLs

if [ "$#" -lt 2 ]; then
  echo "Usage: $0 <api-url> <cdn-url>"
  echo "Example: $0 https://realtimecursor-api.onrender.com https://cdn.jsdelivr.net/npm/realtimecursor-sdk"
  exit 1
fi

API_URL=$1
CDN_URL=$2

echo "Updating documentation with:"
echo "API URL: $API_URL"
echo "CDN URL: $CDN_URL"

# Update README.md
sed -i "s|http://localhost:3000|$API_URL|g" README.md
sed -i "s|http://localhost:5173|$CDN_URL|g" README.md

# Update test-app/index.html
sed -i "s|http://localhost:3001|$API_URL|g" test-app/index.html

# Update DEPLOYMENT.md
sed -i "s|https://your-api-url.com|$API_URL|g" DEPLOYMENT.md
sed -i "s|https://your-cdn-url.com|$CDN_URL|g" DEPLOYMENT.md

# Update SDK README.md
sed -i "s|https://your-api-url.com|$API_URL|g" sdk/README.md

echo "Documentation updated successfully!"