#!/usr/bin/env bash set -euo pipefail ROOT="${1:-.}" BASE="$ROOT/frontend/public" [ -d "$BASE" ] || { echo "❌ Dossier $BASE introuvable"; exit 1; } link_css='' script_js='' changed=0 # Boucle sur tous les .html (récursif via find, compatible macOS) while IFS= read -r -d '' page; do # Inject CSS avant if ! grep -q 'patch-bubbles.css' "$page"; then sed -i '' -e "s## ${link_css}\n#g" "$page" echo "➕ CSS -> $page" changed=$((changed+1)) fi # Inject JS avant if ! grep -q 'bubbles.js' "$page"; then sed -i '' -e "s## ${script_js}\n#g" "$page" echo "➕ JS -> $page" changed=$((changed+1)) fi done < <(find "$BASE" -type f -name "*.html" -print0) echo "✅ Injection terminée (${changed} modifications)."