diff --git a/src/installers/asdf.install.zsh b/src/installers/asdf.install.zsh index 6decc41..7f44293 100644 --- a/src/installers/asdf.install.zsh +++ b/src/installers/asdf.install.zsh @@ -1,11 +1,40 @@ TOOL=asdf INSTALL_DIR=$CLI_CONFIG_ROOT/current/asdf +BIN_PATH=$INSTALL_DIR/bin/asdf -APP_VERSION='v0.16.7' +APP_VERSION='v0.19.0' -if [ -d $INSTALL_DIR ]; then +if [ -f $BIN_PATH ]; then Log 'Seems cli-config/asdf is already installed!' else Log "Installing asdf ${APP_VERSION}" - git clone https://github.com/asdf-vm/asdf.git $INSTALL_DIR --branch ${APP_VERSION} --depth=1 + + # Detect OS + case "$(uname -s)" in + Linux) OS=linux ;; + Darwin) OS=darwin ;; + *) Log "Unsupported OS: $(uname -s)"; exit 1 ;; + esac + + # Detect arch + case "$(uname -m)" in + x86_64) ARCH=amd64 ;; + aarch64|arm64) ARCH=arm64 ;; + i386|i686) ARCH=386 ;; + *) Log "Unsupported arch: $(uname -m)"; exit 1 ;; + esac + + TARBALL="asdf-${APP_VERSION}-${OS}-${ARCH}.tar.gz" + URL="https://github.com/asdf-vm/asdf/releases/download/${APP_VERSION}/${TARBALL}" + + mkdir -p "$INSTALL_DIR/bin" + + Log "Downloading ${URL}" + wget -q -O "$INSTALL_DIR/${TARBALL}" "$URL" + + tar -xzf "$INSTALL_DIR/${TARBALL}" -C "$INSTALL_DIR/bin" + chmod +x "$BIN_PATH" + + rm "$INSTALL_DIR/${TARBALL}" + Log "asdf ${APP_VERSION} installed to ${BIN_PATH}" fi