mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-12-24 20:35:03 -07:00
Compare commits
12 Commits
bc811ae239
...
602a40216d
Author | SHA1 | Date | |
---|---|---|---|
|
602a40216d | ||
|
c778ea1dec | ||
|
98b8c6fd92 | ||
|
04fe7e30ca | ||
|
e8d6372564 | ||
|
fa3d216540 | ||
|
221507f1c0 | ||
|
d462b55ec9 | ||
|
ebdb229ce6 | ||
|
8db4c60934 | ||
|
40ea0e1ce6 | ||
|
82be580602 |
@ -1,4 +1,6 @@
|
|||||||
# asdf [![Lint](https://github.com/asdf-vm/asdf/actions/workflows/lint.yml/badge.svg)](https://github.com/asdf-vm/asdf/actions/workflows/lint.yml) [![Tests](https://github.com/asdf-vm/asdf/actions/workflows/tests.yml/badge.svg)](https://github.com/asdf-vm/asdf/actions/workflows/tests.yml)
|
# asdf
|
||||||
|
|
||||||
|
[![Lint](https://github.com/asdf-vm/asdf/actions/workflows/lint.yml/badge.svg)](https://github.com/asdf-vm/asdf/actions/workflows/lint.yml) [![Tests](https://github.com/asdf-vm/asdf/actions/workflows/tests.yml/badge.svg)](https://github.com/asdf-vm/asdf/actions/workflows/tests.yml)
|
||||||
|
|
||||||
**Manage multiple runtime versions with a single CLI tool, extendable via plugins** - [docs at asdf-vm.com](https://asdf-vm.com/)
|
**Manage multiple runtime versions with a single CLI tool, extendable via plugins** - [docs at asdf-vm.com](https://asdf-vm.com/)
|
||||||
|
|
||||||
|
50
asdf.nu
50
asdf.nu
@ -74,6 +74,30 @@ module asdf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "complete asdf plugin versions all" [context: string] {
|
||||||
|
let plugin = $context | str trim | split words | last
|
||||||
|
^asdf list all $plugin
|
||||||
|
| lines
|
||||||
|
| each { |line| $line | str trim }
|
||||||
|
| prepend "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
def "complete asdf plugin versions installed" [context: string] {
|
||||||
|
let plugin = $context | str trim | split words | last
|
||||||
|
let versions = ^asdf list $plugin
|
||||||
|
| lines
|
||||||
|
| each { |line| $line | str trim }
|
||||||
|
| each { |version| if ($version | str starts-with "*") {{value: ($version | str substring 1..), description: "current version"}} else {{value: $version, description: ""}} }
|
||||||
|
|
||||||
|
let latest = ^asdf latest $plugin | str trim
|
||||||
|
|
||||||
|
if ($versions | get value | any {|el| $el == $latest}) {
|
||||||
|
$versions | prepend {value: "latest", description: $"alias to ($latest)"}
|
||||||
|
} else {
|
||||||
|
$versions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ASDF version manager
|
# ASDF version manager
|
||||||
export extern main [
|
export extern main [
|
||||||
subcommand?: string@"complete asdf sub-commands"
|
subcommand?: string@"complete asdf sub-commands"
|
||||||
@ -145,15 +169,15 @@ module asdf {
|
|||||||
|
|
||||||
# install a package version
|
# install a package version
|
||||||
export extern "asdf install" [
|
export extern "asdf install" [
|
||||||
name?: string # Name of the package
|
name?: string@"complete asdf installed plugins" # Name of the package
|
||||||
version?: string # Version of the package or latest
|
version?: string@"complete asdf plugin versions all" # Version of the package or latest
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Remove an installed package version
|
# Remove an installed package version
|
||||||
export extern "asdf uninstall" [
|
export extern "asdf uninstall" [
|
||||||
name: string@"complete asdf installed" # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version: string # Version of the package
|
version: string@"complete asdf plugin versions installed" # Version of the package
|
||||||
]
|
]
|
||||||
|
|
||||||
# Display current version
|
# Display current version
|
||||||
@ -169,31 +193,31 @@ module asdf {
|
|||||||
# Display install path for an installled package version
|
# Display install path for an installled package version
|
||||||
export extern "asdf where" [
|
export extern "asdf where" [
|
||||||
name: string@"complete asdf installed" # Name of installed package
|
name: string@"complete asdf installed" # Name of installed package
|
||||||
version?: string # Version of installed package
|
version?: string@"complete asdf plugin versions installed" # Version of installed package
|
||||||
]
|
]
|
||||||
|
|
||||||
# Set the package local version
|
# Set the package local version
|
||||||
export extern "asdf local" [
|
export extern "asdf local" [
|
||||||
name: string@"complete asdf installed" # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Version of the package or latest
|
version?: string@"complete asdf plugin versions installed" # Version of the package or latest
|
||||||
]
|
]
|
||||||
|
|
||||||
# Set the package global version
|
# Set the package global version
|
||||||
export extern "asdf global" [
|
export extern "asdf global" [
|
||||||
name: string@"complete asdf installed" # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Version of the package or latest
|
version?: string@"complete asdf plugin versions installed" # Version of the package or latest
|
||||||
]
|
]
|
||||||
|
|
||||||
# Set the package to version in the current shell
|
# Set the package to version in the current shell
|
||||||
export extern "asdf shell" [
|
export extern "asdf shell" [
|
||||||
name: string@"complete asdf installed" # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Version of the package or latest
|
version?: string@"complete asdf plugin versions installed" # Version of the package or latest
|
||||||
]
|
]
|
||||||
|
|
||||||
# Show latest stable version of a package
|
# Show latest stable version of a package
|
||||||
export extern "asdf latest" [
|
export extern "asdf latest" [
|
||||||
name: string # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Filter latest stable version from this version
|
version?: string@"complete asdf plugin versions installed" # Filter latest stable version from this version
|
||||||
]
|
]
|
||||||
|
|
||||||
# Show latest stable version for all installed packages
|
# Show latest stable version for all installed packages
|
||||||
@ -202,13 +226,13 @@ module asdf {
|
|||||||
# List installed package versions
|
# List installed package versions
|
||||||
export extern "asdf list" [
|
export extern "asdf list" [
|
||||||
name?: string@"complete asdf installed" # Name of the package
|
name?: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Filter the version
|
version?: string@"complete asdf plugin versions installed" # Filter the version
|
||||||
]
|
]
|
||||||
|
|
||||||
# List all available package versions
|
# List all available package versions
|
||||||
export def "asdf list all" [
|
export def "asdf list all" [
|
||||||
name: string@"complete asdf installed" # Name of the package
|
name: string@"complete asdf installed" # Name of the package
|
||||||
version?: string="" # Filter the version
|
version?: string@"complete asdf plugin versions installed"="" # Filter the version
|
||||||
] {
|
] {
|
||||||
^asdf list all $name $version | lines | parse "{version}" | str trim
|
^asdf list all $name $version | lines | parse "{version}" | str trim
|
||||||
}
|
}
|
||||||
@ -216,7 +240,7 @@ module asdf {
|
|||||||
# Show documentation for plugin
|
# Show documentation for plugin
|
||||||
export extern "asdf help" [
|
export extern "asdf help" [
|
||||||
name: string@"complete asdf installed" # Name of the plugin
|
name: string@"complete asdf installed" # Name of the plugin
|
||||||
version?: string # Version of the plugin
|
version?: string@"complete asdf plugin versions installed" # Version of the plugin
|
||||||
]
|
]
|
||||||
|
|
||||||
# Execute a command shim for the current version
|
# Execute a command shim for the current version
|
||||||
@ -237,7 +261,7 @@ module asdf {
|
|||||||
# Recreate shims for version package
|
# Recreate shims for version package
|
||||||
export extern "asdf reshim" [
|
export extern "asdf reshim" [
|
||||||
name?: string@"complete asdf installed" # Name of the package
|
name?: string@"complete asdf installed" # Name of the package
|
||||||
version?: string # Version of the package
|
version?: string@"complete asdf plugin versions installed" # Version of the package
|
||||||
]
|
]
|
||||||
|
|
||||||
# List the plugins and versions that provide a command
|
# List the plugins and versions that provide a command
|
||||||
|
@ -56,7 +56,8 @@ _asdf() {
|
|||||||
uninstall | where | reshim)
|
uninstall | where | reshim)
|
||||||
if [[ " $plugins " == *" $prev "* ]]; then
|
if [[ " $plugins " == *" $prev "* ]]; then
|
||||||
local versions
|
local versions
|
||||||
versions=$(asdf list "$prev" 2>/dev/null)
|
# The first two columns are either blank or contain the "current" marker.
|
||||||
|
versions=$(asdf list "$prev" 2>/dev/null | colrm 1 2)
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
|
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
|
||||||
else
|
else
|
||||||
@ -67,7 +68,8 @@ _asdf() {
|
|||||||
local | global | shell)
|
local | global | shell)
|
||||||
if [[ " $plugins " == *" $prev "* ]]; then
|
if [[ " $plugins " == *" $prev "* ]]; then
|
||||||
local versions
|
local versions
|
||||||
versions=$(asdf list "$prev" 2>/dev/null)
|
# The first two columns are either blank or contain the "current" marker.
|
||||||
|
versions=$(asdf list "$prev" 2>/dev/null | colrm 1 2)
|
||||||
versions+=" system"
|
versions+=" system"
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
|
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
|
||||||
|
@ -364,7 +364,7 @@ export ASDF_DIR="/opt/asdf-vm"
|
|||||||
`asdf` scripts need to be sourced **after** you have set your `$PATH` and **after** you have sourced your framework (oh-my-zsh etc).
|
`asdf` scripts need to be sourced **after** you have set your `$PATH` and **after** you have sourced your framework (oh-my-zsh etc).
|
||||||
|
|
||||||
::: warning
|
::: warning
|
||||||
On macOS, starting a Bash or Zsh shell automatically calls a utility called `path_helper`. `path_helper` can rearrange items in `PATH` (and `MANPATH`), causing inconsistent behavior for tools that require specific ordering. To workaround this, `asdf` on macOS defaults to forcily adding its `PATH`-entries to the front (taking highest priority). This is controllable with the `ASDF_FORCE_PREPEND` variable.
|
On macOS, starting a Bash or Zsh shell automatically calls a utility called `path_helper`. `path_helper` can rearrange items in `PATH` (and `MANPATH`), causing inconsistent behavior for tools that require specific ordering. To workaround this, `asdf` on macOS defaults to forcibly adding its `PATH`-entries to the front (taking highest priority). This is controllable with the `ASDF_FORCE_PREPEND` variable.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Restart your shell so that `PATH` changes take effect. Opening a new terminal tab will usually do it.
|
Restart your shell so that `PATH` changes take effect. Opening a new terminal tab will usually do it.
|
||||||
|
@ -80,7 +80,7 @@ asdf local <name> latest[:<version>]
|
|||||||
|
|
||||||
`global` writes the version to `$HOME/.tool-versions`.
|
`global` writes the version to `$HOME/.tool-versions`.
|
||||||
|
|
||||||
`shell` set the version to an environment variable named `ASDF_${TOOL}_VERSION`, for the current shell session only.
|
`shell` sets the version to an environment variable named `ASDF_${TOOL}_VERSION`, for the current shell session only.
|
||||||
|
|
||||||
`local` writes the version to `$PWD/.tool-versions`, creating it if needed.
|
`local` writes the version to `$PWD/.tool-versions`, creating it if needed.
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ write_shim_script() {
|
|||||||
local version=$2
|
local version=$2
|
||||||
local executable_path=$3
|
local executable_path=$3
|
||||||
|
|
||||||
if ! is_executable "$executable_path"; then
|
if ! is_executable "$executable_path" && ! is_executable "$executable_path.exe"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -107,6 +107,32 @@ $(sort -u <"$temp_versions_path")
|
|||||||
exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" # asdf_allow: ' asdf '
|
exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" # asdf_allow: ' asdf '
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
if [ "$OSTYPE" == "msys" ] || [ "$OSTYPE" == "win32" ]; then
|
||||||
|
cat <<EOF >"$shim_path.bat"
|
||||||
|
@ECHO OFF
|
||||||
|
$(sort -u <"$temp_versions_path" | sed -En "s/# /REM /p")
|
||||||
|
|
||||||
|
IF "%1"=="" (
|
||||||
|
GOTO NO_ARGS
|
||||||
|
) ELSE (
|
||||||
|
GOTO ARGS_EXIST
|
||||||
|
)
|
||||||
|
|
||||||
|
:NO_ARGS
|
||||||
|
bash "$HOME/.asdf/shims/${executable_name}"
|
||||||
|
GOTO EXIT
|
||||||
|
|
||||||
|
:ARGS_EXIST
|
||||||
|
SET ARGUMENTS=%*
|
||||||
|
SET ARGUMENTS=%ARGUMENTS:\\=\\\\%
|
||||||
|
bash "$HOME/.asdf/shims/${executable_name}" %ARGUMENTS%
|
||||||
|
GOTO EXIT
|
||||||
|
|
||||||
|
:EXIT
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
rm "$temp_versions_path"
|
rm "$temp_versions_path"
|
||||||
|
|
||||||
chmod +x "$shim_path"
|
chmod +x "$shim_path"
|
||||||
|
@ -243,7 +243,7 @@ install_tool_version() {
|
|||||||
fi
|
fi
|
||||||
# Otherwise, remove the download directory if it exists
|
# Otherwise, remove the download directory if it exists
|
||||||
elif [ -d "$download_path" ]; then
|
elif [ -d "$download_path" ]; then
|
||||||
rm -r "$download_path"
|
rm -rf "$download_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
reshim_command "$plugin_name" "$full_version"
|
reshim_command "$plugin_name" "$full_version"
|
||||||
|
@ -618,6 +618,9 @@ plugin_executables() {
|
|||||||
for bin_path in "${all_bin_paths[@]}"; do
|
for bin_path in "${all_bin_paths[@]}"; do
|
||||||
for executable_file in "$bin_path"/*; do
|
for executable_file in "$bin_path"/*; do
|
||||||
if is_executable "$executable_file"; then
|
if is_executable "$executable_file"; then
|
||||||
|
if [[ "$executable_file" == *".exe" ]]; then
|
||||||
|
executable_file=${executable_file::-4}
|
||||||
|
fi
|
||||||
printf "%s\n" "$executable_file"
|
printf "%s\n" "$executable_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -3,6 +3,11 @@ setup_suite() {
|
|||||||
# tests fail when it is set to something other than the temp dir.
|
# tests fail when it is set to something other than the temp dir.
|
||||||
unset ASDF_DIR
|
unset ASDF_DIR
|
||||||
|
|
||||||
|
# Also unset below variables, because in users shell shimmed commands
|
||||||
|
# (include bats) export them by determining user's real HOME.
|
||||||
|
unset ASDF_DATA_DIR
|
||||||
|
unset ASDF_CONFIG_FILE
|
||||||
|
|
||||||
# Set an agnostic Git configuration directory to prevent personal
|
# Set an agnostic Git configuration directory to prevent personal
|
||||||
# configuration from interfering with the tests
|
# configuration from interfering with the tests
|
||||||
export GIT_CONFIG_GLOBAL=/dev/null
|
export GIT_CONFIG_GLOBAL=/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user