diff --git a/scripts/install-asdf.sh b/scripts/install-asdf.sh index 29dfc36..c187d6e 100755 --- a/scripts/install-asdf.sh +++ b/scripts/install-asdf.sh @@ -4,7 +4,7 @@ # # It also updates asdf and the plugins, and then reshim asdf. # -# Usage: ./install-asdf.sh [both|install|add_plugins] +# Usage: ./install-asdf.sh [both|install|update|add_plugins] # Author: Ismo Vuorinen # License: MIT # @@ -13,9 +13,40 @@ source "${DOTFILES}/config/shared.sh" export ASDF_DIR="${XDG_BIN_HOME}/asdf" export PATH="${ASDF_DIR}/bin:$PATH" +# If ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME is not set, set it +if [ -z "${ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME}" ]; then + export ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME="${XDG_CONFIG_HOME}/asdf/plugin-versions" +fi + msg "Sourcing asdf in your shell" . "$ASDF_DIR/asdf.sh" +ASDF_INSTALLABLES=( + "1password-cli:github.com/NeoHsu/asdf-1password-cli.git" + "age:github.com/threkk/asdf-age.git" + "bottom:github.com/carbonteq/asdf-btm.git" + "direnv:github.com/asdf-community/asdf-direnv.git" + "dotenv-linter:github.com/wesleimp/asdf-dotenv-linter.git" + "editorconfig-checker:github.com/gabitchov/asdf-editorconfig-checker.git" + "fd:gitlab.com/wt0f/asdf-fd.git" + "github-cli:github.com/bartlomiejdanek/asdf-github-cli.git" + "golang:github.com/asdf-community/asdf-golang.git" + "hadolint:github.com/devlincashman/asdf-hadolint.git" + "kubectl:github.com/asdf-community/asdf-kubectl.git" + "nodejs:github.com/asdf-vm/asdf-nodejs.git" + "pipx:github.com/yozachar/asdf-pipx.git" + "pre-commit:github.com/jonathanmorley/asdf-pre-commit.git" + "python:github.com/asdf-community/asdf-python.git" + "ripgrep:gitlab.com/wt0f/asdf-ripgrep.git" + "rust:github.com/code-lever/asdf-rust.git" + "shellcheck:github.com/luizm/asdf-shellcheck.git" + "shfmt:github.com/luizm/asdf-shfmt.git" + "terragrunt:github.com/ohmer/asdf-terragrunt.git" + "tf-summarize:github.com/adamcrews/asdf-tf-summarize.git" + "yamllint:github.com/ericcornelissen/asdf-yamllint.git" + "yq:github.com/sudermanjr/asdf-yq.git" +) + # Function to update asdf and plugins update_asdf() { @@ -24,41 +55,24 @@ update_asdf() asdf global asdf-plugin-manager "$(asdf latest asdf-plugin-manager)" asdf-plugin-manager version asdf-plugin-manager add-all + asdf-plugin-manager update-all + asdf-plugin-manager export > "${ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME}" asdf install return 0 } +update_asdf_commands() +{ + msg "Updating asdf commands using asdf-plugin-manager" + asdf-plugin-manager update-all + return 0 +} + # Function to install asdf plugins install_asdf_plugins() { - ASDF_INSTALLABLES=( - "1password-cli:github.com/NeoHsu/asdf-1password-cli.git" - "age:github.com/threkk/asdf-age.git" - "bottom:github.com/carbonteq/asdf-btm.git" - "direnv:github.com/asdf-community/asdf-direnv.git" - "dotenv-linter:github.com/wesleimp/asdf-dotenv-linter.git" - "editorconfig-checker:github.com/gabitchov/asdf-editorconfig-checker.git" - "fd:gitlab.com/wt0f/asdf-fd.git" - "github-cli:github.com/bartlomiejdanek/asdf-github-cli.git" - "golang:github.com/asdf-community/asdf-golang.git" - "hadolint:github.com/devlincashman/asdf-hadolint.git" - "kubectl:github.com/asdf-community/asdf-kubectl.git" - "nodejs:github.com/asdf-vm/asdf-nodejs.git" - "pipx:github.com/yozachar/asdf-pipx.git" - "pre-commit:github.com/jonathanmorley/asdf-pre-commit.git" - "python:github.com/asdf-community/asdf-python.git" - "ripgrep:gitlab.com/wt0f/asdf-ripgrep.git" - "rust:github.com/code-lever/asdf-rust.git" - "shellcheck:github.com/luizm/asdf-shellcheck.git" - "shfmt:github.com/luizm/asdf-shfmt.git" - "terragrunt:github.com/ohmer/asdf-terragrunt.git" - "tf-summarize:github.com/adamcrews/asdf-tf-summarize.git" - "yamllint:github.com/ericcornelissen/asdf-yamllint.git" - "yq:github.com/sudermanjr/asdf-yq.git" - ) - msg "Installing asdf plugins" for item in "${ASDF_INSTALLABLES[@]}"; do CMD=$(echo "${item}" | awk -F ":" '{print $1}') @@ -70,7 +84,7 @@ install_asdf_plugins() done msg "Exporting asdf plugin versions" - asdf-plugin-manager export > "${XDG_CONFIG_HOME}/asdf/plugin-versions" + asdf-plugin-manager export > "${ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME}" return 0 } @@ -85,7 +99,7 @@ reshim() # create usage function usage() { - echo "Usage: $0 [both|install|add_plugins]" + echo "Usage: $0 [both|install|add_plugins|update]" exit 1 } @@ -97,6 +111,10 @@ main() update_asdf reshim ;; + "update") + update_asdf_commands + reshim + ;; "install") update_asdf reshim