#!/bin/bash # Script de vĂ©rification de la configuration pour Vercel # Usage: ./scripts/verify-vercel-config.sh set -e # Couleurs RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' echo -e "${BLUE}🔍 VĂ©rification de la configuration pour Vercel${NC}" echo "" ERRORS=0 WARNINGS=0 # Fonction pour vĂ©rifier une variable d'environnement check_env_var() { local var_name=$1 local required=${2:-false} if [ -z "${!var_name}" ]; then if [ "$required" = true ]; then echo -e "${RED}❌ ${var_name} n'est pas dĂ©finie (OBLIGATOIRE)${NC}" ERRORS=$((ERRORS + 1)) else echo -e "${YELLOW}⚠ ${var_name} n'est pas dĂ©finie (optionnelle)${NC}" WARNINGS=$((WARNINGS + 1)) fi else echo -e "${GREEN}✅ ${var_name} est dĂ©finie${NC}" fi } # Charger les variables d'environnement depuis .env.local si prĂ©sent if [ -f .env.local ]; then echo -e "${BLUE}📄 Chargement de .env.local...${NC}" set -a source .env.local set +a fi echo -e "${BLUE}📋 VĂ©rification des variables d'environnement critiques:${NC}" echo "" # Variables obligatoires check_env_var "NODE_ENV" true check_env_var "NEXTAUTH_URL" true check_env_var "NEXTAUTH_SECRET" true check_env_var "DATABASE_URL" true echo "" echo -e "${BLUE}🔐 VĂ©rification de l'authentification Keycloak:${NC}" check_env_var "KEYCLOAK_BASE_URL" true check_env_var "KEYCLOAK_REALM" true check_env_var "KEYCLOAK_CLIENT_ID" true check_env_var "KEYCLOAK_CLIENT_SECRET" true check_env_var "KEYCLOAK_ISSUER" false check_env_var "NEXT_PUBLIC_KEYCLOAK_ISSUER" false echo "" echo -e "${BLUE}đŸ’Ÿ VĂ©rification de la base de donnĂ©es:${NC}" if [ -n "$DATABASE_URL" ]; then if [[ "$DATABASE_URL" == postgresql://* ]]; then echo -e "${GREEN}✅ DATABASE_URL semble ĂȘtre une URL PostgreSQL valide${NC}" # VĂ©rifier si SSL est activĂ© (recommandĂ© pour la production) if [[ "$DATABASE_URL" != *"sslmode=require"* ]] && [[ "$DATABASE_URL" != *"sslmode=prefer"* ]]; then echo -e "${YELLOW}⚠ DATABASE_URL ne contient pas sslmode=require (recommandĂ© pour la production)${NC}" WARNINGS=$((WARNINGS + 1)) fi else echo -e "${RED}❌ DATABASE_URL ne semble pas ĂȘtre une URL PostgreSQL valide${NC}" ERRORS=$((ERRORS + 1)) fi fi echo "" echo -e "${BLUE}🔮 VĂ©rification de Redis (optionnel):${NC}" check_env_var "REDIS_URL" false if [ -z "$REDIS_URL" ]; then check_env_var "REDIS_HOST" false check_env_var "REDIS_PORT" false fi check_env_var "REDIS_ENCRYPTION_KEY" false echo "" echo -e "${BLUE}🔧 VĂ©rification des intĂ©grations (optionnelles):${NC}" check_env_var "LEANTIME_API_URL" false check_env_var "LEANTIME_TOKEN" false check_env_var "ROCKET_CHAT_TOKEN" false check_env_var "ROCKET_CHAT_USER_ID" false check_env_var "N8N_API_KEY" false check_env_var "DOLIBARR_API_URL" false check_env_var "DOLIBARR_API_KEY" false echo "" echo -e "${BLUE}📩 VĂ©rification de la configuration Next.js:${NC}" # VĂ©rifier que next.config.mjs existe if [ -f "next.config.mjs" ]; then echo -e "${GREEN}✅ next.config.mjs existe${NC}" # VĂ©rifier que Turbopack n'est pas forcĂ© en production if grep -q "turbopack:" next.config.mjs && [ "$NODE_ENV" = "production" ]; then echo -e "${YELLOW}⚠ Turbopack est activĂ© dans next.config.mjs (peut causer des problĂšmes sur Vercel)${NC}" WARNINGS=$((WARNINGS + 1)) fi else echo -e "${RED}❌ next.config.mjs n'existe pas${NC}" ERRORS=$((ERRORS + 1)) fi # VĂ©rifier package.json if [ -f "package.json" ]; then echo -e "${GREEN}✅ package.json existe${NC}" # VĂ©rifier que le script build existe if grep -q '"build"' package.json; then echo -e "${GREEN}✅ Script 'build' trouvĂ© dans package.json${NC}" else echo -e "${RED}❌ Script 'build' manquant dans package.json${NC}" ERRORS=$((ERRORS + 1)) fi else echo -e "${RED}❌ package.json n'existe pas${NC}" ERRORS=$((ERRORS + 1)) fi echo "" echo -e "${BLUE}đŸ§Ș Test de build (simulation):${NC}" if command -v npm &> /dev/null; then echo -e "${YELLOW}â„č Pour tester le build rĂ©ellement, exĂ©cutez: npm run build${NC}" else echo -e "${YELLOW}⚠ npm n'est pas installĂ©, impossible de tester le build${NC}" WARNINGS=$((WARNINGS + 1)) fi echo "" echo -e "${BLUE}📊 RĂ©sumĂ©:${NC}" echo -e " ${GREEN}✅ Variables correctes${NC}" if [ $WARNINGS -gt 0 ]; then echo -e " ${YELLOW}⚠ $WARNINGS avertissement(s)${NC}" fi if [ $ERRORS -gt 0 ]; then echo -e " ${RED}❌ $ERRORS erreur(s)${NC}" echo "" echo -e "${RED}❌ La configuration n'est pas prĂȘte pour Vercel${NC}" exit 1 else echo "" echo -e "${GREEN}✅ Configuration prĂȘte pour Vercel${NC}" if [ $WARNINGS -gt 0 ]; then echo -e "${YELLOW}⚠ VĂ©rifiez les avertissements ci-dessus${NC}" fi exit 0 fi