Skip to content

Commit

Permalink
Merge pull request #176 from liquibase/feature/lint-update-release
Browse files Browse the repository at this point in the history
Feature/lint update release
  • Loading branch information
mcred authored Nov 15, 2022
2 parents e786ad7 + fc5c7be commit 9c9554c
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '^1.16.0'
go-version: '^1.19.0'

- name: Setup GO environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-update-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '^1.16.0'
go-version: '^1.19.0'

- name: Setup GO environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '^1.16.0'
go-version: '^1.19.0'

- name: Setup GO environment
run: |
Expand Down
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@ VERSION=`cat $(PWD)/VERSION`
VEXRUN_FILE := $(PWD)/utils/vexrun.jar
VEXRUN := java -jar $(VEXRUN_FILE)

.PHONY: build darwin windows linux rpi s390x
.PHONY: build darwin_amd64 darwin_arm64 windows linux_amd64 linux_arm64 s390x

release: updateVersion darwin windows linux rpi s390x
release: updateVersion darwin_amd64 darwin_arm64 windows linux_amd64 linux_arm64 s390x

windows:
GOOS=windows GOARCH=amd64 go build -o $(PWD)/bin/windows/lpm.exe $(PWD)/cmd/lpm/windows.go
cd $(PWD)/bin/windows && zip lpm-$(VERSION)-windows.zip lpm.exe

darwin:
GOOS=darwin GOARCH=amd64 go build -o $(PWD)/bin/darwin/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/darwin && zip lpm-$(VERSION)-darwin.zip lpm
darwin_amd64:
GOOS=darwin GOARCH=amd64 go build -o $(PWD)/bin/darwin_amd64/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/darwin_amd64 && zip lpm-$(VERSION)-darwin.zip lpm

linux:
GOOS=linux GOARCH=amd64 GOARM=7 go build -o $(PWD)/bin/linux/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/linux && zip lpm-$(VERSION)-linux.zip lpm
darwin_arm64:
GOOS=darwin GOARCH=arm64 go build -o $(PWD)/bin/darwin_arm64/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/darwin_arm64 && zip lpm-$(VERSION)-darwin-arm64.zip lpm

rpi:
GOOS=linux GOARCH=arm64 GOARM=7 go build -o $(PWD)/bin/rpi/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/rpi && zip lpm-$(VERSION)-rpi.zip lpm
linux_amd64:
GOOS=linux GOARCH=amd64 GOARM=7 go build -o $(PWD)/bin/linux_amd64/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/linux_amd64 && zip lpm-$(VERSION)-linux.zip lpm

linux_arm64:
GOOS=linux GOARCH=arm64 GOARM=7 go build -o $(PWD)/bin/linux_arm64/lpm $(PWD)/cmd/lpm/darwin.go
cd $(PWD)/bin/linux_arm64 && zip lpm-$(VERSION)-linux-arm64.zip lpm

s390x:
GOOS=linux GOARCH=s390x go build -o $(PWD)/bin/s390x/lpm $(PWD)/cmd/lpm/darwin.go
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.2.0
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module package-manager

go 1.18
go 1.19

require (
github.com/google/go-github/v39 v39.2.0
github.com/hashicorp/go-version v1.6.0
github.com/spf13/cobra v1.6.1
github.com/vifraa/gopom v0.2.1
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
)

Expand All @@ -14,7 +15,6 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vifraa/gopom v0.2.1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210716203947-853a461950ff // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -117,6 +118,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
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/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand All @@ -127,6 +129,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vifraa/gopom v0.2.1 h1:MYVMAMyiGzXPPy10EwojzKIL670kl5Zbae+o3fFvQEM=
github.com/vifraa/gopom v0.2.1/go.mod h1:oPa1dcrGrtlO37WPDBm5SqHAT+wTgF8An1Q71Z6Vv4o=
Expand Down Expand Up @@ -384,6 +387,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
29 changes: 15 additions & 14 deletions internal/app/App.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ import (
_ "embed" // Embed Import for Package Files
"encoding/json"
"io/fs"
"io/ioutil"
"os"
"package-manager/internal/app/errors"
"package-manager/internal/app/packages"
"package-manager/internal/app/utils"
)

//go:embed "VERSION"
var version string

//PackagesJSON is embedded for first time run
// PackagesJSON is embedded for first time run
//
//go:embed "packages.json"
var PackagesJSON []byte

//PackageFile exported for overwrite
// PackageFile exported for overwrite
var PackageFile = "packages.json"

//Classpath exported for overwrite
// Classpath exported for overwrite
var Classpath string

//ClasspathFiles exported for overwrite
// ClasspathFiles exported for overwrite
var ClasspathFiles []fs.FileInfo

//Version output from embedded file
// Version output from embedded file
func Version() string {
return version
}

//SetClasspath to switch between global and local modules
// SetClasspath to switch between global and local modules
func SetClasspath(global bool, globalpath string, globalpathFiles []fs.FileInfo) {
if global {
Classpath = globalpath
Expand All @@ -42,25 +43,25 @@ func SetClasspath(global bool, globalpath string, globalpathFiles []fs.FileInfo)
errors.Exit(err.Error(), 1)
}
Classpath = pwd + "/liquibase_libs/"
ClasspathFiles, _ = ioutil.ReadDir(Classpath)
ClasspathFiles, _ = utils.ReadDir(Classpath)
}
}

