#!/bin/bash # Network Scanner Frontend Setup Script echo "╔══════════════════════════════════════════════════════════════════════════════╗" echo "║ Network Scanner Frontend - Installation Script ║" echo "╚══════════════════════════════════════════════════════════════════════════════╝" echo "" # Check if Node.js is installed if ! command -v node &> /dev/null; then echo "❌ Node.js is not installed. Please install Node.js 18+ first." echo " Visit: https://nodejs.org/" exit 1 fi # Check Node.js version NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1) if [ "$NODE_VERSION" -lt 18 ]; then echo "❌ Node.js version 18 or higher is required. You have: $(node -v)" exit 1 fi echo "✅ Node.js $(node -v) detected" echo "" # Check if npm is installed if ! command -v npm &> /dev/null; then echo "❌ npm is not installed." exit 1 fi echo "✅ npm $(npm -v) detected" echo "" # Install dependencies echo "📦 Installing dependencies..." npm install if [ $? -ne 0 ]; then echo "❌ Failed to install dependencies" exit 1 fi echo "" echo "✅ Dependencies installed successfully" echo "" # Check if .env file exists if [ ! -f .env ]; then echo "⚠️ Creating .env file..." cat > .env << EOF VITE_API_URL=http://localhost:8000 VITE_WS_URL=ws://localhost:8000 EOF echo "✅ .env file created" else echo "✅ .env file already exists" fi echo "" echo "╔══════════════════════════════════════════════════════════════════════════════╗" echo "║ Installation Complete! 🎉 ║" echo "╚══════════════════════════════════════════════════════════════════════════════╝" echo "" echo "Next steps:" echo " 1. Start the backend server (from parent directory):" echo " cd .. && python main.py" echo "" echo " 2. Start the frontend development server:" echo " npm run dev" echo "" echo " 3. Open your browser to:" echo " http://localhost:3000" echo "" echo "For production build:" echo " npm run build" echo " npm run preview" echo ""