From 1ee0c62e51791ee793deb28af0491ba27e6d269f Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Tue, 10 May 2022 22:36:28 +0000 Subject: [PATCH 01/11] Support for disabling short-name repo --- defaults | 1 + lib/utils.bash | 10 +++++----- test/plugin_add_command.bats | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/defaults b/defaults index 0b0964f5d..b04042b94 100644 --- a/defaults +++ b/defaults @@ -1,2 +1,3 @@ # enables the use of .ruby-version like files used by other version managers legacy_version_file = no +asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git \ No newline at end of file diff --git a/lib/utils.bash b/lib/utils.bash index 84f2a2c44..8b860cbaa 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -32,10 +32,6 @@ asdf_dir() { printf "%s\\n" "$ASDF_DIR" } -asdf_repository_url() { - printf "https://github.com/asdf-vm/asdf-plugins.git\\n" -} - asdf_data_dir() { local data_dir @@ -404,7 +400,11 @@ initialize_or_update_repository() { local repository_url local repository_path - repository_url=$(asdf_repository_url) + repository_url="$(get_asdf_config_value "asdf_repository_url")" + if [ ! -n "$repository_url" ]; then + printf "No short-name plugin repository in configuration\\n" >&2 + exit 1 + fi repository_path=$(asdf_data_dir)/repository if [ ! -d "$repository_path" ]; then diff --git a/test/plugin_add_command.bats b/test/plugin_add_command.bats index 021e38508..94b39780f 100644 --- a/test/plugin_add_command.bats +++ b/test/plugin_add_command.bats @@ -41,6 +41,31 @@ teardown() { [ "$output" = "elixir" ] } +@test "plugin_add command with no URL specified adds a plugin using repo from config" { + ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc + cat > $ASDF_CONFIG_FILE <<-EOM +asdf_repository_url = "https://github.com/asdf-vm/asdf-plugins.git" +EOM + + run asdf plugin add "elixir" + [ "$status" -eq 0 ] + + run asdf plugin-list + # whitespace between 'elixir' and url is from printf %-15s %s format + [ "$output" = "elixir" ] +} + +@test "plugin_add command with no URL specified fails to add a plugin when no default repo" { + ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc + cat > $ASDF_CONFIG_FILE <<-EOM +# no asdf_repository_url for the tests +EOM + + run asdf plugin add "elixir" + [ "$status" -eq 1 ] + [ "$output" = "No short-name plugin repository configured" ] +} + @test "plugin_add command with URL specified adds a plugin using repo" { install_mock_plugin_repo "dummy" From 2350375d4511c2251518cff86dccd438a6aa9651 Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Tue, 10 May 2022 22:36:40 +0000 Subject: [PATCH 02/11] Documentation to reference this URL --- docs/manage/configuration.md | 11 +++++++++++ docs/manage/plugins.md | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 45b542e6c..50f992582 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -57,6 +57,7 @@ legacy_version_file = no use_release_candidates = no always_keep_download = no plugin_repository_last_check_duration = 60 +asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git ``` ### `legacy_version_file` @@ -96,6 +97,16 @@ Configure the duration since the last asdf plugin repository sync to the next. C | `0` | Sync on each trigger event | | `never` | Never sync | +### `asdf_repository_url` + +Configure the url of the short-name repository. Commands `asdf plugin add ` or `asdf plugin list all` will trigger a clone of the repository, if a value is set. + +| Options | Description | +| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- | +| Git URL | Clone this repository if installing plugins without URL | +| `https://github.com/asdf-vm/asdf-plugins.git` | Default short-name plugin repository | +| `` | Disable short-name plugin repository. | + ## Environment Variables - `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location. diff --git a/docs/manage/plugins.md b/docs/manage/plugins.md index 011586ff6..3ab9e3b5b 100644 --- a/docs/manage/plugins.md +++ b/docs/manage/plugins.md @@ -74,6 +74,10 @@ Removing a plugin will remove all installations of the tool made with the plugin ## Syncing the Short-name Repository +::: tip Recommendation +The short-name repo can be disabled by removing `asdf_repository_url` from the configuration files. +::: + The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method: - commands `asdf plugin add ` or `asdf plugin list all` can trigger a sync From 575cb274a4a633d589ca47e4b16cd0106bcf3b4f Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Tue, 10 May 2022 22:41:36 +0000 Subject: [PATCH 03/11] trailing new line --- defaults | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults b/defaults index b04042b94..76c9626f2 100644 --- a/defaults +++ b/defaults @@ -1,3 +1,3 @@ # enables the use of .ruby-version like files used by other version managers legacy_version_file = no -asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git \ No newline at end of file +asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git From 190e21d873b1caec7a03eba193c0bfb828b7fff3 Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Tue, 10 May 2022 22:59:04 +0000 Subject: [PATCH 04/11] Docs clarify --- docs/manage/configuration.md | 3 +-- docs/manage/plugins.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 50f992582..473fc35bd 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -103,8 +103,7 @@ Configure the url of the short-name repository. Commands `asdf plugin add | Options | Description | | :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- | -| Git URL | Clone this repository if installing plugins without URL | -| `https://github.com/asdf-vm/asdf-plugins.git` | Default short-name plugin repository | +| Git URL of a short-name repository | Clone this repository if installing plugins without URL | | `` | Disable short-name plugin repository. | ## Environment Variables diff --git a/docs/manage/plugins.md b/docs/manage/plugins.md index 3ab9e3b5b..6e81303f0 100644 --- a/docs/manage/plugins.md +++ b/docs/manage/plugins.md @@ -75,7 +75,7 @@ Removing a plugin will remove all installations of the tool made with the plugin ## Syncing the Short-name Repository ::: tip Recommendation -The short-name repo can be disabled by removing `asdf_repository_url` from the configuration files. +The short-name repo can be disabled by removing `asdf_repository_url` from the default configuration file. ::: The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method: From 107fe90fb75c59517d604c21c21e4e343c1720a8 Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Tue, 10 May 2022 23:38:20 +0000 Subject: [PATCH 05/11] Disclaimer --- docs/manage/configuration.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 473fc35bd..92918580d 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -99,6 +99,10 @@ Configure the duration since the last asdf plugin repository sync to the next. C ### `asdf_repository_url` +::: warning Note +Custom short-name plugin repositories are not supported +::: + Configure the url of the short-name repository. Commands `asdf plugin add ` or `asdf plugin list all` will trigger a clone of the repository, if a value is set. | Options | Description | From d1b2d667a97fd1d4f1af050be6cdc8615634732d Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Wed, 11 May 2022 00:20:01 +0000 Subject: [PATCH 06/11] tests fix --- test/plugin_add_command.bats | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/plugin_add_command.bats b/test/plugin_add_command.bats index 94b39780f..aa906b754 100644 --- a/test/plugin_add_command.bats +++ b/test/plugin_add_command.bats @@ -42,9 +42,12 @@ teardown() { } @test "plugin_add command with no URL specified adds a plugin using repo from config" { - ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc + export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults + echo "" > $ASDF_CONFIG_DEFAULT_FILE + + export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc cat > $ASDF_CONFIG_FILE <<-EOM -asdf_repository_url = "https://github.com/asdf-vm/asdf-plugins.git" +asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git EOM run asdf plugin add "elixir" @@ -56,14 +59,15 @@ EOM } @test "plugin_add command with no URL specified fails to add a plugin when no default repo" { - ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc - cat > $ASDF_CONFIG_FILE <<-EOM -# no asdf_repository_url for the tests -EOM + export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults + echo "" > $ASDF_CONFIG_DEFAULT_FILE + + export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc + echo "" > $ASDF_CONFIG_FILE run asdf plugin add "elixir" [ "$status" -eq 1 ] - [ "$output" = "No short-name plugin repository configured" ] + [ "$output" = "No short-name plugin repository in configuration" ] } @test "plugin_add command with URL specified adds a plugin using repo" { From 7e0c390cfe4676ef0a9486b3d6f6e63acc610a22 Mon Sep 17 00:00:00 2001 From: "Jonathan Beverly (jrbeverly)" Date: Tue, 24 May 2022 22:35:03 -0400 Subject: [PATCH 07/11] Use -z instead of -n --- lib/utils.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.bash b/lib/utils.bash index 8b860cbaa..6ce639edb 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -401,7 +401,7 @@ initialize_or_update_repository() { local repository_path repository_url="$(get_asdf_config_value "asdf_repository_url")" - if [ ! -n "$repository_url" ]; then + if [ ! -z "$repository_url" ]; then printf "No short-name plugin repository in configuration\\n" >&2 exit 1 fi From a3f251477b90bdc5a464118a7f93baa436360ed7 Mon Sep 17 00:00:00 2001 From: "Jonathan Beverly (jrbeverly)" Date: Fri, 3 Jun 2022 22:43:58 -0400 Subject: [PATCH 08/11] Invert boolean condition --- lib/utils.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.bash b/lib/utils.bash index 6ce639edb..2fc3d1509 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -401,7 +401,7 @@ initialize_or_update_repository() { local repository_path repository_url="$(get_asdf_config_value "asdf_repository_url")" - if [ ! -z "$repository_url" ]; then + if [ -z "$repository_url" ]; then printf "No short-name plugin repository in configuration\\n" >&2 exit 1 fi From 4a54c4529d0192145e0960971d5032c31456b810 Mon Sep 17 00:00:00 2001 From: Jonathan Beverly Date: Thu, 23 Jun 2022 00:36:23 +0000 Subject: [PATCH 09/11] Repurpose as disable flag instead of customization --- defaults | 1 - docs/manage/configuration.md | 8 ++++---- docs/manage/plugins.md | 2 +- lib/utils.bash | 12 +++++++++--- test/plugin_add_command.bats | 13 ++++++++----- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/defaults b/defaults index 76c9626f2..0b0964f5d 100644 --- a/defaults +++ b/defaults @@ -1,3 +1,2 @@ # enables the use of .ruby-version like files used by other version managers legacy_version_file = no -asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 92918580d..b8784eff2 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -57,7 +57,7 @@ legacy_version_file = no use_release_candidates = no always_keep_download = no plugin_repository_last_check_duration = 60 -asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git +disable_short_name_repository = yes ``` ### `legacy_version_file` @@ -97,13 +97,13 @@ Configure the duration since the last asdf plugin repository sync to the next. C | `0` | Sync on each trigger event | | `never` | Never sync | -### `asdf_repository_url` +### `disable_short_name_repository` ::: warning Note -Custom short-name plugin repositories are not supported +Existing plugins available from the short-name repository will continue to be installable. ::: -Configure the url of the short-name repository. Commands `asdf plugin add ` or `asdf plugin list all` will trigger a clone of the repository, if a value is set. +Disable installing or updating the short-name repository. Commands `asdf plugin add ` or `asdf plugin list all` will fail if no short-name repository has been configured. | Options | Description | | :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- | diff --git a/docs/manage/plugins.md b/docs/manage/plugins.md index 6e81303f0..99b6ab792 100644 --- a/docs/manage/plugins.md +++ b/docs/manage/plugins.md @@ -75,7 +75,7 @@ Removing a plugin will remove all installations of the tool made with the plugin ## Syncing the Short-name Repository ::: tip Recommendation -The short-name repo can be disabled by removing `asdf_repository_url` from the default configuration file. +The short-name repo can be disabled using the flag `disable_short_name_repository`. ::: The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method: diff --git a/lib/utils.bash b/lib/utils.bash index 2fc3d1509..0a517909a 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -32,6 +32,10 @@ asdf_dir() { printf "%s\\n" "$ASDF_DIR" } +asdf_repository_url() { + printf "https://github.com/asdf-vm/asdf-plugins.git\\n" +} + asdf_data_dir() { local data_dir @@ -400,11 +404,13 @@ initialize_or_update_repository() { local repository_url local repository_path - repository_url="$(get_asdf_config_value "asdf_repository_url")" - if [ -z "$repository_url" ]; then - printf "No short-name plugin repository in configuration\\n" >&2 + disable_short_name_repo="$(get_asdf_config_value "disable_short_name_repository")" + if [ "yes" == "$disable_short_name_repo" ]; then + printf "Short-name plugin repository is disabled\\n" >&2 exit 1 fi + + repository_url=$(asdf_repository_url) repository_path=$(asdf_data_dir)/repository if [ ! -d "$repository_path" ]; then diff --git a/test/plugin_add_command.bats b/test/plugin_add_command.bats index aa906b754..54e23a6b4 100644 --- a/test/plugin_add_command.bats +++ b/test/plugin_add_command.bats @@ -41,15 +41,16 @@ teardown() { [ "$output" = "elixir" ] } -@test "plugin_add command with no URL specified adds a plugin using repo from config" { +@test "plugin_add command with no URL specified adds a plugin when short name repository is enabled" { export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults echo "" > $ASDF_CONFIG_DEFAULT_FILE export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc cat > $ASDF_CONFIG_FILE <<-EOM -asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git +disable_short_name_repository=no EOM + run asdf plugin add "elixir" [ "$status" -eq 0 ] @@ -58,16 +59,18 @@ EOM [ "$output" = "elixir" ] } -@test "plugin_add command with no URL specified fails to add a plugin when no default repo" { +@test "plugin_add command with no URL specified fails to add a plugin when disabled" { export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults echo "" > $ASDF_CONFIG_DEFAULT_FILE export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc - echo "" > $ASDF_CONFIG_FILE + cat > $ASDF_CONFIG_FILE <<-EOM +disable_short_name_repository=yes +EOM run asdf plugin add "elixir" [ "$status" -eq 1 ] - [ "$output" = "No short-name plugin repository in configuration" ] + [ "$output" = "Short-name plugin repository is disabled" ] } @test "plugin_add command with URL specified adds a plugin using repo" { From 286043bd86e0ce1fabffc15b5da0e8547d548a1b Mon Sep 17 00:00:00 2001 From: jthegedus Date: Tue, 28 Jun 2022 02:47:27 +1000 Subject: [PATCH 10/11] feat: update config opt name & rewrite docs --- docs/manage/configuration.md | 38 ++++++++++++++++++++------- docs/manage/plugins.md | 2 +- lib/utils.bash | 4 +-- test/plugin_add_command.bats | 43 ++++++++++++------------------- test/plugin_list_all_command.bats | 27 ++++++++++++++----- 5 files changed, 67 insertions(+), 47 deletions(-) diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index b8784eff2..6d0013dc9 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -7,7 +7,9 @@ Configuration of `asdf` encompasses both the sharable `.tool-versions` files as Whenever `.tool-versions` file is present in a directory, the tool versions it declares will be used in that directory and any subdirectories. ::: warning Note + Global defaults can be set in the file `$HOME/.tool-versions` + ::: This is what a `.tool-versions` file looks like: @@ -57,7 +59,7 @@ legacy_version_file = no use_release_candidates = no always_keep_download = no plugin_repository_last_check_duration = 60 -disable_short_name_repository = yes +disable_plugin_short_name_repository = no ``` ### `legacy_version_file` @@ -89,7 +91,7 @@ Configure the `asdf install` command to keep or delete the source code or binary ### `plugin_repository_last_check_duration` -Configure the duration since the last asdf plugin repository sync to the next. Commands `asdf plugin add ` or `asdf plugin list all` will trigger a check of the duration, if the duration has passed then a sync occurs. +Configure the duration since the last asdf plugin repository sync to the next. Sync events will trigger a check of the duration, if the duration has passed then a sync occurs. | Options | Description | | :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- | @@ -97,18 +99,34 @@ Configure the duration since the last asdf plugin repository sync to the next. C | `0` | Sync on each trigger event | | `never` | Never sync | -### `disable_short_name_repository` +Sync events occur when the following commands are executed: + +- `asdf plugin add ` +- `asdf plugin list all` + +`asdf plugin add ` does NOT trigger a plugin sync. + +### `disable_plugin_short_name_repository` + +Disable synchronization of the asdf plugin short-name repository. Sync events will exit early if the short-name repository is disabled. + +| Options | Description | +| :--------------------------------------------------------- | :-------------------------------------------------------- | +| `no` | Clone or update the asdf plugin repository on sync events | +| `yes` | Disable short-name plugin repository | + +Sync events occur when the following commands are executed: + +- `asdf plugin add ` +- `asdf plugin list all` + +`asdf plugin add ` does NOT trigger a plugin sync. ::: warning Note -Existing plugins available from the short-name repository will continue to be installable. -::: -Disable installing or updating the short-name repository. Commands `asdf plugin add ` or `asdf plugin list all` will fail if no short-name repository has been configured. +Disabling the plugin short-name repository does not remove plugins previously installed from this source. Plugins can be removed with `asdf plugin remove `. Removing a plugin will remove all installed versions of the managed tool. -| Options | Description | -| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- | -| Git URL of a short-name repository | Clone this repository if installing plugins without URL | -| `` | Disable short-name plugin repository. | +::: ## Environment Variables diff --git a/docs/manage/plugins.md b/docs/manage/plugins.md index 99b6ab792..b289a0a1c 100644 --- a/docs/manage/plugins.md +++ b/docs/manage/plugins.md @@ -75,7 +75,7 @@ Removing a plugin will remove all installations of the tool made with the plugin ## Syncing the Short-name Repository ::: tip Recommendation -The short-name repo can be disabled using the flag `disable_short_name_repository`. +The short-name repo can be disabled using the flag `disable_plugin_short_name_repository`. ::: The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method: diff --git a/lib/utils.bash b/lib/utils.bash index 0a517909a..38abed3ec 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -404,8 +404,8 @@ initialize_or_update_repository() { local repository_url local repository_path - disable_short_name_repo="$(get_asdf_config_value "disable_short_name_repository")" - if [ "yes" == "$disable_short_name_repo" ]; then + disable_plugin_short_name_repo="$(get_asdf_config_value "disable_plugin_short_name_repository")" + if [ "yes" == "$disable_plugin_short_name_repo" ]; then printf "Short-name plugin repository is disabled\\n" >&2 exit 1 fi diff --git a/test/plugin_add_command.bats b/test/plugin_add_command.bats index 54e23a6b4..becd6a5d3 100644 --- a/test/plugin_add_command.bats +++ b/test/plugin_add_command.bats @@ -16,7 +16,7 @@ teardown() { run asdf plugin add "plugin_with-all-valid-CHARS-123" "${BASE_DIR}/repo-plugin_with-all-valid-CHARS-123" [ "$status" -eq 0 ] - run asdf plugin-list + run asdf plugin list [ "$output" = "plugin_with-all-valid-CHARS-123" ] } @@ -36,41 +36,30 @@ teardown() { run asdf plugin add "elixir" [ "$status" -eq 0 ] - run asdf plugin-list - # whitespace between 'elixir' and url is from printf %-15s %s format + run asdf plugin list [ "$output" = "elixir" ] } @test "plugin_add command with no URL specified adds a plugin when short name repository is enabled" { - export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults - echo "" > $ASDF_CONFIG_DEFAULT_FILE - - export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc - cat > $ASDF_CONFIG_FILE <<-EOM -disable_short_name_repository=no -EOM - + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo "disable_plugin_short_name_repository=no" >$ASDF_CONFIG_DEFAULT_FILE run asdf plugin add "elixir" [ "$status" -eq 0 ] - run asdf plugin-list - # whitespace between 'elixir' and url is from printf %-15s %s format - [ "$output" = "elixir" ] + local expected="elixir" + run asdf plugin list + [ "$output" = "$expected" ] } @test "plugin_add command with no URL specified fails to add a plugin when disabled" { - export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults - echo "" > $ASDF_CONFIG_DEFAULT_FILE - - export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc - cat > $ASDF_CONFIG_FILE <<-EOM -disable_short_name_repository=yes -EOM + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo "disable_plugin_short_name_repository=yes" >$ASDF_CONFIG_DEFAULT_FILE + local expected="Short-name plugin repository is disabled" run asdf plugin add "elixir" [ "$status" -eq 1 ] - [ "$output" = "Short-name plugin repository is disabled" ] + [ "$output" = "$expected" ] } @test "plugin_add command with URL specified adds a plugin using repo" { @@ -79,7 +68,7 @@ EOM run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy" [ "$status" -eq 0 ] - run asdf plugin-list + run asdf plugin list # whitespace between 'elixir' and url is from printf %-15s %s format [ "$output" = "dummy" ] } @@ -109,7 +98,7 @@ EOM @test "plugin_add command executes configured pre hook (generic)" { install_mock_plugin_repo "dummy" - cat > $HOME/.asdfrc <<-'EOM' + cat >$HOME/.asdfrc <<-'EOM' pre_asdf_plugin_add = echo ADD ${@} EOM @@ -123,7 +112,7 @@ plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy" @test "plugin_add command executes configured pre hook (specific)" { install_mock_plugin_repo "dummy" - cat > $HOME/.asdfrc <<-'EOM' + cat >$HOME/.asdfrc <<-'EOM' pre_asdf_plugin_add_dummy = echo ADD EOM @@ -137,7 +126,7 @@ plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy" @test "plugin_add command executes configured post hook (generic)" { install_mock_plugin_repo "dummy" - cat > $HOME/.asdfrc <<-'EOM' + cat >$HOME/.asdfrc <<-'EOM' post_asdf_plugin_add = echo ADD ${@} EOM @@ -151,7 +140,7 @@ ADD dummy" @test "plugin_add command executes configured post hook (specific)" { install_mock_plugin_repo "dummy" - cat > $HOME/.asdfrc <<-'EOM' + cat >$HOME/.asdfrc <<-'EOM' post_asdf_plugin_add_dummy = echo ADD EOM diff --git a/test/plugin_list_all_command.bats b/test/plugin_list_all_command.bats index 71d829b49..113289ee8 100644 --- a/test/plugin_list_all_command.bats +++ b/test/plugin_list_all_command.bats @@ -12,51 +12,64 @@ teardown() { clean_asdf_dir } +@test "plugin_list_all should exit before syncing the plugin repo if disabled" { + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo 'disable_plugin_short_name_repository=yes' >$ASDF_CONFIG_DEFAULT_FILE + local expected="Short-name plugin repository is disabled" + + run asdf plugin list all + [ "$status" -eq 1 ] + [ "$output" = "$expected" ] +} + @test "plugin_list_all should sync repo when check_duration set to 0" { - echo 'plugin_repository_last_check_duration = 0' > $HOME/.asdfrc - run asdf plugin-list-all + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo 'plugin_repository_last_check_duration = 0' >$ASDF_CONFIG_DEFAULT_FILE local expected_plugin_repo_sync="updating plugin repository..." local expected_plugins_list="\ bar http://example.com/bar dummy *http://example.com/dummy foo http://example.com/foo" + run asdf plugin list all [ "$status" -eq 0 ] [[ "$output" =~ "$expected_plugin_repo_sync" ]] [[ "$output" =~ "$expected_plugins_list" ]] } @test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" { - echo 'plugin_repository_last_check_duration = 10' > $HOME/.asdfrc - run asdf plugin-list-all + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo 'plugin_repository_last_check_duration = 10' >$ASDF_CONFIG_DEFAULT_FILE local expected="\ bar http://example.com/bar dummy *http://example.com/dummy foo http://example.com/foo" + run asdf plugin list all [ "$status" -eq 0 ] [ "$output" = "$expected" ] } @test "plugin_list_all skips repo sync because check_duration is set to never" { - echo 'plugin_repository_last_check_duration = never' > $HOME/.asdfrc - run asdf plugin-list-all + export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc + echo 'plugin_repository_last_check_duration = never' >$ASDF_CONFIG_DEFAULT_FILE local expected="\ bar http://example.com/bar dummy *http://example.com/dummy foo http://example.com/foo" + run asdf plugin list all [ "$status" -eq 0 ] [ "$output" = "$expected" ] } @test "plugin_list_all list all plugins in the repository" { - run asdf plugin-list-all local expected="\ bar http://example.com/bar dummy *http://example.com/dummy foo http://example.com/foo" + run asdf plugin list all [ "$status" -eq 0 ] [ "$output" = "$expected" ] } From 14b2f347fa9b81e9c85902209734138246c32ec3 Mon Sep 17 00:00:00 2001 From: jthegedus Date: Tue, 28 Jun 2022 02:56:06 +1000 Subject: [PATCH 11/11] docs: update explanation of plugin repo sync --- docs/manage/plugins.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/manage/plugins.md b/docs/manage/plugins.md index b289a0a1c..9e63bfebf 100644 --- a/docs/manage/plugins.md +++ b/docs/manage/plugins.md @@ -21,7 +21,9 @@ asdf plugin add ``` ::: tip Recommendation + Prefer the longer `git-url` method as it is independent of the short-name repo. + ::: ## List Installed @@ -72,14 +74,13 @@ asdf plugin remove Removing a plugin will remove all installations of the tool made with the plugin. This can be used as a shorthand for cleaning/pruning many unused versions of a tool. -## Syncing the Short-name Repository - -::: tip Recommendation -The short-name repo can be disabled using the flag `disable_plugin_short_name_repository`. -::: +## Syncing the asdf Short-name Repository -The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method: +The short-name repo is synced to your local machine and periodically refreshed. This method to determine a sync is as follows: -- commands `asdf plugin add ` or `asdf plugin list all` can trigger a sync -- a sync occurs if there has not been one in the last `X` minutes -- `X` defaults to `60`, but can be configured in your `.asdfrc` via the `plugin_repository_last_check_duration` option. See the [asdf config docs](/manage/configuration.md) for more. +- sync events are triggered by commands: + - `asdf plugin add ` + - `asdf plugin list all` +- if configuration option `disable_plugin_short_name_repository` is set to `yes`, then sync is aborted early. See the [asdf config docs](/manage/configuration.md) for more. +- if there has not been a synchroniztion in the last `X` minutes then the sync will occur. + - `X` defaults to `60`, but can be configured in your `.asdfrc` via the `plugin_repository_last_check_duration` option. See the [asdf config docs](/manage/configuration.md) for more.