From d27ebc3281cc792e8bf2ef435fd35cd5eff8ee85 Mon Sep 17 00:00:00 2001 From: "fahmi.irfan" Date: Fri, 4 Sep 2020 15:26:36 +0700 Subject: [PATCH 1/2] feature: update gocek checker result path --- console/gocek.go | 5 +++-- gocek/checker.go | 41 ++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/console/gocek.go b/console/gocek.go index 9d3a3f1..1d166fc 100644 --- a/console/gocek.go +++ b/console/gocek.go @@ -27,10 +27,11 @@ var gocekAllCmd = &cobra.Command{ func gocekAll(cmd *cobra.Command, args []string) { cfg := config.GetFerConfig() checker := gocek.ModuleChecker{ - RootDir: cfg.Gocek.SaveOutputDir, + RootDir: cfg.Gocek.SaveOutputDir, + ServicesDirs: cfg.Gocek.ProjectDirs, } - checker.Checks(cfg.Gocek.ProjectDirs) + checker.Checks() } func gocekCWD(cmd *cobra.Command, args []string) { diff --git a/gocek/checker.go b/gocek/checker.go index 910c44e..94702a6 100644 --- a/gocek/checker.go +++ b/gocek/checker.go @@ -16,16 +16,18 @@ import ( const ( _defaultMaxQueueSize = int(10) + timeLayout = "2006-01-02" ) // ModuleChecker :nodoc: type ModuleChecker struct { - RootDir string + RootDir string + ServicesDirs []string } -// CheckCWD call CheckCWD() and print into stdout +// CheckCWD call checkCWD() and print into stdout func (mc *ModuleChecker) CheckCWD() { - modlist, err := CheckCWD() + modlist, err := checkCWD() if err != nil { log.Fatal(err) } @@ -40,16 +42,24 @@ func (mc *ModuleChecker) CheckCWD() { } // Checks check module projects and save the json file -func (mc *ModuleChecker) Checks(dirs []string) { - for _, dir := range dirs { +func (mc *ModuleChecker) Checks() { + now := time.Now() + folder := now.Format(timeLayout) + savePath := path.Join(mc.RootDir, folder) + err := os.MkdirAll(savePath, 0755) + if err != nil { + log.Fatal(err) + } + + for _, dir := range mc.ServicesDirs { os.Chdir(dir) - modules, err := CheckCWD() + modules, err := checkCWD() if err != nil { continue } sdir := strings.Split(dir, "/") - err = mc.save(sdir[len(sdir)-1], modules) + err = mc.save(savePath, sdir[len(sdir)-1], modules) if err != nil { log.Error(err) return @@ -59,13 +69,9 @@ func (mc *ModuleChecker) Checks(dirs []string) { } // save modules as json -func (mc *ModuleChecker) save(modName string, modules []*SimpleModule) error { - now := time.Now() - layout := "2006-01-02" - fileName := fmt.Sprintf("%s.%s.json", modName, now.Format(layout)) - dst := path.Join(mc.RootDir, fileName) - - f, err := os.Create(dst) +func (mc *ModuleChecker) save(savePath, modName string, modules []*SimpleModule) error { + fileName := fmt.Sprintf("%s.json", modName) + f, err := os.Create(path.Join(savePath, fileName)) if err != nil { log.Error(err) return err @@ -83,8 +89,8 @@ func (mc *ModuleChecker) save(modName string, modules []*SimpleModule) error { return err } -// CheckCWD check current working directory -func CheckCWD() (modules []*SimpleModule, err error) { +// checkCWD check current working directory +func checkCWD() (modules []*SimpleModule, err error) { modList, err := findDirectModList() if err != nil { log.Error(err) @@ -118,7 +124,7 @@ func findAllModuleUpdate(mods []string) (modules []*SimpleModule, err error) { mod, err := findModuleUpdate(m) if err != nil { - log.Error(err) + log.Error("findModuleUpdate: ", err) return } @@ -183,6 +189,7 @@ func findModList() ([]string, error) { func findDirectModList() ([]string, error) { out, err := exec.Command("go", "list", "-m", "-f", `{{ .Path }} | {{ .Indirect }}`, "all").Output() if err != nil { + log.Error("findDirectModList: ", err) return nil, err } splitted := strings.Split(string(out), "\n") From a5d5a99a919d21b4886074b26d48f6b231ff2a29 Mon Sep 17 00:00:00 2001 From: "fahmi.irfan" Date: Wed, 9 Sep 2020 13:21:58 +0700 Subject: [PATCH 2/2] bump: changelog --- CHANGELOG.md | 9 ++++++++- config/version.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88a0f4e..b4d936b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ #Fer + +## [v1.8.0] - 2020-09-04 +### New Features +- update gocek checker result path + + ## [v1.7.2] - 2020-08-04 ### Fixes @@ -117,7 +123,8 @@ - db migrationfile generator ([#3](https://github.com/kumparan/fer/issues/3)) -[Unreleased]: https://github.com/kumparan/fer/compare/v1.7.2...HEAD +[Unreleased]: https://github.com/kumparan/fer/compare/v1.8.0...HEAD +[v1.8.0]: https://github.com/kumparan/fer/compare/v1.7.2...v1.8.0 [v1.7.2]: https://github.com/kumparan/fer/compare/v1.7.1...v1.7.2 [v1.7.1]: https://github.com/kumparan/fer/compare/v1.7.0...v1.7.1 [v1.7.0]: https://github.com/kumparan/fer/compare/v1.6.0...v1.7.0 diff --git a/config/version.go b/config/version.go index f9c1dd3..77d23e8 100644 --- a/config/version.go +++ b/config/version.go @@ -1,4 +1,4 @@ package config // Version define version of fer -const Version = "v1.7.2" +const Version = "v1.8.0"