diff --git a/.gitignore b/.gitignore index 61e8d90..5a5914a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store -dist covprofile +dist +vendor diff --git a/.goreleaser.yml b/.goreleaser.yml index 7d5c3b1..7ef92ed 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,8 +1,8 @@ builds: - goos: - - linux - - darwin - - windows + - linux + - darwin + - windows brews: - tap: diff --git a/CHANGELOG.md b/CHANGELOG.md index f3e3763..0ed19d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v3.2.0 (2022-05-21) + +- Adds a `--greedy` CLI flag so casks can be updated even if they have a UI "auto-update" feature (helps keep Homebrew app versions synced better with what they actually are) + ## v3.1.3 (2022-03-23) - Corrects project namespace by appending `/v3` diff --git a/README.md b/README.md index 50a5762..7d476d2 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,8 @@ Options: Update your Homebrew instance. --force Forces actions such as backing up even when there are errors. (Brew only) + -greedy + Force updates to casks that have auto-update capabilities in their respective UIs. ``` ## Development diff --git a/go.mod b/go.mod index 3928c23..85af98f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( ) require ( - github.com/BurntSushi/toml v1.0.0 // indirect + github.com/BurntSushi/toml v1.1.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index f84f17b..d2027eb 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/justintime50/mockcmd v0.3.0 h1:ifEMnpeUHrnWulgDu3AzfehaWWGCsHj9zbGbabw+Czs= github.com/justintime50/mockcmd v0.3.0/go.mod h1:laf0jpehca2YLCiBUZZ508uc6Y1WLzT5Lqspg25KHoI= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= diff --git a/main.go b/main.go index 0ba27d5..c627a3c 100644 --- a/main.go +++ b/main.go @@ -31,10 +31,11 @@ func main() { brewUpdate := flag.Bool("update", false, "Update your Homebrew instance.") brewBackup := flag.Bool("backup", false, "Backup your Homebrew instance.") force := flag.Bool("force", false, "Forces actions such as backing up even when there are errors.") + greedy := flag.Bool("greedy", false, "Force updates to casks that have auto-update capabilities in their respective UIs.") flag.Parse() if *brewUpdate { - brew.Update() + brew.Update(*greedy) return } else if *brewBackup { brew.Backup(*force) diff --git a/src/brew/update.go b/src/brew/update.go index 42efe6d..266bc8b 100644 --- a/src/brew/update.go +++ b/src/brew/update.go @@ -5,12 +5,13 @@ import ( "log" "os" "os/exec" + "strings" "github.com/Justintime50/alchemist/v3/src/general" ) // Update updates your Homebrew instance -func Update() { +func Update(greedy bool) { action := "update" alchemistUpdateDir := general.SetupDir(action) general.SetupLogging(alchemistUpdateDir, action) @@ -40,8 +41,13 @@ func Update() { } fmt.Println("Alchemist is upgrading brew casks...") - upgradeCasks, upgradeCasksErr := general.RunCommand(exec.Command, "brew", []string{"upgrade", "--cask"}) - if upgradeCasks != nil { + upgradeCaskCommand := []string{"upgrade", "--cask"} + if greedy { + upgradeCaskCommand = []string{"upgrade", "--cask", "--greedy"} + } + upgradeCasks, upgradeCasksErr := general.RunCommand(exec.Command, "brew", upgradeCaskCommand) + // Skip if no errors or if the cask cannot be updated due to having a manual installer + if upgradeCasks != nil || strings.Contains(fmt.Sprint(upgradeCasksErr), "installer manual") { fmt.Println("Alchemist upgraded brew casks!") log.Printf("brew upgrade --cask: %s", upgradeCasks) } else {