WIP: Save current work before CHORUS rebrand
- Agent roles integration progress - Various backend and frontend updates - Storybook cache cleanup 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
212
dev-start.sh
Executable file
212
dev-start.sh
Executable file
@@ -0,0 +1,212 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Hive Development Environment Startup Script
|
||||
# This script provides a fast development cycle with hot reload
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting Hive Development Environment"
|
||||
echo "========================================="
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "docker-compose.dev.yml" ]; then
|
||||
echo -e "${RED}❌ Error: Please run this script from the hive project root directory${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to check if backend is running
|
||||
check_backend() {
|
||||
local backend_url="https://hive.home.deepblack.cloud/api/health"
|
||||
local dev_url="http://localhost:8089/api/health"
|
||||
|
||||
echo -e "${YELLOW}⏳ Checking backend availability...${NC}"
|
||||
|
||||
if curl -s -f "$backend_url" > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Production backend is available at $backend_url${NC}"
|
||||
return 0
|
||||
elif curl -s -f "$dev_url" > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Development backend is available at $dev_url${NC}"
|
||||
return 0
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ No backend detected. Will start development backend.${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to start frontend only (with production backend)
|
||||
start_frontend_only() {
|
||||
echo -e "${GREEN}🎯 Starting frontend with hot reload (using production backend)${NC}"
|
||||
|
||||
cd frontend
|
||||
|
||||
# Install dependencies if needed
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo -e "${YELLOW}📦 Installing frontend dependencies...${NC}"
|
||||
npm install
|
||||
fi
|
||||
|
||||
# Create development .env
|
||||
cat > .env.development.local << EOF
|
||||
VITE_API_BASE_URL=https://hive.home.deepblack.cloud
|
||||
VITE_WS_BASE_URL=https://hive.home.deepblack.cloud
|
||||
VITE_ENABLE_DEBUG_MODE=true
|
||||
VITE_LOG_LEVEL=debug
|
||||
VITE_DEV_MODE=true
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}🔥 Starting frontend development server with hot reload...${NC}"
|
||||
echo -e "${YELLOW}💡 Frontend will be available at: http://localhost:3000${NC}"
|
||||
echo -e "${YELLOW}💡 Backend API: https://hive.home.deepblack.cloud${NC}"
|
||||
echo -e "${YELLOW}💡 Press Ctrl+C to stop${NC}"
|
||||
echo ""
|
||||
|
||||
npm run dev
|
||||
}
|
||||
|
||||
# Function to start full development stack
|
||||
start_full_stack() {
|
||||
echo -e "${GREEN}🔧 Starting full development stack with Docker Compose...${NC}"
|
||||
|
||||
# Build and start development containers
|
||||
echo -e "${YELLOW}🐳 Building development containers...${NC}"
|
||||
docker-compose -f docker-compose.dev.yml build
|
||||
|
||||
echo -e "${YELLOW}🚀 Starting development containers...${NC}"
|
||||
docker-compose -f docker-compose.dev.yml up --remove-orphans
|
||||
}
|
||||
|
||||
# Main menu
|
||||
show_menu() {
|
||||
echo ""
|
||||
echo "Choose development mode:"
|
||||
echo "1) Frontend only (hot reload, uses production backend) - FAST ⚡"
|
||||
echo "2) Full stack (frontend + backend in Docker) - COMPLETE 🔧"
|
||||
echo "3) Check system status 📊"
|
||||
echo "4) Clean development environment 🧹"
|
||||
echo "5) Exit"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Clean development environment
|
||||
clean_dev_env() {
|
||||
echo -e "${YELLOW}🧹 Cleaning development environment...${NC}"
|
||||
|
||||
# Stop and remove dev containers
|
||||
docker-compose -f docker-compose.dev.yml down --remove-orphans || true
|
||||
|
||||
# Remove dev images
|
||||
docker images --format "table {{.Repository}}\t{{.Tag}}" | grep "hive.*dev" | awk '{print $1":"$2}' | xargs -r docker rmi || true
|
||||
|
||||
# Clean frontend
|
||||
if [ -d "frontend/node_modules" ]; then
|
||||
echo -e "${YELLOW}📦 Cleaning frontend node_modules...${NC}"
|
||||
rm -rf frontend/node_modules
|
||||
fi
|
||||
|
||||
# Clean local env files
|
||||
rm -f frontend/.env.development.local
|
||||
|
||||
echo -e "${GREEN}✅ Development environment cleaned${NC}"
|
||||
}
|
||||
|
||||
# Check system status
|
||||
check_status() {
|
||||
echo -e "${YELLOW}📊 System Status Check${NC}"
|
||||
echo "===================="
|
||||
|
||||
# Check production backend
|
||||
if curl -s -f "https://hive.home.deepblack.cloud/api/health" > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Production backend: Online${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Production backend: Offline${NC}"
|
||||
fi
|
||||
|
||||
# Check development backend
|
||||
if curl -s -f "http://localhost:8089/api/health" > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Development backend: Online${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Development backend: Offline${NC}"
|
||||
fi
|
||||
|
||||
# Check frontend
|
||||
if curl -s -f "http://localhost:3000" > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Development frontend: Online${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Development frontend: Offline${NC}"
|
||||
fi
|
||||
|
||||
# Check Docker
|
||||
if docker ps > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✅ Docker: Available${NC}"
|
||||
|
||||
# Check dev containers
|
||||
DEV_CONTAINERS=$(docker-compose -f docker-compose.dev.yml ps --services --filter status=running 2>/dev/null | wc -l)
|
||||
if [ "$DEV_CONTAINERS" -gt 0 ]; then
|
||||
echo -e "${GREEN}✅ Development containers: $DEV_CONTAINERS running${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Development containers: None running${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}❌ Docker: Not available${NC}"
|
||||
fi
|
||||
|
||||
# Check Node.js
|
||||
if command -v node > /dev/null 2>&1; then
|
||||
NODE_VERSION=$(node --version)
|
||||
echo -e "${GREEN}✅ Node.js: $NODE_VERSION${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Node.js: Not installed${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Trap to clean up on exit
|
||||
cleanup() {
|
||||
echo -e "\n${YELLOW}🛑 Shutting down development environment...${NC}"
|
||||
if [ -f docker-compose.dev.yml ]; then
|
||||
docker-compose -f docker-compose.dev.yml down > /dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
# Main script loop
|
||||
while true; do
|
||||
show_menu
|
||||
read -p "Enter your choice (1-5): " choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
if check_backend; then
|
||||
start_frontend_only
|
||||
else
|
||||
echo -e "${RED}❌ No backend available. Please choose option 2 for full stack or start the production backend.${NC}"
|
||||
sleep 2
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
start_full_stack
|
||||
;;
|
||||
3)
|
||||
check_status
|
||||
read -p "Press Enter to return to menu..."
|
||||
;;
|
||||
4)
|
||||
clean_dev_env
|
||||
read -p "Press Enter to return to menu..."
|
||||
;;
|
||||
5)
|
||||
echo -e "${GREEN}👋 Goodbye!${NC}"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}❌ Invalid choice. Please enter 1-5.${NC}"
|
||||
sleep 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user