-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-install.sh
More file actions
executable file
·256 lines (221 loc) · 7.12 KB
/
dev-install.sh
File metadata and controls
executable file
·256 lines (221 loc) · 7.12 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
#!/bin/bash
# Development install/uninstall script for MAIASS testing
# This script helps with development and testing of the MAIASS tool
set -e # Exit on any error
PACKAGE_NAME="maiass"
GLOBAL_BIN_PATH="/usr/local/bin/maiass"
# 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}ℹ️ $1${NC}"
}
print_success() {
echo -e "${GREEN}✅ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
# Function to check if package is globally installed
is_globally_installed() {
command -v "$PACKAGE_NAME" >/dev/null 2>&1
}
# Function to install globally
install_global() {
print_status "Installing $PACKAGE_NAME globally..."
if npm install -g .; then
print_success "Global installation completed"
# Verify installation
if command -v "$PACKAGE_NAME" >/dev/null 2>&1; then
print_success "Command '$PACKAGE_NAME' is available in PATH"
"$PACKAGE_NAME" --version
else
print_warning "Command '$PACKAGE_NAME' not found in PATH, but npm install succeeded"
fi
else
print_error "Global installation failed"
return 1
fi
}
# Function to uninstall globally
uninstall_global() {
print_status "Uninstalling $PACKAGE_NAME globally..."
if is_globally_installed; then
if npm uninstall -g "$PACKAGE_NAME"; then
print_success "Global uninstallation completed"
else
print_error "Global uninstallation failed"
return 1
fi
else
print_warning "Package '$PACKAGE_NAME' is not globally installed"
fi
# Clean up any remaining symlinks or binaries
if [ -L "$GLOBAL_BIN_PATH" ] || [ -f "$GLOBAL_BIN_PATH" ]; then
print_status "Removing binary from $GLOBAL_BIN_PATH"
sudo rm -f "$GLOBAL_BIN_PATH" 2>/dev/null || rm -f "$GLOBAL_BIN_PATH" 2>/dev/null
fi
}
# Function to check Node.js version compatibility
check_node_version() {
local node_version=$(node --version 2>/dev/null | sed 's/v//')
local required_major=18
if [ -z "$node_version" ]; then
print_error "Node.js not found"
echo " Install Node.js 18+ or use built binaries"
return 1
fi
local major_version=$(echo $node_version | cut -d. -f1)
if [ "$major_version" -lt "$required_major" ]; then
print_warning "Node.js $node_version detected (requires 18+)"
echo " Current: Node.js $node_version"
echo " Required: Node.js 18+"
echo " Solutions:"
echo " 1. Use built binaries (no Node.js required)"
echo " 2. Upgrade Node.js: nvm install 18 && nvm use 18"
return 1
else
print_success "Node.js $node_version (compatible)"
return 0
fi
}
# Function to show current installation status
show_status() {
echo -e "\n${BLUE}📊 Current Installation Status${NC}"
echo "================================"
# Check Node.js version first
echo -e "\n${BLUE}🟢 Node.js Compatibility${NC}"
echo "========================"
check_node_version
# Check global npm installation
if is_globally_installed; then
print_success "NPM global installation: INSTALLED"
npm list -g $PACKAGE_NAME 2>/dev/null | grep $PACKAGE_NAME
else
print_warning "NPM global installation: NOT INSTALLED"
fi
# Check command availability
if command -v "$PACKAGE_NAME" >/dev/null 2>&1; then
print_success "Command '$PACKAGE_NAME' available in PATH"
echo " Location: $(which "$PACKAGE_NAME")"
else
print_warning "Command '$PACKAGE_NAME' not available in PATH"
fi
# Check local files
echo -e "\n${BLUE}📁 Local Files Status${NC}"
echo "===================="
# List of files that should exist
files=("maiass.mjs" "maiass.sh" "package.json")
for file in "${files[@]}"; do
if [ -f "$file" ]; then
print_success "$file exists"
else
print_error "$file missing"
fi
done
# Check built binaries
if [ -d "build" ]; then
echo -e "\n${BLUE}🔧 Built Binaries${NC}"
echo "================"
ls -lh build/ 2>/dev/null || print_warning "No built binaries found"
fi
}
# Function to run tests
run_tests() {
print_status "Running installation tests..."
if [ -f "test-install.sh" ]; then
chmod +x test-install.sh
./test-install.sh
else
print_warning "test-install.sh not found, running basic tests..."
# Basic test
if command -v "$PACKAGE_NAME" >/dev/null 2>&1; then
print_status "Running tests..."
"$PACKAGE_NAME" --version
fi
# Local test
if [ -f "nodemaiass.sh" ]; then
print_status "Testing local wrapper..."
./nodemaiass.sh --version
fi
fi
}
# Function to clean everything
clean_all() {
print_status "Performing complete cleanup..."
uninstall_global
# Clean npm cache
print_status "Clearing npm cache..."
npm cache clean --force 2>/dev/null || true
# Remove node_modules and reinstall (for fresh state)
if [ -d "node_modules" ]; then
print_status "Removing node_modules for fresh install..."
rm -rf node_modules
npm install
fi
print_success "Complete cleanup finished"
}
# Main script logic
case "$1" in
"install"|"i")
show_status
echo ""
install_global
echo ""
show_status
;;
"uninstall"|"u")
show_status
echo ""
uninstall_global
echo ""
show_status
;;
"reinstall"|"r")
print_status "Performing reinstall (uninstall + install)..."
uninstall_global
echo ""
install_global
echo ""
show_status
;;
"test"|"t")
run_tests
;;
"clean"|"c")
clean_all
;;
"status"|"s")
show_status
;;
*)
echo -e "${BLUE}🔧 MAIASS Development Install/Test Script${NC}"
echo "============================================="
echo ""
echo "Usage: $0 [command]"
echo ""
echo "Commands:"
echo " install, i Install package globally"
echo " uninstall, u Uninstall package globally"
echo " reinstall, r Uninstall then install (clean reinstall)"
echo " test, t Run installation tests"
echo " clean, c Complete cleanup (uninstall + clear cache + fresh deps)"
echo " status, s Show current installation status"
echo ""
echo "Examples:"
echo " $0 install # Install globally"
echo " $0 uninstall # Remove global installation"
echo " $0 reinstall # Clean reinstall for testing"
echo " $0 test # Test current installation"
echo " $0 status # Check what's currently installed"
echo ""
show_status
;;
esac