//PackagesInClassPath is the packages.json file in global classpath
// PackagesInClassPath is the packages.json file in global classpath
func PackagesInClassPath(cp string) bool {
_, err := os.Stat(cp + PackageFile)
return err == nil
}

//CopyPackagesToClassPath install packages.json to global classpath
// CopyPackagesToClassPath install packages.json to global classpath
func CopyPackagesToClassPath(cp string, p []byte) {
err := ioutil.WriteFile(cp+PackageFile, p, 0664)
err := os.WriteFile(cp+PackageFile, p, 0664)
if err != nil {
errors.Exit(err.Error(), 1)
}
}

//LoadPackages get packages from bytes from file
// LoadPackages get packages from bytes from file
func LoadPackages(b []byte) packages.Packages {
var e packages.Packages
err := json.Unmarshal(b, &e)
Expand All @@ -70,7 +71,7 @@ func LoadPackages(b []byte) packages.Packages {
return e
}

//WritePackages write packages back to file
// WritePackages write packages back to file
func WritePackages(p packages.Packages) {
b, err := json.MarshalIndent(p, "", " ")
if err != nil {
Expand All @@ -80,7 +81,7 @@ func WritePackages(p packages.Packages) {
if err != nil {
errors.Exit(err.Error(), 1)
}
err = ioutil.WriteFile(pwd+"/internal/app/packages.json", b, 0664)
err = os.WriteFile(pwd+"/internal/app/packages.json", b, 0664)
if err != nil {
errors.Exit(err.Error(), 1)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/app/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.2.0
8 changes: 4 additions & 4 deletions internal/app/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package commands

import (
"github.com/spf13/cobra"
"io"
"io/fs"
"io/ioutil"
"os"
"package-manager/internal/app"
"package-manager/internal/app/errors"
Expand All @@ -27,12 +27,12 @@ var rootCmd = &cobra.Command{
Search for, install, and uninstall liquibase drivers, extensions, and utilities.`,
}

//Execute main entry point for CLI
// Execute main entry point for CLI
func Execute(cp string, s string) {
var err error
liquibase = utils.LoadLiquibase(cp)
globalpath = liquibase.Homepath + "lib" + s
globalpathFiles, err = ioutil.ReadDir(globalpath)
globalpathFiles, err = utils.ReadDir(globalpath)
if err != nil {
errors.Exit(err.Error(), 1)
}
Expand Down Expand Up @@ -62,7 +62,7 @@ func initConfig() {
if err != nil {
errors.Exit(err.Error(), 1)
}
b, _ := ioutil.ReadAll(jsonFile)
b, _ := io.ReadAll(jsonFile)

//Load Bytes to Packages
packs = app.LoadPackages(b)
Expand Down
4 changes: 2 additions & 2 deletions internal/app/commands/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package commands
import (
"fmt"
"github.com/spf13/cobra"
"io/ioutil"
"io"
"os"
"package-manager/internal/app"
"package-manager/internal/app/errors"
Expand Down Expand Up @@ -33,7 +33,7 @@ var updateCmd = &cobra.Command{
if err != nil {
errors.Exit(err.Error(), 1)
}
bytes, err = ioutil.ReadAll(file)
bytes, err = io.ReadAll(file)
if err != nil {
errors.Exit(err.Error(), 1)
}
Expand Down
19 changes: 9 additions & 10 deletions internal/app/dependencies/Dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package dependencies

import (
"encoding/json"
"io/ioutil"
"os"
"package-manager/internal/app/errors"
)

//FileLocation exported for testing overwrite
// FileLocation exported for testing overwrite
var FileLocation string

func init() {
Expand All @@ -18,12 +17,12 @@ func init() {
FileLocation = pwd + "/liquibase.json"
}

//Dependencies main wrapper for liquibase.json objects
// Dependencies main wrapper for liquibase.json objects
type Dependencies struct {
Dependencies []Dependency `json:"dependencies"`
}

//CreateFile init liquibase.json file in pwd
// CreateFile init liquibase.json file in pwd
func (d Dependencies) CreateFile() {
file, err := os.Create(FileLocation)
if err != nil {
Expand All @@ -33,19 +32,19 @@ func (d Dependencies) CreateFile() {
d.Write()
}

//Write dump contents to liquibase.json
// Write dump contents to liquibase.json
func (d Dependencies) Write() {
file, err := json.MarshalIndent(d, "", " ")
if err != nil {
errors.Exit(err.Error(), 1)
}
err = ioutil.WriteFile(FileLocation, file, 0664)
err = os.WriteFile(FileLocation, file, 0664)
if err != nil {
errors.Exit(err.Error(), 1)
}
}

//Read get contents from liquibase.json
// Read get contents from liquibase.json
func (d *Dependencies) Read() {
file, _ := os.Open(FileLocation)
defer file.Close()
Expand All @@ -55,17 +54,17 @@ func (d *Dependencies) Read() {
}
}

//FileExists does the liquibase.json file exist
// FileExists does the liquibase.json file exist
func (d Dependencies) FileExists() bool {
_, err := os.Stat(FileLocation)
return err == nil
}

//Remove remove specific dependency from group
// Remove remove specific dependency from group
func (d *Dependencies) Remove(n string) {
for i, m := range d.Dependencies {
if m.GetName() == n {
d.Dependencies = append(d.Dependencies[:i], d.Dependencies[i+1:]...)
}
}
}
}
Loading

0 comments on commit 9c9554c

Please sign in to comment.