workspace-v1/scripts/validate-dependencies.sh
rckrdmrd 66161b1566 feat: Workspace-v1 complete migration with NEXUS v3.4
Sistema NEXUS v3.4 migrado con:

Estructura principal:
- core/orchestration: Sistema SIMCO + CAPVED (27 directivas, 28 perfiles)
- core/catalog: Catalogo de funcionalidades reutilizables
- shared/knowledge-base: Base de conocimiento compartida
- devtools/scripts: Herramientas de desarrollo
- control-plane/registries: Control de servicios y CI/CD
- orchestration/: Configuracion de orquestacion de agentes

Proyectos incluidos (11):
- gamilit (submodule -> GitHub)
- trading-platform (OrbiquanTIA)
- erp-suite con 5 verticales:
  - erp-core, construccion, vidrio-templado
  - mecanicas-diesel, retail, clinicas
- betting-analytics
- inmobiliaria-analytics
- platform_marketing_content
- pos-micro, erp-basico

Configuracion:
- .gitignore completo para Node.js/Python/Docker
- gamilit como submodule (git@github.com:rckrdmrd/gamilit-workspace.git)
- Sistema de puertos estandarizado (3005-3199)

Generated with NEXUS v3.4 Migration System
EPIC-010: Configuracion Git y Repositorios
2026-01-04 03:37:42 -06:00

