Files
dh-inspeccion-v2/scripts/phase-d5-3-13-acceptance.sh

105 lines
5.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
ROOT="${ROOT:-/var/www/dhv2.korexlabs.com}"
API_URL="${API_URL:-http://127.0.0.1:3101/api/v3}"
TMP_MIGRATION="/tmp/dhv2-d5313-accept-migration-$$.log"
trap 'rm -f "$TMP_MIGRATION"' EXIT
cd "$ROOT"
echo "========== D5.3.13 · VERSIONES =========="
[[ "$(node -p "require('./api-v3/package.json').version")" == "0.19.3-13" ]]
[[ "$(node -p "require('./web-v2/package.json').version")" == "0.19.3-13" ]]
grep -Fq "API_PHASE = 'D5.3.13'" api-v3/src/version.ts
grep -Fq "APP_PHASE = 'Fase D5.3.13 · Seguimiento de hallazgos'" web-v2/src/config/version.ts
echo "API: 0.19.3-13"
echo "WEB: 0.19.3-13"
echo
echo "========== D5.3.13 · DB Y MIGRACIONES =========="
[[ "$(docker inspect dhv2-db --format '{{.State.Health.Status}}')" == "healthy" ]]
docker compose exec -T db sh -lc 'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"'
docker compose --profile tools run --rm migrate npm run migration:show 2>&1 | tee "$TMP_MIGRATION"
grep -Fq 'Pending migrations: no' "$TMP_MIGRATION"
echo
echo "========== D5.3.13 · HEALTH =========="
HEALTH="$(curl -fsS "$API_URL/health")"
echo "$HEALTH"
grep -Fq '"version":"0.19.3-13"' <<<"$HEALTH"
grep -Fq '"phase":"D5.3.13"' <<<"$HEALTH"
grep -Fq '"database":"ok"' <<<"$HEALTH"
echo
echo "========== D5.3.13 · DOS VENCIMIENTOS =========="
grep -Fq "COMPANY_OVERDUE" api-v3/src/inspection-findings/dto/list-inspection-findings-query.dto.ts
grep -Fq "VERIFICATION_OVERDUE" api-v3/src/inspection-findings/dto/list-inspection-findings-query.dto.ts
grep -Fq 'companyOverdue' api-v3/src/inspection-findings/inspection-findings.service.ts
grep -Fq 'verificationOverdue' api-v3/src/inspection-findings/inspection-findings.service.ts
grep -Fq 'Vencimiento administrativo' web-v2/src/pages/FindingsPage.tsx
grep -Fq 'Vencimiento de verificación' web-v2/src/pages/FindingsPage.tsx
grep -Fq 'Fecha de verificación / resolución' web-v2/src/pages/FindingDetailPage.tsx
echo "Vencimiento administrativo y vencimiento de verificación separados: OK"
echo
echo "========== D5.3.13 · BANDEJA DE HALLAZGOS =========="
grep -Fq "this.findings.listGlobal(query)" api-v3/src/inspection-findings/inspection-findings.controller.ts
grep -Fq 'listInspectionFindingsGlobal' web-v2/src/lib/api.ts
grep -Fq 'Bandeja de trabajo para respuestas de empresas' web-v2/src/pages/FindingsPage.tsx
grep -Fq 'path="/hallazgos/:id"' web-v2/src/app/App.tsx
grep -Fq 'PROGRAMAR VERIFICACIÓN' web-v2/src/pages/FindingsPage.tsx
echo "Bandeja global de seguimiento: OK"
echo
echo "========== D5.3.13 · RESPUESTA, DOCUMENTACIÓN Y CIERRE =========="
grep -Fq "@Patch(':id/close')" api-v3/src/inspection-findings/inspection-findings.controller.ts
grep -Fq 'finding.status = InspectionFindingStatus.CLOSED' api-v3/src/inspection-findings/inspection-findings.service.ts
grep -Fq 'INSPECTION_FINDING_CLOSED' api-v3/src/database/entities/audit-event.entity.ts
grep -Fq 'closeInspectionFinding' web-v2/src/pages/FindingDetailPage.tsx
grep -Fq 'InspectionEvidencePanel' web-v2/src/pages/FindingDetailPage.tsx
echo "Seguimiento de oficina y cierre auditado: OK"
echo
echo "========== D5.3.13 · DASHBOARD =========="
grep -Fq 'overdueCompanyResponses' api-v3/src/dashboard/dashboard.service.ts
grep -Fq 'awaitingVerificationSchedule' api-v3/src/dashboard/dashboard.service.ts
grep -Fq 'VERIFICACIONES VENCIDAS' web-v2/src/pages/DashboardPage.tsx
grep -Fq 'ESPERANDO RESPUESTA' web-v2/src/pages/DashboardPage.tsx
echo "Dashboard administrativo y operativo: OK"
echo
echo "========== D5.3.13 · IMPORTACIÓN E INVENTARIOS HEREDADOS =========="
grep -Fq "to: '/inventarios', label: 'Inventarios'" web-v2/src/layout/AppLayout.tsx
grep -Fq "@Get('reviews')" api-v3/src/asset-imports/asset-imports.controller.ts
grep -Fq "@Post(':id/apply-safe')" api-v3/src/asset-imports/asset-imports.controller.ts
echo "Inventarios e importación parcial preservados: OK"
echo
echo "========== D5.3.13 · HIGIENE DE CÓDIGO =========="
if grep -RnhE --include='*.ts' --include='*.tsx' '^[[:space:]]*(//|/\*|\*)' api-v3/src web-v2/src; then
echo "ERROR: quedaron comentarios narrativos en código de producción"
exit 1
fi
if grep -nE '/\*|\*/' web-v2/src/styles.css; then
echo "ERROR: quedaron comentarios internos en estilos de producción"
exit 1
fi
echo "Código de producción preparado para revisión externa: OK"
echo
echo "========== D5.3.13 · SEGURIDAD HEREDADA =========="
STRONG_BACKUP="$(find /root/DH_V2_BACKUPS -maxdepth 1 -type d -name 'INVENTARIO_A_REVISAR_*' -printf '%T@ %p\n' | sort -nr | head -n1 | cut -d' ' -f2-)"
[[ -n "$STRONG_BACKUP" && -s "$STRONG_BACKUP/BACKUP_OK.txt" ]]
grep -Fq 'INVENTARIO A REVISAR' "$STRONG_BACKUP/BACKUP_OK.txt"
echo "Backup fuerte de referencia: $STRONG_BACKUP"
echo
echo "========== D5.3.13 · CONTENEDORES =========="
docker compose ps -a
[[ "$(docker inspect dhv2-db --format '{{.State.Health.Status}}')" == "healthy" ]]
[[ "$(docker inspect dhv2-api --format '{{.State.Status}}')" == "running" ]]
[[ "$(docker inspect dhv2-web --format '{{.State.Status}}')" == "running" ]]
echo
echo "ACEPTACIÓN DE FASE D5.3.13: OK"