Files
CurrenciCombo/scripts/verify-frontend.sh

173 lines
5.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Frontend Verification Script
# Verifies Next.js compilation and frontend functionality
echo -e "\n========================================"
echo -e " FRONTEND VERIFICATION"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
PASSED=0
FAILED=0
WARNINGS=0
# Check 1: Environment file
echo -e "${CYAN}1. Environment Configuration${NC}"
if [ -f "webapp/.env.local" ]; then
echo -e " ${GREEN}✅ webapp/.env.local exists${NC}"
if grep -q "NEXT_PUBLIC_ORCH_URL" webapp/.env.local; then
ORCH_URL=$(grep "NEXT_PUBLIC_ORCH_URL" webapp/.env.local | cut -d'=' -f2 | tr -d '"' | tr -d "'")
echo -e " ${GREEN}✅ NEXT_PUBLIC_ORCH_URL: $ORCH_URL${NC}"
((PASSED++))
else
echo -e " ${RED}❌ NEXT_PUBLIC_ORCH_URL missing${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ webapp/.env.local missing${NC}"
((FAILED++))
fi
# Check 2: Dependencies
echo -e "\n${CYAN}2. Dependencies${NC}"
if [ -d "webapp/node_modules" ]; then
echo -e " ${GREEN}✅ Dependencies installed${NC}"
((PASSED++))
else
echo -e " ${RED}❌ Dependencies missing${NC}"
echo -e " Run: cd webapp && npm install"
((FAILED++))
fi
# Check 3: TypeScript compilation
echo -e "\n${CYAN}3. TypeScript Compilation${NC}"
cd webapp || exit 1
if [ -f "tsconfig.json" ]; then
echo -e " Checking TypeScript configuration..."
if npx tsc --noEmit --skipLibCheck 2>&1 | head -20; then
echo -e " ${GREEN}✅ TypeScript compilation successful${NC}"
((PASSED++))
else
TSC_ERROR=$(npx tsc --noEmit --skipLibCheck 2>&1 | grep -i "error" | head -5)
if [ -n "$TSC_ERROR" ]; then
echo -e " ${RED}❌ TypeScript errors found:${NC}"
echo "$TSC_ERROR" | sed 's/^/ /'
((FAILED++))
else
echo -e " ${YELLOW}⚠️ TypeScript check completed with warnings${NC}"
((WARNINGS++))
fi
fi
else
echo -e " ${YELLOW}⚠️ tsconfig.json not found${NC}"
((WARNINGS++))
fi
# Check 4: Next.js build (dry run)
echo -e "\n${CYAN}4. Next.js Build Check${NC}"
if [ -f "next.config.ts" ] || [ -f "next.config.js" ]; then
echo -e " Running Next.js build check (this may take a minute)..."
if timeout 120 npm run build > /tmp/nextjs-build.log 2>&1; then
echo -e " ${GREEN}✅ Next.js build successful${NC}"
((PASSED++))
else
BUILD_ERROR=$(tail -20 /tmp/nextjs-build.log | grep -i "error\|failed" | head -5)
if [ -n "$BUILD_ERROR" ]; then
echo -e " ${RED}❌ Next.js build failed:${NC}"
echo "$BUILD_ERROR" | sed 's/^/ /'
((FAILED++))
else
echo -e " ${YELLOW}⚠️ Build check timed out or had warnings${NC}"
echo -e " Check /tmp/nextjs-build.log for details"
((WARNINGS++))
fi
fi
else
echo -e " ${YELLOW}⚠️ Next.js config not found${NC}"
((WARNINGS++))
fi
cd ..
# Check 5: Webapp service
echo -e "\n${CYAN}5. Webapp Service${NC}"
if nc -z localhost 3000 2>/dev/null; then
echo -e " ${GREEN}✅ Webapp running on port 3000${NC}"
((PASSED++))
# Test HTTP response
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 --max-time 5 2>&1)
if [ "$HTTP_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Webapp responding with HTTP 200${NC}"
((PASSED++))
# Check content
CONTENT=$(curl -s http://localhost:3000 --max-time 5 | head -100)
if echo "$CONTENT" | grep -q "html\|<!DOCTYPE\|<html"; then
echo -e " ${GREEN}✅ Webapp serving HTML content${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Webapp response may not be HTML${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Webapp returned HTTP $HTTP_CODE${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Webapp not running on port 3000${NC}"
echo -e " Start with: cd webapp && npm run dev"
((WARNINGS++))
fi
# Check 6: API connectivity
echo -e "\n${CYAN}6. Orchestrator API Connectivity${NC}"
if [ -f "webapp/.env.local" ]; then
ORCH_URL=$(grep "NEXT_PUBLIC_ORCH_URL" webapp/.env.local | cut -d'=' -f2 | tr -d '"' | tr -d "'" | tr -d ' ')
if [ -n "$ORCH_URL" ]; then
if curl -s "$ORCH_URL/health" > /dev/null 2>&1; then
HEALTH=$(curl -s "$ORCH_URL/health" --max-time 5)
if echo "$HEALTH" | grep -q "healthy\|status"; then
echo -e " ${GREEN}✅ Orchestrator health endpoint accessible${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Orchestrator health endpoint returned unexpected response${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Orchestrator not accessible at $ORCH_URL${NC}"
((WARNINGS++))
fi
fi
fi
# Summary
echo -e "\n========================================"
echo -e " VERIFICATION SUMMARY"
echo -e "========================================\n"
echo -e "${GREEN}✅ Passed: $PASSED${NC}"
echo -e "${YELLOW}⚠️ Warnings: $WARNINGS${NC}"
echo -e "${RED}❌ Failed: $FAILED${NC}"
if [ $FAILED -eq 0 ]; then
if [ $WARNINGS -eq 0 ]; then
echo -e "\n${GREEN}✅ Frontend verification passed!${NC}\n"
exit 0
else
echo -e "\n${YELLOW}⚠️ Frontend verification passed with warnings.${NC}\n"
exit 0
fi
else
echo -e "\n${RED}❌ Frontend verification failed. Please fix errors.${NC}\n"
exit 1
fi