205 lines
7.1 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# Script de Validacion de Dependencias
# Valida que un proyecto tenga correctamente configuradas sus dependencias
# con erp-core y el catalogo de modulos compartidos.
# =============================================================================
set -e
# Colores para output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
WORKSPACE="/home/isem/workspace-v1"
PROJECT=$1
if [ -z "$PROJECT" ]; then
echo -e "${RED}Error: Debe especificar un proyecto${NC}"
echo "Uso: $0 <nombre_proyecto>"
echo "Ejemplo: $0 erp-construccion"
exit 1
fi
PROJECT_PATH="$WORKSPACE/projects/$PROJECT"
if [ ! -d "$PROJECT_PATH" ]; then
echo -e "${RED}Error: Proyecto no encontrado: $PROJECT_PATH${NC}"
exit 1
fi
echo "========================================"
echo "Validando dependencias de: $PROJECT"
echo "========================================"
echo ""
ERRORS=0
WARNINGS=0
# -----------------------------------------------------------------------------
# 1. Verificar estructura de orchestration
# -----------------------------------------------------------------------------
echo "1. Verificando estructura de orchestration..."
if [ -d "$PROJECT_PATH/orchestration/00-guidelines" ]; then
echo -e " ${GREEN}[OK]${NC} orchestration/00-guidelines/ existe"
else
echo -e " ${RED}[ERROR]${NC} orchestration/00-guidelines/ no existe"
((ERRORS++))
fi
# -----------------------------------------------------------------------------
# 2. Verificar HERENCIA-ERP-CORE.md
# -----------------------------------------------------------------------------
echo ""
echo "2. Verificando HERENCIA-ERP-CORE.md..."
HERENCIA_FILE="$PROJECT_PATH/orchestration/00-guidelines/HERENCIA-ERP-CORE.md"
if [ -f "$HERENCIA_FILE" ]; then
echo -e " ${GREEN}[OK]${NC} HERENCIA-ERP-CORE.md existe"
# Verificar que menciona la version de core
if grep -q "Version ERP-Core" "$HERENCIA_FILE" 2>/dev/null; then
VERSION=$(grep "Version ERP-Core" "$HERENCIA_FILE" | head -1)
echo -e " ${GREEN}[OK]${NC} $VERSION"
else
echo -e " ${YELLOW}[WARN]${NC} No especifica version de ERP-Core"
((WARNINGS++))
fi
else
echo -e " ${RED}[ERROR]${NC} HERENCIA-ERP-CORE.md no existe"
((ERRORS++))
fi
# -----------------------------------------------------------------------------
# 3. Verificar CONTEXTO-PROYECTO.md
# -----------------------------------------------------------------------------
echo ""
echo "3. Verificando CONTEXTO-PROYECTO.md..."
CONTEXTO_FILE="$PROJECT_PATH/orchestration/00-guidelines/CONTEXTO-PROYECTO.md"
if [ -f "$CONTEXTO_FILE" ]; then
echo -e " ${GREEN}[OK]${NC} CONTEXTO-PROYECTO.md existe"
# Verificar referencias a workspace-v1
V1_REFS=$(grep -c "workspace-v1" "$CONTEXTO_FILE" 2>/dev/null || echo "0")
if [ "$V1_REFS" -gt "0" ]; then
echo -e " ${GREEN}[OK]${NC} Tiene $V1_REFS referencias a workspace-v1"
else
echo -e " ${YELLOW}[WARN]${NC} No tiene referencias a workspace-v1"
((WARNINGS++))
fi
else
echo -e " ${RED}[ERROR]${NC} CONTEXTO-PROYECTO.md no existe"
((ERRORS++))
fi
# -----------------------------------------------------------------------------
# 4. Verificar directorio referencias/
# -----------------------------------------------------------------------------
echo ""
echo "4. Verificando directorio referencias/..."
REFS_DIR="$PROJECT_PATH/orchestration/referencias"
if [ -d "$REFS_DIR" ]; then
echo -e " ${GREEN}[OK]${NC} orchestration/referencias/ existe"
if [ -f "$REFS_DIR/DEPENDENCIAS-ERP-CORE.yml" ]; then
echo -e " ${GREEN}[OK]${NC} DEPENDENCIAS-ERP-CORE.yml existe"
else
echo -e " ${YELLOW}[WARN]${NC} DEPENDENCIAS-ERP-CORE.yml no existe"
((WARNINGS++))
fi
if [ -f "$REFS_DIR/DEPENDENCIAS-SHARED.yml" ]; then
echo -e " ${GREEN}[OK]${NC} DEPENDENCIAS-SHARED.yml existe"
else
echo -e " ${YELLOW}[WARN]${NC} DEPENDENCIAS-SHARED.yml no existe"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}[WARN]${NC} orchestration/referencias/ no existe"
((WARNINGS++))
fi
# -----------------------------------------------------------------------------
# 5. Verificar variable RLS en DDL
# -----------------------------------------------------------------------------
echo ""
echo "5. Verificando variable RLS en DDL..."
DDL_PATH="$PROJECT_PATH/apps/database"
if [ -d "$DDL_PATH" ]; then
# Buscar uso correcto de variable RLS
CORRECT_RLS=$(grep -r "current_tenant_id" "$DDL_PATH" 2>/dev/null | wc -l)
INCORRECT_RLS=$(grep -r "current_tenant'" "$DDL_PATH" 2>/dev/null | wc -l)
if [ "$CORRECT_RLS" -gt "0" ]; then
echo -e " ${GREEN}[OK]${NC} Variable RLS correcta encontrada ($CORRECT_RLS ocurrencias)"
else
echo -e " ${YELLOW}[WARN]${NC} Variable RLS no encontrada en DDL"
((WARNINGS++))
fi
if [ "$INCORRECT_RLS" -gt "0" ]; then
echo -e " ${RED}[ERROR]${NC} Variable RLS incorrecta detectada ($INCORRECT_RLS ocurrencias)"
((ERRORS++))
fi
else
echo -e " ${YELLOW}[WARN]${NC} Directorio apps/database/ no existe"
((WARNINGS++))
fi
# -----------------------------------------------------------------------------
# 6. Verificar que no hay referencias a rutas antiguas
# -----------------------------------------------------------------------------
echo ""
echo "6. Verificando referencias a rutas antiguas..."
OLD_REFS=$(grep -r "/home/isem/workspace/" "$PROJECT_PATH/orchestration" 2>/dev/null | grep -v "workspace-v1" | wc -l)
if [ "$OLD_REFS" -eq "0" ]; then
echo -e " ${GREEN}[OK]${NC} Sin referencias a workspace/ (ruta antigua)"
else
echo -e " ${RED}[ERROR]${NC} Encontradas $OLD_REFS referencias a ruta antigua (workspace/)"
((ERRORS++))
fi
CP_REFS=$(grep -r "control-plane/orchestration/directivas" "$PROJECT_PATH/orchestration" 2>/dev/null | wc -l)
if [ "$CP_REFS" -eq "0" ]; then
echo -e " ${GREEN}[OK]${NC} Sin referencias a control-plane/orchestration/"
else
echo -e " ${RED}[ERROR]${NC} Encontradas $CP_REFS referencias a control-plane/orchestration/ (obsoleto)"
((ERRORS++))
fi
# -----------------------------------------------------------------------------
# Resumen
# -----------------------------------------------------------------------------
echo ""
echo "========================================"
echo "RESUMEN DE VALIDACION"
echo "========================================"
echo ""
if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
echo -e "${GREEN}VALIDACION EXITOSA${NC}"
echo "El proyecto cumple con todos los requisitos de dependencias."
exit 0
elif [ $ERRORS -eq 0 ]; then
echo -e "${YELLOW}VALIDACION CON ADVERTENCIAS${NC}"
echo "Errores: $ERRORS"
echo "Advertencias: $WARNINGS"
echo ""
echo "El proyecto puede funcionar pero tiene elementos por completar."
exit 0
else
echo -e "${RED}VALIDACION FALLIDA${NC}"
echo "Errores: $ERRORS"
echo "Advertencias: $WARNINGS"
echo ""
echo "El proyecto tiene errores que deben corregirse."
exit 1
fi