New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: asdf latest defer to plugin to determine the latest version #938
Changes from all commits
d4e09ca
7433ed7
9623628
e996455
0613ad4
9f9d2e5
21f8776
6d9b6e9
b28e9bc
60137b9
3bfdb1e
789f2a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,31 @@ latest_command() { | |
|
||
local plugin_name=$1 | ||
local query=$2 | ||
local plugin_path | ||
|
||
[[ -z $query ]] && query="$DEFAULT_QUERY" | ||
|
||
plugin_path=$(get_plugin_path "$plugin_name") | ||
check_if_plugin_exists "$plugin_name" | ||
|
||
local versions | ||
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest) | ||
versions=$(asdf list-all "$plugin_name" "$query" | | ||
grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" | | ||
sed 's/^\s\+//' | | ||
tail -1) | ||
|
||
if [ -z "${versions}" ]; then | ||
exit 1 | ||
|
||
if [ -f "${plugin_path}/bin/latest-stable" ]; then | ||
versions=$(bash "${plugin_path}"/bin/latest-stable "$query") | ||
if [ -z "${versions}" ]; then | ||
# this branch requires this print to mimic the error from the list-all branch | ||
printf "No compatible versions available (%s %s)\n" "$plugin_name" "$query" >&2 | ||
exit 1 | ||
fi | ||
else | ||
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest) | ||
versions=$(asdf list-all "$plugin_name" "$query" | | ||
grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this isn't a new change, but I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. I decided to leave it as it was purely for backward compatibility, just in case someone relied on it. |
||
sed 's/^\s\+//' | | ||
tail -1) | ||
if [ -z "${versions}" ]; then | ||
exit 1 | ||
fi | ||
fi | ||
|
||
printf "%s\n" "$versions" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
versions_list=(1.0 1.1 2.0) | ||
versions_list=(1.0.0 1.1.0 2.0.0) | ||
echo "${versions_list[@]}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
get_latest_stable() { | ||
query=$1 | ||
|
||
version_list=(1.0.0 1.1.0 2.0.0) | ||
printf "%s\n" "${version_list[@]}" | grep -E "^\\s*$query" | tail -1 | ||
} | ||
|
||
get_latest_stable "$1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI at some point hopefully in the near future I'd like to explore allowing callbacks to be written in any language and not just bash. We'd need to change the callback invocations from
bash "${plugin_path}"/bin/<callback> <args>
to just"${plugin_path}"/bin/<callback> <args>
. This will give plugin creators more control over how they implement callbacks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! It sounds good. I don't mind to look into it when the time comes.