|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Ensure we're running with bash |
| 4 | +if [ -z "$BASH_VERSION" ]; then |
| 5 | + echo "This script must be run with bash" |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | + |
| 9 | +menu() { |
| 10 | + echo -e "\n📋 Which eval types would you like to support?\n" |
| 11 | + |
| 12 | + for i in ${!options[@]}; do |
| 13 | + printf " %d) %-6s [%s]" $((i + 1)) "${options[i]}" "${choices[i]:- }" |
| 14 | + |
| 15 | + if [[ $i == 0 ]]; then |
| 16 | + printf " (required)" |
| 17 | + fi |
| 18 | + |
| 19 | + printf "\n" |
| 20 | + done |
| 21 | + |
| 22 | + echo -e " q) quit\n" |
| 23 | +} |
| 24 | + |
| 25 | +has_asdf_plugin() { |
| 26 | + local plugin="$1" |
| 27 | + case "$plugin" in |
| 28 | + nodejs|python|golang|rust) echo "true" ;; |
| 29 | + *) echo "false" ;; |
| 30 | + esac |
| 31 | +} |
| 32 | + |
| 33 | +build_extension() { |
| 34 | + echo "🔨 Building the Roo Code extension..." |
| 35 | + cd .. |
| 36 | + mkdir -p bin |
| 37 | + npm run install-extension -- --silent --no-audit || exit 1 |
| 38 | + npm run install-webview -- --silent --no-audit || exit 1 |
| 39 | + npm run install-e2e -- --silent --no-audit || exit 1 |
| 40 | + npx vsce package --out bin/roo-code-latest.vsix || exit 1 |
| 41 | + code --install-extension bin/roo-code-latest.vsix || exit 1 |
| 42 | + cd evals |
| 43 | +} |
| 44 | + |
| 45 | +# Detect OS type |
| 46 | +OS_TYPE=$(uname -s) |
| 47 | +if [[ "$OS_TYPE" != "Linux" ]]; then |
| 48 | + echo "⚠️ This script is now configured for Ubuntu Linux only." |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | + |
| 52 | +# Check if running on Ubuntu |
| 53 | +if ! command -v lsb_release &>/dev/null || [[ "$(lsb_release -si)" != "Ubuntu" ]]; then |
| 54 | + echo "⚠️ This script is only supported on Ubuntu Linux." |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | + |
| 58 | +options=("nodejs" "python" "golang" "rust" "java") |
| 59 | +binaries=("node" "python" "go" "rustc" "javac") |
| 60 | + |
| 61 | +for i in "${!options[@]}"; do |
| 62 | + choices[i]="*" |
| 63 | +done |
| 64 | + |
| 65 | +prompt="Type 1-5 to select, 'q' to quit, ⏎ to continue: " |
| 66 | + |
| 67 | +while menu && read -rp "$prompt" num && [[ "$num" ]]; do |
| 68 | + [[ "$num" == "q" ]] && exit 0 |
| 69 | + |
| 70 | + [[ "$num" != *[![:digit:]]* ]] && |
| 71 | + ((num > 1 && num <= ${#options[@]})) || |
| 72 | + { |
| 73 | + continue |
| 74 | + } |
| 75 | + |
| 76 | + ((num--)) |
| 77 | + [[ "${choices[num]}" ]] && choices[num]="" || choices[num]="*" |
| 78 | +done |
| 79 | + |
| 80 | +empty=true |
| 81 | + |
| 82 | +for i in ${!options[@]}; do |
| 83 | + [[ "${choices[i]}" ]] && { |
| 84 | + empty=false |
| 85 | + break |
| 86 | + } |
| 87 | +done |
| 88 | + |
| 89 | +[[ "$empty" == true ]] && exit 0 |
| 90 | + |
| 91 | +printf "\n" |
| 92 | + |
| 93 | +# Update package lists |
| 94 | +echo "🔄 Updating package lists..." |
| 95 | +sudo apt-get update || exit 1 |
| 96 | + |
| 97 | +# Install required system packages |
| 98 | +echo "📦 Installing required system packages..." |
| 99 | +sudo apt-get install -y \ |
| 100 | + curl \ |
| 101 | + git \ |
| 102 | + build-essential \ |
| 103 | + pkg-config \ |
| 104 | + libssl-dev \ |
| 105 | + || exit 1 |
| 106 | + |
| 107 | +# Install asdf |
| 108 | +if ! command -v asdf &>/dev/null; then |
| 109 | + echo "🛠️ Installing asdf..." |
| 110 | + git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1 || exit 1 |
| 111 | + |
| 112 | + # Add asdf to shell configuration |
| 113 | + if [[ "$SHELL" == */bash ]]; then |
| 114 | + echo ". \"\$HOME/.asdf/asdf.sh\"" >> ~/.bashrc |
| 115 | + echo ". \"\$HOME/.asdf/completions/asdf.bash\"" >> ~/.bashrc |
| 116 | + elif [[ "$SHELL" == */zsh ]]; then |
| 117 | + echo ". \"\$HOME/.asdf/asdf.sh\"" >> ~/.zshrc |
| 118 | + echo ". \"\$HOME/.asdf/completions/asdf.zsh\"" >> ~/.zshrc |
| 119 | + fi |
| 120 | + |
| 121 | + . "$HOME/.asdf/asdf.sh" |
| 122 | + ASDF_VERSION=$(asdf --version) |
| 123 | + echo "✅ asdf is installed ($ASDF_VERSION)" |
| 124 | +else |
| 125 | + ASDF_VERSION=$(asdf --version) |
| 126 | + echo "✅ asdf is installed ($ASDF_VERSION)" |
| 127 | +fi |
| 128 | + |
| 129 | +# Install GitHub CLI |
| 130 | +if ! command -v gh &>/dev/null; then |
| 131 | + echo "👨💻 Installing GitHub CLI..." |
| 132 | + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg |
| 133 | + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null |
| 134 | + sudo apt-get update |
| 135 | + sudo apt-get install -y gh |
| 136 | + GH_VERSION=$(gh --version | head -n 1) |
| 137 | + echo "✅ gh is installed ($GH_VERSION)" |
| 138 | + gh auth status || gh auth login -w -p https |
| 139 | +else |
| 140 | + GH_VERSION=$(gh --version | head -n 1) |
| 141 | + echo "✅ gh is installed ($GH_VERSION)" |
| 142 | +fi |
| 143 | + |
| 144 | +for i in "${!options[@]}"; do |
| 145 | + [[ "${choices[i]}" ]] || continue |
| 146 | + |
| 147 | + plugin="${options[$i]}" |
| 148 | + binary="${binaries[$i]}" |
| 149 | + |
| 150 | + if [[ "$(has_asdf_plugin "$plugin")" == "true" ]]; then |
| 151 | + if ! asdf plugin list | grep -q "^${plugin}$" && ! command -v "${binary}" &>/dev/null; then |
| 152 | + echo "📦 Installing ${plugin} asdf plugin..." |
| 153 | + asdf plugin add "${plugin}" || exit 1 |
| 154 | + echo "✅ asdf ${plugin} plugin installed successfully" |
| 155 | + fi |
| 156 | + fi |
| 157 | + |
| 158 | + case "${plugin}" in |
| 159 | + "nodejs") |
| 160 | + if ! command -v node &>/dev/null; then |
| 161 | + asdf install nodejs v20.18.1 || exit 1 |
| 162 | + asdf set nodejs v20.18.1 || exit 1 |
| 163 | + NODE_VERSION=$(node --version) |
| 164 | + echo "✅ Node.js is installed ($NODE_VERSION)" |
| 165 | + else |
| 166 | + NODE_VERSION=$(node --version) |
| 167 | + echo "✅ Node.js is installed ($NODE_VERSION)" |
| 168 | + fi |
| 169 | + |
| 170 | + if [[ $(node --version) != "v20.18.1" ]]; then |
| 171 | + NODE_VERSION=$(node --version) |
| 172 | + echo "🚨 You have the wrong version of node installed ($NODE_VERSION)." |
| 173 | + echo "💡 If you are using nvm then run 'nvm install' to install the version specified by the repo's .nvmrc." |
| 174 | + exit 1 |
| 175 | + fi |
| 176 | + ;; |
| 177 | + |
| 178 | + "python") |
| 179 | + if ! command -v python &>/dev/null; then |
| 180 | + asdf install python 3.13.2 || exit 1 |
| 181 | + asdf set python 3.13.2 || exit 1 |
| 182 | + PYTHON_VERSION=$(python --version) |
| 183 | + echo "✅ Python is installed ($PYTHON_VERSION)" |
| 184 | + else |
| 185 | + PYTHON_VERSION=$(python --version) |
| 186 | + echo "✅ Python is installed ($PYTHON_VERSION)" |
| 187 | + fi |
| 188 | + |
| 189 | + if ! command -v uv &>/dev/null; then |
| 190 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 191 | + UV_VERSION=$(uv --version) |
| 192 | + echo "✅ uv is installed ($UV_VERSION)" |
| 193 | + else |
| 194 | + UV_VERSION=$(uv --version) |
| 195 | + echo "✅ uv is installed ($UV_VERSION)" |
| 196 | + fi |
| 197 | + ;; |
| 198 | + |
| 199 | + "golang") |
| 200 | + if ! command -v go &>/dev/null; then |
| 201 | + asdf install golang 1.24.2 || exit 1 |
| 202 | + asdf set golang 1.24.2 || exit 1 |
| 203 | + GO_VERSION=$(go version) |
| 204 | + echo "✅ Go is installed ($GO_VERSION)" |
| 205 | + else |
| 206 | + GO_VERSION=$(go version) |
| 207 | + echo "✅ Go is installed ($GO_VERSION)" |
| 208 | + fi |
| 209 | + ;; |
| 210 | + |
| 211 | + "rust") |
| 212 | + if ! command -v rustc &>/dev/null; then |
| 213 | + asdf install rust 1.85.1 || exit 1 |
| 214 | + asdf set rust 1.85.1 || exit 1 |
| 215 | + RUST_VERSION=$(rustc --version) |
| 216 | + echo "✅ Rust is installed ($RUST_VERSION)" |
| 217 | + else |
| 218 | + RUST_VERSION=$(rustc --version) |
| 219 | + echo "✅ Rust is installed ($RUST_VERSION)" |
| 220 | + fi |
| 221 | + ;; |
| 222 | + |
| 223 | + "java") |
| 224 | + if ! command -v javac &>/dev/null || ! javac --version &>/dev/null; then |
| 225 | + echo "☕ Installing Java..." |
| 226 | + sudo apt-get install -y openjdk-17-jdk || exit 1 |
| 227 | + |
| 228 | + # Update alternatives |
| 229 | + sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java |
| 230 | + sudo update-alternatives --set javac /usr/lib/jvm/java-17-openjdk-amd64/bin/javac |
| 231 | + |
| 232 | + JAVA_VERSION=$(javac --version | head -n 1) |
| 233 | + echo "✅ Java is installed ($JAVA_VERSION)" |
| 234 | + else |
| 235 | + JAVA_VERSION=$(javac --version | head -n 1) |
| 236 | + echo "✅ Java is installed ($JAVA_VERSION)" |
| 237 | + fi |
| 238 | + ;; |
| 239 | + esac |
| 240 | +done |
| 241 | + |
| 242 | +# Install pnpm |
| 243 | +if ! command -v pnpm &>/dev/null; then |
| 244 | + echo "📦 Installing pnpm..." |
| 245 | + curl -fsSL https://get.pnpm.io/install.sh | sh - |
| 246 | + PNPM_VERSION=$(pnpm --version) |
| 247 | + echo "✅ pnpm is installed ($PNPM_VERSION)" |
| 248 | +else |
| 249 | + PNPM_VERSION=$(pnpm --version) |
| 250 | + echo "✅ pnpm is installed ($PNPM_VERSION)" |
| 251 | +fi |
| 252 | + |
| 253 | +pnpm install --silent || exit 1 |
| 254 | + |
| 255 | +if [[ ! -d "../../evals" ]]; then |
| 256 | + if gh auth status &>/dev/null; then |
| 257 | + read -p "🔗 Would you like to be able to share eval results? (Y/n): " fork_evals |
| 258 | + |
| 259 | + if [[ "$fork_evals" =~ ^[Yy]|^$ ]]; then |
| 260 | + gh repo fork cte/evals --clone ../../evals || exit 1 |
| 261 | + else |
| 262 | + gh repo clone cte/evals ../../evals || exit 1 |
| 263 | + fi |
| 264 | + else |
| 265 | + git clone https://github.com/cte/evals.git ../../evals || exit 1 |
| 266 | + fi |
| 267 | +fi |
| 268 | + |
| 269 | +if [[ ! -s .env ]]; then |
| 270 | + cp .env.sample .env || exit 1 |
| 271 | +fi |
| 272 | + |
| 273 | +if [[ ! -s /tmp/evals.db ]]; then |
| 274 | + echo "🗄️ Creating database..." |
| 275 | + pnpm --filter @evals/db db:push || exit 1 |
| 276 | + pnpm --filter @evals/db db:enable-wal || exit 1 |
| 277 | +fi |
| 278 | + |
| 279 | +if ! grep -q "OPENROUTER_API_KEY" .env; then |
| 280 | + read -p "🔐 Enter your OpenRouter API key (sk-or-v1-...): " openrouter_api_key |
| 281 | + echo "🔑 Validating..." |
| 282 | + curl --silent --fail https://openrouter.ai/api/v1/key -H "Authorization: Bearer $openrouter_api_key" &>/dev/null || exit 1 |
| 283 | + echo "OPENROUTER_API_KEY=$openrouter_api_key" >> .env || exit 1 |
| 284 | +fi |
| 285 | + |
| 286 | +if ! command -v code &>/dev/null; then |
| 287 | + echo "⚠️ Visual Studio Code cli is not installed" |
| 288 | + exit 1 |
| 289 | +else |
| 290 | + VSCODE_VERSION=$(code --version | head -n 1) |
| 291 | + echo "✅ Visual Studio Code is installed ($VSCODE_VERSION)" |
| 292 | +fi |
| 293 | + |
| 294 | +if [[ ! -s "../bin/roo-code-latest.vsix" ]]; then |
| 295 | + build_extension |
| 296 | +else |
| 297 | + read -p "💻 Do you want to build a new version of the Roo Code extension? (y/N): " build_extension |
| 298 | + |
| 299 | + if [[ "$build_extension" =~ ^[Yy]$ ]]; then |
| 300 | + build_extension |
| 301 | + fi |
| 302 | +fi |
| 303 | + |
| 304 | +echo -e "\n🚀 You're ready to rock and roll! \n" |
| 305 | + |
| 306 | +if ! nc -z localhost 3000; then |
| 307 | + read -p "🌐 Would you like to start the evals web app? (Y/n): " start_evals |
| 308 | + |
| 309 | + if [[ "$start_evals" =~ ^[Yy]|^$ ]]; then |
| 310 | + pnpm web |
| 311 | + else |
| 312 | + echo "💡 You can start it anytime with 'pnpm web'." |
| 313 | + fi |
| 314 | +else |
| 315 | + echo "👟 The evals web app is running at http://localhost:3000" |
| 316 | +fi |
0 commit comments