From a1138ed84bed9ea1e9ce4f2bec382250c9b194db Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Wed, 22 Aug 2018 15:19:29 -0400 Subject: [PATCH] allows for buffalo new and buffalo build to work with apps using go modules (#1237) * allows for buffalo new and buffalo build to work with apps using go modules * removed unused method * allow creation of buffalo apps outside of gopath when using modules * adds a message about go modules support being enabled * fixed issue with breaking GOPATH new apps * updated deps * mod tidy * fixed linter issue --- Makefile | 4 +-- buffalo/cmd/build/bin.go | 34 +++------------------ buffalo/cmd/build/templates/main.go.tmpl | 9 ++---- buffalo/cmd/build/transform_main.go | 24 +++++++++++++++ generators/newapp/generator.go | 3 ++ generators/newapp/new.go | 18 +++++++++++ generators/soda/soda.go | 2 +- go.mod | 16 ++++++---- go.sum | 38 +++++++++++++++++++++--- meta/app.go | 38 +++++++++++++++++------- test.sh | 13 -------- 11 files changed, 126 insertions(+), 73 deletions(-) delete mode 100755 test.sh diff --git a/Makefile b/Makefile index d7fa7ef92..89ca21759 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ install: deps packr clean test: - $(GO_BIN) test -vet off -tags ${TAGS} ./... + $(GO_BIN) test -tags ${TAGS} ./... ci-test: - $(GO_BIN) test -vet off -tags ${TAGS} -race -v ./... + $(GO_BIN) test -tags ${TAGS} -race -v ./... docker build . lint: diff --git a/buffalo/cmd/build/bin.go b/buffalo/cmd/build/bin.go index 60b5384ef..3abacc608 100644 --- a/buffalo/cmd/build/bin.go +++ b/buffalo/cmd/build/bin.go @@ -1,36 +1,13 @@ package build import ( - "bytes" - "fmt" - "os" - "os/exec" "regexp" "strings" - "time" "github.com/gobuffalo/envy" "github.com/pkg/errors" ) -func version() (string, string) { - _, err := exec.LookPath("git") - buildTime := fmt.Sprintf("\"%s\"", time.Now().Format(time.RFC3339)) - version := buildTime - if err == nil { - cmd := exec.Command("git", "rev-parse", "--short", "HEAD") - out := &bytes.Buffer{} - cmd.Stdout = out - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err == nil && out.String() != "" { - version = strings.TrimSpace(out.String()) - } - } - return version, buildTime -} - func (b *Builder) buildBin() error { buildArgs := []string{"build", "-i"} if b.Debug { @@ -42,11 +19,7 @@ func (b *Builder) buildBin() error { buildArgs = append(buildArgs, "-o", b.Bin) - version, buildTime := version() - flags := []string{ - fmt.Sprintf("-X main.BuildVersion=%s", version), - fmt.Sprintf("-X main.BuildTime=%s", buildTime), - } + flags := []string{} if b.Static { flags = append(flags, "-linkmode external", "-extldflags \"-static\"") @@ -62,8 +35,9 @@ func (b *Builder) buildBin() error { } flags = append(flags, b.LDFlags) } - - buildArgs = append(buildArgs, "-ldflags", strings.Join(flags, " ")) + if len(flags) > 0 { + buildArgs = append(buildArgs, "-ldflags", strings.Join(flags, " ")) + } return b.exec(envy.Get("GO_BIN", "go"), buildArgs...) } diff --git a/buffalo/cmd/build/templates/main.go.tmpl b/buffalo/cmd/build/templates/main.go.tmpl index aaa959fcb..c669190b3 100644 --- a/buffalo/cmd/build/templates/main.go.tmpl +++ b/buffalo/cmd/build/templates/main.go.tmpl @@ -6,7 +6,6 @@ import ( "os" "os/exec" "time" - "strings" "github.com/markbates/grift/grift" "github.com/gobuffalo/buffalo/runtime" @@ -22,17 +21,13 @@ import ( <% } %> ) -var BuildVersion = "" -var BuildTime = "" - func init() { - BuildTime = strings.Trim(BuildTime, "\"") - t, err := time.Parse(time.RFC3339, BuildTime) +t, err := time.Parse(time.RFC3339, "<%= buildTime %>") if err != nil { fmt.Println(err) } runtime.SetBuild(runtime.BuildInfo{ - Version: BuildVersion, + Version: "<%= buildVersion %>", Time: t, }) } diff --git a/buffalo/cmd/build/transform_main.go b/buffalo/cmd/build/transform_main.go index 056a702b6..7b9a817ed 100644 --- a/buffalo/cmd/build/transform_main.go +++ b/buffalo/cmd/build/transform_main.go @@ -4,7 +4,10 @@ import ( "bytes" "io" "os" + "os/exec" "path/filepath" + "strings" + "time" "github.com/gobuffalo/plush" "github.com/pkg/errors" @@ -24,10 +27,31 @@ func (b *Builder) transformMain() error { }) } +func (b *Builder) buildVersion(version string) string { + _, err := exec.LookPath("git") + if err != nil { + return version + } + cmd := exec.Command("git", "rev-parse", "--short", "HEAD") + out := &bytes.Buffer{} + cmd.Stdout = out + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + err = cmd.Run() + if err == nil && out.String() != "" { + version = strings.TrimSpace(out.String()) + } + return version +} + func (b *Builder) createBuildMain() error { ctx := plush.NewContext() ctx.Set("opts", b.Options) + bt := time.Now().Format(time.RFC3339) + ctx.Set("buildTime", bt) + ctx.Set("buildVersion", b.buildVersion(bt)) + t, err := templates.MustString("main.go.tmpl") if err != nil { return errors.WithStack(err) diff --git a/generators/newapp/generator.go b/generators/newapp/generator.go index 62126e2d0..d397c511a 100644 --- a/generators/newapp/generator.go +++ b/generators/newapp/generator.go @@ -95,6 +95,9 @@ func (g Generator) Validate() error { } func (g Generator) validateInGoPath() error { + if g.App.WithModules { + return nil + } gpMultiple := envy.GoPaths() larp := strings.ToLower(meta.ResolveSymlinks(filepath.Dir(g.Root))) diff --git a/generators/newapp/new.go b/generators/newapp/new.go index 865649632..fd74aa862 100644 --- a/generators/newapp/new.go +++ b/generators/newapp/new.go @@ -87,6 +87,10 @@ func (a Generator) Run(root string, data makr.Data) error { return errors.WithStack(err) } + if a.WithModules { + g.Add(makr.NewCommand(exec.Command(envy.Get("GO_BIN", "go"), "mod", "init", a.PackagePkg))) + } + g.Add(makr.NewCommand(a.goGet())) g.Add(makr.Func{ @@ -204,9 +208,15 @@ func (a Generator) goGet() *exec.Cmd { cd, _ := os.Getwd() defer os.Chdir(cd) os.Chdir(a.Root) + if a.WithDep { return exec.Command("dep", "ensure", "-v") } + + if a.WithModules { + return a.goGetMod() + } + appArgs := []string{"get", "-t"} if a.Verbose { appArgs = append(appArgs, "-v") @@ -215,6 +225,14 @@ func (a Generator) goGet() *exec.Cmd { return exec.Command(envy.Get("GO_BIN", "go"), appArgs...) } +func (a Generator) goGetMod() *exec.Cmd { + cmd := exec.Command(envy.Get("GO_BIN", "go"), "mod", "tidy") + if a.Verbose { + cmd.Args = append(cmd.Args, "-v") + } + return cmd +} + const nTravis = `language: go go: diff --git a/generators/soda/soda.go b/generators/soda/soda.go index 364e4b25e..87f282522 100644 --- a/generators/soda/soda.go +++ b/generators/soda/soda.go @@ -28,7 +28,7 @@ func (sd Generator) Run(root string, data makr.Data) error { f.Should = should g.Add(f) - if !sd.App.WithDep { + if !sd.App.WithModules { c := makr.NewCommand(makr.GoGet("github.com/gobuffalo/pop/...")) c.Should = should g.Add(c) diff --git a/go.mod b/go.mod index 6e2dc0dc5..05ce22b42 100644 --- a/go.mod +++ b/go.mod @@ -6,34 +6,38 @@ require ( github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d github.com/fatih/color v1.7.0 github.com/gobuffalo/buffalo-plugins v0.0.0-20180820141205-03ceb944b112 - github.com/gobuffalo/buffalo-pop v0.0.0-20180818124224-e3bbd0b11d3e + github.com/gobuffalo/buffalo-pop v0.0.0-20180818124224-e3bbd0b11d3e // indirect github.com/gobuffalo/envy v1.6.4 - github.com/gobuffalo/fizz v1.0.9 // indirect + github.com/gobuffalo/fizz v1.0.10 // indirect github.com/gobuffalo/github_flavored_markdown v1.0.0 - github.com/gobuffalo/makr v1.1.2 + github.com/gobuffalo/makr v1.1.4 github.com/gobuffalo/mw-basicauth v0.0.0-20180802152105-15d67c4ac152 github.com/gobuffalo/mw-contenttype v0.0.0-20180802152300-74f5a47f4d56 github.com/gobuffalo/mw-csrf v0.0.0-20180802151833-446ff26e108b github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130 github.com/gobuffalo/mw-i18n v0.0.0-20180802152014-e3060b7e13d6 github.com/gobuffalo/mw-paramlogger v0.0.0-20180807082017-6b90b69a724a + github.com/gobuffalo/mw-poptx v0.0.0-20180814214442-e78b7f0a596a github.com/gobuffalo/mw-tokenauth v0.0.0-20180802152212-d09751da96e0 github.com/gobuffalo/packr v1.13.2 github.com/gobuffalo/plush v3.7.16+incompatible - github.com/gobuffalo/pop v4.6.7+incompatible + github.com/gobuffalo/pop v4.6.8+incompatible github.com/gobuffalo/shoulders v0.0.0-20180815165021-5569039eac2f github.com/gobuffalo/tags v2.0.9+incompatible github.com/gobuffalo/uuid v2.0.3+incompatible github.com/gobuffalo/x v0.0.0-20180816203319-dc54d929c4a2 + github.com/golang/protobuf v1.2.0 // indirect github.com/gorilla/context v1.1.1 github.com/gorilla/mux v1.6.2 github.com/gorilla/sessions v1.1.1 + github.com/lib/pq v0.0.0-20180822103908-55f6f2718ccb // indirect github.com/markbates/deplist v1.0.2 github.com/markbates/grift v1.0.1 github.com/markbates/inflect v1.0.0 github.com/markbates/refresh v1.4.2 github.com/markbates/sigtx v1.0.0 github.com/markbates/willie v1.0.7 + github.com/microcosm-cc/bluemonday v1.0.1 // indirect github.com/monoculum/formam v0.0.0-20180818005819-0a5cdaa81e2e github.com/pkg/errors v0.8.0 github.com/sirupsen/logrus v1.0.6 @@ -42,6 +46,8 @@ require ( github.com/spf13/viper v1.1.0 github.com/stretchr/testify v1.2.2 golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac + golang.org/x/net v0.0.0-20180821023952-922f4815f713 // indirect golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f + golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 // indirect gopkg.in/mail.v2 v2.0.0-20180731213649-a0242b2233b4 -) +) \ No newline at end of file diff --git a/go.sum b/go.sum index fe1c2a18e..9525ef697 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7 h1:XFqp7V github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk= github.com/codegangsta/negroni v0.3.0 h1:ByBtJaE0u71x6Ebli7lm95c8oCkrmF88+s5qB2o6j8I= github.com/codegangsta/negroni v0.3.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0= +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/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= @@ -28,19 +29,24 @@ github.com/gobuffalo/buffalo-plugins v0.0.0-20180820141205-03ceb944b112 h1:HNySa github.com/gobuffalo/buffalo-plugins v0.0.0-20180820141205-03ceb944b112/go.mod h1:zRqRWL38hEJux6FsYHQHYRqANAsQlKxzcPrfHKQycmA= github.com/gobuffalo/buffalo-pop v0.0.0-20180818124224-e3bbd0b11d3e h1:UkZtClt8Oy83+v5N8dJ3zDPNbGk7K3fHJpagXgcNx6k= github.com/gobuffalo/buffalo-pop v0.0.0-20180818124224-e3bbd0b11d3e/go.mod h1:pjzWxoot16IF9xupOei/JRVox5XQTOM8YJjKR1fr/VA= +github.com/gobuffalo/envy v1.6.3 h1:I9iyNACF0Tovfta7iqLrUAXFHYBDBWveQrjpEv2XeWs= github.com/gobuffalo/envy v1.6.3/go.mod h1:gOxUQY+OEwqH1a2m25Sqax1GIhj31tPNOIdFzj8QThs= github.com/gobuffalo/envy v1.6.4 h1:kxamN+VYjPMzEdjc2mn4CIKiuYXGxc8VIwXJNixFlNY= github.com/gobuffalo/envy v1.6.4/go.mod h1:Abh+Jfw475/NWtYMEt+hnJWRiC8INKWibIMyNt1w2Mc= +github.com/gobuffalo/fizz v1.0.7 h1:xvG4eDlZvwzFq1cUk13VsveNNBHAIxOBDYBW3MGCLtg= github.com/gobuffalo/fizz v1.0.7/go.mod h1:fbtmvB0dcsGJUxM/S8biqkQtvykqPQGdkcg94zVu8GA= -github.com/gobuffalo/fizz v1.0.9 h1:SZmqgBmxHvWMrirZsy5BCBunmjn1hl4GIuXEdAF4Vig= -github.com/gobuffalo/fizz v1.0.9/go.mod h1:fbtmvB0dcsGJUxM/S8biqkQtvykqPQGdkcg94zVu8GA= +github.com/gobuffalo/fizz v1.0.10 h1:MspJcEEBN2eApqiFd4tuoTpYZF6wM5B6/Ink/rJcqOI= +github.com/gobuffalo/fizz v1.0.10/go.mod h1:jpD+pJ065MDYCc4nA86aUQ/ovwCjGGNl4zq4xrAxJa0= github.com/gobuffalo/flect v0.0.0-20180728145722-2949e73d74b0/go.mod h1:B1X1r2SsFPE8Idc2OCoc+/eGmiknyq6oWDXLAYzRFLE= +github.com/gobuffalo/genny v0.0.0-20180818195054-34f68115d51f h1:G4IHVYSIej7Xil0jTed2UFwBdIy6Zg7fBrTbja8OjUc= github.com/gobuffalo/genny v0.0.0-20180818195054-34f68115d51f/go.mod h1:b6zAEpWtCPxZisqb6/WRqvGOQ7Mg5SlUwoQZySx1w1U= github.com/gobuffalo/github_flavored_markdown v1.0.0 h1:e2dK+SoHgOc/vfXuYMdXwEg2vAUlFzp8SBRwTOXckQ0= github.com/gobuffalo/github_flavored_markdown v1.0.0/go.mod h1:c8/8gRnd6MSyyk+fp6E8O8cUTHd7P2cnDnH4G7o91l0= github.com/gobuffalo/makr v1.1.1/go.mod h1:1Ga9O4Gqd5xXc+AoI3eLwgu7k+gWamSUXd2Ps942KkM= github.com/gobuffalo/makr v1.1.2 h1:Dix34nvNM3v4EHNmoVysaAZBgPbMFJTwKXBrVonw2Kg= github.com/gobuffalo/makr v1.1.2/go.mod h1:5/uvRIyR+DQHJrX0UPCPF0WhQGMJG5/xd9XT9qEXQE8= +github.com/gobuffalo/makr v1.1.4 h1:REIMYySfhRCK0He5MdDaIN/4NpfCtrt8g/ENLcmmzPg= +github.com/gobuffalo/makr v1.1.4/go.mod h1:Y+o0btAH1kYAMDJW/TX3+oAXEu0bmSLLoC9mIFxtzOw= github.com/gobuffalo/mw-basicauth v0.0.0-20180802152105-15d67c4ac152 h1:gxsF8w9epZSG/LrhrIfBDrqxDwjNPv0J1hkGVCmDExo= github.com/gobuffalo/mw-basicauth v0.0.0-20180802152105-15d67c4ac152/go.mod h1:+vSUajk1TCB7xvyLuDIzhIK+XKqn0St6xLK/CxxpUU4= github.com/gobuffalo/mw-contenttype v0.0.0-20180802152300-74f5a47f4d56 h1:SUFp8EbFjlKXkvqstoxPWx3nVPV3BSKZTswQNTZFaik= @@ -53,6 +59,8 @@ github.com/gobuffalo/mw-i18n v0.0.0-20180802152014-e3060b7e13d6 h1:pZhsgF8RXEngH github.com/gobuffalo/mw-i18n v0.0.0-20180802152014-e3060b7e13d6/go.mod h1:91AQfukc52A6hdfIfkxzyr+kpVYDodgAeT5cjX1UIj4= github.com/gobuffalo/mw-paramlogger v0.0.0-20180807082017-6b90b69a724a h1:ZNTj3jf8lXOCjT5QzQ/wcmOVbwhddDum3DHSix2W2w0= github.com/gobuffalo/mw-paramlogger v0.0.0-20180807082017-6b90b69a724a/go.mod h1:6OJr6VwSzgJMqWMj7TYmRUqzNe2LXu/W1rRW4MAz/ME= +github.com/gobuffalo/mw-poptx v0.0.0-20180814214442-e78b7f0a596a h1:gFIU1mNCjNFeTtjMI3AZx4UmjXlVELKb11uIs+0uPR8= +github.com/gobuffalo/mw-poptx v0.0.0-20180814214442-e78b7f0a596a/go.mod h1:3vwk6nIqjlXS4gz4/Z2S6u8QyfFCaOm5fIsmeCxHXB8= github.com/gobuffalo/mw-tokenauth v0.0.0-20180802152212-d09751da96e0 h1:v5r9HjKo88iTByIoeNARxrzfZbrQzm/yKlCBXB/RkMw= github.com/gobuffalo/mw-tokenauth v0.0.0-20180802152212-d09751da96e0/go.mod h1:UqBF00IfKvd39ni5+yI5MLMjAf4gX7cDKN/26zDOD6c= github.com/gobuffalo/packr v1.13.1/go.mod h1:m3J/Q/tkaODAQq3r6NyWhDhJs2cVZS/lU0+0Edmfv3c= @@ -62,8 +70,8 @@ github.com/gobuffalo/plush v0.0.0-20180810170812-274552812256/go.mod h1:vdLIKHIw github.com/gobuffalo/plush v3.7.16+incompatible h1:nonpy24axg04np13bYi0zNu3gr812cXKJDNLSkKcEwk= github.com/gobuffalo/plush v3.7.16+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI= github.com/gobuffalo/pop v0.0.0-20180810203029-9f8bf0c11920/go.mod h1:rYdFIDMO4v9I4SK6BQ3q+vnd5HlQnTtlY/ANF7wKzGM= -github.com/gobuffalo/pop v4.6.7+incompatible h1:bOrcgje3pdugJE2uoYIsAFRK2c7ML8YmuNyeA+tHbok= -github.com/gobuffalo/pop v4.6.7+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg= +github.com/gobuffalo/pop v4.6.8+incompatible h1:Rqmz7Cj0Iq/eiZjaDNiOS1DgGVOga+Q8xORj9eLvsLo= +github.com/gobuffalo/pop v4.6.8+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg= github.com/gobuffalo/shoulders v0.0.0-20180815165021-5569039eac2f h1:FdNwdqDxs4t4GKKS1yG3krQRVWSmJ9tntDhm69wfVq4= github.com/gobuffalo/shoulders v0.0.0-20180815165021-5569039eac2f/go.mod h1:6BOi9bQ44FOef+BnbjTps9APr8fZE1Yvcs4BdeY940U= github.com/gobuffalo/tags v2.0.6+incompatible/go.mod h1:9XmhOkyaB7UzvuY4UoZO4s67q8/xRMVJEaakauVQYeY= @@ -72,14 +80,18 @@ github.com/gobuffalo/tags v2.0.9+incompatible/go.mod h1:9XmhOkyaB7UzvuY4UoZO4s67 github.com/gobuffalo/uuid v2.0.0+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE= github.com/gobuffalo/uuid v2.0.3+incompatible h1:W83ymTRbzM+XNntIsjC8j63FyzGytcfKTudU1Cg6xyk= github.com/gobuffalo/uuid v2.0.3+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE= +github.com/gobuffalo/validate v2.0.0+incompatible h1:KllrOhUUzAeTil8MaaQorZOH0Bx6KOvi8mRVlwFHRA4= github.com/gobuffalo/validate v2.0.0+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM= github.com/gobuffalo/validate v2.0.3+incompatible h1:6f4JCEz11Zi6iIlexMv7Jz10RBPvgI795AOaubtCwTE= github.com/gobuffalo/validate v2.0.3+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM= +github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd h1:0AiAe/jaKqMCar/zjOQFewW33iOLsCD6lPbqYlTcr2Q= github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd/go.mod h1:WevpGD+5YOreDJznWevcn8NTmQEW5STSBgIkpkjzqXc= github.com/gobuffalo/x v0.0.0-20180816203319-dc54d929c4a2 h1:L4IIzLTXHRmnCnH4/OOa7yeDL9kk6dK+tnLcXfu8nDo= github.com/gobuffalo/x v0.0.0-20180816203319-dc54d929c4a2/go.mod h1:oX3kj94UfTZqmz9XowUgR7Ghpz5I+JmkMDpWJlwa9h8= github.com/golang/protobuf v1.1.0 h1:0iH4Ffd/meGoXqF2lSAhZHt8X+cPgkfn/cb6Cce5Vpc= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= @@ -107,11 +119,14 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 h1:it29sI2IM490luSc3RAhp5WuCYnc6RtbfLVAB7nmC5M= github.com/lib/pq v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v0.0.0-20180822103908-55f6f2718ccb h1:y4wxGMpTq5l97SEl+BPMZoDPyRHQjrKwb5ze4psanic= +github.com/lib/pq v0.0.0-20180822103908-55f6f2718ccb/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/markbates/deplist v1.0.2 h1:91fPoNtVdkSJa/F0Zv/5+CzcZ9OnCzbWYUmFpCKe3X8= github.com/markbates/deplist v1.0.2/go.mod h1:ZerU6FuDYMFbdh+BdCNmce+SexbmOZd/ftnrcxVyNXQ= github.com/markbates/going v1.0.0/go.mod h1:I6mnB4BPnEeqo85ynXIx1ZFLLbtiLHNXVgWeFO9OGOA= +github.com/markbates/going v1.0.1 h1:IFDakPS7ROqx1rESYPSZmURUTwI4HWuM5waQIFCUZZQ= github.com/markbates/going v1.0.1/go.mod h1:I6mnB4BPnEeqo85ynXIx1ZFLLbtiLHNXVgWeFO9OGOA= github.com/markbates/going v1.0.2 h1:uNQHDDfMRNOUmuxDbPbvatyw4wr4UOSUZkGkdkcip1o= github.com/markbates/going v1.0.2/go.mod h1:UWCk3zm0UKefHZ7l8BNqi26UyiEMniznk8naLdTcy6c= @@ -123,11 +138,13 @@ github.com/markbates/hmax v1.0.0 h1:yo2N0gBoCnUMKhV/VRLHomT6Y9wUm+oQQENuWJqCdlM= github.com/markbates/hmax v1.0.0/go.mod h1:cOkR9dktiESxIMu+65oc/r/bdY4bE8zZw3OLhLx0X2c= github.com/markbates/inflect v1.0.0 h1:gTffXSQCc+WaIvBcI/IItJQMOemietXr5EIKLXDYqI4= github.com/markbates/inflect v1.0.0/go.mod h1:oTeZL2KHA7CUX6X+fovmK9OvIOFuqu0TwdQrZjLTh88= +github.com/markbates/refresh v1.4.1 h1:+kEJt7Bz6Bn/pjmnbFHhyAEnO+mW0POtyqsVyK62o3A= github.com/markbates/refresh v1.4.1/go.mod h1:og/05QDfszH/SCl3w8VI2Or990yna0wS2lqRcJoDqAg= github.com/markbates/refresh v1.4.2 h1:xQfceULuw5iEON8MB6hAs9XoMrOpYrd7feQgRWFDj+0= github.com/markbates/refresh v1.4.2/go.mod h1:C/Zey3IPrq0lXq1+SDhCQOuy7dKR3CabthJTTZP8AQg= github.com/markbates/sigtx v1.0.0 h1:y/xtkBvNPRjD4KeEplf4w9rJVSc23/xl+jXYGowTwy0= github.com/markbates/sigtx v1.0.0/go.mod h1:QF1Hv6Ic6Ca6W+T+DL0Y/ypborFKyvUY9HmuCD4VeTc= +github.com/markbates/willie v1.0.6 h1:VguZshKlOyixOjcEdtlWxzCgr7AZE/3u+2bai9Ik1wY= github.com/markbates/willie v1.0.6/go.mod h1:XtK+fmQ7tgVMIVAS1ghwuqVPup3GtgrNY3UCvUlPdzM= github.com/markbates/willie v1.0.7 h1:0W+oMu9Ah+jvukKH9OmXFeKNDmbjqry8BcS9dQiRshU= github.com/markbates/willie v1.0.7/go.mod h1:42G0jXiZEVLXutUa33JFH8tQW2dsHAqwYWNlVHfPtvM= @@ -139,6 +156,9 @@ github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/microcosm-cc/bluemonday v1.0.0 h1:dr58SIfmOwOVr+m4Ye1xLWv8Dk9OFwXAtYnbJSmJ65k= github.com/microcosm-cc/bluemonday v1.0.0/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/microcosm-cc/bluemonday v1.0.1 h1:SIYunPjnlXcW+gVfvm0IlSeR5U3WZUOLfVmqg85Go44= +github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9 h1:Y94YB7jrsihrbGSqRNMwRWJ2/dCxr0hdC2oPRohkx0A= github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v0.0.0-20180801233206-58046073cbff h1:jM4Eo4qMmmcqePS3u6X2lcEELtVuXWkWJIS/pRI3oSk= github.com/mitchellh/go-homedir v0.0.0-20180801233206-58046073cbff/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -199,23 +219,32 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/unrolled/secure v0.0.0-20180618144512-8287f3899c8e h1:tgJKQPcQriVRZoTd6NXN3jITyBs6vR1H+0JsulRuX6s= github.com/unrolled/secure v0.0.0-20180618144512-8287f3899c8e/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA= +golang.org/x/crypto v0.0.0-20180808211826-de0752318171 h1:vYogbvSFj2YXcjQxFHu/rASSOt9sLytpCaSkiwQ135I= golang.org/x/crypto v0.0.0-20180808211826-de0752318171/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180816225734-aabede6cba87 h1:gCHhzI+1R9peHIMyiWVxoVaWlk1cYK7VThX5ptLtbXY= golang.org/x/crypto v0.0.0-20180816225734-aabede6cba87/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180811021610-c39426892332 h1:efGso+ep0DjyCBJPjvoz0HI6UldX4Md2F1rZFe1ir0E= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180816102801-aaf60122140d h1:211XH5RPVP5tOBkz6xm3/b7KxtjqVf6PYG+evqJpE08= golang.org/x/net v0.0.0-20180816102801-aaf60122140d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180821023952-922f4815f713 h1:rMJUcaDGbG+X967I4zGKCq5laYqcGKJmpB+3jhpOhPw= +golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180616030259-6c888cc515d3/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180814072032-4e1fef560951 h1:VfGaXvV9wRnTJreeGDE0FWEDiQP1WWUDmutCjCThDz8= golang.org/x/sys v0.0.0-20180814072032-4e1fef560951/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c h1:uHnKXcvx6SNkuwC+nrzxkJ+TpPwZOtumbhWrrOYN5YA= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 h1:0w2EXzxbB03VAzqwe3csbadu4CPhMRtxCz/rjw9gkic= +golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20180817170705-7d1dc997617f h1:PKEiTD+GsM0tTOVt125xcm3tN+JExjPbuypItbieWw0= golang.org/x/tools v0.0.0-20180817170705-7d1dc997617f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -241,3 +270,4 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= + diff --git a/meta/app.go b/meta/app.go index 9b9d1f93b..2683f379f 100644 --- a/meta/app.go +++ b/meta/app.go @@ -3,16 +3,26 @@ package meta import ( "bytes" "encoding/json" + "fmt" "io/ioutil" "os" "path" "path/filepath" "runtime" + "strings" "github.com/gobuffalo/envy" "github.com/markbates/inflect" ) +var modsOn = (strings.TrimSpace(envy.Get("GO111MODULE", "off")) == "on") + +func init() { + if modsOn { + fmt.Println("experimental go modules support has been enabled [GO111MODULE=on]") + } +} + // App represents meta data for a Buffalo application on disk type App struct { Pwd string `json:"pwd"` @@ -32,6 +42,7 @@ type App struct { WithYarn bool `json:"with_yarn"` WithDocker bool `json:"with_docker"` WithGrifts bool `json:"with_grifts"` + WithModules bool `json:"with_modules"` } // New App based on the details found at the provided root path @@ -60,20 +71,25 @@ func New(root string) App { // Gather meta data name := inflect.Name(filepath.Base(root)) - pp := envy.CurrentPackage() - if filepath.Base(pp) != string(name) { - pp = path.Join(pp, string(name)) + + pp := name.String() + if !modsOn { + pp = envy.CurrentPackage() + if filepath.Base(pp) != string(name) { + pp = path.Join(pp, string(name)) + } } app := App{ - Pwd: pwd, - Root: root, - GoPath: envy.GoPath(), - Name: name, - PackagePkg: pp, - ActionsPkg: pp + "/actions", - ModelsPkg: pp + "/models", - GriftsPkg: pp + "/grifts", + Pwd: pwd, + Root: root, + GoPath: envy.GoPath(), + Name: name, + PackagePkg: pp, + ActionsPkg: pp + "/actions", + ModelsPkg: pp + "/models", + GriftsPkg: pp + "/grifts", + WithModules: modsOn, } app.Bin = filepath.Join("bin", filepath.Base(root)) diff --git a/test.sh b/test.sh deleted file mode 100755 index 8a2a2def8..000000000 --- a/test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -e - -verbose="" - -if [[ "$@" == "-v" ]] -then - verbose="-v" -fi - -# export GO111MODULE=on -# export GO_BIN=go111 -go test -tags sqlite -vet off $verbose ./...