mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
feat: update config opt name & rewrite docs
This commit is contained in:
parent
4a54c4529d
commit
286043bd86
@ -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 <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 |
|
||||
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- |
|
||||
@ -97,19 +99,35 @@ 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 <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
|
||||
Existing plugins available from the short-name repository will continue to be installable.
|
||||
|
||||
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.
|
||||
|
||||
:::
|
||||
|
||||
Disable installing or updating the short-name repository. Commands `asdf plugin add <name>` or `asdf plugin list all` will fail if no short-name repository has been configured.
|
||||
|
||||
| Options | Description |
|
||||
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- |
|
||||
| Git URL of a short-name repository | Clone this repository if installing plugins without URL |
|
||||
| `` | Disable short-name plugin repository. |
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location.
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user