Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/backend/test_aqua
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export MISE_EXPERIMENTAL=1

assert_contains "mise x aqua:BurntSushi/ripgrep@14.0.0 -- rg --version" "ripgrep 14.0.0"
assert "mise x age@1.2.0 -- age --version" "v1.2.0"
assert_contains "mise x helm@3.16.3 -- helm version" "v3.16.3"
3 changes: 3 additions & 0 deletions e2e/backend/test_ubi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

assert "mise x ubi:goreleaser/goreleaser@v1.25.0 -- goreleaser -v | grep -o 1.25.0" "1.25.0"

mise use ubi:kellyjonbrazil/jc@1.25.3
assert_contains "$MISE_DATA_DIR/shims/jc --version" "jc version: 1.25.3"
9 changes: 8 additions & 1 deletion src/aqua/aqua_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ impl AquaPackage {
return "tar.gz";
}
if self.format.is_empty() {
let asset = self.asset(v);
let asset = if !self.asset.is_empty() {
self.asset(v)
} else if !self.url.is_empty() {
self.url.to_string()
} else {
debug!("no asset or url for {}/{}", self.repo_owner, self.repo_name);
"".to_string()
};
if asset.ends_with(".tar.gz") {
"tar.gz"
} else if asset.ends_with(".tar.xz") {
Expand Down
66 changes: 32 additions & 34 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,14 @@ impl Backend for AquaBackend {
.package_with_version(&self.id, &tv.version)?
.wrap_err_with(|| format!("no aqua registry found for {}", self.ba))?;

let srcs = pkg
.files
.iter()
.flat_map(|f| {
if let Some(prefix) = &pkg.version_prefix {
return vec![f.src(&pkg, &format!("{}{}", prefix, tv.version))]
.into_iter()
.flatten();
}
vec![
f.src(&pkg, &tv.version),
f.src(&pkg, &format!("v{}", tv.version)),
]
.into_iter()
.flatten()
})
.collect_vec();
let srcs = self.srcs(&pkg, tv);
if srcs.is_empty() {
return Ok(vec![tv.install_path()]);
}

Ok(srcs
.iter()
.map(|f| {
PathBuf::from(f)
.parent()
.map(|p| tv.install_path().join(p))
.unwrap_or_else(|| tv.install_path())
})
.map(|(_, dst)| dst.parent().unwrap().to_path_buf())
.filter(|p| p.exists())
.unique()
.collect())
Expand Down Expand Up @@ -222,7 +201,7 @@ impl AquaBackend {
let tar_opts = TarOptions {
format: format.parse().unwrap_or_default(),
pr: Some(ctx.pr.as_ref()),
..Default::default()
strip_components: 0,
};
if pkg.r#type == AquaPackageType::GithubArchive {
file::untar(&tarball_path, &install_path, &tar_opts)?;
Expand Down Expand Up @@ -250,22 +229,41 @@ impl AquaBackend {
bail!("unsupported format: {}", format);
}

for file in &pkg.files {
if let Some(src) = file.src(pkg, v) {
let src_path = install_path.join(&src);
let dest_path = src_path.parent().unwrap().join(file.name.as_str());
if src_path != dest_path {
if cfg!(windows) {
file::rename(&src_path, &dest_path)?;
} else {
file::make_symlink(&PathBuf::from(".").join(&src), &dest_path)?;
}
for (src, dst) in self.srcs(pkg, &ctx.tv) {
if src != dst {
if cfg!(windows) {
file::rename(&src, &dst)?;
} else {
file::make_symlink(&PathBuf::from(".").join(&src), &dst)?;
}
}
}

Ok(())
}

fn srcs(&self, pkg: &AquaPackage, tv: &ToolVersion) -> Vec<(PathBuf, PathBuf)> {
pkg.files
.iter()
.flat_map(|f| {
let srcs = if let Some(prefix) = &pkg.version_prefix {
vec![f.src(pkg, &format!("{}{}", prefix, tv.version))]
} else {
vec![
f.src(pkg, &tv.version),
f.src(pkg, &format!("v{}", tv.version)),
]
};
srcs.into_iter()
.flatten()
.map(|src| tv.install_path().join(src))
.map(|src| {
let dst = src.parent().unwrap().join(f.name.as_str());
(src, dst)
})
})
.collect()
}
}

fn validate(pkg: &AquaPackage) -> Result<()> {
Expand Down
4 changes: 3 additions & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ pub fn is_executable(path: &Path) -> bool {

#[cfg(unix)]
pub fn make_executable<P: AsRef<Path>>(path: P) -> Result<()> {
trace!("chmod +x {}", display_path(&path));
let path = path.as_ref();
let mut perms = path.metadata()?.permissions();
perms.set_mode(perms.mode() | 0o111);
Expand All @@ -390,7 +391,8 @@ pub fn make_executable<P: AsRef<Path>>(path: P) -> Result<()> {
}

#[cfg(windows)]
pub fn make_executable<P: AsRef<Path>>(_path: P) -> Result<()> {
pub fn make_executable<P: AsRef<Path>>(path: P) -> Result<()> {
trace!("chmod +x {}", display_path(&path));
warn!("make executable is not available on Windows, use windows_executable_extensions settings instead");
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ User to run as

## `render:fig`

- Depends: build, render:usage
- Depends: build, render:usage, render:completions

- **Usage**: `render:fig`

Expand Down
2 changes: 1 addition & 1 deletion tasks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ env = { NO_COLOR = "1" }
run = "mise render-mangen"

["render:fig"]
depends = ["build", "render:usage"]
depends = ["build", "render:usage", "render:completions"]
run = [
'usage generate fig --file mise.usage.kdl --out-file tasks/fig/src/mise.ts',
"tsx tasks/fig/addCustomGenerators.ts tasks/fig/src/mise.ts tasks/fig/src/mise.ts"
Expand Down