From d0fdded388ccf8ec8ed1b2022f550776d971ec9f Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 1 Jan 2025 14:30:32 +0100 Subject: [PATCH] feat: use aqua for gradle Fixes #3889 --- docs/registry.md | 2 +- registry.toml | 24 ++++++++++-------------- src/cli/test_tool.rs | 13 +++++++++++-- src/http.rs | 7 ++++--- src/toolset/install_state.rs | 19 +++++++++++++++++-- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/docs/registry.md b/docs/registry.md index 7bc2138b94..6102fccfda 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -305,7 +305,7 @@ You can also specify the full name for a tool using `mise use aqua:1password/cli | goss | [aqua:goss-org/goss](https://github.com/goss-org/goss) [asdf:raimon49/asdf-goss](https://github.com/raimon49/asdf-goss) | | gotestsum | [aqua:gotestyourself/gotestsum](https://github.com/gotestyourself/gotestsum) [asdf:pmalek/mise-gotestsum](https://github.com/pmalek/mise-gotestsum) | | graalvm | [asdf:asdf-community/asdf-graalvm](https://github.com/asdf-community/asdf-graalvm) | -| gradle | [asdf:rfrancis/asdf-gradle](https://github.com/rfrancis/asdf-gradle) [vfox:version-fox/vfox-gradle](https://github.com/version-fox/vfox-gradle) [aqua:gradle/gradle-distributions](https://github.com/gradle/gradle-distributions) | +| gradle | [aqua:gradle/gradle](https://github.com/gradle/gradle) [vfox:version-fox/vfox-gradle](https://github.com/version-fox/vfox-gradle) | | gradle-profiler | [asdf:joschi/asdf-gradle-profiler](https://github.com/joschi/asdf-gradle-profiler) | | grails | [asdf:weibemoura/asdf-grails](https://github.com/weibemoura/asdf-grails) | | grain | [asdf:cometkim/asdf-grain](https://github.com/cometkim/asdf-grain) | diff --git a/registry.toml b/registry.toml index 4c34cb4834..9d558e8056 100644 --- a/registry.toml +++ b/registry.toml @@ -9,7 +9,7 @@ 1password.backends = ["asdf:NeoHsu/asdf-1password-cli", "aqua:1password/cli"] # 1password.test = ["op --version", "{{version}}"] fails on CI for some reason aapt2.backends = ["asdf:ronnnnn/asdf-aapt2"] -aapt2.test = ["aapt2 version", "Android Asset Packaging Tool (aapt)"] +aapt2.test = ["aapt2 version 2>&1", "Android Asset Packaging Tool (aapt)"] act.backends = ["aqua:nektos/act", "ubi:nektos/act", "asdf:gr1m0h/asdf-act"] act.test = ["act --version", "act version {{version}}"] action-validator.backends = [ @@ -43,7 +43,7 @@ age-plugin-yubikey.backends = [ # test seems to fail on linux # age-plugin-yubikey.test = ["age-plugin-yubikey --version", "age-plugin-yubikey {{version}}"] agebox.backends = ["ubi:slok/agebox", "asdf:slok/asdf-agebox"] -agebox.test = ["agebox --version", "v{{version}}"] +agebox.test = ["agebox --version 2>&1", "v{{version}}"] air.backends = ["aqua:air-verse/air", "asdf:pdemagny/asdf-air"] air.test = ["air -v", "{{version}}"] aks-engine.backends = [ @@ -56,7 +56,7 @@ allure.test = ["allure --version", "{{version}}"] alp.backends = ["aqua:tkuchiki/alp", "asdf:asdf-community/asdf-alp"] alp.test = ["alp --version", "{{version}}"] amass.backends = ["ubi:owasp-amass/amass", "asdf:dhoeric/asdf-amass"] -amass.test = ["amass -version", "v{{version}}"] +amass.test = ["amass -version 2>&1", "v{{version}}"] amazon-ecr-credential-helper.backends = [ "aqua:awslabs/amazon-ecr-credential-helper", "asdf:dex4er/asdf-amazon-ecr-credential-helper" @@ -298,7 +298,7 @@ choose.backends = [ ] chromedriver.backends = ["asdf:schinckel/asdf-chromedriver"] cidr-merger.backends = ["ubi:zhanhb/cidr-merger", "asdf:ORCID/asdf-cidr-merger"] -cidr-merger.test = ["cidr-merger --version", "cidr merger {{version}}"] +cidr-merger.test = ["cidr-merger --version 2>&1", "cidr merger {{version}}"] cidrchk.backends = ["ubi:mhausenblas/cidrchk", "asdf:ORCID/asdf-cidrchk"] cidrchk.test = ["cidrchk --version", "{{version}},"] cilium-cli.backends = [ @@ -741,7 +741,7 @@ gomigrate.backends = [ "aqua:golang-migrate/migrate", "asdf:joschi/asdf-gomigrate" ] -gomigrate.test = ["migrate --version", "{{version}}"] +gomigrate.test = ["migrate --version 2>&1", "{{version}}"] gomplate.backends = [ "aqua:hairyhenderson/gomplate", "asdf:sneakybeaky/asdf-gomplate" @@ -758,13 +758,9 @@ gotestsum.backends = [ "asdf:pmalek/mise-gotestsum" ] graalvm.backends = ["asdf:asdf-community/asdf-graalvm"] -gradle.backends = [ - "asdf:rfrancis/asdf-gradle", - "vfox:version-fox/vfox-gradle", - "aqua:gradle/gradle-distributions" -] +gradle.backends = ["aqua:gradle/gradle", "vfox:version-fox/vfox-gradle"] gradle.depends = ["java"] -# gradle.test = ["gradle -V", "Gradle {{version}}"] TODO: make test-tool use dependencies +gradle.test = ["gradle -V", "Gradle"] gradle-profiler.backends = ["asdf:joschi/asdf-gradle-profiler"] grails.backends = ["asdf:weibemoura/asdf-grails"] grain.backends = ["asdf:cometkim/asdf-grain"] @@ -829,7 +825,7 @@ hls.backends = ["asdf:sestrella/asdf-ghcup"] hostctl.backends = ["aqua:guumaster/hostctl", "asdf:svenluijten/asdf-hostctl"] httpie-go.backends = ["aqua:nojima/httpie-go", "asdf:abatilo/asdf-httpie-go"] httpie-go.os = ["linux", "macos"] -httpie-go.test = ["ht --version", "httpie-go {{version}}"] +httpie-go.test = ["ht --version 2>&1", "httpie-go {{version}}"] hub.backends = ["aqua:mislav/hub", "asdf:mise-plugins/asdf-hub"] hugo.backends = [ "aqua:gohugoio/hugo", @@ -867,7 +863,7 @@ istioctl.test = ["istioctl version", "client version: {{version}}"] janet.backends = ["asdf:Jakski/asdf-janet"] java.backends = ["core:java"] jb.backends = ["aqua:jsonnet-bundler/jsonnet-bundler", "asdf:beardix/asdf-jb"] -jb.test = ["jb --version", "v{{version}}"] +jb.test = ["jb --version 2>&1", "v{{version}}"] jbang.backends = ["asdf:jbangdev/jbang-asdf"] jfrog-cli.backends = ["asdf:LozanoMatheus/asdf-jfrog-cli"] jib.backends = ["asdf:joschi/asdf-jib"] @@ -1014,7 +1010,7 @@ kubent.backends = [ "aqua:doitintl/kube-no-trouble", "asdf:virtualstaticvoid/asdf-kubent" ] -kubent.test = ["kubent --version", "version {{version}}"] +kubent.test = ["kubent --version 2>&1", "version {{version}}"] kubergrunt.backends = [ "aqua:gruntwork-io/kubergrunt", "asdf:NeoHsu/asdf-kubergrunt" diff --git a/src/cli/test_tool.rs b/src/cli/test_tool.rs index 83dfadd5cf..38a28c2369 100644 --- a/src/cli/test_tool.rs +++ b/src/cli/test_tool.rs @@ -106,8 +106,17 @@ impl TestTool { } fn test(&self, tool: &ToolArg, cmd: &str, expected: &str) -> Result<()> { + let mut args = vec![tool.clone()]; + args.extend( + tool.ba + .backend()? + .get_all_dependencies(false)? + .into_iter() + .map(|ba| ba.to_string().parse()) + .collect::>>()?, + ); let mut ts = ToolsetBuilder::new() - .with_args(&[tool.clone()]) + .with_args(&args) .with_default_to_latest(true) .build(&Config::get())?; let opts = InstallOptions { @@ -144,7 +153,7 @@ impl TestTool { } else { cmd!("sh", "-c", cmd) }; - cmd = cmd.stderr_to_stdout().stdout_capture(); + cmd = cmd.stdout_capture(); for (k, v) in env.iter() { cmd = cmd.env(k, v); } diff --git a/src/http.rs b/src/http.rs index 240a612532..73c699ba77 100644 --- a/src/http.rs +++ b/src/http.rs @@ -1,4 +1,3 @@ -use std::fs::File; use std::io::Write; use std::path::Path; use std::time::Duration; @@ -174,14 +173,16 @@ impl Client { } } - file::create_dir_all(path.parent().unwrap())?; - let mut file = File::create(path)?; + let parent = path.parent().unwrap(); + file::create_dir_all(parent)?; + let mut file = tempfile::NamedTempFile::with_prefix_in(path, parent)?; while let Some(chunk) = resp.chunk().await? { file.write_all(&chunk)?; if let Some(pr) = pr { pr.inc(chunk.len() as u64); } } + file.persist(path)?; Ok::<(), eyre::Error>(()) })?; Ok(()) diff --git a/src/toolset/install_state.rs b/src/toolset/install_state.rs index c3a4c4e110..6e4c315078 100644 --- a/src/toolset/install_state.rs +++ b/src/toolset/install_state.rs @@ -1,6 +1,7 @@ use crate::backend::backend_type::BackendType; use crate::cli::args::BackendArg; use crate::file::display_path; +use crate::git::Git; use crate::plugins::PluginType; use crate::{dirs, file, runtime_symlinks}; use eyre::{Ok, Result}; @@ -9,7 +10,7 @@ use itertools::Itertools; use rayon::prelude::*; use std::collections::BTreeMap; use std::ops::Deref; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use versions::Versioning; @@ -55,7 +56,11 @@ fn init_plugins() -> MutexResult { .filter_map(|d| { time!("init_plugins {d}"); let path = dirs::PLUGINS.join(&d); - if path.join("metadata.lua").exists() { + if is_banned_plugin(&path) { + info!("removing banned plugin {d}"); + let _ = file::remove_all(&path); + None + } else if path.join("metadata.lua").exists() { Some((d, PluginType::Vfox)) } else if path.join("bin").join("list-all").exists() { Some((d, PluginType::Asdf)) @@ -128,6 +133,16 @@ pub fn list_plugins() -> Result>> { Ok(plugins) } +fn is_banned_plugin(path: &Path) -> bool { + if path.ends_with("gradle") { + let repo = Git::new(path); + if let Some(url) = repo.get_remote_url() { + return url == "https://github.com/rfrancis/asdf-gradle.git"; + } + } + false +} + pub fn get_tool_full(short: &str) -> Result> { let tools = init_tools()?; Ok(tools.get(short).and_then(|t| t.full.clone()))