-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathinstall-local.sh
More file actions
executable file
·129 lines (115 loc) · 3.89 KB
/
install-local.sh
File metadata and controls
executable file
·129 lines (115 loc) · 3.89 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
#!/usr/bin/env bash
# Install autohand CLI locally
# Usage: ./install-local.sh
set -e
SKIP_COMPILE=false
if [ "${1:-}" = "--skip-compile" ]; then
SKIP_COMPILE=true
fi
echo "🚀 Installing Autohand CLI..."
# Detect platform
OS=$(uname -s)
ARCH=$(uname -m)
if [ "$OS" = "Darwin" ]; then
if [ "$ARCH" = "arm64" ]; then
BINARY="autohand-macos-arm64"
else
BINARY="autohand-macos-x64"
fi
elif [ "$OS" = "Linux" ]; then
if [ "$ARCH" = "x86_64" ]; then
BINARY="autohand-linux-x64"
elif [ "$ARCH" = "aarch64" ]; then
BINARY="autohand-linux-arm64"
else
echo "❌ Unsupported architecture: $ARCH"
exit 1
fi
else
echo "❌ Unsupported OS: $OS (use Windows installer for Windows)"
exit 1
fi
# Remove existing installations from all common paths
echo "🧹 Removing existing autohand installations..."
POSSIBLE_PATHS=(
"/usr/local/bin/autohand"
"/usr/bin/autohand"
"/opt/homebrew/bin/autohand"
"$HOME/.local/bin/autohand"
"$HOME/bin/autohand"
"$HOME/.bun/bin/autohand"
"$HOME/.autohand/bin/autohand"
)
for path in "${POSSIBLE_PATHS[@]}"; do
if [ -f "$path" ]; then
echo " Removing $path..."
if [ -w "$(dirname "$path")" ]; then
rm -f "$path"
else
sudo rm -f "$path"
fi
fi
done
# Also check if autohand is linked via npm/bun
if command -v autohand &> /dev/null; then
EXISTING=$(which autohand 2>/dev/null || true)
if [ -n "$EXISTING" ] && [ -f "$EXISTING" ]; then
echo " Removing $EXISTING..."
if [ -w "$(dirname "$EXISTING")" ]; then
rm -f "$EXISTING"
else
sudo rm -f "$EXISTING"
fi
fi
fi
echo "✅ Cleaned up existing installations"
if [ "$SKIP_COMPILE" = false ]; then
# Always compile fresh to ensure latest code
echo "📦 Compiling latest $BINARY..."
case "$BINARY" in
autohand-macos-arm64)
env -i PATH="$HOME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" HOME="$HOME" bun build ./src/index.ts --compile --target=bun-darwin-arm64 --outfile ./binaries/autohand-macos-arm64
;;
autohand-macos-x64)
env -i PATH="$HOME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" HOME="$HOME" bun build ./src/index.ts --compile --target=bun-darwin-x64 --outfile ./binaries/autohand-macos-x64
;;
autohand-linux-x64)
env -i PATH="$HOME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" HOME="$HOME" bun build ./src/index.ts --compile --target=bun-linux-x64 --outfile ./binaries/autohand-linux-x64
;;
autohand-linux-arm64)
env -i PATH="$HOME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" HOME="$HOME" bun build ./src/index.ts --compile --target=bun-linux-arm64 --outfile ./binaries/autohand-linux-arm64
;;
*)
echo "❌ Unsupported binary target: $BINARY"
exit 1
;;
esac
elif [ ! -f "binaries/$BINARY" ]; then
echo "❌ Missing precompiled binary: binaries/$BINARY"
exit 1
fi
# Install to /usr/local/bin when writable, otherwise use the user-local bin.
if [ -w "/usr/local/bin" ]; then
INSTALL_PATH="/usr/local/bin/autohand"
else
mkdir -p "$HOME/.local/bin"
INSTALL_PATH="$HOME/.local/bin/autohand"
fi
echo "📥 Installing to $INSTALL_PATH..."
if [ -w "$(dirname "$INSTALL_PATH")" ]; then
cp "binaries/$BINARY" "$INSTALL_PATH"
chmod +x "$INSTALL_PATH"
else
sudo cp "binaries/$BINARY" "$INSTALL_PATH"
sudo chmod +x "$INSTALL_PATH"
fi
# Verify installation
echo ""
echo "✅ Autohand installed successfully!"
INSTALLED_VERSION=$("$INSTALL_PATH" --version 2>/dev/null || echo "unknown")
echo " Version: $INSTALLED_VERSION"
echo " Path: $INSTALL_PATH"
echo ""
echo "Try it out:"
echo " autohand --help"
echo " autohand"