Skip to content
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

Merged
merged 12 commits into from Jul 7, 2021

Conversation

threkk
Copy link
Contributor

@threkk threkk commented May 11, 2021

Summary

If the command latest-stable exists in the plugin, asdf latest defers to it to determine the latest stable version.

Fixes: #763
Resolution of #648 now falls to plugin authors.

If the command `latest-stable` exists in the plugin, `asdf latest`
defers to it to determine the latest stable version.

Fixes asdf-vm#763
@threkk threkk requested a review from a team as a code owner May 11, 2021 07:46
@threkk
Copy link
Contributor Author

threkk commented May 30, 2021

I have opened this pull request which solves an existing issue about three weeks ago, but it has gotten no attention since then. Is there anything missing or anything I can do so it can be taken in consideration? :(

@jthegedus
Copy link
Contributor

@threkk Sorry mate, will look at this in the next couple of days. We appreciate the help and this PR isn't going unnoticed. Sometimes I don't look at a PR until I know I have enough time to give it attention. Which these past few weeks hasn't been much time at all.

Will look at this next.

@jthegedus
Copy link
Contributor

jthegedus commented Jul 7, 2021

@Stratus3D I am confident the changes here so will push through.

I will clean up the testing in a future PR as we need to test most of the code against 2 different plugins, ones with the minimum scripts and another with all optional scripts like latest-stable as added here. In the meantime I have used dummy_legacy_plugin though this is incorrect.

Additionally, I will PR some docs updates about plugin API. We're currently handling calling out to scripts from plugins in different ways, expecting different results, eg: list-all does a lot more work to capture plugin reported errors, whereas here (latest-stable) we expect something or nothing and no stderrs, though we're not guarding against plugin reported errors in these scripts, however once documented that can be argued as breaking the API.

Copy link
Contributor

@jthegedus jthegedus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@threkk Thanks for contributing this. I added more testing scenarios and merged with the changes on master that came from #633

@jthegedus jthegedus merged commit 664d82e into asdf-vm:master Jul 7, 2021
@threkk
Copy link
Contributor Author

threkk commented Jul 7, 2021

Thank you very much for taking it in consideration. This will also allow me to finish a plug-in I was working on too :)

exit 1

if [ -f "${plugin_path}/bin/latest-stable" ]; then
versions=$(bash "${plugin_path}"/bin/latest-stable "$query")
Copy link
Member

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.

Copy link
Contributor Author

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.

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)" |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't a new change, but I think Available versions could be left out of this list. Plugins should just be printing the list of available versions and nothing else. An Available versions heading is not what is specified in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@Stratus3D
Copy link
Member

@jthegedus thank you for handling. I am sorry I dropped the ball on this.

@threkk thank you for this PR! I'd been meaning to implement this on my own for months now, this is a great improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asdf latest command should defer to plugin to determine latest version
3 participants