committed by
GitHub
parent
06369e6e4a
commit
f5e6dc0fb3
@@ -150,7 +150,6 @@ fn run() -> Result<()> {
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
runner.execute(Step::Brew, "Brew Cask", || macos::run_brew_cask(&ctx))?;
|
|
||||||
runner.execute(Step::MacPorts, "MacPorts", || macos::run_macports(&ctx))?;
|
runner.execute(Step::MacPorts, "MacPorts", || macos::run_macports(&ctx))?;
|
||||||
runner.execute(Step::MicrosoftAutoUpdate, "Microsoft AutoUpdate", || {
|
runner.execute(Step::MicrosoftAutoUpdate, "Microsoft AutoUpdate", || {
|
||||||
macos::run_msupdate(&ctx)
|
macos::run_msupdate(&ctx)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{CommandExt, RunType};
|
use crate::executor::RunType;
|
||||||
use crate::terminal::{print_separator, prompt_yesno};
|
use crate::terminal::{print_separator, prompt_yesno};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::TopgradeError,
|
error::TopgradeError,
|
||||||
@@ -19,40 +19,6 @@ pub fn run_msupdate(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
ctx.run_type().execute(msupdate).arg("--install").check_run()
|
ctx.run_type().execute(msupdate).arg("--install").check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_brew_cask(ctx: &ExecutionContext) -> Result<()> {
|
|
||||||
let brew = require("brew")?;
|
|
||||||
print_separator("Brew Cask");
|
|
||||||
|
|
||||||
let config = ctx.config();
|
|
||||||
let run_type = ctx.run_type();
|
|
||||||
|
|
||||||
let cask_upgrade_exists = Command::new(&brew)
|
|
||||||
.args(&["--repository", "buo/cask-upgrade"])
|
|
||||||
.check_output()
|
|
||||||
.map(|p| Path::new(p.trim()).exists())?;
|
|
||||||
|
|
||||||
let cask_args = if cask_upgrade_exists {
|
|
||||||
let mut args = vec!["cu", "-y"];
|
|
||||||
if config.brew_cask_greedy() {
|
|
||||||
args.push("-a");
|
|
||||||
}
|
|
||||||
args
|
|
||||||
} else {
|
|
||||||
let mut args = vec!["upgrade", "--cask"];
|
|
||||||
if config.brew_cask_greedy() {
|
|
||||||
args.push("--greedy");
|
|
||||||
}
|
|
||||||
args
|
|
||||||
};
|
|
||||||
run_type.execute(&brew).args(&cask_args).check_run()?;
|
|
||||||
|
|
||||||
if ctx.config().cleanup() {
|
|
||||||
run_type.execute(&brew).arg("cleanup").check_run()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
||||||
require("port")?;
|
require("port")?;
|
||||||
let sudo = ctx.sudo().as_ref().unwrap();
|
let sudo = ctx.sudo().as_ref().unwrap();
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
use crate::error::SkipStep;
|
use crate::error::SkipStep;
|
||||||
use crate::error::TopgradeError;
|
use crate::error::TopgradeError;
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{ExecutorExitStatus, RunType};
|
use crate::executor::{CommandExt, ExecutorExitStatus, RunType};
|
||||||
use crate::terminal::{print_separator, print_warning};
|
use crate::terminal::{print_separator, print_warning};
|
||||||
use crate::utils::{require, PathExt};
|
use crate::utils::{require, PathExt};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::env;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::{env, path::Path};
|
||||||
|
|
||||||
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||||
let fish = require("fish")?;
|
let fish = require("fish")?;
|
||||||
@@ -47,11 +47,37 @@ pub fn run_brew(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
print_separator("Brew");
|
print_separator("Brew");
|
||||||
let run_type = ctx.run_type();
|
let run_type = ctx.run_type();
|
||||||
|
|
||||||
|
let cask_upgrade_exists = Command::new(&brew)
|
||||||
|
.args(&["--repository", "buo/cask-upgrade"])
|
||||||
|
.check_output()
|
||||||
|
.map(|p| Path::new(p.trim()).exists())?;
|
||||||
|
|
||||||
|
let mut brew_args = vec!["upgrade", "--ignore-pinned"];
|
||||||
|
|
||||||
|
if cask_upgrade_exists {
|
||||||
|
brew_args.push("--formula")
|
||||||
|
}
|
||||||
|
if ctx.config().brew_cask_greedy() {
|
||||||
|
brew_args.push("--greedy");
|
||||||
|
}
|
||||||
|
|
||||||
run_type.execute(&brew).arg("update").check_run()?;
|
run_type.execute(&brew).arg("update").check_run()?;
|
||||||
run_type
|
run_type.execute(&brew).args(&brew_args).check_run()?;
|
||||||
.execute(&brew)
|
|
||||||
.args(&["upgrade", "--ignore-pinned"])
|
if cask_upgrade_exists {
|
||||||
.check_run()
|
let mut args = vec!["cu", "-y"];
|
||||||
|
if ctx.config().brew_cask_greedy() {
|
||||||
|
args.push("-a");
|
||||||
|
}
|
||||||
|
|
||||||
|
run_type.execute(&brew).args(&args).check_run()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.config().cleanup() {
|
||||||
|
run_type.execute(&brew).arg("cleanup").check_run()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user