#!/bin/sh set -e # Umono CLI Installer # Usage: curl -fsSL https://umono.io/install.sh | sh REPO="umono-cms/cli" INSTALL_DIR="$HOME/.local/bin" BINARY_NAME="umono" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color info() { printf "${GREEN}==>${NC} %s\n" "$1" } warn() { printf "${YELLOW}warning:${NC} %s\n" "$1" } error() { printf "${RED}error:${NC} %s\n" "$1" >&2 exit 1 } # Detect OS detect_os() { case "$(uname -s)" in Linux*) echo "linux" ;; Darwin*) echo "darwin" ;; *) error "Unsupported operating system: $(uname -s)" ;; esac } # Detect architecture detect_arch() { case "$(uname -m)" in x86_64) echo "amd64" ;; amd64) echo "amd64" ;; arm64) echo "arm64" ;; aarch64) echo "arm64" ;; *) error "Unsupported architecture: $(uname -m)" ;; esac } # Get latest release version from GitHub get_latest_version() { if command -v curl > /dev/null 2>&1; then curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' elif command -v wget > /dev/null 2>&1; then wget -qO- "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' else error "curl or wget is required" fi } # Download file download() { url="$1" output="$2" if command -v curl > /dev/null 2>&1; then curl -fsSL "$url" -o "$output" elif command -v wget > /dev/null 2>&1; then wget -q "$url" -O "$output" else error "curl or wget is required" fi } # Check if directory is in PATH check_path() { case ":$PATH:" in *":$1:"*) return 0 ;; *) return 1 ;; esac } main() { info "Installing Umono CLI..." OS=$(detect_os) ARCH=$(detect_arch) info "Detected platform: ${OS}/${ARCH}" # Get latest version VERSION=$(get_latest_version) if [ -z "$VERSION" ]; then error "Failed to get latest version" fi info "Latest version: ${VERSION}" # Create install directory if it doesn't exist mkdir -p "$INSTALL_DIR" # Build download URL ARCHIVE_NAME="umono-cli_${VERSION}_${OS}_${ARCH}.tar.gz" DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE_NAME}" # Create temp directory TMP_DIR=$(mktemp -d) trap 'rm -rf "$TMP_DIR"' EXIT # Download info "Downloading ${ARCHIVE_NAME}..." download "$DOWNLOAD_URL" "$TMP_DIR/archive.tar.gz" # Extract info "Extracting..." tar -xzf "$TMP_DIR/archive.tar.gz" -C "$TMP_DIR" # Install info "Installing to ${INSTALL_DIR}..." mv "$TMP_DIR/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME" chmod +x "$INSTALL_DIR/$BINARY_NAME" # Verify installation printf "\n" info "Umono CLI installed successfully!" printf "\n" echo " Version: ${VERSION}" echo " Path: ${INSTALL_DIR}/${BINARY_NAME}" printf "\n" # Check PATH if ! check_path "$INSTALL_DIR"; then warn "$INSTALL_DIR is not in your PATH" printf "\n" echo "Add this to your shell config (~/.bashrc, ~/.zshrc, etc.):" printf "\n" echo " export PATH=\"\$HOME/.local/bin:\$PATH\"" printf "\n" echo "Then restart your terminal or run: source ~/.bashrc" printf "\n" else echo "Get started:" echo " umono create my-website" printf "\n" fi } main