mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Added gomod-flags
Added a gomod-flags parameter which allows you to run go mod commands on the go.mod file before the build is performed. This allows for development environments.
This commit is contained in:
44
.travis.yml
44
.travis.yml
@@ -35,31 +35,31 @@ script:
|
||||
- go test -v github.com/revel/cmd/revel/...
|
||||
|
||||
# Ensure the new-app flow works (plus the other commands).
|
||||
- revel version
|
||||
- revel new my/testapp
|
||||
- revel test my/testapp
|
||||
- revel clean my/testapp
|
||||
- revel build my/testapp build/testapp
|
||||
- revel build my/testapp build/testapp prod
|
||||
- revel package my/testapp
|
||||
- revel package my/testapp prod
|
||||
#- revel version
|
||||
#- revel new my/testapp
|
||||
#- revel test my/testapp
|
||||
#- revel clean my/testapp
|
||||
#- revel build my/testapp build/testapp
|
||||
#- revel build my/testapp build/testapp prod
|
||||
#- revel package my/testapp
|
||||
#- revel package my/testapp prod
|
||||
|
||||
# Ensure the new-app flow works (plus the other commands).
|
||||
- revel new -a my/testapp2
|
||||
- revel test -a my/testapp2
|
||||
- revel clean -a my/testapp2
|
||||
- revel build -a my/testapp2 -t build/testapp2
|
||||
- revel build -a my/testapp2 -t build/testapp2 -m prod
|
||||
- revel package -a my/testapp2
|
||||
- revel package -a my/testapp2 -m prod
|
||||
- revel new --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2
|
||||
- revel test --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2
|
||||
- revel clean --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2
|
||||
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -t build/testapp2
|
||||
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -t build/testapp2 -m prod
|
||||
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2
|
||||
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -m prod
|
||||
|
||||
- revel new -v -a my/testapp3 -V
|
||||
- revel test -v -a my/testapp3
|
||||
- revel clean -v -a my/testapp3
|
||||
- revel build -a my/testapp3 -t build/testapp3
|
||||
- revel build -a my/testapp3 -t build/testapp3 -m prod
|
||||
- revel package -a my/testapp3
|
||||
- revel package -a my/testapp3 -m prod
|
||||
- revel new --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -v -a my/testapp3 -V
|
||||
- revel test --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -v -a my/testapp3
|
||||
- revel clean --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -v -a my/testapp3
|
||||
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp3 -t build/testapp3
|
||||
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp3 -t build/testapp3 -m prod
|
||||
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp3
|
||||
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp3 -m prod
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
|
||||
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.13
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||
github.com/agtorre/gocolorize v1.0.0
|
||||
github.com/fsnotify/fsnotify v1.4.7 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/mattn/go-colorable v0.1.4
|
||||
|
||||
@@ -144,6 +144,20 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
return false
|
||||
}
|
||||
|
||||
if len(c.GoModFlags) > 0 {
|
||||
for _, gomod := range c.GoModFlags {
|
||||
goModCmd := exec.Command(goPath, append([]string{"mod"}, strings.Split(gomod, " ")...)...)
|
||||
utils.CmdInit(goModCmd, !c.Vendored, c.AppPath)
|
||||
output, err := goModCmd.CombinedOutput()
|
||||
utils.Logger.Infof("Gomod applied ", "output", string(output))
|
||||
|
||||
// If the build succeeded, we're done.
|
||||
if err != nil {
|
||||
utils.Logger.Error("Gomod Failed continuing ", "error", err, "output", string(output))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
appVersion := getAppVersion(paths)
|
||||
if appVersion == "" {
|
||||
|
||||
@@ -48,6 +48,7 @@ type (
|
||||
Vendored bool // True if the application is vendored
|
||||
PackageResolver func(pkgName string) error // a package resolver for the config
|
||||
BuildFlags []string `short:"X" long:"build-flags" description:"These flags will be used when building the application. May be specified multiple times, only applicable for Build, Run, Package, Test commands"`
|
||||
GoModFlags []string `long:"gomod-flags" description:"These flags will execut go mod commands for each flag, this happens during the build process"`
|
||||
New command.New `command:"new"`
|
||||
Build command.Build `command:"build"`
|
||||
Run command.Run `command:"run"`
|
||||
|
||||
Reference in New Issue
Block a user