From c041d51c59e2c8a5caf55291b68ccac1dab4a273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:41:44 +0200 Subject: [PATCH] update install scripts --- install.ps1 | 17 +++++++++-------- install.sh | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/install.ps1 b/install.ps1 index a774711..af9dfef 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,6 +8,7 @@ $REPO = "moritz-hoelting/shulkerscript-cli" $PROGRAM_DISPLAY_NAME = "Shulkerscript CLI" $LATEST_RELEASE_URL = "https://api.github.com/repos/$REPO/releases/latest" $BIN_NAME = "shulkerscript" +$CRATE_NAME = "shulkerscript-cli" $INSTALL_PATH = Join-Path $env:USERPROFILE "AppData\Local\Programs\$BIN_NAME" $PATH_REGISTRY = "Registry::HKEY_CURRENT_USER\Environment" @@ -28,7 +29,7 @@ if ($ARCH -eq 'AMD64') { $ARCH = 'i686' } else { Write-Host "Unsupported architecture: $ARCH" -ForegroundColor Red - exit 1 + return "Error" } # Fetch the latest release data from GitHub @@ -37,7 +38,7 @@ try { } catch { Write-Host "Failed to fetch latest release data." -ForegroundColor Red - exit 1 + return "Error" } # Get the latest version number @@ -52,7 +53,7 @@ if (Get-Command $BIN_NAME -ErrorAction Ignore) { if ($INSTALLED_VERSION -eq $CLEAN_LATEST_VERSION) { Write-Host "$PROGRAM_DISPLAY_NAME is already up to date." - exit 0 + return } else { Write-Host "A new version is available. Upgrading..." @@ -66,9 +67,9 @@ else { # Use cargo-binstall if available if (Get-Command cargo-binstall -ErrorAction SilentlyContinue) { Write-Host "cargo-binstall is available. Installing/upgrading using cargo-binstall..." - cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME + cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $CRATE_NAME Remove-Old-Version - exit 0 + return } # Get the download url of the latest release @@ -78,13 +79,13 @@ if ([string]::IsNullOrEmpty($DOWNLOAD_URL)) { # if there is no prebuilt binary, try to build from source if (Get-Command cargo -ErrorAction SilentlyContinue) { Write-Host "No prebuilt binary available for your platform. Building from source..." - cargo install --git "https://github.com/$REPO" --force --locked + cargo install --force --locked $CRATE_NAME Remove-Old-Version - exit 0 + return } else { Write-Host "No prebuilt binary available for your platform. Please install Rust and Cargo using https://rustup.rs and try again." - exit 1 + return "Error" } } diff --git a/install.sh b/install.sh index b07abb1..6324915 100644 --- a/install.sh +++ b/install.sh @@ -8,6 +8,7 @@ REPO="moritz-hoelting/shulkerscript-cli" PROGRAM_DISPLAY_NAME="Shulkerscript CLI" LATEST_RELEASE_URL="https://api.github.com/repos/$REPO/releases/latest" BIN_NAME="shulkerscript" +CRATE_NAME="shulkerscript-cli" INSTALL_PATH="$HOME/bin/$BIN_NAME" function removeOldVersion() { @@ -48,7 +49,7 @@ fi # Use cargo-binstall if available if which cargo-binstall &> /dev/null; then echo "Found cargo-binstall. Installing/upgrading using cargo-binstall..." - cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME + cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $CRATE_NAME # Remove old version removeOldVersion @@ -62,7 +63,7 @@ if [ -z "$DOWNLOAD_URL" ]; then # if there is no prebuilt binary, try to build from source if which cargo &> /dev/null; then echo "No prebuilt binary available for your platform. Building from source..." - cargo install --git "https://github.com/$REPO" --force --locked + cargo install --force --locked $CRATE_NAME removeOldVersion exit 0 else