Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Go Modules: Add support for mod flag in build command fixes #1469 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates authored Feb 4, 2019
1 parent a6e2fa5 commit b8342b3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 8 deletions.
16 changes: 16 additions & 0 deletions buffalo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,19 @@ Buffalo helps you to generate a web project that already has everything from fro
Buffalo **isn't just a framework**, it's a holistic web development environment and project structure that **lets developers get straight to the business** of, well, building their business.
*/
package buffalo

// we need to import the runtime package
// as its needed by `buffalo build` and without
// this import the package doesn't get vendored
// by go mod vendor or by dep. this import fixes
// this problem.
import "github.com/gobuffalo/buffalo/runtime"

var version string

func init() {
// this is here to make sure that goimports
// doesn't remove the runtime import because
// it isn't being used.
version = runtime.Version
}
1 change: 1 addition & 0 deletions buffalo/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func init() {
xbuildCmd.Flags().BoolVar(&buildOptions.DryRun, "dry-run", false, "runs the build 'dry'")
xbuildCmd.Flags().BoolVar(&buildOptions.SkipTemplateValidation, "skip-template-validation", false, "skip validating templates")
xbuildCmd.Flags().StringVarP(&buildOptions.Environment, "environment", "", "development", "set the environment for the binary")
xbuildCmd.Flags().StringVar(&buildOptions.Mod, "mod", "", "-mod flag for go build")
}

func buildVersion(version string) string {
Expand Down
2 changes: 2 additions & 0 deletions buffalo/cmd/internal/integration/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build integration_test

package integration

import (
Expand Down
4 changes: 4 additions & 0 deletions genny/build/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func buildCmd(opts *Options) (*exec.Cmd, error) {
buildArgs = append(buildArgs, "-i")
}

if len(opts.Mod) != 0 {
buildArgs = append(buildArgs, "-mod", opts.Mod)
}

buildArgs = append(buildArgs, opts.BuildFlags...)

tf := opts.App.BuildTags(opts.Environment, opts.Tags...)
Expand Down
3 changes: 3 additions & 0 deletions genny/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package build
import (
"time"

"github.com/gobuffalo/buffalo/runtime"

"github.com/gobuffalo/events"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/packr/v2"
Expand Down Expand Up @@ -51,6 +53,7 @@ func New(opts *Options) (*genny.Generator, error) {
ctx.Set("opts", opts)
ctx.Set("buildTime", opts.BuildTime.Format(time.RFC3339))
ctx.Set("buildVersion", opts.BuildVersion)
ctx.Set("buffaloVersion", runtime.Version)
g.Transformer(plushgen.Transformer(ctx))

// create the ./a pkg
Expand Down
2 changes: 1 addition & 1 deletion genny/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// TODO: once `buffalo new` is converted to use genny
// create an integration test that first generates a new application
// and then tries to build using genny/build.
var coke = packr.NewBox("../build/_fixtures/coke")
var coke = packr.New("github.com/gobuffalo/buffalo/genny/build/build_test", "../build/_fixtures/coke")

var cokeRunner = func() *genny.Runner {
run := gentest.NewRunner()
Expand Down
4 changes: 3 additions & 1 deletion genny/build/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ type Options struct {
// TemplateValidators can be used to validate the applications templates.
// Empty by default
TemplateValidators []TemplateValidator `json:"-"`
rollback *sync.Map
// Mod is the -mod flag
Mod string
rollback *sync.Map
}

// Validate that options are usuable
Expand Down
8 changes: 6 additions & 2 deletions genny/build/templates/a/a.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ func init() {

box := packr.New("buffalo:a:init", "./")
if box.Has("inflections.json") {
r := strings.NewReader(box.String("inflections.json"))
err := inflect.LoadReader(r)
s, err := box.FindString("inflections.json")
if err != nil {
log.Fatal(err)
}
r := strings.NewReader(s)
err = inflect.LoadReader(r)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM=
github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
Expand Down Expand Up @@ -171,6 +172,7 @@ github.com/gobuffalo/licenser v0.0.0-20181116224424-1b7fd3f9cbb4/go.mod h1:icHYf
github.com/gobuffalo/licenser v0.0.0-20181128165715-cc7305f8abed/go.mod h1:oU9F9UCE+AzI/MueCKZamsezGOOHfSirltllOVeRTAE=
github.com/gobuffalo/licenser v0.0.0-20181128170751-82cc989582b9/go.mod h1:oU9F9UCE+AzI/MueCKZamsezGOOHfSirltllOVeRTAE=
github.com/gobuffalo/licenser v0.0.0-20181203160806-fe900bbede07/go.mod h1:ph6VDNvOzt1CdfaWC+9XwcBnlSTBz2j49PBwum6RFaU=
github.com/gobuffalo/licenser v0.0.0-20181211173111-f8a311c51159 h1:bbR/354ALkf/k/CoHxgPPAToVU38WZVwXcxF/UgT7V4=
github.com/gobuffalo/licenser v0.0.0-20181211173111-f8a311c51159/go.mod h1:ve/Ue99DRuvnTaLq2zKa6F4KtHiYf7W046tDjuGYPfM=
github.com/gobuffalo/logger v0.0.0-20181022175615-46cfb361fc27/go.mod h1:8sQkgyhWipz1mIctHF4jTxmJh1Vxhp7mP8IqbljgJZo=
github.com/gobuffalo/logger v0.0.0-20181027144941-73d08d2bb969/go.mod h1:7uGg2duHKpWnN4+YmyKBdLXfhopkAdVM6H3nKbyFbz8=
Expand Down Expand Up @@ -284,7 +286,9 @@ github.com/gobuffalo/release v1.0.72/go.mod h1:NP5NXgg/IX3M5XmHmWR99D687/3Dt9qZt
github.com/gobuffalo/release v1.0.74/go.mod h1:NP5NXgg/IX3M5XmHmWR99D687/3Dt9qZtTK/Lbwc1hU=
github.com/gobuffalo/release v1.1.1/go.mod h1:Sluak1Xd6kcp6snkluR1jeXAogdJZpFFRzTYRs/2uwg=
github.com/gobuffalo/release v1.1.3/go.mod h1:CuXc5/m+4zuq8idoDt1l4va0AXAn/OSs08uHOfMVr8E=
github.com/gobuffalo/release v1.1.6 h1:haad/N5NdoEKK4bmaHLuMeuZdNYIJyXmv+TA8ZwFYwo=
github.com/gobuffalo/release v1.1.6/go.mod h1:18naWa3kBsqO0cItXZNJuefCKOENpbbUIqRL1g+p6z0=
github.com/gobuffalo/shoulders v1.0.1 h1:BqVJBUXlBWAf+WLhXijVk3SCpp75LXrVBiIkOCzZbNc=
github.com/gobuffalo/shoulders v1.0.1/go.mod h1:V33CcVmaQ4gRUmHKwq1fiTXuf8Gp/qjQBUL5tHPmvbA=
github.com/gobuffalo/syncx v0.0.0-20181120191700-98333ab04150/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
github.com/gobuffalo/syncx v0.0.0-20181120194010-558ac7de985f h1:S5EeH1reN93KR0L6TQvkRpu9YggCYXrUqFh1iEgvdC0=
Expand Down
Loading

0 comments on commit b8342b3

Please sign in to comment.