-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·169 lines (145 loc) · 4.22 KB
/
dev.sh
File metadata and controls
executable file
·169 lines (145 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "package.json" ] || [ ! -d "frontend" ] || [ ! -d "src-tauri" ]; then
print_error "Please run this script from the Building-Blocks root directory"
exit 1
fi
print_status "🚀 Starting Building Blocks development environment..."
# Function to cleanup background processes
cleanup() {
print_warning "Shutting down development servers..."
jobs -p | xargs -r kill
exit
}
# Set trap to cleanup on script exit
trap cleanup EXIT INT TERM
# Parse command line arguments
BACKEND_ONLY=false
FRONTEND_ONLY=false
TAURI_ONLY=false
while [[ $# -gt 0 ]]; do
case $1 in
--backend-only)
BACKEND_ONLY=true
shift
;;
--frontend-only)
FRONTEND_ONLY=true
shift
;;
--tauri-only)
TAURI_ONLY=true
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --backend-only Start only the Python backend server"
echo " --frontend-only Start only the Vue frontend dev server"
echo " --tauri-only Start only the Tauri app (assumes backend is running)"
echo " --help Show this help message"
echo ""
echo "Default: Start backend + Tauri (which includes frontend)"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
print_status "Installing root dependencies..."
npm install
fi
cd frontend
if [ ! -d "node_modules" ]; then
print_status "Installing frontend dependencies..."
npm install
fi
cd ..
# Backend-only mode
if [ "$BACKEND_ONLY" = true ]; then
print_status "Starting backend server..."
print_warning "Backend will be available at http://localhost:8000"
print_warning "API docs at http://localhost:8000/api/docs"
cd backend
source venv/bin/activate
python main.py
exit 0
fi
# Frontend-only mode
if [ "$FRONTEND_ONLY" = true ]; then
print_status "Starting frontend development server..."
print_warning "Frontend will be available at http://localhost:3000"
print_warning "Make sure backend is running at http://localhost:8000"
cd frontend
npm run dev
exit 0
fi
# Tauri-only mode
if [ "$TAURI_ONLY" = true ]; then
print_status "Starting Tauri development mode..."
print_warning "Make sure backend is running at http://localhost:8000"
npm run tauri:dev
exit 0
fi
# Default: Full development environment
print_status "Starting full development environment..."
print_status "This will start:"
print_status " 1. Python backend server (port 8000)"
print_status " 2. Tauri app with Vue frontend (port 3000)"
# Check if backend virtual environment exists
if [ ! -d "backend/venv" ]; then
print_warning "Backend virtual environment not found"
print_status "Setting up Python backend..."
cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cd ..
print_success "Backend setup completed"
fi
# Start backend server in background
print_status "Starting backend server..."
cd backend
source venv/bin/activate
python main.py &
BACKEND_PID=$!
cd ..
# Wait a moment for backend to start
sleep 3
# Check if backend is running
if ! curl -s http://localhost:8000/api/health >/dev/null 2>&1; then
print_warning "Backend might not be ready yet, continuing..."
else
print_success "Backend server is running at http://localhost:8000"
fi
# Start Tauri development mode
print_status "Starting Tauri development mode..."
npm run tauri:dev
# If we reach here, Tauri has exited
print_status "Tauri development session ended"