#!/usr/bin/bash set -euo pipefail IFS=$'\n\t' readonly ScriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly RepoRoot="$(cd "${ScriptDir}/.." && pwd)" readonly WebSrc="${RepoRoot}/web/src" readonly WebVendor="${RepoRoot}/web/vendor" readonly WebDist="${RepoRoot}/web/dist" main() { echo "==> [1/3] Preparando directorio de distribución en ${WebDist}..." mkdir -p "${WebDist}" rm -f "${WebDist}/vigia.html" "${WebDist}/app.js" "${WebDist}/app.css" echo "==> [2/3] Ensamblando archivo único autocontenido (vigia.html)..." local output_html="${WebDist}/vigia.html" if [[ ! -f "${WebVendor}/leaflet/leaflet.css" ]] || [[ ! -f "${WebVendor}/leaflet/leaflet.js" ]]; then echo "Error: Dependencias de Leaflet no encontradas en ${WebVendor}/leaflet" >&2 exit 1 fi if [[ ! -f "${WebSrc}/app.js" ]] || [[ ! -f "${WebSrc}/style.css" ]]; then echo "Error: Fuentes web (app.js o style.css) no encontrados en ${WebSrc}" >&2 exit 1 fi cat > "${output_html}" << 'HTML_HEADER' Vigía | Observabilidad de Espejos IPFS
HTML_FOOTER local total_size total_size="$(du -h "${output_html}" | cut -f1)" echo " Generado exitosamente: ${output_html} (${total_size})" echo "==> [3/3] Copiando guardianes.json y metadatos complementarios a ${WebDist}..." if [[ -f "${RepoRoot}/guardianes.json" ]]; then cp -f "${RepoRoot}/guardianes.json" "${WebDist}/guardianes.json" fi if [[ -f "${WebSrc}/logo.svg" ]]; then cp -f "${WebSrc}/logo.svg" "${WebDist}/logo.svg" fi if [[ -f "${WebSrc}/favicon.ico" ]]; then cp -f "${WebSrc}/favicon.ico" "${WebDist}/favicon.ico" fi if [[ -f "${WebSrc}/favicon.svg" ]]; then cp -f "${WebSrc}/favicon.svg" "${WebDist}/favicon.svg" fi if [[ -f "${RepoRoot}/data/telemetry.json" ]]; then cp -f "${RepoRoot}/data/telemetry.json" "${WebDist}/telemetry.json" fi echo "==> Proceso de compilación web completado con éxito." } main "$@"