-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·186 lines (154 loc) Β· 5.51 KB
/
install.sh
File metadata and controls
executable file
Β·186 lines (154 loc) Β· 5.51 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
#!/bin/bash
set -e
# π§ CodeCompass Installation Script
# Navigate Your Code Quality
VERSION="v1.0.0"
BINARY_NAME="codecompass"
INSTALL_DIR="/usr/local/bin"
CONFIG_DIR="$HOME/.config/codecompass"
echo "π§ CodeCompass Installation Script"
echo "=================================="
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
armv7l) ARCH="arm" ;;
*) echo "β Unsupported architecture: $ARCH"; exit 1 ;;
esac
case $OS in
linux|darwin) ;;
*) echo "β Unsupported OS: $OS"; exit 1 ;;
esac
echo "π Detected: $OS ($ARCH)"
# Check dependencies
check_dependency() {
if ! command -v $1 &> /dev/null; then
echo "β Required dependency '$1' not found"
return 1
else
echo "β
Found $1"
return 0
fi
}
echo ""
echo "π Checking dependencies..."
check_dependency "git" || exit 1
check_dependency "curl" || exit 1
# Optional dependencies
echo ""
echo "π Checking optional dependencies..."
check_dependency "go" && echo " - Can build from source" || echo " - Will use prebuilt binary"
check_dependency "node" && echo " - ESLint support available" || echo " - ESLint support not available"
check_dependency "python3" && echo " - Python analysis support available" || echo " - Python analysis support not available"
echo ""
echo "π¦ Installation method:"
echo "1. Build from source (requires Go)"
echo "2. Download prebuilt binary (coming soon)"
echo "3. Use Homebrew (macOS)"
read -p "Choose installation method (1-3): " METHOD
case $METHOD in
1)
echo "π¨ Building from source..."
# Check if we're already in the codecompass directory
if [[ -f "go.mod" ]] && grep -q "codecompass" go.mod; then
echo "β
Using current directory (codecompass repository)"
BUILD_DIR="."
else
echo "π₯ Cloning repository..."
BUILD_DIR="/tmp/codecompass-build"
rm -rf $BUILD_DIR
git clone https://github.com/xeon-zolt/codecompass.git $BUILD_DIR
cd $BUILD_DIR
fi
echo "ποΈ Building binary..."
if [[ "$BUILD_DIR" != "." ]]; then
cd $BUILD_DIR
fi
go build -ldflags "-s -w -X main.version=$VERSION -X main.buildDate=$(date +'%Y-%m-%d')" -o $BINARY_NAME
echo "π Installing binary..."
sudo cp $BINARY_NAME $INSTALL_DIR/
sudo chmod +x $INSTALL_DIR/$BINARY_NAME
if [[ "$BUILD_DIR" != "." ]]; then
cd - > /dev/null
rm -rf $BUILD_DIR
fi
;;
2)
echo "β Prebuilt binaries not yet available"
echo "π‘ Please use method 1 (build from source) or method 3 (Homebrew)"
exit 1
;;
3)
if [[ "$OS" != "darwin" ]]; then
echo "β Homebrew is only available on macOS"
echo "π‘ Please use method 1 (build from source)"
exit 1
fi
if ! command -v brew &> /dev/null; then
echo "β Homebrew not found. Install it from https://brew.sh"
exit 1
fi
echo "πΊ Installing via Homebrew..."
# For now, install from source since tap isn't published yet
echo "β οΈ Note: Installing from source via Homebrew"
brew install go
BUILD_DIR="/tmp/codecompass-homebrew"
rm -rf $BUILD_DIR
git clone https://github.com/xeon-zolt/codecompass.git $BUILD_DIR
cd $BUILD_DIR
go build -ldflags "-s -w -X main.version=$VERSION -X main.buildDate=$(date +'%Y-%m-%d')" -o $BINARY_NAME
cp $BINARY_NAME /usr/local/bin/
cd - > /dev/null
rm -rf $BUILD_DIR
;;
*)
echo "β Invalid choice"
exit 1
;;
esac
# Create configuration directory
echo ""
echo "βοΈ Setting up configuration..."
mkdir -p $CONFIG_DIR
# Generate sample configuration
$BINARY_NAME --generate-config > /dev/null 2>&1 || true
if [[ -f ".codecompass.rc" ]]; then
cp .codecompass.rc $CONFIG_DIR/codecompass.rc.example
echo "β
Sample configuration created at $CONFIG_DIR/codecompass.rc.example"
fi
# Verify installation
echo ""
echo "π§ͺ Verifying installation..."
if command -v $BINARY_NAME &> /dev/null; then
echo "β
CodeCompass installed successfully!"
VERSION_OUTPUT=$($BINARY_NAME --version)
echo "π $VERSION_OUTPUT"
else
echo "β Installation failed"
exit 1
fi
echo ""
echo "π Installation Complete!"
echo "========================"
echo ""
echo "π Quick Start:"
echo " codecompass --help # Show all available options"
echo " codecompass --summary # Quick repository overview"
echo " codecompass --quality # Comprehensive quality analysis"
echo ""
echo "π Advanced Features:"
echo " codecompass --trends # Trend analysis with charts"
echo " codecompass --hotspots # Detect high-risk code areas"
echo " codecompass --team # Team performance metrics"
echo ""
echo "βοΈ Configuration:"
echo " codecompass --generate-config # Create .codecompass.rc file"
echo " Sample: $CONFIG_DIR/codecompass.rc.example"
echo ""
echo "π Documentation:"
echo " β’ README: https://github.com/xeon-zolt/codecompass/blob/main/README.md"
echo " β’ Homebrew: https://github.com/xeon-zolt/codecompass/blob/main/HOMEBREW.md"
echo ""
echo "π§ Navigate Your Code Quality with CodeCompass!"