Skip to content

Commit

Permalink
Merge pull request #18 from kumparan/feature/gocek
Browse files Browse the repository at this point in the history
feature: add gocek
  • Loading branch information
Muhammad Fahmi Irfananda authored Apr 16, 2020
2 parents d7a45a5 + b4074b2 commit 1270dad
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .ferconfig.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gocek": {
"project_directories": [],
"output_save_folder": ""
}
}
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
#Fer

<a name="v1.6.0"></a>
## [v1.6.0] - 2020-04-16
### New Features
- add fer & gocek config
- add gocek all to check all modules provided
- add gocek to console
- add checker
- add mod model

### Other Improvements
- add .ferconfig.json.example & update README
- remove debug log
- add .ferconfig.json example


<a name="v1.5.4"></a>
## [v1.5.4] - 2020-04-14
### Fixes
- fix self update
- self update ([#17](https://github.com/kumparan/fer/issues/17))


<a name="v1.5.3"></a>
Expand Down Expand Up @@ -84,7 +99,8 @@
- db migrationfile generator ([#3](https://github.com/kumparan/fer/issues/3))


[Unreleased]: https://github.com/kumparan/fer/compare/v1.5.4...HEAD
[Unreleased]: https://github.com/kumparan/fer/compare/v1.6.0...HEAD
[v1.6.0]: https://github.com/kumparan/fer/compare/v1.5.4...v1.6.0
[v1.5.4]: https://github.com/kumparan/fer/compare/v1.5.3...v1.5.4
[v1.5.3]: https://github.com/kumparan/fer/compare/v1.5.2...v1.5.3
[v1.5.2]: https://github.com/kumparan/fer/compare/v1.5.1...v1.5.2
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ fer version
- [x] Generate Service&test files and Client files From Proto
- [x] DB migration file generator
- [x] Generate Repository (include model)
- [x] Gocek, checks go mod update info
- [ ] Add worker with command
- [ ] Add Nats Subscriber with command

## Config
Add `.ferconfig.json` into `$HOME/.ferconfig.json`, use the `.ferconfig.json.example` as reference

## Kumparan Microservices Generator
`fer generate project content-service --proto pb/example/example.proto`

Expand Down Expand Up @@ -99,3 +103,9 @@ for deployment, push deployment tag
`fer create chglog vx.x.x`
to generate CHANGELOG.md

## Gocek
`fer gocek`
check current working directory

`fer gocek all`
check all directory listed in `.ferconfig.json`
11 changes: 11 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package config

import (
"os"
"path/filepath"
)

// FerConfigPath :nodoc:
func FerConfigPath() string {
return filepath.Join(os.Getenv("HOME"), ".ferconfig.json")
}
3 changes: 2 additions & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const (
RichgoInstallerURL = "github.com/kyoh86/richgo"
// GolintInstallerURL :nodoc:
GolintInstallerURL = "github.com/golangci/golangci-lint/cmd/golangci-lint"
ProtobufVersion = "3.7.1"
// ProtobufVersion :nodoc:
ProtobufVersion = "3.7.1"
// ProtobufOSXInstallerURL :nodoc:
ProtobufOSXInstallerURL = "https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-osx-x86_64.zip"
// ProtobufLinuxInstallerURL :nodoc:
Expand Down
69 changes: 69 additions & 0 deletions config/ferconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package config

import (
"encoding/json"
"io/ioutil"
"os"
"sync"

log "github.com/sirupsen/logrus"
)

var cfg FerConfig
var once sync.Once

// GocekConfig :nodoc:
type GocekConfig struct {
ProjectDirs []string `json:"project_directories"`
SaveOutputDir string `json:"output_save_folder"`
}

// FerConfig :nodoc:
type FerConfig struct {
Gocek GocekConfig `json:"gocek"`
}

func init() {
once.Do(func() {
loadCfg()
})
}

func loadCfg() {
cfgPath := FerConfigPath()
_, err := os.Stat(cfgPath)
switch {
case os.IsNotExist(err):
f, err := os.Create(cfgPath)
if err != nil {
log.Fatal(err)
}
defer f.Close()

cfg.Gocek.ProjectDirs = make([]string, 0)
bt, _ := json.MarshalIndent(cfg, "", " ")
_, err = f.Write([]byte(bt))
if err != nil {
log.Fatal(err)
}

case err == nil:
b, err := ioutil.ReadFile(FerConfigPath())
if err != nil {
log.Fatal(err)
}

err = json.Unmarshal(b, &cfg)
if err != nil {
log.Fatal(err)
}

default:
log.Fatal(err)
}
}

// GetFerConfig :nodoc:
func GetFerConfig() FerConfig {
return cfg
}
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package config

// Version define version of fer
const Version = "v1.5.4"
const Version = "v1.6.0"
39 changes: 39 additions & 0 deletions console/gocek.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package console

import (
"github.com/kumparan/fer/config"
"github.com/kumparan/fer/gocek"
"github.com/spf13/cobra"
)

func init() {
gocekCmd.AddCommand(gocekAllCmd)
rootCmd.AddCommand(gocekCmd)
}

var gocekCmd = &cobra.Command{
Use: "gocek",
Short: "gocek check a module update info",
Long: `default check current working directory`,
Run: gocekCWD,
}

var gocekAllCmd = &cobra.Command{
Use: "all",
Short: "check all module update info",
Run: gocekAll,
}

func gocekAll(cmd *cobra.Command, args []string) {
cfg := config.GetFerConfig()
checker := gocek.ModuleChecker{
RootDir: cfg.Gocek.SaveOutputDir,
}

checker.Checks(cfg.Gocek.ProjectDirs)
}

func gocekCWD(cmd *cobra.Command, args []string) {
checker := gocek.ModuleChecker{}
checker.CheckCWD()
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ require (
github.com/hashicorp/go-version v1.2.0
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
github.com/kr/pretty v0.1.0 // indirect
github.com/magiconair/properties v1.8.0
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.4.0
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY79
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -45,15 +47,21 @@ github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW1
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
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/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q=
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
Expand All @@ -78,6 +86,7 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191009170203-06d7bd2c5f4f h1:hjzMYz/7Ea1mNKfOnFOfktR0mlA5jqhvywClCMHM/qw=
Expand Down
Loading

0 comments on commit 1270dad

Please sign in to comment.