#!/bin/sh # Konigle CLI installer # # Usage: # curl -fsSL https://hostbento.com/install/cli | sh # set -e PACKAGE="konigle" UV_INSTALL="https://astral.sh/uv/install.sh" BOLD="\033[1m" GREEN="\033[0;32m" YELLOW="\033[0;33m" RED="\033[0;31m" DIM="\033[2m" RESET="\033[0m" info() { printf "${BOLD} %s${RESET}\n" "$1"; } success() { printf "${GREEN} ✓ %s${RESET}\n" "$1"; } warn() { printf "${YELLOW} ! %s${RESET}\n" "$1"; } step() { printf "${DIM} → %s${RESET}\n" "$1"; } error() { printf "${RED} ✗ error: %s${RESET}\n" "$1" >&2; exit 1; } # --------------------------------------------------------------------------- # OS check # --------------------------------------------------------------------------- OS="$(uname -s)" case "$OS" in Linux|Darwin) ;; *) error "Unsupported OS: $OS. Only Linux and macOS are supported." ;; esac # --------------------------------------------------------------------------- # Bootstrap uv (manages its own Python — no system Python required) # --------------------------------------------------------------------------- ensure_uv() { if command -v uv > /dev/null 2>&1; then return 0 fi step "uv not found — installing uv..." if ! command -v curl > /dev/null 2>&1; then error "curl is required to install uv. Please install curl and try again." fi curl -LsSf "$UV_INSTALL" | sh # Add the most common uv install locations to PATH for this session. for dir in "$HOME/.local/bin" "$HOME/.cargo/bin"; do if [ -x "$dir/uv" ]; then export PATH="$dir:$PATH" break fi done if ! command -v uv > /dev/null 2>&1; then error "uv installed but not found on PATH. Open a new terminal and run: uv tool install $PACKAGE" fi success "uv installed" } # --------------------------------------------------------------------------- # Install the konigle CLI as an isolated tool # --------------------------------------------------------------------------- install_konigle() { if uv tool list 2>/dev/null | grep -q "^$PACKAGE "; then step "Upgrading konigle CLI..." uv tool upgrade "$PACKAGE" --quiet success "konigle CLI upgraded to $(konigle --version 2>/dev/null || echo 'latest')" else step "Installing konigle CLI..." uv tool install "$PACKAGE" --quiet success "konigle CLI installed" fi } # --------------------------------------------------------------------------- # PATH hint — uv tool binaries land in ~/.local/bin # --------------------------------------------------------------------------- print_path_hint() { TOOL_BIN="$(uv tool dir)/bin" case ":$PATH:" in *":$TOOL_BIN:"*) return ;; esac printf "\n" warn "Add the following to your shell profile to make 'konigle' available:" printf "\n" printf " ${BOLD}export PATH=\"$TOOL_BIN:\$PATH\"${RESET}\n" printf "\n" warn "Then restart your terminal or run: source ~/.zshrc (or ~/.bashrc)" } # --------------------------------------------------------------------------- # Main # --------------------------------------------------------------------------- printf "\n" printf "${BOLD}Konigle CLI${RESET}\n" printf "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" printf "\n" ensure_uv install_konigle print_path_hint printf "\n" printf "${BOLD}Quick start:${RESET}\n" printf "\n" printf " ${DIM}# Add your Konigle project${RESET}\n" printf " konigle projects add mysite --api-key YOUR_API_KEY\n" printf "\n" printf " ${DIM}# Link your app directory and deploy${RESET}\n" printf " cd your-app\n" printf " konigle cloud link\n" printf " konigle cloud deploy\n" printf "\n" printf " ${DIM}# Promote to production when ready${RESET}\n" printf " konigle cloud promote\n" printf "\n" printf "${DIM}Docs: https://konigle.github.io/konigle-python/${RESET}\n" printf "\n"