diff --git a/install/install.ps1 b/install/install.ps1 index 485bd81..148830b 100644 --- a/install/install.ps1 +++ b/install/install.ps1 @@ -1,101 +1,100 @@ $ErrorActionPreference = "Stop" - $Repo = "HiveSofts/hive-cli" $Binary = "hive.exe" +# Colors +$Green = [System.ConsoleColor]::Green +$Yellow = [System.ConsoleColor]::Yellow +$Cyan = [System.ConsoleColor]::Cyan +$Red = [System.ConsoleColor]::Red +$Blue = [System.ConsoleColor]::Blue Write-Host "" -Write-Host "🐝 Hive CLI Installer" -Write-Host "━━━━━━━━━━━━━━━━━━━━" +Write-Host " 🐝 Hive CLI Installer" -ForegroundColor $Cyan -NoNewline +Write-Host "" +Write-Host " ━━━━━━━━━━━━━━━━━━━━" -ForegroundColor $Blue Write-Host "" +Write-Host " âŗ Detecting latest version..." -ForegroundColor $Yellow -$Release = Invoke-RestMethod ` -"https://api.github.com/repos/$Repo/releases/latest" - - -$Version = $Release.tag_name - +try { + $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -ErrorAction Stop + $Version = $Release.tag_name +} catch { + Write-Host " ❌ Failed to detect latest Hive version" -ForegroundColor $Red + Write-Host " Error: $($_.Exception.Message)" -ForegroundColor $Red + exit 1 +} -Write-Host "Version: $Version" +Write-Host " ✅ Version: $Version" -ForegroundColor $Green Write-Host "" - $Asset = "hive-windows.exe" +$DownloadUrl = "https://github.com/$Repo/releases/download/$Version/$Asset" +Write-Host " âŦ‡ī¸ Downloading Hive..." -ForegroundColor $Yellow -$DownloadUrl = ` -"https://github.com/$Repo/releases/download/$Version/$Asset" - - - -$temp = Join-Path ` -$env:TEMP ` -$Binary - - - -Write-Host "âŦ‡ī¸ Downloading Hive..." - -Invoke-WebRequest ` --Uri $DownloadUrl ` --OutFile $temp +$temp = Join-Path $env:TEMP $Binary +try { + Invoke-WebRequest -Uri $DownloadUrl -OutFile $temp -ErrorAction Stop +} catch { + Write-Host " ❌ Download failed" -ForegroundColor $Red + Write-Host " Error: $($_.Exception.Message)" -ForegroundColor $Red + exit 1 +} +if (!(Test-Path $temp) -or (Get-Item $temp).Length -eq 0) { + Write-Host " ❌ Download failed — file is empty" -ForegroundColor $Red + exit 1 +} $InstallDir = "$env:USERPROFILE\.hive\bin" - if (!(Test-Path $InstallDir)) { - New-Item ` - -ItemType Directory ` - -Path $InstallDir | Out-Null + Write-Host " 📁 Creating $InstallDir..." -ForegroundColor $Yellow + New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } +$Target = Join-Path $InstallDir $Binary +Write-Host " đŸ“Ļ Installing Hive..." -ForegroundColor $Yellow -$Target = Join-Path ` -$InstallDir ` -$Binary - - - -Move-Item ` --Force ` -$temp ` -$Target - - +Move-Item -Force $temp $Target Write-Host "" -Write-Host "âš™ī¸ Updating PATH..." - - - -$currentPath = [Environment]::GetEnvironmentVariable( -"Path", -"User" -) +Write-Host " âš™ī¸ Updating PATH..." -ForegroundColor $Yellow +$currentPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($currentPath -notlike "*$InstallDir*") { + [Environment]::SetEnvironmentVariable("Path", "$currentPath;$InstallDir", "User") - [Environment]::SetEnvironmentVariable( - "Path", - "$currentPath;$InstallDir", - "User" - ) - + # Update current session PATH + $env:Path += ";$InstallDir" +} else { + Write-Host " â„šī¸ PATH already contains $InstallDir" -ForegroundColor $Blue } - - Write-Host "" -Write-Host "✅ Hive installed successfully" +Write-Host " ✅ Hive installed successfully!" -ForegroundColor $Green -NoNewline Write-Host "" -Write-Host "Restart terminal then run:" +# Test installation Write-Host "" +if (Get-Command hive -ErrorAction SilentlyContinue) { + Write-Host " Version:" -ForegroundColor $Cyan + hive --version 2>$null +} else { + Write-Host " âš ī¸ Hive not found in current session PATH" -ForegroundColor $Yellow + Write-Host "" + Write-Host " To use Hive in this terminal, run:" -ForegroundColor $Yellow + Write-Host " `$env:Path += `";$InstallDir`"" -ForegroundColor $Cyan +} -Write-Host " hive --help" +Write-Host "" +Write-Host " 🚀 Get started:" -ForegroundColor $Cyan -NoNewline +Write-Host "" +Write-Host " hive --help" -ForegroundColor $Cyan +Write-Host "" \ No newline at end of file diff --git a/install/install.sh b/install/install.sh index 109e72c..875f974 100644 --- a/install/install.sh +++ b/install/install.sh @@ -4,84 +4,86 @@ set -e REPO="HiveSofts/hive-cli" BINARY="hive" - INSTALL_DIR="/usr/local/bin" +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +BOLD='\033[1m' +RESET='\033[0m' + +echo "" +echo -e "${CYAN}${BOLD} 🐝 Hive CLI Installer${RESET}" +echo -e "${BLUE} ━━━━━━━━━━━━━━━━━━━━${RESET}" +echo "" + +# Detect latest version +echo -e "${YELLOW} âŗ Detecting latest version...${RESET}" VERSION=$(curl -s https://api.github.com/repos/$REPO/releases/latest \ -| grep '"tag_name":' \ -| sed -E 's/.*"([^"]+)".*/\1/') + | grep '"tag_name":' \ + | sed -E 's/.*"([^"]+)".*/\1/') if [ -z "$VERSION" ]; then - echo "❌ Failed to detect latest Hive version" + echo -e "${RED} ❌ Failed to detect latest Hive version${RESET}" exit 1 fi - +echo -e "${GREEN} ✅ Version: ${BOLD}${VERSION}${RESET}" echo "" -echo "🐝 Hive CLI Installer" -echo "━━━━━━━━━━━━━━━━━━━━" -echo "Version: $VERSION" -echo "" - +# Detect OS OS="$(uname -s)" ARCH="$(uname -m)" - case "$OS" in Linux) PLATFORM="linux" ;; - Darwin) PLATFORM="macos" ;; - *) - echo "❌ Unsupported operating system" + echo -e "${RED} ❌ Unsupported operating system: $OS${RESET}" exit 1 ;; esac - case "$ARCH" in - x86_64) + x86_64|amd64) ARCH="x86_64" ;; - aarch64|arm64) ARCH="aarch64" ;; - *) - echo "❌ Unsupported architecture: $ARCH" + echo -e "${RED} ❌ Unsupported architecture: $ARCH${RESET}" exit 1 ;; esac - ASSET="hive-$PLATFORM" - - DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$ASSET" - -echo "âŦ‡ī¸ Downloading Hive..." -echo "$DOWNLOAD_URL" - +echo -e "${YELLOW} âŦ‡ī¸ Downloading Hive...${RESET}" +echo -e "${BLUE} ${DOWNLOAD_URL}${RESET}" TMP=$(mktemp) +# Download with progress +curl -L --progress-bar "$DOWNLOAD_URL" -o "$TMP" -curl -L "$DOWNLOAD_URL" -o "$TMP" - +if [ ! -s "$TMP" ]; then + echo -e "${RED} ❌ Download failed — file is empty${RESET}" + exit 1 +fi chmod +x "$TMP" - echo "" -echo "đŸ“Ļ Installing Hive..." - +echo -e "${YELLOW} đŸ“Ļ Installing Hive...${RESET}" if [ -w "$INSTALL_DIR" ]; then mv "$TMP" "$INSTALL_DIR/$BINARY" @@ -89,17 +91,20 @@ else sudo mv "$TMP" "$INSTALL_DIR/$BINARY" fi - echo "" -echo "✅ Hive installed successfully" +echo -e "${GREEN}${BOLD} ✅ Hive installed successfully!${RESET}" echo "" -echo "Version:" -hive --version || true +# Test installation +if command -v hive &> /dev/null; then + echo -e "${CYAN} Version:${RESET}" + hive --version 2>/dev/null || echo -e "${YELLOW} (version info not available)${RESET}" +else + echo -e "${YELLOW} âš ī¸ Hive not found in PATH. Try:${RESET}" + echo -e " export PATH=\$PATH:$INSTALL_DIR" +fi echo "" - -echo "Run:" -echo " hive --help" - +echo -e "${CYAN}${BOLD} 🚀 Get started:${RESET}" +echo -e " ${BOLD}hive --help${RESET}" echo "" \ No newline at end of file