forked from hyperb1iss/git-iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·164 lines (142 loc) · 4.3 KB
/
install.sh
File metadata and controls
executable file
·164 lines (142 loc) · 4.3 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
#!/bin/sh
# Git-Iris Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/hyperb1iss/git-iris/main/install.sh | sh
#
# Environment variables:
# IRIS_INSTALL_DIR - Installation directory (default: ~/.local/bin)
# IRIS_VERSION - Specific version to install (default: latest)
set -e
# SilkCircuit Neon colors
CYAN='\033[38;2;128;255;234m'
PURPLE='\033[38;2;225;53;255m'
CORAL='\033[38;2;255;106;193m'
GREEN='\033[38;2;80;250;123m'
YELLOW='\033[38;2;241;250;140m'
RED='\033[38;2;255;99;99m'
RESET='\033[0m'
BOLD='\033[1m'
REPO="hyperb1iss/git-iris"
BINARY_NAME="git-iris"
INSTALL_DIR="${IRIS_INSTALL_DIR:-$HOME/.local/bin}"
info() {
printf '%b>%b %b\n' "$CYAN" "$RESET" "$1"
}
success() {
printf '%b%b%b %b\n' "$GREEN" "✓" "$RESET" "$1"
}
warn() {
printf '%b!%b %b\n' "$YELLOW" "$RESET" "$1"
}
error() {
printf '%b%b%b %b\n' "$RED" "✗" "$RESET" "$1" >&2
exit 1
}
# Detect OS
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "macos" ;;
MINGW* | MSYS* | CYGWIN*) echo "windows" ;;
*) error "Unsupported operating system: $(uname -s)" ;;
esac
}
# Detect architecture
detect_arch() {
case "$(uname -m)" in
x86_64 | amd64) echo "amd64" ;;
aarch64 | arm64) echo "arm64" ;;
*) error "Unsupported architecture: $(uname -m)" ;;
esac
}
# Get latest version from GitHub
get_latest_version() {
if command -v curl >/dev/null 2>&1; then
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/'
elif command -v wget >/dev/null 2>&1; then
wget -qO- "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/'
else
error "curl or wget is required"
fi
}
# Download file
download() {
url="$1"
output="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$output"
elif command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$output"
else
error "curl or wget is required"
fi
}
# Main installation
main() {
printf '\n'
printf '%b%b ◆ Git-Iris Installer%b\n' "$PURPLE" "$BOLD" "$RESET"
printf '%b ─────────────────────%b\n\n' "$CORAL" "$RESET"
# Detect platform
OS=$(detect_os)
ARCH=$(detect_arch)
info "Detected platform: ${BOLD}${OS}-${ARCH}${RESET}"
# Map to artifact names
case "${OS}-${ARCH}" in
linux-amd64) ARTIFACT="git-iris-linux-amd64" ;;
linux-arm64) ARTIFACT="git-iris-linux-arm64" ;;
macos-arm64) ARTIFACT="git-iris-macos-arm64" ;;
macos-amd64)
warn "macOS x86_64 not pre-built, try: cargo install git-iris"
exit 1
;;
windows-*)
warn "For Windows, download from GitHub releases or use: cargo install git-iris"
exit 1
;;
*) error "No pre-built binary for ${OS}-${ARCH}" ;;
esac
# Get version
VERSION="${IRIS_VERSION:-$(get_latest_version)}"
if [ -z "$VERSION" ]; then
error "Failed to determine version"
fi
info "Installing version: ${BOLD}${VERSION}${RESET}"
# Create install directory
mkdir -p "$INSTALL_DIR"
# Download binary
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARTIFACT}"
TMP_FILE=$(mktemp)
info "Downloading from GitHub releases..."
download "$DOWNLOAD_URL" "$TMP_FILE" || error "Download failed. Check if ${VERSION} exists."
# Install binary
mv "$TMP_FILE" "${INSTALL_DIR}/${BINARY_NAME}"
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
success "Installed to ${CYAN}${INSTALL_DIR}/${BINARY_NAME}${RESET}"
# Check PATH
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
printf '\n'
warn "Add ${CYAN}${INSTALL_DIR}${RESET} to your PATH:"
printf '\n'
printf '%b # Add to ~/.bashrc or ~/.zshrc:%b\n' "$CORAL" "$RESET"
printf ' export PATH="$HOME/.local/bin:$PATH"\n'
printf '\n'
;;
esac
# Verify installation
if command -v git-iris >/dev/null 2>&1 || [ -x "${INSTALL_DIR}/${BINARY_NAME}" ]; then
printf '\n'
success "${GREEN}${BOLD}Installation complete!${RESET}"
printf '\n'
printf '%b Get started:%b\n' "$PURPLE" "$RESET"
printf ' git-iris config --provider <openai|anthropic|google>\n'
printf ' git-iris gen %b# Generate commit message%b\n' "$CORAL" "$RESET"
printf ' git-iris studio %b# Launch interactive TUI%b\n' "$CORAL" "$RESET"
printf '\n'
printf '%b Docs: https://hyperb1iss.github.io/git-iris%b\n' "$CYAN" "$RESET"
printf '\n'
else
error "Installation verification failed"
fi
}
main "$@"