-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·211 lines (181 loc) Β· 6.28 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
Β·211 lines (181 loc) Β· 6.28 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
#!/bin/bash
# π AI Visual Code Review - Installation Script
# Installs the tool globally or locally for easy use in any Git repository
set -e
INSTALL_DIR="/usr/local/bin"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GLOBAL_INSTALL=false
LOCAL_INSTALL=false
echo "π AI Visual Code Review - Installation"
echo "====================================="
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--global|-g)
GLOBAL_INSTALL=true
shift
;;
--local|-l)
LOCAL_INSTALL=true
shift
;;
--help|-h)
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --global, -g Install globally (requires sudo)"
echo " --local, -l Install to current directory"
echo " --help, -h Show this help"
echo ""
echo "Examples:"
echo " $0 --global # Install globally"
echo " $0 --local # Install to current directory"
echo " $0 # Interactive installation"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Check Node.js installation
if ! command -v node &> /dev/null; then
echo "β Node.js not found"
echo "π‘ Please install Node.js (version 14 or higher) from https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node --version | sed 's/v//')
REQUIRED_VERSION="14.0.0"
if ! node -e "
const current = '$NODE_VERSION'.split('.').map(Number);
const required = '$REQUIRED_VERSION'.split('.').map(Number);
const isValid = current[0] > required[0] ||
(current[0] === required[0] && current[1] > required[1]) ||
(current[0] === required[0] && current[1] === required[1] && current[2] >= required[2]);
process.exit(isValid ? 0 : 1);
" 2>/dev/null; then
echo "β Node.js version $NODE_VERSION is too old"
echo "π‘ Please upgrade to Node.js 14.0.0 or higher"
exit 1
fi
echo "β
Node.js $NODE_VERSION detected"
# Check Git installation
if ! command -v git &> /dev/null; then
echo "β Git not found"
echo "π‘ Please install Git from https://git-scm.com/"
exit 1
fi
echo "β
Git $(git --version | cut -d' ' -f3) detected"
# Interactive installation if no options specified
if [ "$GLOBAL_INSTALL" = false ] && [ "$LOCAL_INSTALL" = false ]; then
echo ""
echo "Choose installation type:"
echo "1) Global installation (recommended) - available everywhere"
echo "2) Local installation - copy to current directory"
echo "3) NPM installation - install from npm (if published)"
echo ""
read -p "Enter your choice (1-3): " choice
case $choice in
1)
GLOBAL_INSTALL=true
;;
2)
LOCAL_INSTALL=true
;;
3)
echo "π¦ Installing from NPM..."
npm install -g ai-visual-code-review
if [ $? -eq 0 ]; then
echo "β
Successfully installed ai-visual-code-review globally via NPM"
echo ""
echo "π― Usage:"
echo " ai-review # Start visual review server"
echo " ai-review quick # Generate quick AI review"
echo " ai-review --help # Show help"
exit 0
else
echo "β NPM installation failed. Falling back to local installation."
LOCAL_INSTALL=true
fi
;;
*)
echo "Invalid choice. Defaulting to local installation."
LOCAL_INSTALL=true
;;
esac
fi
# Install dependencies
echo ""
echo "π¦ Installing dependencies..."
cd "$SCRIPT_DIR"
if [ ! -f "package.json" ]; then
echo "β package.json not found in $SCRIPT_DIR"
exit 1
fi
npm install --production
if [ $? -ne 0 ]; then
echo "β Failed to install dependencies"
exit 1
fi
echo "β
Dependencies installed successfully"
# Global installation
if [ "$GLOBAL_INSTALL" = true ]; then
echo ""
echo "π Installing globally..."
# Check if we need sudo
if [ ! -w "$INSTALL_DIR" ]; then
echo "π Requesting administrator privileges..."
SUDO_CMD="sudo"
else
SUDO_CMD=""
fi
# Create symlink to CLI tool
$SUDO_CMD ln -sf "$SCRIPT_DIR/bin/ai-review.js" "$INSTALL_DIR/ai-review"
# Make scripts executable
chmod +x "$SCRIPT_DIR/bin/ai-review.js"
chmod +x "$SCRIPT_DIR/scripts/quick-ai-review.sh"
echo "β
Installed globally to $INSTALL_DIR/ai-review"
echo ""
echo "π― Usage (from any directory):"
echo " ai-review # Start visual review server"
echo " ai-review start --port 3003 # Custom port"
echo " ai-review quick # Generate quick AI review"
echo " ai-review --help # Show help"
# Local installation
elif [ "$LOCAL_INSTALL" = true ]; then
echo ""
echo "π Installing locally..."
TARGET_DIR="$(pwd)/ai-visual-code-review"
# Create target directory if it doesn't exist
if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "$TARGET_DIR"
fi
# Copy files
cp -r "$SCRIPT_DIR"/* "$TARGET_DIR/"
# Make scripts executable
chmod +x "$TARGET_DIR/bin/ai-review.js"
chmod +x "$TARGET_DIR/scripts/quick-ai-review.sh"
echo "β
Installed locally to $TARGET_DIR"
echo ""
echo "π― Usage (from current directory):"
echo " ./ai-visual-code-review/bin/ai-review.js # Start visual server"
echo " ./ai-visual-code-review/scripts/quick-ai-review.sh # Quick review"
echo ""
echo "π‘ Add to PATH for easier access:"
echo " echo 'export PATH=\"\$PATH:$(pwd)/ai-visual-code-review/bin\"' >> ~/.bashrc"
echo " source ~/.bashrc"
fi
echo ""
echo "π Installation completed successfully!"
echo ""
echo "π Quick Start:"
echo "1. Navigate to any Git repository"
echo "2. Stage some changes: git add ."
echo "3. Run: ai-review"
echo "4. Open browser at http://localhost:3002"
echo "5. Review and export for AI analysis"
echo ""
echo "π For more information, see README.md"
echo "π Report issues: https://github.com/PrakharMNNIT/ai-visual-code-review/issues"