Skip to content

Commit

Permalink
Merge branch 'main' into feat/bazel-watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Feb 25, 2025
2 parents f623a96 + 0de4089 commit 7754b33
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 48 deletions.
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ feature-depth = 1
# output a note when they are encountered.
ignore = [
{ id = "RUSTSEC-2024-0370", reason = "subdependency cannot be updated" },
{ id = "RUSTSEC-2025-0007", reason = "subdependency cannot be updated" },
#"RUSTSEC-0000-0000",
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
#"[email protected]", # you can also ignore yanked crate versions if you wish
Expand Down
13 changes: 12 additions & 1 deletion docs/dev-tools/backends/ubi.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ use the `exe` option to specify the executable name:
"ubi:cli/cli" = { version = "latest", exe = "gh" } # github's cli
```

### `rename_exe`

The `rename_exe` option allows you to specify the name of the executable once it has been extracted.

use the `rename_exe` option to specify the target executable name:

```toml
[tools]
"ubi:cli/cli" = { version = "latest", exe = "gh", rename_exe = "github" } # github's cli
```

### `matching`

Set a string to match against the release filename when there are multiple files for your
Expand All @@ -60,7 +71,7 @@ then this will be ignored.

### `extract_all`

Set to `true` to extract all files in the tarball instead of just the "bin". Not compatible with `exe`.
Set to `true` to extract all files in the tarball instead of just the "bin". Not compatible with `exe` nor `rename_exe`.

```toml
[tools]
Expand Down
2 changes: 1 addition & 1 deletion docs/installing-mise.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ You will need to first create the parent directory if it does not exist.
:::

```powershell
echo '~/.local/bin/mise activate mise activate pwsh | Out-String | Invoke-Expression' >> $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
echo 'mise activate pwsh | Out-String | Invoke-Expression' >> $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
```

### Nushell
Expand Down
2 changes: 1 addition & 1 deletion docs/lang/zig.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The following installs zig and makes it the global default:
```sh
mise use -g [email protected] # install zig 0.13.x
mise use -g zig@latest # install latest zig release
mise use -g zig@ref:master # instaLL latest nightly from master
mise use -g zig@ref:master # install latest nightly from master
mise use -g zig@ref:mach-latest # install latest nominated zig
mise use -g [email protected]+271452d22 # install dev version
```
Expand Down
55 changes: 55 additions & 0 deletions e2e-win/shim.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Describe 'shim_mode' {

BeforeAll {
function changeShimMode {
param (
[string]$mode
)

mise settings windows_shim_mode $mode
mise reshim --force
}

$shimPath = Join-Path -Path $env:MISE_DATA_DIR -ChildPath "shims"
}

AfterAll {
mise settings unset windows_shim_mode
}

It 'run on symlink' {
changeShimMode "symlink"

mise x go@1.23.3 -- where go
mise x go@1.23.3 -- go version | Should -BeLike "go version go1.23.3 windows/*"

(Get-Item -Path (Join-Path -Path $shimPath -ChildPath go.exe)).LinkType | Should -Be "SymbolicLink"
}

It 'run on file' {
changeShimMode "file"

mise x go@1.23.3 -- where go
mise x go@1.23.3 -- go version | Should -BeLike "go version go1.23.3 windows/*"

(Get-Item -Path (Join-Path -Path $shimPath -ChildPath go.cmd)).LinkType | Should -Be $null
}

It 'run on hardlink' {
mise settings windows_shim_mode "hardlink"

# make mise is on same filesystem
$misePath = (Get-Command -Type Application mise -all | Select-Object -First 1).Source
$binPath = (Join-Path -Path $env:MISE_DATA_DIR -ChildPath "bin")
$newMisePath = (Join-Path -Path $binPath -ChildPath "mise.exe")
New-Item -ItemType Directory -Path $binPath -Force
Copy-Item $misePath $newMisePath

&$newMisePath reshim --force

&$newMisePath x go@1.23.3 -- where go
&$newMisePath x go@1.23.3 -- go version | Should -BeLike "go version go1.23.3 windows/*"

(Get-Item -Path (Join-Path -Path $shimPath -ChildPath go.exe)).LinkType | Should -Be "HardLink"
}
}
3 changes: 3 additions & 0 deletions e2e/cli/test_outdated
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

assert "mise outdated --json" "{}"
assert "mise outdated" ""

echo 'dummy 1' >.tool-versions
mise install [email protected]

Expand Down
5 changes: 5 additions & 0 deletions e2e/cli/test_unuse
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env bash

assert "mise install [email protected]"
assert "ls $MISE_DATA_DIR/installs/dummy" "1
1.0
1.0.0
latest"
assert "mise rm dummy"
assert_empty "mise ls"
assert_fail "ls $MISE_DATA_DIR/installs/dummy"

assert "mise use [email protected]"
assert_contains "mise ls dummy" "1.0.0"
Expand Down
7 changes: 7 additions & 0 deletions e2e/cli/test_use
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ assert "cat ~/.config/mise/config.toml" '[tools]
gh = "2"'
rm -f ~/.config/mise/config.toml

export MISE_ENV=test
mise use -g dummy@1
assert "cat ~/.config/mise/config.toml" '[tools]
dummy = "1"'
rm -f ~/.config/mise/config.toml
unset MISE_ENV

mise uninstall dummy --all
mise use dummy@system
assert "mise ls dummy" "dummy system ~/workdir/mise.toml system"
Expand Down
13 changes: 11 additions & 2 deletions registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ gwvault.backends = [
"asdf:GoodwayGroup/asdf-gwvault"
]
hadolint.backends = [
"aqua:hadolint/hadolint",
"ubi:hadolint/hadolint",
"asdf:devlincashman/asdf-hadolint"
]
Expand Down Expand Up @@ -982,7 +983,11 @@ k3kcli.backends = [
k3s.backends = ["asdf:mise-plugins/mise-k3s"]
k3sup.backends = ["aqua:alexellis/k3sup", "asdf:cgroschupp/asdf-k3sup"]
k6.backends = ["ubi:grafana/k6", "asdf:gr1m0h/asdf-k6"]
k9s.backends = ["ubi:derailed/k9s", "asdf:looztra/asdf-k9s"]
k9s.backends = [
"aqua:derailed/k9s",
"ubi:derailed/k9s",
"asdf:looztra/asdf-k9s"
]
kafka.backends = ["asdf:mise-plugins/mise-kafka"]
kafkactl.backends = [
"aqua:deviceinsight/kafkactl",
Expand Down Expand Up @@ -1615,7 +1620,11 @@ sonobuoy.backends = [
"ubi:vmware-tanzu/sonobuoy",
"asdf:Nick-Triller/asdf-sonobuoy"
]
sops.backends = ["ubi:getsops/sops", "asdf:mise-plugins/mise-sops"]
sops.backends = [
"aqua:getsops/sops",
"ubi:getsops/sops",
"asdf:mise-plugins/mise-sops"
]
sopstool.backends = ["aqua:ibotta/sopstool", "asdf:elementalvoid/asdf-sopstool"]
soracom.backends = ["ubi:soracom/soracom-cli", "asdf:gr1m0h/asdf-soracom"]
sourcery.backends = ["asdf:mise-plugins/mise-sourcery"]
Expand Down
5 changes: 5 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,11 @@
"type": "string"
}
},
"windows_shim_mode": {
"default": "file",
"description": "Shim file mode for Windows. Options: `file`, `hardlink`, `symlink`.",
"type": "string"
},
"yes": {
"description": "This will automatically answer yes or no to prompts. This is useful for scripting.",
"type": "boolean"
Expand Down
11 changes: 11 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,17 @@ default = ["exe", "bat", "cmd", "com", "ps1", "vbs"]
parse_env = "list_by_comma"
description = "List of executable extensions for Windows. For example, `exe` for .exe files, `bat` for .bat files, and so on."

[windows_shim_mode]
env = "MISE_WINDOWS_SHIM_MODE"
type = "String"
default = "file"
description = "Shim file mode for Windows. Options: `file`, `hardlink`, `symlink`."
docs = """
`file`: Creates a file with the content `mise exec`.
`hardlink`: Uses Windows NTFS Hardlink, required on same filesystems. Need run `mise reshim --force` after upgrade mise
`symlink`: Uses Windows NTFS SymbolicLink. Requires Windows Vista or later with admin privileges or enabling "Developer Mode" in Windows 10/11.
"""

[yes]
env = "MISE_YES"
type = "Bool"
Expand Down
9 changes: 7 additions & 2 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ impl Backend for UbiBackend {

if extract_all {
builder = builder.extract_all();
} else if let Some(exe) = opts.get("exe") {
builder = builder.exe(exe);
} else {
if let Some(exe) = opts.get("exe") {
builder = builder.exe(exe);
}
if let Some(rename_exe) = opts.get("rename_exe") {
builder = builder.rename_exe_to(rename_exe)
}
}
if let Some(matching) = opts.get("matching") {
builder = builder.matching(matching);
Expand Down
22 changes: 14 additions & 8 deletions src/cli/outdated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ impl Outdated {
ts.versions
.retain(|_, tvl| tool_set.is_empty() || tool_set.contains(&tvl.backend));
let outdated = ts.list_outdated_versions(self.bump);
self.display(outdated)?;
Ok(())
}

fn display(&self, outdated: Vec<OutdatedInfo>) -> Result<()> {
match self.json {
true => self.display_json(outdated)?,
false => self.display_table(outdated)?,
}
Ok(())
}

fn display_table(&self, outdated: Vec<OutdatedInfo>) -> Result<()> {
if outdated.is_empty() {
info!("All tools are up to date");
if !self.bump {
Expand All @@ -62,15 +75,8 @@ impl Outdated {
""
);
}
} else if self.json {
self.display_json(outdated)?;
} else {
self.display(outdated)?;
return Ok(());
}
Ok(())
}

fn display(&self, outdated: Vec<OutdatedInfo>) -> Result<()> {
let mut table = tabled::Table::new(outdated);
if !self.bump {
table.with(Remove::column(ByColumnName::new("bump")));
Expand Down
1 change: 1 addition & 0 deletions src/cli/unuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Unuse {

if !self.no_prune {
prune(self.installed_tool.iter().map(|ta| &ta.ba).collect(), false)?;
config::rebuild_shims_and_runtime_symlinks(&[])?;
}

Ok(())
Expand Down
6 changes: 4 additions & 2 deletions src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ impl Use {

fn get_config_file(&self) -> Result<Box<dyn ConfigFile>> {
let cwd = env::current_dir()?;
let path = if let Some(p) = &self.path {
let path = if self.global {
MISE_GLOBAL_CONFIG_FILE.clone()
} else if let Some(p) = &self.path {
let from_dir = config_file_from_dir(p).absolutize()?.to_path_buf();
if from_dir.starts_with(&cwd) {
from_dir
Expand All @@ -212,7 +214,7 @@ impl Use {
} else if !env::MISE_ENV.is_empty() {
let env = env::MISE_ENV.last().unwrap();
config_file_from_dir(&cwd.join(format!("mise.{env}.toml")))
} else if self.global || env::in_home_dir() {
} else if env::in_home_dir() {
MISE_GLOBAL_CONFIG_FILE.clone()
} else {
config_file_from_dir(&cwd)
Expand Down
9 changes: 6 additions & 3 deletions src/config/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ impl Tracker {
return Ok(output);
}
for path in read_dir(&*TRACKED_CONFIGS)? {
let path = path?.path();
if !path.is_symlink() {
let mut path = path?.path();
if path.is_symlink() {
path = fs::read_link(path)?;
} else if cfg!(target_os = "windows") {
path = PathBuf::from(fs::read_to_string(&path)?.trim());
} else {
continue;
}
let path = fs::read_link(path)?;
if path.exists() {
output.push(path);
}
Expand Down
Loading

0 comments on commit 7754b33

Please sign in to comment.