-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·135 lines (120 loc) · 3.19 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·135 lines (120 loc) · 3.19 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
#!/usr/bin/env sh
# setup.sh ─────────────────────────────────────────────────────────
# Portable global tool installer for macOS (POSIX shell)
# Requirements:
# - homebrew (https://brew.sh)
# - node v20+
#
# Usage:
# 1. Clone & run locally:
# git clone https://github.com/sablier-labs/devkit.git
# cd devkit/shell
# sh setup.sh
# # Or make it executable:
# chmod +x setup.sh
# ./setup.sh
#
# 2. Directly from GitHub:
# curl -fsSL https://raw.githubusercontent.com/sablier-labs/devkit/main/shell/setup.sh | sh
# Exit on error or undefined variable
set -eu
LOG_FILE="sablier_devkit_setup.log"
printf "Logging to %s\n" "$LOG_FILE"
# Redirect both stdout and stderr to log file
exec >>"$LOG_FILE" 2>&1
# Check if command exists
check_command() {
cmd="$1"
if command -v "$cmd" >/dev/null 2>&1; then
printf "✓ %s is already installed\n" "$cmd"
return 0
else
printf "✗ %s is not installed\n" "$cmd"
return 1
fi
}
# OS check
OS="$(uname -s)"
if [ "$OS" != "Darwin" ]; then
printf "⚠️ Unsupported OS: %s. This script works only on macOS.\n" "$OS" 1>&2
exit 1
fi
# Ensure Homebrew
if ! command -v brew >/dev/null 2>&1; then
printf "Homebrew not found. Please install it: https://brew.sh\n" 1>&2
exit 1
fi
# Check Node.js version
if ! command -v node >/dev/null 2>&1; then
printf "✗ node is not installed. Install Node.js v20+ and rerun.\n" 1>&2
exit 1
fi
NODE_VERSION="$(node -v)"
# Extract major version
NODE_MAJOR=$(printf "%s" "$NODE_VERSION" | sed -E 's/^v([0-9]+)\..*/\1/')
case "$NODE_MAJOR" in
'' | *[!0-9]*)
printf "✗ Could not parse Node.js version: %s\n" "$NODE_VERSION" 1>&2
exit 1
;;
*)
if [ "$NODE_MAJOR" -lt 20 ]; then
printf "✗ Node.js v20+ required (found %s)\n" "$NODE_VERSION" 1>&2
exit 1
else
printf "✓ Node.js %s\n" "$NODE_VERSION"
fi
;;
esac
# Installer functions
install_just() {
if ! check_command just; then
printf "Installing Just...\n"
brew install just
fi
}
install_bun() {
if ! check_command bun; then
printf "Installing Bun...\n"
npm install -g bun
fi
}
install_ni() {
if ! check_command ni; then
printf "Installing Ni...\n"
npm install -g @antfu/ni
fi
}
install_foundry() {
if ! check_command forge; then
printf "Installing Foundry...\n"
curl -L https://foundry.paradigm.xyz | sh
# ensure foundryup in PATH
if command -v foundryup >/dev/null 2>&1; then
foundryup
fi
fi
}
install_rust() {
if ! check_command rustc; then
printf "Installing Rust...\n"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
printf "To use Rust tools, ensure %s/.cargo/bin is in your PATH.\n" "$HOME"
fi
}
install_bulloak() {
if ! check_command bulloak; then
printf "Installing Bulloak...\n"
cargo install bulloak
fi
}
# Main installation
printf "=== Starting installation ===\n"
install_bun
install_foundry
install_just
install_ni
install_rust
install_bulloak
printf "=== Installation complete! ===\n"
printf "Ensure your shell PATH includes npm globals and %s/.cargo/bin if not already.\n" "$HOME"