-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·141 lines (114 loc) · 2.99 KB
/
setup.sh
File metadata and controls
executable file
·141 lines (114 loc) · 2.99 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
#!/bin/bash
# EscapeMint Setup Script
# Checks dependencies and sets up the development environment
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_status() {
echo -e "${GREEN}[OK]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_step() {
echo -e "\n${GREEN}==>${NC} $1"
}
# Check if Node.js is installed and version is 20+
check_node() {
print_step "Checking Node.js..."
if ! command -v node &> /dev/null; then
print_error "Node.js is not installed"
echo ""
echo "Please install Node.js 20 or higher:"
echo " - macOS: brew install node"
echo " - Or download from: https://nodejs.org/"
echo ""
exit 1
fi
NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
if [ "$NODE_VERSION" -lt 20 ]; then
print_error "Node.js version 20+ required (found v$(node -v | sed 's/v//'))"
echo ""
echo "Please upgrade Node.js:"
echo " - macOS: brew upgrade node"
echo " - Or download from: https://nodejs.org/"
echo ""
exit 1
fi
print_status "Node.js $(node -v) found"
}
# Check if npm is available
check_npm() {
print_step "Checking npm..."
if ! command -v npm &> /dev/null; then
print_error "npm is not installed (should come with Node.js)"
exit 1
fi
print_status "npm $(npm -v) found"
}
# Install dependencies
install_deps() {
print_step "Installing dependencies..."
npm install
print_status "Dependencies installed"
}
# Build packages
build_packages() {
print_step "Building packages..."
npm run build:packages
print_status "Packages built"
}
# Setup data directory
setup_data() {
print_step "Setting up data directory..."
mkdir -p data/funds
print_status "Data directory created at ./data/funds/"
}
# Install PM2 globally if not present
check_pm2() {
print_step "Checking PM2..."
if ! command -v pm2 &> /dev/null; then
print_warning "PM2 not found globally, installing..."
npm install -g pm2
fi
print_status "PM2 $(pm2 -v) found"
}
# Start development servers
start_servers() {
print_step "Starting development servers..."
npm run dev
}
# Main setup flow
main() {
echo ""
echo "================================"
echo " EscapeMint Setup"
echo "================================"
check_node
check_npm
check_pm2
install_deps
build_packages
setup_data
echo ""
echo "================================"
echo -e " ${GREEN}Setup complete!${NC}"
echo "================================"
echo ""
echo "Starting the application..."
echo ""
echo " Frontend: http://localhost:5550"
echo " API: http://localhost:5551"
echo ""
echo "Press Ctrl+C to exit logs (servers keep running)"
echo "Use 'npm run dev:stop' to stop servers"
echo ""
start_servers
}
main