Skip to content

Commit

Permalink
feat: update command
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Dec 31, 2024
1 parent 3fc7362 commit 62cd831
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 88 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log (go-package-manager)

## 0.24.0

- feat: `update` command which updates all dependencies of current project
- refactor: updated all dependencies

## 0.23.0

- refactor: `generate project` now runs in a terminal UI
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- [Start project](#start-project-)
- [Synchronize with Git remotes](#synchronize-with-git-remotes-)
- [Uninstall dependencies](#uninstall-dependencies-)
- [Update dependencies](#update-dependencies-)
- [Setup AI](#setup-ai-)
- [OpenAI / ChatGPT](#openai--chatgpt-)
- [Ollama](#ollama-)
Expand Down Expand Up @@ -546,6 +547,14 @@ gpm uninstall yaml

later which will simply call `go get -u https://github.com/go-yaml/yaml@none` instead.

#### Update dependencies [<a href="#commands-">↑</a>]

```bash
gpm update
```

is a short version of `go get -u ./... && go mod tidy` and will update all dependencies.

## Setup AI [<a href="#table-of-contents">↑</a>]

If you would like to use AI feature, like suggestion of branch names, you can setup one of the following APIs:
Expand Down
52 changes: 52 additions & 0 deletions commands/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// MIT License
//
// Copyright (c) 2024 Marcel Joachim Kloubert (https://marcel.coffee)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package commands

import (
"github.com/mkloubert/go-package-manager/types"
"github.com/spf13/cobra"
)

func Init_Update_Command(parentCmd *cobra.Command, app *types.AppContext) {
var noCleanup bool

var updateCmd = &cobra.Command{
Use: "update",
Aliases: []string{"upd"},
Short: "Update dependencies",
Long: `Updates all dependencies in this project.`,
Run: func(cmd *cobra.Command, args []string) {
app.RunShellCommandByArgs("go", "get", "-u", "./...")

if !noCleanup {
app.RunShellCommandByArgs("go", "mod", "tidy")
}
},
}

updateCmd.Flags().BoolVarP(&noCleanup, "no-cleanup", "", false, "do not cleanup go.mod and go.sum")

parentCmd.AddCommand(
updateCmd,
)
}
41 changes: 20 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,60 @@ go 1.22.0
require (
github.com/alecthomas/chroma v0.10.0
github.com/atotto/clipboard v0.1.4
github.com/briandowns/spinner v1.23.0
github.com/briandowns/spinner v1.23.1
github.com/c-bata/go-prompt v0.2.6
github.com/charmbracelet/glamour v0.8.0
github.com/fatih/color v1.17.0
github.com/fatih/color v1.18.0
github.com/gdamore/tcell/v2 v2.7.4
github.com/gizak/termui/v3 v3.1.0
github.com/goccy/go-yaml v1.11.3
github.com/hashicorp/go-version v1.6.0
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/goccy/go-yaml v1.15.13
github.com/hashicorp/go-version v1.7.0
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/joho/godotenv v1.5.1
github.com/rivo/tview v0.0.0-20241227133733-17b7edb88c57
github.com/schollz/progressbar/v3 v3.14.2
github.com/shirou/gopsutil/v3 v3.24.4
github.com/schollz/progressbar/v3 v3.17.1
github.com/shirou/gopsutil/v3 v3.24.5
github.com/spf13/cobra v1.8.1
)

require (
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/lipgloss v0.12.1 // indirect
github.com/charmbracelet/x/ansi v0.1.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.6.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/gdamore/encoding v1.0.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-tty v0.0.5 // indirect
github.com/mattn/go-tty v0.0.7 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yuin/goldmark v1.7.4 // indirect
github.com/yuin/goldmark-emoji v1.0.3 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-emoji v1.0.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 62cd831

Please sign in to comment.