-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
71 lines (59 loc) · 1.91 KB
/
Copy pathinstall.sh
File metadata and controls
71 lines (59 loc) · 1.91 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
#!/usr/bin/env sh
#
# Regulus CLI installer.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/neul-labs/regulus/main/install.sh | sh
#
# What it does:
# - downloads the latest regulus-cli.jar to ~/.regulus/bin/
# - drops a shell shim at ~/.regulus/bin/regulus
# - prints the PATH line to add to your shell profile
#
set -eu
INSTALL_DIR="${REGULUS_INSTALL_DIR:-$HOME/.regulus/bin}"
RELEASES_API="https://api.github.com/repos/neul-labs/regulus/releases/latest"
red() { printf '\033[31m%s\033[0m\n' "$*"; }
green() { printf '\033[32m%s\033[0m\n' "$*"; }
blue() { printf '\033[34m%s\033[0m\n' "$*"; }
require() {
if ! command -v "$1" >/dev/null 2>&1; then
red "regulus install: missing required command: $1"
exit 1
fi
}
require curl
require java
mkdir -p "$INSTALL_DIR"
blue "regulus install: resolving latest release..."
ASSET_URL=$(curl -fsSL "$RELEASES_API" \
| grep -E '"browser_download_url".*regulus-cli.*\.jar"' \
| head -n 1 \
| sed -E 's/.*"browser_download_url": "([^"]+)".*/\1/')
if [ -z "$ASSET_URL" ]; then
red "regulus install: could not find regulus-cli jar in latest release."
red " Visit https://github.com/neul-labs/regulus/releases for manual install."
exit 1
fi
blue "regulus install: downloading $ASSET_URL"
curl -fsSL -o "$INSTALL_DIR/regulus-cli.jar" "$ASSET_URL"
cat > "$INSTALL_DIR/regulus" <<'WRAPPER'
#!/usr/bin/env sh
exec java -jar "$(dirname "$0")/regulus-cli.jar" "$@"
WRAPPER
chmod +x "$INSTALL_DIR/regulus"
green "regulus install: installed to $INSTALL_DIR"
echo
case ":$PATH:" in
*":$INSTALL_DIR:"*) green "PATH already includes $INSTALL_DIR — you're set." ;;
*)
blue "Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.):"
echo
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
echo
;;
esac
echo "Verify:"
echo " $INSTALL_DIR/regulus --version"
echo
echo "Docs: https://docs.neullabs.com"