From 69999870d8f2f470a1c825ee2e10b1ebe55f9e2e Mon Sep 17 00:00:00 2001 From: Nicconike <38905025+Nicconike@users.noreply.github.com> Date: Wed, 16 Oct 2024 01:56:22 +0530 Subject: [PATCH] update to v2 --- files/go.json | 2 +- go.mod | 8 ++++---- go.sum | 42 ++++++++++++++++++++++-------------------- main.go | 21 ++++++++++++++------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/files/go.json b/files/go.json index a69d538..cabdc20 100644 --- a/files/go.json +++ b/files/go.json @@ -2,6 +2,6 @@ "goVersion": "1.19.5", "projectName": "test-automatedgo", "dependencies": [ - "github.com/Nicconike/AutomatedGo" + "github.com/Nicconike/AutomatedGo/v2" ] } diff --git a/go.mod b/go.mod index 2c44f90..e7b2a18 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,12 @@ module test-automatedgo go 1.23.1 -require github.com/Nicconike/AutomatedGo v1.2.0 +require github.com/Nicconike/AutomatedGo/v2 v2.0.3 require ( github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/schollz/progressbar/v3 v3.14.6 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.22.0 // indirect + github.com/schollz/progressbar/v3 v3.16.1 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect ) diff --git a/go.sum b/go.sum index 8a43667..ae9381c 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,30 @@ -github.com/Nicconike/AutomatedGo v1.2.0 h1:3YFXVEIlxYefceYxBQzTE85gAZsOmz5dam0VYwZQzWM= -github.com/Nicconike/AutomatedGo v1.2.0/go.mod h1:/bfI8xoEg48inxL9+kq/Ky16hwcwE2zwZpEukomjFoc= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/Nicconike/AutomatedGo/v2 v2.0.3 h1:o363ZbQgWGAR1RAXBhcglbZlelLQjnBo07TbEN7K2as= +github.com/Nicconike/AutomatedGo/v2 v2.0.3/go.mod h1:RjMoanHWbJr2Mx/PLe9oKdMIzJfY8/udApmcBnpHvSs= +github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7mk9/PwM= +github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/schollz/progressbar/v3 v3.14.6 h1:GyjwcWBAf+GFDMLziwerKvpuS7ZF+mNTAXIB2aspiZs= -github.com/schollz/progressbar/v3 v3.14.6/go.mod h1:Nrzpuw3Nl0srLY0VlTvC4V6RL50pcEymjy6qyJAaLa0= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +github.com/schollz/progressbar/v3 v3.16.0 h1:+MbBim/cE9DqDb8UXRfLJ6RZdyDkXG1BDy/sWc5s0Mc= +github.com/schollz/progressbar/v3 v3.16.0/go.mod h1:lLiKjKJ9/yzc9Q8jk+sVLfxWxgXKsktvUf6TO+4Y2nw= +github.com/schollz/progressbar/v3 v3.16.1 h1:RnF1neWZFzLCoGx8yp1yF7SDl4AzNDI5y4I0aUJRrZQ= +github.com/schollz/progressbar/v3 v3.16.1/go.mod h1:I2ILR76gz5VXqYMIY/LdLecvMHDPVcQm3W/MSKi1TME= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index ac58f16..d0656b5 100644 --- a/main.go +++ b/main.go @@ -5,32 +5,39 @@ import ( "log" "os/exec" - "github.com/Nicconike/AutomatedGo/pkg" + "github.com/Nicconike/AutomatedGo/v2/pkg" ) func main() { + // Create a new VersionService + service := &pkg.VersionService{ + Downloader: &pkg.DefaultDownloader{}, + Remover: &pkg.DefaultRemover{}, + Checksum: &pkg.DefaultChecksumCalculator{}, + } + // Get the latest Go version - latestVersion, err := pkg.GetLatestVersion() + latestVersion, err := service.GetLatestVersion() if err != nil { log.Fatalf("Error getting latest version: %v", err) } fmt.Printf("Latest Go version: %s\n", latestVersion) // Get current version - currentVersion, err := pkg.GetCurrentVersion("tests/Dockerfile", "") + currentVersion, err := service.GetCurrentVersion("tests/Dockerfile", "") if err != nil { log.Fatalf("Error getting current version: %v", err) } fmt.Printf("Current Go version: %s\n", currentVersion) // Check if update is needed - if !pkg.IsNewer(latestVersion, currentVersion) { + if !service.IsNewer(latestVersion, currentVersion) { fmt.Println("Already on the latest version. No update needed.") return } // Download the latest Go version - err = pkg.DownloadGo(latestVersion, "", "") + err = service.DownloadGo(latestVersion, "", "", "") if err != nil { log.Fatalf("Error downloading Go: %v", err) } @@ -50,8 +57,8 @@ func commitAndPush(version string) error { name string args []string }{ - {"git", []string{"config", "--local", "user.name", "nicconike"}}, - {"git", []string{"config", "--local", "user.email", "38905025+Nicconike@users.noreply.github.com"}}, + {"git", []string{"config", "--local", "user.name", "github-actions[bot]"}}, + {"git", []string{"config", "--local", "user.email", "41898282+github-actions[bot]@users.noreply.github.com"}}, {"git", []string{"add", "."}}, {"git", []string{"commit", "-m", fmt.Sprintf("Update Go version to %s", version)}}, {"git", []string{"push"}},