#!/usr/bin/env bash
set -e

# Orbicus CLI One-Line Installer
REPO="Jafar-Sabaouni/orbicus"
TAG="v1.0.0"

echo "Installing Orbicus CLI (@orbicus/cli $TAG)..."

if command -v npm >/dev/null 2>&1; then
  echo "Found Node.js/npm. Installing via npm global..."
  npm install -g @orbicus/cli || {
    echo "Global install with user permissions..."
    npm install -g --prefix "$HOME/.local" @orbicus/cli
  }
  echo "Orbicus CLI successfully installed! Run 'orbicus --help' to get started."
  exit 0
else
  echo "Error: Node.js 18+ and npm are required to run Orbicus CLI."
  echo "Please install Node.js from https://nodejs.org or your system package manager."
  exit 1
fi
