Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
17
install.ps1
17
install.ps1
|
@ -8,7 +8,6 @@ $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"
|
||||
|
||||
|
@ -29,7 +28,7 @@ if ($ARCH -eq 'AMD64') {
|
|||
$ARCH = 'i686'
|
||||
} else {
|
||||
Write-Host "Unsupported architecture: $ARCH" -ForegroundColor Red
|
||||
return "Error"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Fetch the latest release data from GitHub
|
||||
|
@ -38,7 +37,7 @@ try {
|
|||
}
|
||||
catch {
|
||||
Write-Host "Failed to fetch latest release data." -ForegroundColor Red
|
||||
return "Error"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get the latest version number
|
||||
|
@ -53,7 +52,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."
|
||||
return
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
Write-Host "A new version is available. Upgrading..."
|
||||
|
@ -67,9 +66,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 $CRATE_NAME
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
Remove-Old-Version
|
||||
return
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Get the download url of the latest release
|
||||
|
@ -79,13 +78,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 --force --locked $CRATE_NAME
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
Remove-Old-Version
|
||||
return
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
Write-Host "No prebuilt binary available for your platform. Please install Rust and Cargo using https://rustup.rs and try again."
|
||||
return "Error"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ 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() {
|
||||
|
@ -49,7 +48,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 $CRATE_NAME
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
|
||||
# Remove old version
|
||||
removeOldVersion
|
||||
|
@ -63,7 +62,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 --force --locked $CRATE_NAME
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
removeOldVersion
|
||||
exit 0
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue