From c8bb751595339d407c85633860bbbe6b7d42657e Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 24 Dec 2024 12:31:54 +0000 Subject: [PATCH] Use mise instead of asdf if present --- packages/ansible-language-server/Taskfile.yml | 4 +- tools/test-setup.sh | 39 ++++++++++++------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/ansible-language-server/Taskfile.yml b/packages/ansible-language-server/Taskfile.yml index 5fe90bea4..ac08ee798 100644 --- a/packages/ansible-language-server/Taskfile.yml +++ b/packages/ansible-language-server/Taskfile.yml @@ -43,9 +43,7 @@ tasks: dir: "{{ .TASKFILE_DIR }}" desc: Update dependencies cmds: - - npm install -g npm@latest - # - installs tools from .tool-versions - - asdf install + - task: shared:setup - "{{.VIRTUAL_ENV}}/bin/python3 -m pre_commit autoupdate" - npm outdated # bumps some developments dependencies diff --git a/tools/test-setup.sh b/tools/test-setup.sh index b662f3c91..3d019e38e 100755 --- a/tools/test-setup.sh +++ b/tools/test-setup.sh @@ -75,16 +75,30 @@ if [[ -z "${HOSTNAME:-}" ]]; then exit 2 fi -log notice "Install required build tools" -for PLUGIN in yarn nodejs task python direnv; do - if ! asdf plugin-list | grep -q $PLUGIN; then - asdf plugin add $PLUGIN - fi -done -asdf install +log notice "Install required build tools (mise/asdf)..." + +if type mise >/dev/null; then + VERSION_MANAGER=mise + mise install +else + VERSION_MANAGER=asdf + echo "mise not found, trying to use asdf" + + for PLUGIN in yarn nodejs task python direnv; do + if ! asdf plugin-list | grep -q $PLUGIN; then + asdf plugin add $PLUGIN + fi + done + asdf install -log notice "Report current build tool versions..." -asdf current + log notice "Report current build tool versions..." + asdf current +fi + +command -v npm >/dev/null 2>&1 || { + log error "Failed to find npm." + exit 56 +} if [[ "${OSTYPE:-}" != darwin* ]]; then pgrep "dbus-(daemon|broker)" >/dev/null || { @@ -333,11 +347,6 @@ for CMD in ansible ansible-lint; do done unset CMD -command -v npm >/dev/null 2>&1 || { - log notice "Installing nodejs stable." - asdf install -} - if [[ -f yarn.lock ]]; then command -v yarn >/dev/null 2>&1 || { # Check if npm has permissions to install packages (system installed does not) @@ -479,7 +488,7 @@ env: tools: ansible-lint: $(get_version ansible-lint) ansible: $(get_version ansible) - asdf: $(get_version asdf) + $VERSION_MANAGER: $(get_version $VERSION_MANAGER) bash: $(get_version bash) gh: $(get_version gh || echo null) git: $(get_version git)