From fbfc243c429754d49db1a5e3325f870fd9dbb28d Mon Sep 17 00:00:00 2001 From: Cyan Changes Date: Wed, 18 Mar 2026 22:52:11 +0900 Subject: [PATCH 1/2] chore: add install scripts --- scripts/install.ps1 | 46 +++++++++++++++++++++++++++++++++++++ scripts/install.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 scripts/install.ps1 create mode 100644 scripts/install.sh diff --git a/scripts/install.ps1 b/scripts/install.ps1 new file mode 100644 index 0000000..98169d0 --- /dev/null +++ b/scripts/install.ps1 @@ -0,0 +1,46 @@ +$ErrorActionPreference = 'Stop' + +$ARCH = $env:PROCESSOR_ARCHITECTURE + +switch -Regex ($ARCH) { + "AMD64" { $ARCH_NAME = "x86_64" } + "x86" { $ARCH_NAME = "i686" } + "ARM64" { $ARCH_NAME = "aarch64" } + default { + Write-Host "❌ Error: Unsupported Architecture: $ARCH" + exit 1 + } +} + +$BASE_URL = "https://fast-down-update.s121.top/cli/download/latest" +$DOWNLOAD_URL = "$BASE_URL/windows/$ARCH_NAME" + +# Idiomatic Windows user-level installation path +$INSTALL_DIR = "$env:LOCALAPPDATA\Programs\fast-down" +$BIN_NAME = "fast-down.exe" +$TMP_FILE = [System.IO.Path]::GetTempFileName() + +Write-Host "Downloading $DOWNLOAD_URL ..." +try { + Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $TMP_FILE -UseBasicParsing +} catch { + Write-Host "❌ Error: Failed to download the file." + Remove-Item -Path $TMP_FILE -ErrorAction SilentlyContinue + exit 1 +} + +if (-not (Test-Path -Path $INSTALL_DIR)) { + New-Item -ItemType Directory -Force -Path $INSTALL_DIR | Out-Null +} + +Move-Item -Path $TMP_FILE -Destination "$INSTALL_DIR\$BIN_NAME" -Force + +Write-Host "🎉 Installed to $INSTALL_DIR\$BIN_NAME" + +# Check if the install directory is in the PATH +if (($env:PATH -split ';') -notcontains $INSTALL_DIR) { + Write-Host "⚠️ Note: You need to add $INSTALL_DIR to your PATH environment variable." + Write-Host " You can do this by searching for 'Edit environment variables for your account' in the Start menu." +} else { + Write-Host "🚀 You can now run 'fast-down' from your terminal!" +} diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..b839591 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +OS="$(uname -s)" +ARCH="$(uname -m)" + +case "$OS" in + Linux*) OS_NAME="linux" ;; + Darwin*) OS_NAME="macos" ;; + *) echo "❌ Error: Unsupported OS: $OS. This script only supports Linux and macOS."; exit 1 ;; +esac + +case "$ARCH" in + x86_64|amd64) ARCH_NAME="x86_64" ;; + i386|i686|x86) ARCH_NAME="i686" ;; + aarch64|arm64|armv8) ARCH_NAME="aarch64" ;; + *) echo "❌ Error: Unsupported Architecture: $ARCH"; exit 1 ;; +esac + +if [ "$OS_NAME" = "macos" ] && [ "$ARCH_NAME" != "aarch64" ]; then + echo "❌ Error: Only supports Mac with Apple Silicon (aarch64)." + exit 1 +fi + +BASE_URL="https://fast-down-update.s121.top/cli/download/latest" +DOWNLOAD_URL="${BASE_URL}/${OS_NAME}/${ARCH_NAME}" + +INSTALL_DIR="$HOME/.local/bin" +BIN_NAME="fast-down" +TMP_FILE=$(mktemp) + +# 5. Download the binary +echo "Downloading $DOWNLOAD_URL ..." +if command -v curl >/dev/null 2>&1; then + curl -# -L -o "$TMP_FILE" "$DOWNLOAD_URL" +elif command -v wget >/dev/null 2>&1; then + wget -q --show-progress -O "$TMP_FILE" "$DOWNLOAD_URL" +else + echo "❌ Error: curl or wget is required to download the file." + rm -f "$TMP_FILE" + exit 1 +fi + +chmod +x "$TMP_FILE" +mkdir -p "$INSTALL_DIR" +mv "$TMP_FILE" "$INSTALL_DIR/$BIN_NAME" + +echo "🎉 Installed to $INSTALL_DIR/$BIN_NAME" + +if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then + echo "⚠️ Note: You may need to add $INSTALL_DIR to your PATH in your ~/.bashrc or ~/.zshrc." +else + echo "🚀 You can now run '$BIN_NAME' from your terminal!" +fi From 99598a20a08811ff49f696659f276cdda70a1433 Mon Sep 17 00:00:00 2001 From: share121 Date: Wed, 18 Mar 2026 22:21:34 +0800 Subject: [PATCH 2/2] feat: Add x86_64 support for macOS install script --- scripts/install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index b839591..0a16d02 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -18,9 +18,11 @@ case "$ARCH" in *) echo "❌ Error: Unsupported Architecture: $ARCH"; exit 1 ;; esac -if [ "$OS_NAME" = "macos" ] && [ "$ARCH_NAME" != "aarch64" ]; then - echo "❌ Error: Only supports Mac with Apple Silicon (aarch64)." - exit 1 +if [ "$OS_NAME" = "macos" ]; then + if [ "$ARCH_NAME" != "aarch64" ] && [ "$ARCH_NAME" != "x86_64" ]; then + echo "❌ Error: Unsupported architecture for macOS: $ARCH_NAME. Only aarch64 and x86_64 are supported." + exit 1 + fi fi BASE_URL="https://fast-down-update.s121.top/cli/download/latest"