refactor: move RunType::execute to ExecutionContext
This commit is contained in:
@@ -70,8 +70,7 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep(message).into());
|
||||
};
|
||||
|
||||
ctx.run_type()
|
||||
.execute(cargo_update)
|
||||
ctx.execute(cargo_update)
|
||||
.args(["install-update", "--git", "--all"])
|
||||
.status_checked()?;
|
||||
|
||||
@@ -80,7 +79,7 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
.ok()
|
||||
.or_else(|| cargo_dir.join("bin/cargo-cache").if_exists());
|
||||
if let Some(e) = cargo_cache {
|
||||
ctx.run_type().execute(e).args(["-a"]).status_checked()?;
|
||||
ctx.execute(e).args(["-a"]).status_checked()?;
|
||||
} else {
|
||||
let message = String::from("cargo-cache isn't installed so Topgrade can't cleanup cargo packages.\nInstall cargo-cache by running `cargo install cargo-cache`");
|
||||
print_warning(message);
|
||||
@@ -94,7 +93,7 @@ pub fn run_flutter_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
let flutter = require("flutter")?;
|
||||
|
||||
print_separator("Flutter");
|
||||
ctx.run_type().execute(flutter).arg("upgrade").status_checked()
|
||||
ctx.execute(flutter).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_gem(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -103,7 +102,7 @@ pub fn run_gem(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Gems");
|
||||
|
||||
let mut command = ctx.run_type().execute(gem);
|
||||
let mut command = ctx.execute(gem);
|
||||
command.arg("update");
|
||||
|
||||
if env::var_os("RBENV_SHELL").is_none() {
|
||||
@@ -125,15 +124,11 @@ pub fn run_rubygems(ctx: &ExecutionContext) -> Result<()> {
|
||||
|| gem_path_str.to_str().unwrap().contains(".rbenv")
|
||||
|| gem_path_str.to_str().unwrap().contains(".rvm")
|
||||
{
|
||||
ctx.run_type()
|
||||
.execute(gem)
|
||||
.args(["update", "--system"])
|
||||
.status_checked()?;
|
||||
ctx.execute(gem).args(["update", "--system"]).status_checked()?;
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
if !Path::new("/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb").exists() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg("-EH")
|
||||
.arg(gem)
|
||||
.args(["update", "--system"])
|
||||
@@ -157,10 +152,10 @@ pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("haxelib");
|
||||
|
||||
let mut command = if directory_writable {
|
||||
ctx.run_type().execute(&haxelib)
|
||||
ctx.execute(&haxelib)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&haxelib);
|
||||
c
|
||||
};
|
||||
@@ -173,10 +168,7 @@ pub fn run_sheldon(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Sheldon");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sheldon)
|
||||
.args(["lock", "--update"])
|
||||
.status_checked()
|
||||
ctx.execute(sheldon).args(["lock", "--update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_fossil(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -184,7 +176,7 @@ pub fn run_fossil(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Fossil");
|
||||
|
||||
ctx.run_type().execute(fossil).args(["all", "sync"]).status_checked()
|
||||
ctx.execute(fossil).args(["all", "sync"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -193,7 +185,6 @@ pub fn run_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("micro");
|
||||
|
||||
let stdout = ctx
|
||||
.run_type()
|
||||
.execute(micro)
|
||||
.args(["-plugin", "update"])
|
||||
.output_checked_utf8()?
|
||||
@@ -218,10 +209,7 @@ pub fn run_apm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Atom Package Manager");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(apm)
|
||||
.args(["upgrade", "--confirm=false"])
|
||||
.status_checked()
|
||||
ctx.execute(apm).args(["upgrade", "--confirm=false"]).status_checked()
|
||||
}
|
||||
|
||||
enum Aqua {
|
||||
@@ -251,7 +239,7 @@ fn get_aqua(ctx: &ExecutionContext) -> Result<Aqua> {
|
||||
let aqua = require("aqua")?;
|
||||
|
||||
// Check if `aqua --help` mentions "aqua". JetBrains Aqua does not, Aqua CLI does.
|
||||
let output = ctx.run_type().execute(&aqua).arg("--help").output_checked()?;
|
||||
let output = ctx.execute(&aqua).arg("--help").output_checked()?;
|
||||
|
||||
if String::from_utf8(output.stdout)?.contains("aqua") {
|
||||
debug!("Detected `aqua` as Aqua CLI");
|
||||
@@ -271,8 +259,8 @@ pub fn run_aqua(ctx: &ExecutionContext) -> Result<()> {
|
||||
println!("{}", t!("Updating aqua installed cli tools ..."));
|
||||
Ok(())
|
||||
} else {
|
||||
ctx.run_type().execute(&aqua).arg("update-aqua").status_checked()?;
|
||||
ctx.run_type().execute(&aqua).arg("update").status_checked()
|
||||
ctx.execute(&aqua).arg("update-aqua").status_checked()?;
|
||||
ctx.execute(&aqua).arg("update").status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,14 +268,14 @@ pub fn run_rustup(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rustup = require("rustup")?;
|
||||
|
||||
print_separator("rustup");
|
||||
ctx.run_type().execute(rustup).arg("update").status_checked()
|
||||
ctx.execute(rustup).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_rye(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rye = require("rye")?;
|
||||
|
||||
print_separator("Rye");
|
||||
ctx.run_type().execute(rye).args(["self", "update"]).status_checked()
|
||||
ctx.execute(rye).args(["self", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -296,7 +284,7 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("elan");
|
||||
|
||||
let disabled_error_msg = "self-update is disabled";
|
||||
let executor_output = ctx.run_type().execute(&elan).args(["self", "update"]).output()?;
|
||||
let executor_output = ctx.execute(&elan).args(["self", "update"]).output()?;
|
||||
match executor_output {
|
||||
ExecutorOutput::Wet(command_output) => {
|
||||
if command_output.status.success() {
|
||||
@@ -323,7 +311,7 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
|
||||
ExecutorOutput::Dry => { /* nothing needed because in a dry run */ }
|
||||
}
|
||||
|
||||
ctx.run_type().execute(&elan).arg("update").status_checked()
|
||||
ctx.execute(&elan).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_juliaup(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -332,16 +320,13 @@ pub fn run_juliaup(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("juliaup");
|
||||
|
||||
if juliaup.canonicalize()?.is_descendant_of(&HOME_DIR) {
|
||||
ctx.run_type()
|
||||
.execute(&juliaup)
|
||||
.args(["self", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&juliaup).args(["self", "update"]).status_checked()?;
|
||||
}
|
||||
|
||||
ctx.run_type().execute(&juliaup).arg("update").status_checked()?;
|
||||
ctx.execute(&juliaup).arg("update").status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&juliaup).arg("gc").status_checked()?;
|
||||
ctx.execute(&juliaup).arg("gc").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -351,10 +336,9 @@ pub fn run_choosenim(ctx: &ExecutionContext) -> Result<()> {
|
||||
let choosenim = require("choosenim")?;
|
||||
|
||||
print_separator("choosenim");
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
run_type.execute(&choosenim).args(["update", "self"]).status_checked()?;
|
||||
run_type.execute(&choosenim).args(["update", "stable"]).status_checked()
|
||||
ctx.execute(&choosenim).args(["update", "self"]).status_checked()?;
|
||||
ctx.execute(&choosenim).args(["update", "stable"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_krew_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -362,7 +346,7 @@ pub fn run_krew_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Krew");
|
||||
|
||||
ctx.run_type().execute(krew).args(["upgrade"]).status_checked()
|
||||
ctx.execute(krew).args(["upgrade"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_gcloud_components_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -375,7 +359,6 @@ pub fn run_gcloud_components_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("gcloud");
|
||||
|
||||
let output = ctx
|
||||
.run_type()
|
||||
.execute(&gcloud)
|
||||
.args(["components", "update", "--quiet"])
|
||||
.output()?;
|
||||
@@ -411,10 +394,7 @@ pub fn run_jetpack(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Jetpack");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(jetpack)
|
||||
.args(["global", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(jetpack).args(["global", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -422,7 +402,7 @@ pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("rtcl");
|
||||
|
||||
ctx.run_type().execute(rupdate).status_checked()
|
||||
ctx.execute(rupdate).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -430,9 +410,9 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("OCaml Package Manager");
|
||||
|
||||
ctx.run_type().execute(&opam).arg("update").status_checked()?;
|
||||
ctx.execute(&opam).arg("update").status_checked()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(&opam);
|
||||
let mut command = ctx.execute(&opam);
|
||||
command.arg("upgrade");
|
||||
if ctx.config().yes(Step::Opam) {
|
||||
command.arg("--yes");
|
||||
@@ -440,7 +420,7 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&opam).arg("clean").status_checked()?;
|
||||
ctx.execute(&opam).arg("clean").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -457,10 +437,10 @@ pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let is_root_install = false;
|
||||
|
||||
let mut command = if is_root_install {
|
||||
ctx.run_type().execute(&vcpkg)
|
||||
ctx.execute(&vcpkg)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&vcpkg);
|
||||
c
|
||||
};
|
||||
@@ -525,7 +505,7 @@ fn run_vscode_compatible<const VSCODIUM: bool>(ctx: &ExecutionContext) -> Result
|
||||
"Visual Studio Code extensions"
|
||||
});
|
||||
|
||||
let mut cmd = ctx.run_type().execute(bin);
|
||||
let mut cmd = ctx.execute(bin);
|
||||
// If its VSCode (not VSCodium)
|
||||
if !VSCODIUM {
|
||||
// And we have configured use of a profile
|
||||
@@ -567,17 +547,14 @@ pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command_args.push("--quiet");
|
||||
}
|
||||
|
||||
ctx.run_type().execute(pipx).args(command_args).status_checked()
|
||||
ctx.execute(pipx).args(command_args).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pipxu_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let pipxu = require("pipxu")?;
|
||||
print_separator("pipxu");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(pipxu)
|
||||
.args(["upgrade", "--all"])
|
||||
.status_checked()
|
||||
ctx.execute(pipxu).args(["upgrade", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -599,7 +576,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let env_names = once(&base_env_name).chain(addl_env_names);
|
||||
|
||||
for env_name in env_names {
|
||||
let mut command = ctx.run_type().execute(&conda);
|
||||
let mut command = ctx.execute(&conda);
|
||||
command.args(["update", "--all", "-n", env_name]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -610,7 +587,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
// Update any environments given by path
|
||||
if let Some(env_paths) = ctx.config().conda_env_paths() {
|
||||
for env_path in env_paths.iter() {
|
||||
let mut command = ctx.run_type().execute(&conda);
|
||||
let mut command = ctx.execute(&conda);
|
||||
command.args(["update", "--all", "-p", env_path]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -621,7 +598,7 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
// Cleanup (conda clean) is global (not tied to a particular environment)
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(conda);
|
||||
let mut command = ctx.execute(conda);
|
||||
command.args(["clean", "--all"]);
|
||||
if ctx.config().yes(Step::Conda) {
|
||||
command.arg("--yes");
|
||||
@@ -638,15 +615,14 @@ pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
// Check if `pixi --help` mentions self-update, if yes, self-update must be enabled.
|
||||
// pixi self-update --help works regardless of whether the feature is enabled.
|
||||
let top_level_help_output = ctx.run_type().execute(&pixi).arg("--help").output_checked_utf8()?;
|
||||
let top_level_help_output = ctx.execute(&pixi).arg("--help").output_checked_utf8()?;
|
||||
|
||||
if top_level_help_output.stdout.contains("self-update") {
|
||||
let self_update_help_output = ctx
|
||||
.run_type()
|
||||
.execute(&pixi)
|
||||
.args(["self-update", "--help"])
|
||||
.output_checked_utf8()?;
|
||||
let mut cmd = ctx.run_type().execute(&pixi);
|
||||
let mut cmd = ctx.execute(&pixi);
|
||||
cmd.arg("self-update");
|
||||
// check if help mentions --no-release-note to check if it is supported
|
||||
if self_update_help_output.stdout.contains("--no-release-note") && !ctx.config().show_pixi_release_notes() {
|
||||
@@ -655,10 +631,7 @@ pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
cmd.status_checked()?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&pixi)
|
||||
.args(["global", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(&pixi).args(["global", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -666,7 +639,7 @@ pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Mamba");
|
||||
|
||||
let mut command = ctx.run_type().execute(&mamba);
|
||||
let mut command = ctx.execute(&mamba);
|
||||
command.args(["update", "--all", "-n", "base"]);
|
||||
if ctx.config().yes(Step::Mamba) {
|
||||
command.arg("--yes");
|
||||
@@ -674,7 +647,7 @@ pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&mamba);
|
||||
let mut command = ctx.execute(&mamba);
|
||||
command.args(["clean", "--all"]);
|
||||
if ctx.config().yes(Step::Mamba) {
|
||||
command.arg("--yes");
|
||||
@@ -689,10 +662,7 @@ pub fn run_miktex_packages_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let miktex = require("miktex")?;
|
||||
print_separator("miktex");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(miktex)
|
||||
.args(["packages", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(miktex).args(["packages", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_pip3_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -770,8 +740,7 @@ pub fn run_pip3_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep("Does not run inside a virtual environment".to_string()).into());
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&python3)
|
||||
ctx.execute(&python3)
|
||||
.args(["-m", "pip", "install", "--upgrade", "--user", "pip"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -787,10 +756,7 @@ pub fn run_pip_review_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pip-review is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pip_review)
|
||||
.arg("--auto")
|
||||
.status_checked_with_codes(&[1])?;
|
||||
ctx.execute(pip_review).arg("--auto").status_checked_with_codes(&[1])?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -806,8 +772,7 @@ pub fn run_pip_review_local_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pip-review (local) is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pip_review)
|
||||
ctx.execute(pip_review)
|
||||
.arg("--local")
|
||||
.arg("--auto")
|
||||
.status_checked_with_codes(&[1])?;
|
||||
@@ -825,8 +790,7 @@ pub fn run_pipupgrade_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
);
|
||||
return Err(SkipStep(String::from("Pipupgrade is disabled by default")).into());
|
||||
}
|
||||
ctx.run_type()
|
||||
.execute(pipupgrade)
|
||||
ctx.execute(pipupgrade)
|
||||
.args(ctx.config().pipupgrade_arguments().split_whitespace())
|
||||
.status_checked()?;
|
||||
|
||||
@@ -844,14 +808,14 @@ pub fn run_stack_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let stack = require("stack")?;
|
||||
print_separator("stack");
|
||||
|
||||
ctx.run_type().execute(stack).arg("upgrade").status_checked()
|
||||
ctx.execute(stack).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_ghcup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let ghcup = require("ghcup")?;
|
||||
print_separator("ghcup");
|
||||
|
||||
ctx.run_type().execute(ghcup).arg("upgrade").status_checked()
|
||||
ctx.execute(ghcup).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -884,10 +848,10 @@ pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("TeX Live package manager");
|
||||
|
||||
let mut command = if directory_writable {
|
||||
ctx.run_type().execute(&tlmgr)
|
||||
ctx.execute(&tlmgr)
|
||||
} else {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
let mut c = ctx.run_type().execute(sudo);
|
||||
let mut c = ctx.execute(sudo);
|
||||
c.arg(&tlmgr);
|
||||
c
|
||||
};
|
||||
@@ -902,7 +866,7 @@ pub fn run_chezmoi_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("chezmoi");
|
||||
|
||||
ctx.run_type().execute(chezmoi).arg("update").status_checked()
|
||||
ctx.execute(chezmoi).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -911,14 +875,12 @@ pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("myrepos");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&myrepos)
|
||||
ctx.execute(&myrepos)
|
||||
.arg("--directory")
|
||||
.arg(&*HOME_DIR)
|
||||
.arg("checkout")
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&myrepos)
|
||||
ctx.execute(&myrepos)
|
||||
.arg("--directory")
|
||||
.arg(&*HOME_DIR)
|
||||
.arg("update")
|
||||
@@ -927,7 +889,7 @@ pub fn run_myrepos_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
pub fn run_custom_command(name: &str, command: &str, ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator(name);
|
||||
let mut exec = ctx.run_type().execute(shell());
|
||||
let mut exec = ctx.execute(shell());
|
||||
#[cfg(unix)]
|
||||
let command = if let Some(command) = command.strip_prefix("-i ") {
|
||||
exec.arg("-i");
|
||||
@@ -964,32 +926,31 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
// If self-update fails without sudo then there's probably an update
|
||||
let has_update = match ctx.run_type().execute(&composer).arg("self-update").output()? {
|
||||
let has_update = match ctx.execute(&composer).arg("self-update").output()? {
|
||||
ExecutorOutput::Wet(output) => !output.status.success(),
|
||||
_ => false
|
||||
};
|
||||
|
||||
if has_update {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&composer)
|
||||
.arg("self-update")
|
||||
.status_checked()?;
|
||||
ctx.execute(sudo)
|
||||
.arg(&composer)
|
||||
.arg("self-update")
|
||||
.status_checked()?;
|
||||
}
|
||||
} else {
|
||||
ctx.run_type().execute(&composer).arg("self-update").status_checked()?;
|
||||
ctx.execute(&composer).arg("self-update").status_checked()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let output = ctx.run_type().execute(&composer).args(["global", "update"]).output()?;
|
||||
let output = ctx.execute(&composer).args(["global", "update"]).output()?;
|
||||
if let ExecutorOutput::Wet(output) = output {
|
||||
let output: Utf8Output = output.try_into()?;
|
||||
print!("{}\n{}", output.stdout, output.stderr);
|
||||
if output.stdout.contains("valet") || output.stderr.contains("valet") {
|
||||
if let Some(valet) = which("valet") {
|
||||
ctx.run_type().execute(valet).arg("install").status_checked()?;
|
||||
ctx.execute(valet).arg("install").status_checked()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1003,7 +964,6 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
// Skip when the `dotnet tool list` subcommand fails.
|
||||
// (This is expected when a dotnet runtime is installed but no SDK.)
|
||||
let output = match ctx
|
||||
.run_type()
|
||||
.execute(&dotnet)
|
||||
.args(["tool", "list", "--global"])
|
||||
// dotnet will print a greeting message on its first run, from this question:
|
||||
@@ -1052,8 +1012,7 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
for package in packages {
|
||||
let package_name = package.split_whitespace().next().unwrap();
|
||||
ctx.run_type()
|
||||
.execute(&dotnet)
|
||||
ctx.execute(&dotnet)
|
||||
.args(["tool", "update", package_name, "--global"])
|
||||
.status_checked()
|
||||
.with_context(|| format!("Failed to update .NET package {package_name:?}"))?;
|
||||
@@ -1090,7 +1049,7 @@ fn get_hx(ctx: &ExecutionContext) -> Result<Hx> {
|
||||
let hx = require("hx")?;
|
||||
|
||||
// Check if `hx --help` mentions "helix". Helix does, hx (hexdump alternative) doesn't.
|
||||
let output = ctx.run_type().execute(&hx).arg("--help").output_checked()?;
|
||||
let output = ctx.execute(&hx).arg("--help").output_checked()?;
|
||||
|
||||
if String::from_utf8(output.stdout)?.contains("helix") {
|
||||
debug!("Detected `hx` as Helix");
|
||||
@@ -1106,14 +1065,12 @@ pub fn run_helix_grammars(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Helix");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&helix)
|
||||
ctx.execute(&helix)
|
||||
.args(["--grammar", "fetch"])
|
||||
.status_checked()
|
||||
.with_context(|| "Failed to download helix grammars!")?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&helix)
|
||||
ctx.execute(&helix)
|
||||
.args(["--grammar", "build"])
|
||||
.status_checked()
|
||||
.with_context(|| "Failed to build helix grammars!")?;
|
||||
@@ -1126,17 +1083,14 @@ pub fn run_raco_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Racket Package Manager"));
|
||||
|
||||
ctx.run_type()
|
||||
.execute(raco)
|
||||
.args(["pkg", "update", "--all"])
|
||||
.status_checked()
|
||||
ctx.execute(raco).args(["pkg", "update", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn bin_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let bin = require("bin")?;
|
||||
|
||||
print_separator("Bin");
|
||||
ctx.run_type().execute(bin).arg("update").status_checked()
|
||||
ctx.execute(bin).arg("update").status_checked()
|
||||
}
|
||||
|
||||
pub fn spicetify_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1144,7 +1098,7 @@ pub fn spicetify_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
let spicetify = require("spicetify").or(require("spicetify-cli"))?;
|
||||
|
||||
print_separator("Spicetify");
|
||||
ctx.run_type().execute(spicetify).arg("upgrade").status_checked()
|
||||
ctx.execute(spicetify).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_ghcli_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1156,8 +1110,7 @@ pub fn run_ghcli_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
print_separator(t!("GitHub CLI Extensions"));
|
||||
ctx.run_type()
|
||||
.execute(&gh)
|
||||
ctx.execute(&gh)
|
||||
.args(["extension", "upgrade", "--all"])
|
||||
.status_checked()
|
||||
}
|
||||
@@ -1167,7 +1120,7 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator(t!("Julia Packages"));
|
||||
|
||||
let mut executor = ctx.run_type().execute(julia);
|
||||
let mut executor = ctx.execute(julia);
|
||||
|
||||
executor.arg(if ctx.config().julia_use_startup_file() {
|
||||
"--startup-file=yes"
|
||||
@@ -1185,7 +1138,7 @@ pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let no_repo = "no repositories found";
|
||||
let mut success = true;
|
||||
let mut exec = ctx.run_type().execute(helm);
|
||||
let mut exec = ctx.execute(helm);
|
||||
if let Err(e) = exec.arg("repo").arg("update").status_checked() {
|
||||
error!("Updating repositories failed: {e}");
|
||||
success = match exec.output_checked_utf8() {
|
||||
@@ -1208,7 +1161,7 @@ pub fn run_stew(ctx: &ExecutionContext) -> Result<()> {
|
||||
let stew = require("stew")?;
|
||||
|
||||
print_separator("stew");
|
||||
ctx.run_type().execute(stew).args(["upgrade", "--all"]).status_checked()
|
||||
ctx.execute(stew).args(["upgrade", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_bob(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1216,7 +1169,7 @@ pub fn run_bob(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bob");
|
||||
|
||||
ctx.run_type().execute(bob).args(["update", "--all"]).status_checked()
|
||||
ctx.execute(bob).args(["update", "--all"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1225,7 +1178,7 @@ pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Certbot");
|
||||
|
||||
let mut cmd = ctx.run_type().execute(sudo);
|
||||
let mut cmd = ctx.execute(sudo);
|
||||
cmd.arg(certbot);
|
||||
cmd.arg("renew");
|
||||
|
||||
@@ -1238,7 +1191,7 @@ pub fn run_certbot(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn run_freshclam(ctx: &ExecutionContext) -> Result<()> {
|
||||
let freshclam = require("freshclam")?;
|
||||
print_separator(t!("Update ClamAV Database(FreshClam)"));
|
||||
ctx.run_type().execute(freshclam).status_checked()
|
||||
ctx.execute(freshclam).status_checked()
|
||||
}
|
||||
|
||||
/// Involve `pio upgrade` to update PlatformIO core.
|
||||
@@ -1258,7 +1211,7 @@ pub fn run_platform_io(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("PlatformIO Core");
|
||||
|
||||
ctx.run_type().execute(bin_path).arg("upgrade").status_checked()
|
||||
ctx.execute(bin_path).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
/// Run `lensfun-update-data` to update lensfun database.
|
||||
@@ -1272,16 +1225,14 @@ pub fn run_lensfun_update_data(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().lensfun_use_sudo() {
|
||||
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
|
||||
print_separator(SEPARATOR);
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
ctx.execute(sudo)
|
||||
.arg(lensfun_update_data)
|
||||
// `lensfun-update-data` returns 1 when there is no update available
|
||||
// which should be considered success
|
||||
.status_checked_with_codes(&[EXIT_CODE_WHEN_NO_UPDATE])
|
||||
} else {
|
||||
print_separator(SEPARATOR);
|
||||
ctx.run_type()
|
||||
.execute(lensfun_update_data)
|
||||
ctx.execute(lensfun_update_data)
|
||||
.status_checked_with_codes(&[EXIT_CODE_WHEN_NO_UPDATE])
|
||||
}
|
||||
}
|
||||
@@ -1390,10 +1341,7 @@ pub fn run_poetry(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
print_separator("Poetry");
|
||||
ctx.run_type()
|
||||
.execute(&poetry)
|
||||
.args(["self", "update"])
|
||||
.status_checked()
|
||||
ctx.execute(&poetry).args(["self", "update"]).status_checked()
|
||||
}
|
||||
|
||||
pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1406,11 +1354,7 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
// To check if this feature is enabled or not, different version of `uv` need
|
||||
// different approaches, we need to know the version first and handle them
|
||||
// separately.
|
||||
let uv_version_output = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.arg("--version")
|
||||
.output_checked_utf8()?;
|
||||
let uv_version_output = ctx.execute(&uv_exec).arg("--version").output_checked_utf8()?;
|
||||
// Multiple possible output formats are possible according to uv source code
|
||||
//
|
||||
// https://github.com/astral-sh/uv/blob/6b7f60c1eaa840c2e933a0fb056ab46f99c991a5/crates/uv-cli/src/version.rs#L28-L42
|
||||
@@ -1445,18 +1389,10 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
// For uv before version 0.4.25 (exclusive), the `self` sub-command only
|
||||
// exists under the `self-update` feature, we run `uv self --help` to check
|
||||
// the feature gate.
|
||||
let self_update_feature_enabled = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "--help"])
|
||||
.output_checked()
|
||||
.is_ok();
|
||||
let self_update_feature_enabled = ctx.execute(&uv_exec).args(["self", "--help"]).output_checked().is_ok();
|
||||
|
||||
if self_update_feature_enabled {
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "update"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&uv_exec).args(["self", "update"]).status_checked()?;
|
||||
}
|
||||
} else {
|
||||
// After 0.4.25 (inclusive), running `uv self` succeeds regardless of the
|
||||
@@ -1482,7 +1418,6 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
];
|
||||
|
||||
let output = ctx
|
||||
.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["self", "update"])
|
||||
// `output()` captures the output so that users won't see it for now.
|
||||
@@ -1510,17 +1445,13 @@ pub fn run_uv(ctx: &ExecutionContext) -> Result<()> {
|
||||
};
|
||||
|
||||
// 2. Update the installed tools
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
ctx.execute(&uv_exec)
|
||||
.args(["tool", "upgrade", "--all"])
|
||||
.status_checked()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
// 3. Prune cache
|
||||
ctx.run_type()
|
||||
.execute(&uv_exec)
|
||||
.args(["cache", "prune"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&uv_exec).args(["cache", "prune"]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1532,7 +1463,7 @@ pub fn run_zvm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("ZVM");
|
||||
|
||||
ctx.run_type().execute(zvm).arg("upgrade").status_checked()
|
||||
ctx.execute(zvm).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1540,7 +1471,7 @@ pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bun");
|
||||
|
||||
ctx.run_type().execute(bun).arg("upgrade").status_checked()
|
||||
ctx.execute(bun).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -1560,16 +1491,14 @@ pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
for zig_version in config.zigup_target_versions() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
ctx.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("fetch")
|
||||
.arg(&zig_version)
|
||||
.status_checked()?;
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
ctx.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("keep")
|
||||
.arg(&zig_version)
|
||||
@@ -1578,11 +1507,7 @@ pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(zigup)
|
||||
.args(&path_args)
|
||||
.arg("clean")
|
||||
.status_checked()?;
|
||||
ctx.execute(zigup).args(&path_args).arg("clean").status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1632,7 +1557,7 @@ fn run_jetbrains_ide_generic<const IS_JETBRAINS: bool>(ctx: &ExecutionContext, b
|
||||
print_separator(format!("{prefix}{name} plugins"));
|
||||
|
||||
// The `update` command is undocumented, but tested on all of the below.
|
||||
let output = ctx.run_type().execute(&bin).arg("update").output()?;
|
||||
let output = ctx.execute(&bin).arg("update").output()?;
|
||||
let output = match output {
|
||||
ExecutorOutput::Dry => return Ok(()),
|
||||
ExecutorOutput::Wet(output) => output,
|
||||
@@ -1765,5 +1690,5 @@ pub fn run_yazi(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Yazi packages");
|
||||
|
||||
ctx.run_type().execute(ya).args(["pkg", "upgrade"]).status_checked()
|
||||
ctx.execute(ya).args(["pkg", "upgrade"]).status_checked()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user