From da63207ee7494d88287410520f5438476b616e26 Mon Sep 17 00:00:00 2001 From: cadamsdev Date: Mon, 19 Jan 2026 22:39:08 -0500 Subject: [PATCH 1/4] install scripts --- README.md | 25 ++++++- install.ps1 | 160 ++++++++++++++++++++++++++++++++++++++++++ install.sh | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 install.ps1 create mode 100755 install.sh diff --git a/README.md b/README.md index 87deef9..b537f13 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,31 @@ Support development by becoming a sponsor! Your avatar or company logo will appe ## 📦 Installation +### Quick Install + +**Linux & macOS:** +```bash +curl -fsSL https://raw.githubusercontent.com/cadamsdev/restman/main/install.sh | bash +``` + +**Windows:** +```powershell +powershell -c "irm https://raw.githubusercontent.com/cadamsdev/restman/main/install.ps1 | iex" +``` + +### Manual Installation + +Download the latest release for your platform from [GitHub Releases](https://github.com/cadamsdev/restman/releases/latest): + +- **Linux:** `restman-linux-x64.tar.gz` or `restman-linux-arm64.tar.gz` +- **macOS:** `restman-darwin-x64.zip` or `restman-darwin-arm64.zip` +- **Windows:** `restman-windows-x64.zip` + +Extract the archive and add the binary to your PATH. + +**macOS users:** After extracting, you may need to remove the quarantine attribute: ```bash -TODO +xattr -d com.apple.quarantine /path/to/restman ``` ## 🚀 Usage diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..76e168e --- /dev/null +++ b/install.ps1 @@ -0,0 +1,160 @@ +#!/usr/bin/env pwsh +# RestMan installer script for Windows +# Usage: powershell -c "irm restman.sh/install.ps1 | iex" + +$ErrorActionPreference = 'Stop' + +# Configuration +$Repo = "cadamsdev/restman" +$InstallDir = if ($env:RESTMAN_INSTALL) { $env:RESTMAN_INSTALL } else { "$HOME\.restman" } +$BinDir = "$InstallDir\bin" +$Executable = "$BinDir\restman.exe" + +# Helper function for colored output +function Write-ColorOutput { + param( + [string]$Message, + [string]$Color = "White" + ) + + $previousColor = $Host.UI.RawUI.ForegroundColor + $Host.UI.RawUI.ForegroundColor = $Color + Write-Output $Message + $Host.UI.RawUI.ForegroundColor = $previousColor +} + +# Detect architecture +function Get-Architecture { + $arch = $env:PROCESSOR_ARCHITECTURE + + switch ($arch) { + "AMD64" { return "x64" } + "ARM64" { return "arm64" } + default { + Write-ColorOutput "Unsupported architecture: $arch" "Red" + exit 1 + } + } +} + +# Get latest release version +function Get-LatestVersion { + try { + $response = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" + return $response.tag_name + } + catch { + Write-ColorOutput "Failed to get latest version: $_" "Red" + exit 1 + } +} + +# Download and install RestMan +function Install-RestMan { + $arch = Get-Architecture + $version = Get-LatestVersion + $platform = "windows-$arch" + + Write-ColorOutput "Installing RestMan $version for $platform..." "Green" + + # Construct download URL + $archiveName = "restman-$platform.zip" + $downloadUrl = "https://github.com/$Repo/releases/download/$version/$archiveName" + + Write-Output "Downloading from: $downloadUrl" + + # Create directories + New-Item -ItemType Directory -Force -Path $BinDir | Out-Null + + # Download to temp directory + $tempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "restman-install-$(Get-Random)") + $archivePath = Join-Path $tempDir $archiveName + + try { + Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath -UseBasicParsing + + # Extract archive + $extractDir = Join-Path $tempDir "extracted" + Expand-Archive -Path $archivePath -DestinationPath $extractDir -Force + + # Find and move binary (look for restman.exe or restman) + $extractedBinary = Get-ChildItem -Path $extractDir -Recurse -Filter "restman*" | Where-Object { + $_.Name -eq "restman.exe" -or $_.Name -eq "restman" + } | Select-Object -First 1 + + if ($extractedBinary) { + Copy-Item -Path $extractedBinary.FullName -Destination $Executable -Force + Write-ColorOutput "✓ RestMan installed to $Executable" "Green" + } + else { + Write-ColorOutput "Binary not found in archive" "Red" + exit 1 + } + } + catch { + Write-ColorOutput "Installation failed: $_" "Red" + exit 1 + } + finally { + # Cleanup temp directory + Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue + } +} + +# Add to PATH +function Update-Path { + # Check if already in PATH + $currentPath = [Environment]::GetEnvironmentVariable("Path", "User") + + if ($currentPath -like "*$BinDir*") { + Write-ColorOutput "✓ $BinDir is already in PATH" "Green" + return + } + + # Add to user PATH + try { + $newPath = "$currentPath;$BinDir" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") + + # Update current session PATH + $env:Path = "$env:Path;$BinDir" + + Write-ColorOutput "✓ Added $BinDir to PATH" "Green" + Write-ColorOutput "Note: You may need to restart your terminal for PATH changes to take effect" "Yellow" + } + catch { + Write-ColorOutput "Failed to update PATH: $_" "Yellow" + Write-ColorOutput "Please manually add $BinDir to your PATH" "Yellow" + } +} + +# Verify installation +function Test-Installation { + try { + $version = & $Executable --version 2>&1 + Write-ColorOutput "✓ RestMan is working: $version" "Green" + } + catch { + Write-ColorOutput "Warning: Could not verify installation" "Yellow" + } +} + +# Main installation flow +function Main { + Write-ColorOutput "RestMan Installer" "Green" + Write-Output "" + + Install-RestMan + Update-Path + + Write-Output "" + Write-ColorOutput "Installation complete!" "Green" + Write-Output "" + Write-Output "To get started:" + Write-Output " 1. Restart your terminal or run: refreshenv (if using chocolatey)" + Write-Output " 2. Run: restman" + Write-Output "" + Write-Output "For more information, visit: https://github.com/$Repo" +} + +Main diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..5725db8 --- /dev/null +++ b/install.sh @@ -0,0 +1,195 @@ +#!/usr/bin/env bash +# RestMan installer script for Linux and macOS +# Usage: curl -fsSL https://restman.sh/install | bash + +set -euo pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Configuration +REPO="cadamsdev/restman" +INSTALL_DIR="${RESTMAN_INSTALL:-$HOME/.restman}" +BIN_DIR="$INSTALL_DIR/bin" +EXECUTABLE="$BIN_DIR/restman" + +# Detect OS and architecture +detect_platform() { + local os arch + + os=$(uname -s | tr '[:upper:]' '[:lower:]') + arch=$(uname -m) + + case "$os" in + linux*) + os="linux" + ;; + darwin*) + os="darwin" + ;; + *) + echo -e "${RED}Unsupported OS: $os${NC}" >&2 + exit 1 + ;; + esac + + case "$arch" in + x86_64 | amd64) + arch="x64" + ;; + aarch64 | arm64) + arch="arm64" + ;; + *) + echo -e "${RED}Unsupported architecture: $arch${NC}" >&2 + exit 1 + ;; + esac + + echo "${os}-${arch}" +} + +# Get the latest release version from GitHub +get_latest_version() { + local version + version=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + + if [ -z "$version" ]; then + echo -e "${RED}Failed to get latest version${NC}" >&2 + exit 1 + fi + + echo "$version" +} + +# Download and extract RestMan +install_restman() { + local platform version download_url archive_name + + platform=$(detect_platform) + version=$(get_latest_version) + + echo -e "${GREEN}Installing RestMan ${version} for ${platform}...${NC}" + + # Construct download URL + archive_name="restman-${platform}" + if [[ "$platform" == "linux-"* ]]; then + archive_name="${archive_name}.tar.gz" + else + archive_name="${archive_name}.zip" + fi + + download_url="https://github.com/$REPO/releases/download/${version}/${archive_name}" + + echo "Downloading from: $download_url" + + # Create directories + mkdir -p "$BIN_DIR" + + # Download and extract + local temp_dir + temp_dir=$(mktemp -d) + trap 'rm -rf "$temp_dir"' EXIT + + cd "$temp_dir" + + if ! curl -fL "$download_url" -o "$archive_name"; then + echo -e "${RED}Failed to download RestMan${NC}" >&2 + exit 1 + fi + + # Extract based on format + if [[ "$archive_name" == *.tar.gz ]]; then + tar -xzf "$archive_name" + else + unzip -q "$archive_name" + fi + + # Find and move binary to install directory + # The archive contains a directory like restman-platform/restman + local binary_path + binary_path=$(find . -name "restman" -type f | head -n 1) + + if [ -n "$binary_path" ] && [ -f "$binary_path" ]; then + mv "$binary_path" "$EXECUTABLE" + chmod +x "$EXECUTABLE" + else + echo -e "${RED}Binary not found in archive${NC}" >&2 + exit 1 + fi + + # macOS specific: Remove quarantine attribute + if [[ "$(uname -s)" == "Darwin" ]]; then + echo -e "${YELLOW}Removing macOS quarantine attribute...${NC}" + xattr -d com.apple.quarantine "$EXECUTABLE" 2>/dev/null || true + fi + + echo -e "${GREEN}✓ RestMan installed to $EXECUTABLE${NC}" +} + +# Add to PATH by updating shell profile +update_path() { + local shell_profile + + # Detect shell and corresponding profile + if [ -n "${BASH_VERSION:-}" ]; then + if [ -f "$HOME/.bashrc" ]; then + shell_profile="$HOME/.bashrc" + else + shell_profile="$HOME/.bash_profile" + fi + elif [ -n "${ZSH_VERSION:-}" ]; then + shell_profile="$HOME/.zshrc" + elif [ -n "${FISH_VERSION:-}" ]; then + shell_profile="$HOME/.config/fish/config.fish" + else + shell_profile="$HOME/.profile" + fi + + # Check if already in PATH + if [[ ":$PATH:" == *":$BIN_DIR:"* ]]; then + echo -e "${GREEN}✓ $BIN_DIR is already in PATH${NC}" + return + fi + + # Add to profile + local export_line + if [[ "$shell_profile" == *"fish"* ]]; then + export_line="set -gx PATH \$PATH $BIN_DIR" + else + export_line="export PATH=\"\$PATH:$BIN_DIR\"" + fi + + if ! grep -q "$BIN_DIR" "$shell_profile" 2>/dev/null; then + echo "" >> "$shell_profile" + echo "# RestMan" >> "$shell_profile" + echo "$export_line" >> "$shell_profile" + echo -e "${GREEN}✓ Added $BIN_DIR to PATH in $shell_profile${NC}" + echo -e "${YELLOW}Run 'source $shell_profile' or restart your terminal to use restman${NC}" + else + echo -e "${GREEN}✓ $BIN_DIR already configured in $shell_profile${NC}" + fi +} + +# Main installation flow +main() { + echo -e "${GREEN}RestMan Installer${NC}" + echo "" + + install_restman + update_path + + echo "" + echo -e "${GREEN}Installation complete!${NC}" + echo "" + echo "To get started:" + echo " 1. Reload your shell or run: source ~/.bashrc (or ~/.zshrc)" + echo " 2. Run: restman" + echo "" + echo "For more information, visit: https://github.com/$REPO" +} + +main From 20192108f313f03f90eb41c14870b4decd296391 Mon Sep 17 00:00:00 2001 From: cadamsdev Date: Mon, 19 Jan 2026 22:42:16 -0500 Subject: [PATCH 2/4] wip --- install.sh | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/install.sh b/install.sh index 5725db8..bd5153a 100755 --- a/install.sh +++ b/install.sh @@ -92,7 +92,6 @@ install_restman() { # Download and extract local temp_dir temp_dir=$(mktemp -d) - trap 'rm -rf "$temp_dir"' EXIT cd "$temp_dir" @@ -118,6 +117,7 @@ install_restman() { chmod +x "$EXECUTABLE" else echo -e "${RED}Binary not found in archive${NC}" >&2 + rm -rf "$temp_dir" exit 1 fi @@ -128,26 +128,41 @@ install_restman() { fi echo -e "${GREEN}✓ RestMan installed to $EXECUTABLE${NC}" + + # Cleanup + rm -rf "$temp_dir" } # Add to PATH by updating shell profile update_path() { - local shell_profile - - # Detect shell and corresponding profile - if [ -n "${BASH_VERSION:-}" ]; then - if [ -f "$HOME/.bashrc" ]; then - shell_profile="$HOME/.bashrc" - else - shell_profile="$HOME/.bash_profile" - fi - elif [ -n "${ZSH_VERSION:-}" ]; then - shell_profile="$HOME/.zshrc" - elif [ -n "${FISH_VERSION:-}" ]; then - shell_profile="$HOME/.config/fish/config.fish" - else - shell_profile="$HOME/.profile" - fi + local shell_profile shell_name + + # Detect shell from $SHELL environment variable + shell_name=$(basename "${SHELL:-/bin/sh}") + + case "$shell_name" in + bash) + if [ -f "$HOME/.bashrc" ]; then + shell_profile="$HOME/.bashrc" + elif [ -f "$HOME/.bash_profile" ]; then + shell_profile="$HOME/.bash_profile" + else + shell_profile="$HOME/.profile" + fi + ;; + zsh) + shell_profile="$HOME/.zshrc" + ;; + fish) + # Ensure fish config directory exists + mkdir -p "$HOME/.config/fish" + shell_profile="$HOME/.config/fish/config.fish" + ;; + *) + # Default to .profile for unknown shells + shell_profile="$HOME/.profile" + ;; + esac # Check if already in PATH if [[ ":$PATH:" == *":$BIN_DIR:"* ]]; then @@ -157,12 +172,13 @@ update_path() { # Add to profile local export_line - if [[ "$shell_profile" == *"fish"* ]]; then + if [[ "$shell_name" == "fish" ]]; then export_line="set -gx PATH \$PATH $BIN_DIR" else export_line="export PATH=\"\$PATH:$BIN_DIR\"" fi + # Check if BIN_DIR is already configured in the profile if ! grep -q "$BIN_DIR" "$shell_profile" 2>/dev/null; then echo "" >> "$shell_profile" echo "# RestMan" >> "$shell_profile" From 4e50797f3710ac7634e096e8f535feb0a451bd3e Mon Sep 17 00:00:00 2001 From: cadamsdev Date: Mon, 19 Jan 2026 22:44:54 -0500 Subject: [PATCH 3/4] wip --- install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index bd5153a..bdbda05 100755 --- a/install.sh +++ b/install.sh @@ -202,7 +202,10 @@ main() { echo -e "${GREEN}Installation complete!${NC}" echo "" echo "To get started:" - echo " 1. Reload your shell or run: source ~/.bashrc (or ~/.zshrc)" + echo " 1. Reload your shell or run one of:" + echo " source ~/.bashrc" + echo " source ~/.zshrc" + echo " source ~/.config/fish/config.fish" echo " 2. Run: restman" echo "" echo "For more information, visit: https://github.com/$REPO" From 305cf90e63ad448e8dbc190a2385eee6bfe0c44d Mon Sep 17 00:00:00 2001 From: cadamsdev Date: Thu, 22 Jan 2026 22:18:44 -0500 Subject: [PATCH 4/4] format code --- scripts/build-target.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-target.ts b/scripts/build-target.ts index ce7868e..d49657b 100644 --- a/scripts/build-target.ts +++ b/scripts/build-target.ts @@ -2,7 +2,7 @@ /** * build script for restman CLI * Usage: bun run scripts/build-target.ts - * + * * Note: Builds natively for the current platform. The target parameter * is used for naming the output archive. */