-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·359 lines (303 loc) · 9.92 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·359 lines (303 loc) · 9.92 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#!/bin/bash
# RAGme.io Setup Script
# This script sets up all dependencies for the RAGme.io project
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
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "${BLUE}[SETUP]${NC} $1"
}
print_help() {
echo -e "${BLUE}RAGme.io Setup Script${NC}"
echo ""
echo "Usage: ./setup.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --help, -h Show this help message"
echo " --skip-python Skip Python dependency installation"
echo " --skip-node Skip Node.js dependency installation"
echo " --skip-brew Skip Homebrew dependency installation"
echo " --force Force reinstall all dependencies"
echo ""
echo "This script will:"
echo " 1. Check and install system dependencies (Homebrew, Node.js, Python)"
echo " 2. Install Python dependencies using uv"
echo " 3. Install agent framework dependencies"
echo " 4. Install Node.js dependencies for the frontend"
echo " 5. Run initial tests to verify setup"
echo ""
echo "Examples:"
echo " ./setup.sh # Full setup"
echo " ./setup.sh --skip-python # Skip Python setup"
echo " ./setup.sh --force # Force reinstall everything"
}
# Parse command line arguments
SKIP_PYTHON=false
SKIP_NODE=false
SKIP_BREW=false
FORCE=false
while [[ $# -gt 0 ]]; do
case $1 in
--help|-h)
print_help
exit 0
;;
--skip-python)
SKIP_PYTHON=true
shift
;;
--skip-node)
SKIP_NODE=true
shift
;;
--skip-brew)
SKIP_BREW=false
shift
;;
--force)
FORCE=true
shift
;;
*)
print_error "Unknown option: $1"
print_help
exit 1
;;
esac
done
print_header "Starting RAGme.io Setup..."
# Check if we're on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
print_warning "This script is optimized for macOS. Some features may not work on other systems."
fi
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install Homebrew if not present
install_homebrew() {
if ! command_exists brew; then
print_status "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to PATH for Apple Silicon Macs
if [[ -f "/opt/homebrew/bin/brew" ]]; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
else
print_status "Homebrew is already installed"
fi
}
# Function to install Node.js if not present
install_nodejs() {
if ! command_exists node; then
print_status "Installing Node.js..."
brew install node
else
print_status "Node.js is already installed ($(node --version))"
fi
if ! command_exists npm; then
print_error "npm not found after Node.js installation"
exit 1
fi
}
# Function to install Python dependencies
install_python_deps() {
print_header "Setting up Python dependencies..."
# Check if uv is installed
if ! command_exists uv; then
print_status "Installing uv (Python package manager)..."
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.cargo/env
else
print_status "uv is already installed ($(uv --version))"
fi
# Install Python dependencies
print_status "Installing Python dependencies..."
uv sync
# Install test dependencies
print_status "Installing test dependencies..."
uv pip install -r requirements-test.txt
# Install agent dependencies
if [ -f requirements-agents.txt ]; then
print_status "Installing agent framework dependencies..."
uv pip install -r requirements-agents.txt
else
print_warning "requirements-agents.txt not found, skipping agent dependencies"
fi
# Install development tools
print_status "Installing development tools..."
uv pip install ruff
print_status "Python dependencies installed successfully!"
}
# Function to install Node.js dependencies
install_node_deps() {
print_header "Setting up Node.js dependencies..."
cd frontend
# Clean install if force flag is set
if [ "$FORCE" = true ]; then
print_status "Force reinstalling Node.js dependencies..."
rm -rf node_modules package-lock.json
fi
# Install dependencies
print_status "Installing Node.js dependencies..."
npm install
# Test build
print_status "Testing TypeScript compilation..."
npm run build
# Test linting
print_status "Testing ESLint..."
npm run lint
# Verify ES module configuration
print_status "Verifying ES module configuration..."
if grep -q '"type": "module"' package.json && grep -q '"module": "ES2020"' tsconfig.json; then
print_status "✅ ES module configuration verified"
else
print_warning "⚠️ ES module configuration may need attention"
fi
cd ..
print_status "Node.js dependencies installed successfully!"
}
# Function to install MinIO
install_minio() {
print_header "Installing MinIO..."
# Check if MinIO is already installed
if command_exists minio; then
print_status "✅ MinIO is already installed"
return 0
fi
# Install MinIO using Homebrew
print_status "Installing MinIO via Homebrew..."
if brew install minio/stable/minio; then
print_status "✅ MinIO installed successfully"
else
print_error "❌ Failed to install MinIO"
print_warning "You can install MinIO manually from https://min.io/download"
return 1
fi
# Create minio_data directory
print_status "Creating MinIO data directory..."
mkdir -p minio_data
print_status "✅ MinIO data directory created"
}
# Function to run initial tests
run_initial_tests() {
print_header "Running initial tests..."
# Test Python setup
print_status "Testing Python setup..."
if uv run --active python -c "import sys; print(f'Python {sys.version}')"; then
print_status "✅ Python setup verified"
else
print_error "❌ Python setup failed"
exit 1
fi
# Test Node.js setup
print_status "Testing Node.js setup..."
if cd frontend && npm run build && cd ..; then
print_status "✅ Node.js setup verified"
else
print_error "❌ Node.js setup failed"
exit 1
fi
# Run basic linting
print_status "Running basic linting checks..."
if ./tools/lint.sh; then
print_status "✅ Linting checks passed"
else
print_warning "⚠️ Some linting checks failed (this is normal for initial setup)"
fi
}
# Function to create .env file if it doesn't exist
setup_env_file() {
if [ ! -f .env ]; then
print_status "Creating .env file from template..."
if [ -f env.example ]; then
cp env.example .env
print_warning "Created .env file from template. Please edit it with your API keys."
else
print_warning "No env.example found. You may need to create a .env file manually."
fi
else
print_status ".env file already exists"
fi
}
# Function to check system requirements
check_system_requirements() {
print_header "Checking system requirements..."
# Check available disk space (at least 1GB)
available_space=$(df . | awk 'NR==2 {print $4}')
if [ "$available_space" -lt 1048576 ]; then
print_error "Insufficient disk space. Need at least 1GB available."
exit 1
fi
# Check available memory (at least 2GB)
total_mem=$(sysctl -n hw.memsize 2>/dev/null || echo "0")
if [ "$total_mem" -lt 2147483648 ]; then
print_warning "Low memory detected. Some operations may be slow."
fi
print_status "System requirements check passed"
}
# Main setup process
main() {
print_header "RAGme.io Setup Process"
echo "================================"
# Check system requirements
check_system_requirements
# Install system dependencies
if [ "$SKIP_BREW" = false ]; then
print_header "Installing system dependencies..."
install_homebrew
install_nodejs
else
print_status "Skipping system dependency installation"
fi
# Setup environment file
setup_env_file
# Install Python dependencies
if [ "$SKIP_PYTHON" = false ]; then
install_python_deps
else
print_status "Skipping Python dependency installation"
fi
# Install Node.js dependencies
if [ "$SKIP_NODE" = false ]; then
install_node_deps
else
print_status "Skipping Node.js dependency installation"
fi
# Install MinIO
install_minio
# Run initial tests
run_initial_tests
print_header "Setup Complete! 🎉"
echo "================================"
print_status "RAGme.io is now ready to use!"
echo ""
print_status "Next steps:"
echo " 1. Edit .env file with your API keys"
echo " 2. Run './start.sh' to start the services"
echo " 3. Visit http://localhost:8020 to access the frontend"
echo ""
print_status "Useful commands:"
echo " ./start.sh # Start all services"
echo " ./stop.sh # Stop all services"
echo " ./test.sh unit # Run unit tests"
echo " ./tools/lint.sh # Run linting checks"
echo ""
print_status "For more information, see README.md"
}
# Run main function
main "$@"