Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added task_auto_install setting #3481

Merged
merged 3 commits into from
Dec 11, 2024
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
7 changes: 7 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,13 @@
"description": "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var.",
"type": "string"
},
"task_auto_install": {
"description": "Instead of auto-installing all tools on `mise run`, only install these tools. Set to '[]' to disable the behavior entirely.",
"type": "array",
"items": {
"type": "string"
}
},
"task_disable_paths": {
"default": [],
"description": "Paths that mise will not look for tasks in.",
Expand Down
9 changes: 9 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,14 @@ type = "Path"
optional = true
description = "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var."

[task_auto_install]
env = "MISE_TASK_AUTO_INSTALL"
type = "ListString"
rust_type = "Vec<String>"
parse_env = "list_by_comma"
optional = true
description = "Instead of auto-installing all tools on `mise run`, only install these tools. Set to '[]' to disable the behavior entirely."

[task_disable_paths]
env = "MISE_TASK_DISABLE_PATHS"
type = "ListPath"
Expand Down Expand Up @@ -873,6 +881,7 @@ Change output style when executing tasks. This controls the output of `mise run`
env = "MISE_TASK_RUN_AUTO_INSTALL"
type = "Bool"
default = true
hide = true
description = "Automatically install missing tools when executing tasks."

[task_skip]
Expand Down
1 change: 1 addition & 0 deletions src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl Exec {
|| !console::user_attended_stderr()
|| *env::__MISE_SHIM,
resolve_options: Default::default(),
..Default::default()
};
measure!("install_arg_versions", {
ts.install_missing_versions(&opts)?
Expand Down
1 change: 1 addition & 0 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl Install {
use_locked_version: true,
latest_versions: true,
},
..Default::default()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl Run {

ts.install_missing_versions(&InstallOptions {
missing_args_only: !SETTINGS.task_run_auto_install,
missing_tools_auto_install: SETTINGS.task_auto_install.clone(),
..Default::default()
})?;
let mut env = ts.env_with_path(&Config::get())?;
Expand Down
9 changes: 9 additions & 0 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub struct InstallOptions {
pub raw: bool,
/// only install missing tools if passed as arguments
pub missing_args_only: bool,
pub missing_tools_auto_install: Option<Vec<String>>,
pub resolve_options: ResolveOptions,
}

Expand All @@ -70,6 +71,7 @@ impl Default for InstallOptions {
raw: SETTINGS.raw,
force: false,
missing_args_only: true,
missing_tools_auto_install: None,
resolve_options: Default::default(),
}
}
Expand Down Expand Up @@ -143,6 +145,13 @@ impl Toolset {
!opts.missing_args_only
|| matches!(self.versions[tv.ba()].source, ToolSource::Argument)
})
.filter(|tv| {
if let Some(missing_tools_auto_install) = &opts.missing_tools_auto_install {
missing_tools_auto_install.contains(&tv.ba().short)
} else {
true
}
})
.map(|tv| tv.request)
.collect_vec();
let versions = self.install_all_versions(versions, &mpr, opts)?;
Expand Down
Loading