From 27e7c1576a360138e088fbbaa90fb1e966cd2632 Mon Sep 17 00:00:00 2001 From: Stanislas Michalak Date: Sun, 26 May 2019 20:13:49 +0200 Subject: [PATCH] Fix missing deps when not using dep or modules (#1667) * Fix missing deps when not using dep or modules Fixes #1622 #1612 * Fix tests * fixing broken test * updating helpers version --- genny/newapp/api/api.go | 16 ++++++++++++++++ genny/newapp/api/api_test.go | 1 + genny/newapp/web/web.go | 16 ++++++++++++++++ genny/newapp/web/web_test.go | 1 + 4 files changed, 34 insertions(+) diff --git a/genny/newapp/api/api.go b/genny/newapp/api/api.go index 2c7738050..b15501b5d 100644 --- a/genny/newapp/api/api.go +++ b/genny/newapp/api/api.go @@ -6,6 +6,7 @@ import ( "github.com/gobuffalo/buffalo/genny/newapp/core" "github.com/gobuffalo/genny" "github.com/gobuffalo/gogen" + "github.com/gobuffalo/gogen/gomods" "github.com/gobuffalo/packr/v2" ) @@ -33,5 +34,20 @@ func New(opts *Options) (*genny.Group, error) { gg.Add(g) + // DEP/MODS/go get should be last + if !opts.App.WithDep && !opts.App.WithModules { + g := genny.New() + g.Command(gogen.Get("./...", "-t")) + gg.Add(g) + } + + if opts.App.WithModules { + g, err := gomods.Tidy(opts.App.Root, false) + if err != nil { + return gg, err + } + gg.Add(g) + } + return gg, nil } diff --git a/genny/newapp/api/api_test.go b/genny/newapp/api/api_test.go index f8ed1070e..d975d7097 100644 --- a/genny/newapp/api/api_test.go +++ b/genny/newapp/api/api_test.go @@ -40,6 +40,7 @@ func Test_New(t *testing.T) { cmds := []string{"go get github.com/gobuffalo/buffalo-plugins", "go get -t ./...", + "go get -t ./...", } r.Len(res.Commands, len(cmds)) diff --git a/genny/newapp/web/web.go b/genny/newapp/web/web.go index 31a1abe26..25299121e 100644 --- a/genny/newapp/web/web.go +++ b/genny/newapp/web/web.go @@ -8,6 +8,7 @@ import ( "github.com/gobuffalo/buffalo/genny/newapp/core" "github.com/gobuffalo/genny" "github.com/gobuffalo/gogen" + "github.com/gobuffalo/gogen/gomods" "github.com/gobuffalo/packr/v2" ) @@ -54,5 +55,20 @@ func New(opts *Options) (*genny.Group, error) { gg.Add(g) } + // DEP/MODS/go get should be last + if !opts.App.WithDep && !opts.App.WithModules { + g := genny.New() + g.Command(gogen.Get("./...", "-t")) + gg.Add(g) + } + + if opts.App.WithModules { + g, err := gomods.Tidy(opts.App.Root, false) + if err != nil { + return gg, err + } + gg.Add(g) + } + return gg, nil } diff --git a/genny/newapp/web/web_test.go b/genny/newapp/web/web_test.go index 1f165e1e1..8dbdb562d 100644 --- a/genny/newapp/web/web_test.go +++ b/genny/newapp/web/web_test.go @@ -38,6 +38,7 @@ func Test_New(t *testing.T) { cmds := []string{"go get github.com/gobuffalo/buffalo-plugins", "go get -t ./...", + "go get -t ./...", } r.Len(res.Commands, len(cmds))