diff --git a/bootstrap_install_mage.bat b/bootstrap_install_mage.bat new file mode 100644 index 0000000..819f19c --- /dev/null +++ b/bootstrap_install_mage.bat @@ -0,0 +1,31 @@ +@echo off +SETLOCAL + +mage -version >nul 2>&1 +IF %ERRORLEVEL% EQU 0 ( + echo Mage is already installed. + GOTO DOWNLOAD +) + +go version >nul 2>&1 +IF NOT %ERRORLEVEL% EQU 0 ( + echo Go is not installed. Please install Go and try again. + exit /b 1 +) + +echo Installing Mage... +go install github.com/magefile/mage@latest + +mage -version >nul 2>&1 +IF NOT %ERRORLEVEL% EQU 0 ( + echo Mage installation failed. + echo Please ensure that %GOPATH%/bin is in your PATH. + exit /b 1 +) + +echo Mage installed successfully. + +:DOWNLOAD +go mod download + +ENDLOCAL diff --git a/bootstrap_install_mage.sh b/bootstrap_install_mage.sh new file mode 100644 index 0000000..f79cd1f --- /dev/null +++ b/bootstrap_install_mage.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then + TARGET_DIR="$HOME/.local/bin" +else + TARGET_DIR="/usr/local/bin" + echo "Using /usr/local/bin as the installation directory. Might require sudo permissions." +fi + +if ! command -v mage &> /dev/null; then + echo "Installing Mage to $TARGET_DIR ..." + GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest +fi + +if ! command -v mage &> /dev/null; then + echo "Mage installation failed." + echo "Please ensure that $TARGET_DIR is in your \$PATH." + exit 1 +fi + +echo "Mage installed successfully." + +go mod download