#!/usr/bin/env bash main() { set -euo pipefail Color_Off='' Red='' Green='' Yellow='' Dim='' Bold='' Blue='' if [[ -t 1 ]]; then Color_Off='\033[0m' Red='\033[0;31m' Green='\033[0;32m' Yellow='\033[0;33m' Dim='\033[0;2m' Bold='\033[1m' Blue='\033[0;34m' fi error() { printf "%b\n" "${Red}error${Color_Off}: $*" >&2 exit 1 } info() { printf "%b\n" "${Dim}$*${Color_Off}" } success() { printf "%b\n" "${Green}$*${Color_Off}" } bold() { printf "%b\n" "${Bold}$*${Color_Off}" } command -v curl >/dev/null 2>&1 || error "curl is required but was not found." command -v node >/dev/null 2>&1 || error "node is required but was not found." command -v npm >/dev/null 2>&1 || error "npm is required but was not found." PACKAGE="@remix-gg/cli" VERSION="${1:-latest}" INSTALL_TARGET="${PACKAGE}" if [[ "$VERSION" != "latest" ]]; then INSTALL_TARGET="${PACKAGE}@${VERSION#v}" fi echo "" bold " Installing Remix CLI..." echo "" info " Running npm install -g ${INSTALL_TARGET}" npm install -g "$INSTALL_TARGET" >/dev/null 2>&1 || error "npm global install failed." if ! command -v remix >/dev/null 2>&1; then NPM_BIN=$(npm bin -g 2>/dev/null || true) if [[ -n "$NPM_BIN" ]]; then error "Installed successfully, but \`remix\` is not on PATH.\n\nAdd this directory to PATH and re-open your shell:\n ${NPM_BIN}" fi error "Installed successfully, but \`remix\` is not on PATH." fi INSTALLED_VERSION=$(remix --version 2>/dev/null || echo "unknown") echo "" success " Remix CLI ${INSTALLED_VERSION} installed successfully!" echo "" bold " Run ${Blue}remix --help${Color_Off}${Bold} to get started${Color_Off}" echo "" } main "$@"