mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
feat: Disable short-name repository with config value (#1227)
Co-authored-by: jthegedus <jthegedus@hey.com>
This commit is contained in:
parent
9eea8516c9
commit
18caea3eb7
@ -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.
|
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
|
::: warning Note
|
||||||
|
|
||||||
Global defaults can be set in the file `$HOME/.tool-versions`
|
Global defaults can be set in the file `$HOME/.tool-versions`
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
This is what a `.tool-versions` file looks like:
|
This is what a `.tool-versions` file looks like:
|
||||||
@ -57,6 +59,7 @@ legacy_version_file = no
|
|||||||
use_release_candidates = no
|
use_release_candidates = no
|
||||||
always_keep_download = no
|
always_keep_download = no
|
||||||
plugin_repository_last_check_duration = 60
|
plugin_repository_last_check_duration = 60
|
||||||
|
disable_plugin_short_name_repository = no
|
||||||
```
|
```
|
||||||
|
|
||||||
### `legacy_version_file`
|
### `legacy_version_file`
|
||||||
@ -88,7 +91,7 @@ Configure the `asdf install` command to keep or delete the source code or binary
|
|||||||
|
|
||||||
### `plugin_repository_last_check_duration`
|
### `plugin_repository_last_check_duration`
|
||||||
|
|
||||||
Configure the duration since the last asdf plugin repository sync to the next. Commands `asdf plugin add <name>` 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 |
|
| Options | Description |
|
||||||
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- |
|
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- |
|
||||||
@ -96,6 +99,35 @@ Configure the duration since the last asdf plugin repository sync to the next. C
|
|||||||
| `0` | Sync on each trigger event |
|
| `0` | Sync on each trigger event |
|
||||||
| `never` | Never sync |
|
| `never` | Never sync |
|
||||||
|
|
||||||
|
Sync events occur when the following commands are executed:
|
||||||
|
|
||||||
|
- `asdf plugin add <name>`
|
||||||
|
- `asdf plugin list all`
|
||||||
|
|
||||||
|
`asdf plugin add <name> <git-url>` 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` <Badge type="tip" text="default" vertical="middle" /> | 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 <name>`
|
||||||
|
- `asdf plugin list all`
|
||||||
|
|
||||||
|
`asdf plugin add <name> <git-url>` does NOT trigger a plugin sync.
|
||||||
|
|
||||||
|
::: warning Note
|
||||||
|
|
||||||
|
Disabling the plugin short-name repository does not remove plugins previously installed from this source. Plugins can be removed with `asdf plugin remove <name>`. Removing a plugin will remove all installed versions of the managed tool.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
- `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location.
|
- `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location.
|
||||||
|
@ -21,7 +21,9 @@ asdf plugin add <name>
|
|||||||
```
|
```
|
||||||
|
|
||||||
::: tip Recommendation
|
::: tip Recommendation
|
||||||
|
|
||||||
Prefer the longer `git-url` method as it is independent of the short-name repo.
|
Prefer the longer `git-url` method as it is independent of the short-name repo.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## List Installed
|
## List Installed
|
||||||
@ -72,10 +74,13 @@ asdf plugin remove <name>
|
|||||||
|
|
||||||
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.
|
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
|
## 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 <name>` or `asdf plugin list all` can trigger a sync
|
- sync events are triggered by commands:
|
||||||
- a sync occurs if there has not been one in the last `X` minutes
|
- `asdf plugin add <name>`
|
||||||
- `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.
|
- `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.
|
||||||
|
@ -412,6 +412,12 @@ initialize_or_update_repository() {
|
|||||||
local repository_url
|
local repository_url
|
||||||
local repository_path
|
local repository_path
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
repository_url=$(asdf_repository_url)
|
repository_url=$(asdf_repository_url)
|
||||||
repository_path=$(asdf_data_dir)/repository
|
repository_path=$(asdf_data_dir)/repository
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ teardown() {
|
|||||||
run asdf plugin add "plugin_with-all-valid-CHARS-123" "${BASE_DIR}/repo-plugin_with-all-valid-CHARS-123"
|
run asdf plugin add "plugin_with-all-valid-CHARS-123" "${BASE_DIR}/repo-plugin_with-all-valid-CHARS-123"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
run asdf plugin-list
|
run asdf plugin list
|
||||||
[ "$output" = "plugin_with-all-valid-CHARS-123" ]
|
[ "$output" = "plugin_with-all-valid-CHARS-123" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +52,39 @@ teardown() {
|
|||||||
run asdf plugin add "elixir"
|
run asdf plugin add "elixir"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
run asdf plugin-list
|
run asdf plugin list
|
||||||
# whitespace between 'elixir' and url is from printf %-15s %s format
|
|
||||||
[ "$output" = "elixir" ]
|
[ "$output" = "elixir" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "plugin_add command with no URL specified adds a plugin when short name repository is enabled" {
|
||||||
|
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 ]
|
||||||
|
|
||||||
|
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=$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" = "$expected" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "plugin_add command with URL specified adds a plugin using repo" {
|
@test "plugin_add command with URL specified adds a plugin using repo" {
|
||||||
install_mock_plugin_repo "dummy"
|
install_mock_plugin_repo "dummy"
|
||||||
|
|
||||||
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
|
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
run asdf plugin-list
|
run asdf plugin list
|
||||||
# whitespace between 'elixir' and url is from printf %-15s %s format
|
# whitespace between 'elixir' and url is from printf %-15s %s format
|
||||||
[ "$output" = "dummy" ]
|
[ "$output" = "dummy" ]
|
||||||
}
|
}
|
||||||
|
@ -12,51 +12,64 @@ teardown() {
|
|||||||
clean_asdf_dir
|
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" {
|
@test "plugin_list_all should sync repo when check_duration set to 0" {
|
||||||
echo 'plugin_repository_last_check_duration = 0' >$HOME/.asdfrc
|
export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc
|
||||||
run asdf plugin-list-all
|
echo 'plugin_repository_last_check_duration = 0' >$ASDF_CONFIG_DEFAULT_FILE
|
||||||
local expected_plugin_repo_sync="updating plugin repository..."
|
local expected_plugin_repo_sync="updating plugin repository..."
|
||||||
local expected_plugins_list="\
|
local expected_plugins_list="\
|
||||||
bar http://example.com/bar
|
bar http://example.com/bar
|
||||||
dummy *http://example.com/dummy
|
dummy *http://example.com/dummy
|
||||||
foo http://example.com/foo"
|
foo http://example.com/foo"
|
||||||
|
|
||||||
|
run asdf plugin list all
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" =~ "$expected_plugin_repo_sync" ]]
|
[[ "$output" =~ "$expected_plugin_repo_sync" ]]
|
||||||
[[ "$output" =~ "$expected_plugins_list" ]]
|
[[ "$output" =~ "$expected_plugins_list" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" {
|
@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
|
export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc
|
||||||
run asdf plugin-list-all
|
echo 'plugin_repository_last_check_duration = 10' >$ASDF_CONFIG_DEFAULT_FILE
|
||||||
local expected="\
|
local expected="\
|
||||||
bar http://example.com/bar
|
bar http://example.com/bar
|
||||||
dummy *http://example.com/dummy
|
dummy *http://example.com/dummy
|
||||||
foo http://example.com/foo"
|
foo http://example.com/foo"
|
||||||
|
|
||||||
|
run asdf plugin list all
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugin_list_all skips repo sync because check_duration is set to never" {
|
@test "plugin_list_all skips repo sync because check_duration is set to never" {
|
||||||
echo 'plugin_repository_last_check_duration = never' >$HOME/.asdfrc
|
export ASDF_CONFIG_DEFAULT_FILE=$HOME/.asdfrc
|
||||||
run asdf plugin-list-all
|
echo 'plugin_repository_last_check_duration = never' >$ASDF_CONFIG_DEFAULT_FILE
|
||||||
local expected="\
|
local expected="\
|
||||||
bar http://example.com/bar
|
bar http://example.com/bar
|
||||||
dummy *http://example.com/dummy
|
dummy *http://example.com/dummy
|
||||||
foo http://example.com/foo"
|
foo http://example.com/foo"
|
||||||
|
|
||||||
|
run asdf plugin list all
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugin_list_all list all plugins in the repository" {
|
@test "plugin_list_all list all plugins in the repository" {
|
||||||
run asdf plugin-list-all
|
|
||||||
local expected="\
|
local expected="\
|
||||||
bar http://example.com/bar
|
bar http://example.com/bar
|
||||||
dummy *http://example.com/dummy
|
dummy *http://example.com/dummy
|
||||||
foo http://example.com/foo"
|
foo http://example.com/foo"
|
||||||
|
|
||||||
|
run asdf plugin list all
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user