-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (84 loc) · 4.05 KB
/
install.sh
File metadata and controls
executable file
·97 lines (84 loc) · 4.05 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
#!/usr/bin/env bash
set -euo pipefail
# bb CLI installer — source-from-clone approach
# Adds a `source` line to your shell RC pointing to this repo's bb.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BB_SCRIPT="$SCRIPT_DIR/bb.sh"
# ── Detect shell RC file ─────────────────────────────────────────────────────────
detect_rc() {
local shell_name
shell_name=$(basename "$SHELL")
case "$shell_name" in
zsh) echo "$HOME/.zshrc" ;;
bash) echo "$HOME/.bashrc" ;;
*) echo "$HOME/.${shell_name}rc" ;;
esac
}
RC_FILE=$(detect_rc)
SOURCE_LINE="source \"$BB_SCRIPT\""
MARKER="# bb-cli"
# ── Colors ───────────────────────────────────────────────────────────────────────
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
NC='\033[0m'
echo ""
echo "┌──────────────────────────────────────────────────────────────────┐"
echo "│ bb CLI — Installer │"
echo "└──────────────────────────────────────────────────────────────────┘"
echo ""
# ── Check prerequisites ──────────────────────────────────────────────────────────
echo " Checking prerequisites..."
missing=()
command -v curl >/dev/null 2>&1 || missing+=("curl")
command -v jq >/dev/null 2>&1 || missing+=("jq (brew install jq)")
command -v python3 >/dev/null 2>&1 || missing+=("python3")
command -v git >/dev/null 2>&1 || missing+=("git")
if [[ ${#missing[@]} -gt 0 ]]; then
echo -e " ${RED}Missing dependencies:${NC}"
for dep in "${missing[@]}"; do
echo " - $dep"
done
echo ""
echo " Install them and re-run this script."
exit 1
fi
echo -e " ${GREEN}All prerequisites found.${NC}"
echo ""
# ── Add source line to shell RC ──────────────────────────────────────────────────
if grep -qF "$BB_SCRIPT" "$RC_FILE" 2>/dev/null; then
echo -e " ${YELLOW}Already installed.${NC} Source line found in $RC_FILE"
else
echo "" >> "$RC_FILE"
echo "$SOURCE_LINE $MARKER" >> "$RC_FILE"
echo -e " ${GREEN}Added to $RC_FILE:${NC}"
echo " $SOURCE_LINE"
fi
echo ""
# ── Create config directory ──────────────────────────────────────────────────────
mkdir -p "$HOME/.config/bb"
# ── Run setup if no credentials exist ────────────────────────────────────────────
if [[ ! -f "$HOME/.config/bb/credentials" ]]; then
echo " No credentials found. Starting setup..."
echo ""
# Source the script and run setup
source "$BB_SCRIPT"
_bb_setup
else
echo -e " ${GREEN}Credentials already configured.${NC}"
echo " Run 'bb setup' anytime to reconfigure."
fi
echo ""
echo " ────────────────────────────────────────────────────────"
echo -e " ${GREEN}Installation complete!${NC}"
echo ""
echo " Reload your shell or run:"
echo " source $RC_FILE"
echo ""
echo " Then try:"
echo " bb auth status"
echo " bb help"
echo ""
echo " To update bb CLI later, just 'git pull' in this directory."
echo " ────────────────────────────────────────────────────────"
echo ""