#!/bin/bash # Cursor Full Stack AI IDE - Complete Setup Script # This script sets up everything needed for the AI IDE set -e # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' PURPLE='\033[0;35m' CYAN='\033[0;36m' NC='\033[0m' echo -e "${BLUE}" echo "==========================================" echo " ๐Ÿš€ Cursor Full Stack AI IDE" echo " ๐ŸŽฏ Complete Setup & Deployment" echo "==========================================" echo -e "${NC}" # Check system requirements check_requirements() { echo -e "${YELLOW}Checking system requirements...${NC}" # Check if Node.js is installed if ! command -v node &> /dev/null; then error "Node.js is not installed. Please install Node.js 18+ first." exit 1 fi # Check if npm is installed if ! command -v npm &> /dev/null; then error "npm is not installed. Please install npm first." exit 1 fi # Check Node.js version NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1) if [ "$NODE_VERSION" -lt 18 ]; then error "Node.js version 18+ is required. Current version: $(node -v)" exit 1 fi echo -e "${GREEN}โœ… System requirements met${NC}" } # Install global dependencies install_global_dependencies() { echo -e "${YELLOW}Installing global dependencies...${NC}" # Install Wrangler CLI if ! command -v wrangler &> /dev/null; then echo "Installing Wrangler CLI..." npm install -g wrangler fi # Install other useful tools if ! command -v git &> /dev/null; then echo "Git is not installed. Please install Git first." exit 1 fi echo -e "${GREEN}โœ… Global dependencies installed${NC}" } # Setup workspace setup_workspace() { echo -e "${YELLOW}Setting up workspace...${NC}" ./setup-workspace.sh echo -e "${GREEN}โœ… Workspace setup complete${NC}" } # Authenticate with Cloudflare authenticate_cloudflare() { echo -e "${YELLOW}Authenticating with Cloudflare...${NC}" if ! wrangler whoami &> /dev/null; then echo "Please log in to Cloudflare..." wrangler login fi echo -e "${GREEN}โœ… Cloudflare authentication complete${NC}" } # Deploy application deploy_application() { echo -e "${YELLOW}Deploying application...${NC}" ./auto-deploy.sh --skip-confirmation echo -e "${GREEN}โœ… Application deployed successfully${NC}" } # Test deployment test_deployment() { echo -e "${YELLOW}Testing deployment...${NC}" # Get the deployed URLs from the auto-deploy script BACKEND_URL=$(grep "Backend URL:" /tmp/deploy.log 2>/dev/null | cut -d' ' -f3 || echo "https://cursor-backend.workers.dev") FRONTEND_URL=$(grep "Frontend URL:" /tmp/deploy.log 2>/dev/null | cut -d' ' -f3 || echo "https://cursor-frontend.pages.dev") echo "Testing backend health..." if curl -f "$BACKEND_URL/health" > /dev/null 2>&1; then echo -e "${GREEN}โœ… Backend is healthy${NC}" else echo -e "${YELLOW}โš ๏ธ Backend health check failed (this is normal for new deployments)${NC}" fi echo "Testing frontend accessibility..." if curl -f "$FRONTEND_URL" > /dev/null 2>&1; then echo -e "${GREEN}โœ… Frontend is accessible${NC}" else echo -e "${YELLOW}โš ๏ธ Frontend is not accessible (this is normal for new deployments)${NC}" fi } # Generate final summary generate_final_summary() { echo -e "\n${PURPLE}==========================================" echo " ๐ŸŽ‰ SETUP COMPLETE! ๐ŸŽ‰" echo "==========================================" echo -e "${NC}" echo -e "${GREEN}โœ… Workspace setup complete${NC}" echo -e "${GREEN}โœ… Cloudflare authentication complete${NC}" echo -e "${GREEN}โœ… Application deployed successfully${NC}" echo -e "${GREEN}โœ… All services configured${NC}" echo -e "\n${BLUE}๐Ÿ”— Your AI IDE is now live:${NC}" echo -e "Frontend: https://cursor-frontend.pages.dev" echo -e "Backend: https://cursor-backend.workers.dev" echo -e "WebSocket: wss://cursor-backend.workers.dev" echo -e "\n${YELLOW}๐Ÿ“‹ What you can do now:${NC}" echo "1. ๐ŸŒ Open your AI IDE in the browser" echo "2. ๐Ÿ”‘ Configure your AI provider API keys" echo "3. ๐Ÿงช Test the AI chat functionality" echo "4. ๐Ÿ“ Explore the workspace structure" echo "5. ๐Ÿš€ Start building your projects" echo -e "\n${CYAN}๐Ÿ› ๏ธ Available tools:${NC}" echo "โ€ข AI Chat with 5 providers" echo "โ€ข Monaco Editor (VS Code experience)" echo "โ€ข File operations and management" echo "โ€ข Git integration" echo "โ€ข Terminal access" echo "โ€ข Docker support" echo "โ€ข NPM package management" echo "โ€ข Code search and analysis" echo -e "\n${GREEN}==========================================" echo " ๐Ÿš€ Ready to code with AI! ๐Ÿš€" echo "==========================================" echo -e "${NC}" } # Main execution main() { check_requirements install_global_dependencies setup_workspace authenticate_cloudflare deploy_application test_deployment generate_final_summary } # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in --help) echo "Usage: $0 [OPTIONS]" echo "Options:" echo " --help Show this help message" echo "" echo "This script will:" echo "1. Check system requirements" echo "2. Install global dependencies" echo "3. Setup workspace structure" echo "4. Authenticate with Cloudflare" echo "5. Deploy the application" echo "6. Test the deployment" echo "7. Provide you with live URLs" exit 0 ;; *) error "Unknown option: $1" exit 1 ;; esac done # Run main function main