From 342bebc4838c60e0632170cd25524ff89d85eeec Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Mon, 15 Dec 2025 16:41:24 +0100 Subject: [PATCH] fix: unblock production frontend build Remove unsupported Toast isVisible prop and harden deploy script to reliably rebuild/restart Next.js standalone on the server. --- deploy.sh | 36 ++++++++++++++++++++----- frontend/src/app/terminal/cfo/page.tsx | 2 +- frontend/src/app/terminal/hunt/page.tsx | 1 - 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/deploy.sh b/deploy.sh index ffce0a7..086f892 100755 --- a/deploy.sh +++ b/deploy.sh @@ -8,7 +8,7 @@ # - Rebuilds frontend in background # ============================================================================ -set -e +set -euo pipefail # Colors GREEN='\033[0;32m' @@ -25,6 +25,12 @@ SERVER_PATH="/home/user/pounce" SERVER_PASS="user" SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +if ! command -v sshpass >/dev/null 2>&1; then + echo -e "${RED}✗ sshpass is required but not installed.${NC}" + echo -e " Install with: ${CYAN}brew install sshpass${NC}" + exit 1 +fi + # Parse flags QUICK_MODE=false BACKEND_ONLY=false @@ -109,7 +115,7 @@ fi # Step 3: Reload backend (graceful, no restart) if ! $FRONTEND_ONLY; then echo -e "\n${YELLOW}[3/4] Reloading backend (graceful)...${NC}" - sshpass -p "$SERVER_PASS" ssh -tt $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'BACKEND_EOF' + sshpass -p "$SERVER_PASS" ssh $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'BACKEND_EOF' set -e cd ~/pounce/backend @@ -150,8 +156,16 @@ fi # Step 4: Rebuild frontend (in background to minimize downtime) if ! $BACKEND_ONLY; then echo -e "\n${YELLOW}[4/4] Rebuilding frontend...${NC}" - sshpass -p "$SERVER_PASS" ssh -tt $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'FRONTEND_EOF' + sshpass -p "$SERVER_PASS" ssh $SSH_OPTS $SERVER_USER@$SERVER_HOST << 'FRONTEND_EOF' + set -e cd ~/pounce/frontend + + echo " Installing dependencies..." + if [ -f "package-lock.json" ]; then + npm ci + else + npm install + fi # Build new version echo " Building..." @@ -165,7 +179,7 @@ if ! $BACKEND_ONLY; then ln -sfn ../../public .next/standalone/public # Gracefully restart Next.js - NEXT_PID=$(pgrep -af 'next-serv|next start|node \\.next/standalone/server\\.js' | awk 'NR==1{print $1; exit}') + NEXT_PID=$(pgrep -af 'node \\.next/standalone/server\\.js|next start|next-server|next-serv' | awk 'NR==1{print $1; exit}') if [ -n "$NEXT_PID" ]; then echo " Restarting Next.js (PID: $NEXT_PID)..." @@ -178,18 +192,28 @@ if ! $BACKEND_ONLY; then sleep 1 # Start new instance - nohup npm run start > frontend.log 2>&1 & + if [ -f ".next/standalone/server.js" ]; then + echo " Starting Next.js (standalone)..." + nohup env NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 node .next/standalone/server.js > frontend.log 2>&1 & + else + echo " Starting Next.js (npm start)..." + nohup env NODE_ENV=production npm run start > frontend.log 2>&1 & + fi sleep 2 # Verify - NEW_PID=$(pgrep -af 'next-serv|next start|node \\.next/standalone/server\\.js' | awk 'NR==1{print $1; exit}') + NEW_PID=$(pgrep -af 'node \\.next/standalone/server\\.js|next start|next-server|next-serv' | awk 'NR==1{print $1; exit}') if [ -n "$NEW_PID" ]; then echo " ✓ Frontend running (PID: $NEW_PID)" else echo " ⚠ Frontend may not have started correctly" + echo " Last 80 lines of frontend.log:" + tail -n 80 frontend.log || true fi else echo " ✗ Build failed, keeping old version" + echo " Last 120 lines of build output (frontend.log):" + tail -n 120 frontend.log || true fi FRONTEND_EOF else diff --git a/frontend/src/app/terminal/cfo/page.tsx b/frontend/src/app/terminal/cfo/page.tsx index af0dd31..1286b5f 100644 --- a/frontend/src/app/terminal/cfo/page.tsx +++ b/frontend/src/app/terminal/cfo/page.tsx @@ -168,7 +168,7 @@ export default function CfoPage() { {toast && ( - + )} ) diff --git a/frontend/src/app/terminal/hunt/page.tsx b/frontend/src/app/terminal/hunt/page.tsx index 92b98a0..627ed36 100644 --- a/frontend/src/app/terminal/hunt/page.tsx +++ b/frontend/src/app/terminal/hunt/page.tsx @@ -49,7 +49,6 @@ export default function HuntPage() { )}