-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
143 lines (116 loc) · 4.66 KB
/
install.sh
File metadata and controls
143 lines (116 loc) · 4.66 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
#!/usr/bin/env bash
# Codekin installer
# curl -fsSL https://raw.githubusercontent.com/Multiplier-Labs/codekin/main/install.sh | bash
set -euo pipefail
CODEKIN_VERSION="${CODEKIN_VERSION:-latest}"
MIN_NODE_VERSION=20
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
info() { printf '\033[0;34m[codekin]\033[0m %s\n' "$*"; }
success() { printf '\033[0;32m[codekin]\033[0m %s\n' "$*"; }
warn() { printf '\033[0;33m[codekin]\033[0m %s\n' "$*" >&2; }
die() { printf '\033[0;31m[codekin]\033[0m ERROR: %s\n' "$*" >&2; exit 1; }
# ---------------------------------------------------------------------------
# 1. Check / install Node.js
# ---------------------------------------------------------------------------
node_version() {
node -e "process.stdout.write(process.version.slice(1).split('.')[0])" 2>/dev/null || echo "0"
}
ensure_node() {
if command -v node &>/dev/null && [[ $(node_version) -ge $MIN_NODE_VERSION ]]; then
info "Node.js $(node --version) found."
return
fi
info "Node.js >=${MIN_NODE_VERSION} not found. Installing via nvm..."
# Install nvm if needed
if ! command -v nvm &>/dev/null && [[ ! -f "$HOME/.nvm/nvm.sh" ]]; then
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh | bash
fi
# shellcheck disable=SC1090
source "$HOME/.nvm/nvm.sh" 2>/dev/null || true
nvm install --lts
nvm use --lts
command -v node &>/dev/null || die "Node.js installation failed. Install manually: https://nodejs.org"
info "Node.js $(node --version) installed."
}
# ---------------------------------------------------------------------------
# 2. Check Claude Code CLI
# ---------------------------------------------------------------------------
check_claude() {
if ! command -v claude &>/dev/null; then
warn "Claude Code CLI not found."
info "Install it with: npm install -g @anthropic-ai/claude-code"
info "Then run 'claude' once to authenticate, and re-run this installer."
exit 1
fi
info "Claude Code CLI found ($(claude --version 2>/dev/null | head -1 || echo 'unknown version'))."
}
# ---------------------------------------------------------------------------
# 3. Check GitHub CLI auth
# ---------------------------------------------------------------------------
check_github() {
if ! command -v gh &>/dev/null; then
warn "GitHub CLI (gh) not found."
info "The repo browser needs 'gh' to list and clone your repositories."
info "Install it: https://cli.github.com"
info "Then run: gh auth login"
echo ""
return
fi
if ! gh auth status &>/dev/null; then
warn "GitHub CLI is not authenticated."
info "The repo browser needs GitHub auth to list and clone your repositories."
info "Run this after installation: gh auth login"
echo ""
return
fi
info "GitHub CLI authenticated ($(gh auth status 2>&1 | grep -o 'Logged in to [^ ]*' | head -1 || echo 'ok'))."
}
# ---------------------------------------------------------------------------
# 4. Install / upgrade codekin
# ---------------------------------------------------------------------------
install_codekin() {
if [[ "$CODEKIN_VERSION" == "latest" ]]; then
info "Installing codekin (latest)..."
npm install -g codekin --loglevel=error
else
info "Installing codekin@${CODEKIN_VERSION}..."
npm install -g "codekin@${CODEKIN_VERSION}" --loglevel=error
fi
success "codekin $(codekin --version 2>/dev/null || echo 'installed')."
}
# ---------------------------------------------------------------------------
# 5. First-time setup (idempotent)
# ---------------------------------------------------------------------------
run_setup() {
mkdir -p "$HOME/.config/codekin"
# Delegate to the CLI (token generation, env file write)
# Redirect stdin from /dev/tty so interactive prompts work when piped (curl | bash)
codekin setup </dev/tty
}
# ---------------------------------------------------------------------------
# 6. Install background service
# ---------------------------------------------------------------------------
install_service() {
info "Installing background service..."
codekin service install </dev/tty
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
echo ""
echo " Codekin Installer"
echo " ================="
echo ""
ensure_node
check_claude
check_github
install_codekin
run_setup
install_service
echo ""
success "Installation complete!"
info "Run 'codekin token' at any time to get your access URL."
info "Run 'codekin service status' to check the service."
echo ""