From 22334f98ae7fbb075324d0c21cef21d5c6a3d4c3 Mon Sep 17 00:00:00 2001 From: lyxal <36217120+Lyxal@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:17:13 +1100 Subject: [PATCH] Start on making vyxasd3f work --- LICENSE | 4 +--- bin/download | 11 ++--------- bin/latest-stable | 16 ++++------------ bin/list-all | 7 ++++++- lib/utils.bash | 16 ++++++++-------- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/LICENSE b/LICENSE index 678969f..faa9053 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,6 @@ -TODO: INSERT YOUR NAME COPYRIGHT YEAR (if applicable to your license) - MIT License -Copyright (c) [year] [fullname] +Copyright (c) lyxal 2025 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bin/download b/bin/download index c11ee53..c3d64ba 100755 --- a/bin/download +++ b/bin/download @@ -10,14 +10,7 @@ source "${plugin_dir}/lib/utils.bash" mkdir -p "$ASDF_DOWNLOAD_PATH" -# TODO: Adapt this to proper extension and adapt extracting strategy. -release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz" +release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME.jar" -# Download tar.gz file to the download directory +# Download the jar to the download directory download_release "$ASDF_INSTALL_VERSION" "$release_file" - -# Extract contents of tar.gz file into the download directory -tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file" - -# Remove the tar.gz file since we don't need to keep it -rm "$release_file" diff --git a/bin/latest-stable b/bin/latest-stable index 818f26e..57e8e03 100755 --- a/bin/latest-stable +++ b/bin/latest-stable @@ -14,16 +14,8 @@ if [ -n "${GITHUB_API_TOKEN:-}" ]; then curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") fi -# curl of REPO/releases/latest is expected to be a 302 to another URL -# when no releases redirect_url="REPO/releases" -# when there are releases redirect_url="REPO/releases/tag/v" -redirect_url=$(curl "${curl_opts[@]}" "$GH_REPO/releases/latest" | sed -n -e "s|^location: *||p" | sed -n -e "s|\r||p") -version= -printf "redirect url: %s\n" "$redirect_url" >&2 -if [[ "$redirect_url" == "$GH_REPO/releases" ]]; then - version="$(list_all_versions | sort_versions | tail -n1 | xargs echo)" -else - version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')" -fi +# Have to manually make sure the latest 2.x.x version is selected +# because the default asdf script gets the latest 3.x.x version +version="$(list_all_versions | sort_versions | tail -n1 | xargs echo)" -printf "%s\n" "$version" +printf "%s\n" "$version" \ No newline at end of file diff --git a/bin/list-all b/bin/list-all index 9b8b666..649ad4c 100755 --- a/bin/list-all +++ b/bin/list-all @@ -8,4 +8,9 @@ plugin_dir=$(dirname "$(dirname "$current_script_path")") # shellcheck source=./lib/utils.bash source "${plugin_dir}/lib/utils.bash" -list_all_versions | sort_versions | xargs echo +# list_all_versions | sort_versions | xargs echo +git ls-remote --tags --refs "https://github.com/Vyxal/Vyxal" | +grep -o 'refs/tags/.*' | cut -d/ -f3- | sed 's/^v//' | grep '^2\.' | +sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | +LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | +awk '{print $2}' | xargs echo \ No newline at end of file diff --git a/lib/utils.bash b/lib/utils.bash index 4731fb7..9f7eb5f 100755 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -14,11 +14,11 @@ fail() { curl_opts=(-fsSL) -# NOTE: You might want to remove this if vyxal3 is not hosted on GitHub releases. if [ -n "${GITHUB_API_TOKEN:-}" ]; then curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") fi + sort_versions() { sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' @@ -27,22 +27,20 @@ sort_versions() { list_github_tags() { git ls-remote --tags --refs "$GH_REPO" | grep -o 'refs/tags/.*' | cut -d/ -f3- | - sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags + sed 's/^v//' | + grep '^3\.' # Only list v3.x.x releases } list_all_versions() { - # TODO: Adapt this. By default we simply list the tag names from GitHub releases. - # Change this function if vyxal3 has other means of determining installable versions. list_github_tags } + download_release() { local version filename url version="$1" filename="$2" - - # TODO: Adapt the release URL convention for vyxal3 - url="$GH_REPO/archive/v${version}.tar.gz" + url="$GH_REPO/releases/download/v${version}/vyxal-${version}.jar" echo "* Downloading $TOOL_NAME release $version..." curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" @@ -61,7 +59,9 @@ install_version() { mkdir -p "$install_path" cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path" - # TODO: Assert vyxal3 executable exists. + echo '#!/bin/bash +java -jar "$(dirname "$0")/vyxal3.jar" "$@"' > vyxal && chmod +x vyxal + local tool_cmd tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)" test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."