From 4766a2b0b277385a99aa7669360895a788e98db0 Mon Sep 17 00:00:00 2001 From: Victor Hugo Borja Date: Sat, 19 Jan 2019 04:12:52 -0600 Subject: [PATCH 1/2] New shim metadata to allow many plugins with same executable names Features * New shim version meta-data allows shims to not depend on a particular plugin nor on its relative executable path (#431) Upgrading requires shim re-generation and should happen automatically by `asdf-exec`: `rm -rf ~/.asdf/shims/` followed by `asdf reshim` * Added lots of tests for shim execution. We now make sure that shim execution obeys plugins hooks like `list-bin-paths` and `exec-path`. * Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might be faster for most common use case: (versions on local .tool-versions file) but fallbacks to slower `get_preset_version_for` which takes legacy formats into account. * Shim exec recommends which plugins or versions to set when command is not found. Fixed Bugs * Allow many plugins to provide shims with same executable name (#431) --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16dd1ee2..825fce75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,25 @@ Fixed Bugs * Custom exec path tests (#324, #424) +Features + +* New shim version meta-data allows shims to not depend on a particular plugin + nor on its relative executable path (#431) + Upgrading requires shim re-generation and should happen automatically by `asdf-exec`: + `rm -rf ~/.asdf/shims/` followed by `asdf reshim` +* Added lots of tests for shim execution. + We now make sure that shim execution obeys plugins hooks like `list-bin-paths` and + `exec-path`. +* Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might be faster + for most common use case: (versions on local .tool-versions file) but fallbacks to + slower `get_preset_version_for` which takes legacy formats into account. +* Shim exec recommends which plugins or versions to set when command is not found. + +Fixed Bugs + +* Allow many plugins to provide shims with same executable name (#431) + + ## 0.6.2 Fixed Bugs From 7fda291df02c6197af6f6f0c5bc51293f33b6755 Mon Sep 17 00:00:00 2001 From: Victor Hugo Borja Date: Sat, 19 Jan 2019 04:48:22 -0600 Subject: [PATCH 2/2] Add `asdf shim-versions command` (#380) For example `asdf shim-versions npm` will list the plugins and their versions on which the `npm` command is available. Based on #432 --- CHANGELOG.md | 2 ++ bin/asdf | 7 ++++--- help.txt | 3 ++- lib/commands/shim_versions.sh | 4 ++++ test/shim_versions_command.bats | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 lib/commands/shim_versions.sh create mode 100644 test/shim_versions_command.bats diff --git a/CHANGELOG.md b/CHANGELOG.md index 825fce75..6328eff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Features slower `get_preset_version_for` which takes legacy formats into account. * Shim exec recommends which plugins or versions to set when command is not found. * `asdf reshim` without arguments now reshims all installed plugins (#407) +* Add `asdf shim-versions ` to list on which plugins and versions is a command + available. (#380) Fixed Bugs diff --git a/bin/asdf b/bin/asdf index e064320e..0c0d8a26 100755 --- a/bin/asdf +++ b/bin/asdf @@ -17,6 +17,8 @@ source "$(dirname "$(dirname "$0")")/lib/commands/current.sh" source "$(dirname "$(dirname "$0")")/lib/commands/where.sh" # shellcheck source=lib/commands/which.sh source "$(dirname "$(dirname "$0")")/lib/commands/which.sh" +# shellcheck source=lib/commands/shim_versions.sh +source "$(dirname "$(dirname "$0")")/lib/commands/shim_versions.sh" # shellcheck source=lib/commands/version_commands.sh source "$(dirname "$(dirname "$0")")/lib/commands/version_commands.sh" # shellcheck source=lib/commands/list.sh @@ -83,9 +85,6 @@ case $1 in "list-all") list_all_command $callback_args;; -"shim") - shim_command $callback_args;; - "reshim") reshim_command $callback_args;; @@ -111,6 +110,8 @@ case $1 in "plugin-test") plugin_test_command $callback_args;; +"shim-versions") + shim_versions_command $callback_args;; *) help_command exit 1;; diff --git a/help.txt b/help.txt index 2896aa0e..4d88644e 100644 --- a/help.txt +++ b/help.txt @@ -17,7 +17,7 @@ MANAGE PACKAGES asdf current Display current version set or being used for all packages asdf current Display current version set or being used for package asdf where [] Display install path for an installed or current version - asdf which Display install path for current version + asdf which Display the path to an executable asdf local Set the package local version asdf global Set the package global version asdf list List installed versions of a package @@ -26,6 +26,7 @@ MANAGE PACKAGES UTILS asdf reshim Recreate shims for version of a package + asdf shim-versions List on which plugins and versions is an executable provided. asdf update Update asdf to the latest stable release asdf update --head Update asdf to the latest on the master branch diff --git a/lib/commands/shim_versions.sh b/lib/commands/shim_versions.sh new file mode 100644 index 00000000..f2cbe7ad --- /dev/null +++ b/lib/commands/shim_versions.sh @@ -0,0 +1,4 @@ +shim_versions_command() { + local shim_name=$1 + shim_plugin_versions "$shim_name" +} diff --git a/test/shim_versions_command.bats b/test/shim_versions_command.bats new file mode 100644 index 00000000..367e27ed --- /dev/null +++ b/test/shim_versions_command.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats + +load test_helpers + +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/shim_versions.sh +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh +. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh + +setup() { + setup_asdf_dir + install_dummy_plugin + + PROJECT_DIR=$HOME/project + mkdir -p $PROJECT_DIR + cd $PROJECT_DIR +} + +teardown() { + clean_asdf_dir +} + +@test "shim_versions_command should list plugins and versions where command is available" { + cd $PROJECT_DIR + run install_command dummy 3.0 + run install_command dummy 1.0 + run reshim_command dummy + + run shim_versions_command dummy + [ "$status" -eq 0 ] + + echo "$output" | grep "dummy 3.0" + echo "$output" | grep "dummy 1.0" +}