mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 02:34:32 +00:00
Merge branch 'develop' into lint
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
.temp/
|
||||
|
||||
50
.vscode/launch.json
vendored
Normal file
50
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Help",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceRoot}/revel",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "Create new",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "Clean-Test-Project",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceRoot}/revel",
|
||||
"args": ["new", "-v","-a", "${workspaceRoot}/.temp/revel/reveltest", "-p","revel.com/testproject"],
|
||||
"env": {
|
||||
"GOPATH": "${workspaceRoot}/.temp/revel/GOPATH"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "Run program",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceRoot}/revel",
|
||||
"args": ["run","-v", "-v","-a", "${workspaceRoot}/.temp/revel/reveltest"],
|
||||
"env": {
|
||||
"GOPATH": "${workspaceRoot}/.temp/revel/GOPATH"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "Run program Directly",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceRoot}/.temp/revel/reveltest/app/tmp/main.go",
|
||||
"args": ["-port=9000","-importPath=revel.com/testproject/reveltest", "-runMode={\"mode\":\"dev\", \"specialUseFlag\":true,\"packagePathMap\":{\"github.com/revel/modules/static\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/static\",\"github.com/revel/modules/testrunner\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/testrunner\",\"github.com/revel/revel\":\"/home/notzippy/go/pkg/mod/github.com/revel/revel@v1.0.0\",\"revel.com/testproject/reveltest\":\"/mnt/DevSystem/Work/Workareas/revel/revel3/cmd/.temp/revel/reveltest\"}}"],
|
||||
"env": {
|
||||
"GOPATH": "${workspaceRoot}/.temp/revel/GOPATH"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
1
.vscode/load.sh
vendored
Executable file
1
.vscode/load.sh
vendored
Executable file
@@ -0,0 +1 @@
|
||||
http_load -rate 5 -seconds 10 load.web
|
||||
2
.vscode/load.web
vendored
Normal file
2
.vscode/load.web
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
http://localhost:9000/
|
||||
http://localhost:9000/miss
|
||||
20
.vscode/tasks.json
vendored
Normal file
20
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Clean-Test-Project",
|
||||
"type": "shell",
|
||||
"command": "rm -rf ${workspaceRoot}/.temp/revel/testproject"
|
||||
},
|
||||
{
|
||||
"label": "Update Go Mod",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceRoot}/.temp/revel/testproject"
|
||||
},
|
||||
"command": "go mod tidy && go mod edit -replace github.com/revel/revel => ../../../revel"
|
||||
},
|
||||
]
|
||||
}
|
||||
6
go.mod
6
go.mod
@@ -3,7 +3,6 @@ module github.com/revel/cmd
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||
github.com/agtorre/gocolorize v1.0.0
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
@@ -23,9 +22,8 @@ require (
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
|
||||
golang.org/x/tools v0.0.0-20200219054238-753a1d49df85
|
||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0
|
||||
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect
|
||||
)
|
||||
|
||||
replace github.com/revel/revel v0.21.0 => ../revel
|
||||
|
||||
15
go.sum
15
go.sum
@@ -1,6 +1,8 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/agtorre/gocolorize v1.0.0 h1:TvGQd+fAqWQlDjQxSKe//Y6RaxK+RHpEU9X/zPmHW50=
|
||||
github.com/agtorre/gocolorize v1.0.0/go.mod h1:cH6imfTkHVBRJhSOeSeEZhB4zqEYSq0sXuIyehgZMIY=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||
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/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
@@ -22,6 +24,7 @@ github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/myesui/uuid v1.0.0/go.mod h1:2CDfNgU0LR8mIdO8vdWd8i9gWWxLlcoIGGpSNgafq84=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -48,6 +51,7 @@ github.com/xeonx/timeago v1.0.0-rc4 h1:9rRzv48GlJC0vm+iBpLcWAr8YbETyN9Vij+7h2amm
|
||||
github.com/xeonx/timeago v1.0.0-rc4/go.mod h1:qDLrYEFynLO7y5Ho7w3GwgtYgpy5UfhcXIIQvMKVDkA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -73,7 +77,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20200219054238-753a1d49df85 h1:XNHaQ2CZDl/SjEZlUXGh7+OQvfLuFgmk3oNWkCFfERE=
|
||||
golang.org/x/tools v0.0.0-20200219054238-753a1d49df85/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo=
|
||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE=
|
||||
@@ -82,6 +88,9 @@ gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXL
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 h1:lMH45EKqD8Nf6LwoF+43YOKjOAEEHQRVgDyG8RCV4MU=
|
||||
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0/go.mod h1:kl/bNzW/jgTgUOCGDj3XPn9/Hbfhw6pjfBRUnaTioFQ=
|
||||
gopkg.in/stretchr/testify.v1 v1.2.2 h1:yhQC6Uy5CqibAIlk1wlusa/MJ3iAN49/BsR/dCCKz3M=
|
||||
gopkg.in/stretchr/testify.v1 v1.2.2/go.mod h1:QI5V/q6UbPmuhtm10CaFZxED9NreB8PnFYN9JcR6TxU=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/revel/cmd/model"
|
||||
@@ -74,6 +74,7 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta
|
||||
func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}}
|
||||
cmd.Stdout = listeningWriter
|
||||
cmd.Stderr = listeningWriter
|
||||
utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath)
|
||||
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
|
||||
if err := cmd.Cmd.Start(); err != nil {
|
||||
@@ -84,8 +85,9 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
case exitState := <-cmd.waitChan():
|
||||
fmt.Println("Startup failure view previous messages, \n Proxy is listening :", c.Run.Port)
|
||||
err := utils.NewError("", "Revel Run Error", "starting your application there was an exception. See terminal output, "+exitState, "")
|
||||
atomic.SwapInt32(&startupError, 1)
|
||||
// TODO pretiffy command line output
|
||||
// err.MetaError = listeningWriter.getLastOutput()
|
||||
err.Stack = listeningWriter.buffer.String()
|
||||
return err
|
||||
|
||||
case <-time.After(60 * time.Second):
|
||||
@@ -143,11 +145,8 @@ func (cmd AppCmd) Kill() {
|
||||
|
||||
// Send an interrupt signal to allow for a graceful shutdown
|
||||
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
|
||||
var err error
|
||||
if runtime.GOOS != "windows" {
|
||||
// os.Interrupt is not available on windows
|
||||
err = cmd.Process.Signal(os.Interrupt)
|
||||
}
|
||||
|
||||
err := cmd.Process.Signal(os.Interrupt)
|
||||
|
||||
if err != nil {
|
||||
utils.Logger.Info(
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
)
|
||||
|
||||
var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"")
|
||||
var importErrorPattern2 = regexp.MustCompile("no required module provides package ([^;]+)+")
|
||||
var addPackagePattern = regexp.MustCompile(`to add:\n\tgo get (.*)\n`)
|
||||
|
||||
type ByString []*model.TypeInfo
|
||||
|
||||
@@ -210,6 +212,13 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
|
||||
// See if it was an import error that we can go get.
|
||||
matches := importErrorPattern.FindAllStringSubmatch(stOutput, -1)
|
||||
if matches == nil {
|
||||
matches = importErrorPattern2.FindAllStringSubmatch(stOutput, -1)
|
||||
}
|
||||
if matches == nil {
|
||||
matches = addPackagePattern.FindAllStringSubmatch(stOutput, -1)
|
||||
|
||||
}
|
||||
utils.Logger.Info("Build failed checking for missing imports", "message", stOutput, "missing_imports", len(matches))
|
||||
if matches == nil {
|
||||
utils.Logger.Info("Build failed no missing imports", "message", stOutput)
|
||||
@@ -226,6 +235,7 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
}
|
||||
gotten[pkgName] = struct{}{}
|
||||
if err := c.PackageResolver(pkgName); err != nil {
|
||||
panic("failed to resolve")
|
||||
utils.Logger.Error("Unable to resolve package", "package", pkgName, "error", err)
|
||||
return nil, newCompileError(paths, []byte(err.Error()))
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ var (
|
||||
doNotWatch = []string{"tmp", "views", "routes"}
|
||||
|
||||
lastRequestHadError int32
|
||||
startupError int32
|
||||
startupErrorText error
|
||||
)
|
||||
|
||||
// Harness reverse proxies requests to the application server.
|
||||
@@ -207,8 +209,8 @@ func NewHarness(c *model.CommandConfig, paths *model.RevelContainer, runMode str
|
||||
// Refresh method rebuilds the Revel application and run it on the given port.
|
||||
// called by the watcher.
|
||||
func (h *Harness) Refresh() (err *utils.SourceError) {
|
||||
t := time.Now()
|
||||
fmt.Println("Changed detected, recompiling")
|
||||
t := time.Now();
|
||||
fmt.Println("Change detected, recompiling")
|
||||
err = h.refresh()
|
||||
if err != nil && !h.ranOnce && h.useProxy {
|
||||
addr := fmt.Sprintf("%s:%d", h.paths.HTTPAddr, h.paths.HTTPPort)
|
||||
@@ -247,7 +249,7 @@ func (h *Harness) refresh() (err *utils.SourceError) {
|
||||
|
||||
err = &utils.SourceError{
|
||||
Title: "App failed to start up",
|
||||
Description: err.Error(),
|
||||
Description: newErr.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
@@ -263,8 +265,8 @@ func (h *Harness) refresh() (err *utils.SourceError) {
|
||||
if len(h.app.PackagePathMap) > 0 {
|
||||
paths, _ = json.Marshal(h.app.PackagePathMap)
|
||||
}
|
||||
|
||||
runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose, string(paths))
|
||||
|
||||
runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose[0], string(paths))
|
||||
}
|
||||
|
||||
if err2 := h.app.Cmd(runMode).Start(h.config); err2 != nil {
|
||||
@@ -310,12 +312,12 @@ func (h *Harness) Run() {
|
||||
paths = append(paths, h.paths.CodePaths...)
|
||||
h.watcher = watcher.NewWatcher(h.paths, false)
|
||||
h.watcher.Listen(h, paths...)
|
||||
|
||||
go func() {
|
||||
if err := h.Refresh(); err != nil {
|
||||
utils.Logger.Error("Failed to refresh", "error", err)
|
||||
}
|
||||
}()
|
||||
// h.watcher.Notify()
|
||||
|
||||
if h.useProxy {
|
||||
go func() {
|
||||
|
||||
@@ -173,8 +173,6 @@ func (c *CommandConfig) initAppFolder() (err error) {
|
||||
} else {
|
||||
appFolder = filepath.Join(wd, appFolder)
|
||||
}
|
||||
} else if strings.Contains(appFolder, ".") {
|
||||
appFolder = filepath.Join(wd, filepath.Base(c.ImportPath))
|
||||
} else if !filepath.IsAbs(appFolder) {
|
||||
appFolder = filepath.Join(wd, appFolder)
|
||||
}
|
||||
@@ -245,7 +243,7 @@ func (c *CommandConfig) InitPackageResolver() {
|
||||
var getCmd *exec.Cmd
|
||||
print("Downloading related packages ...")
|
||||
if c.Vendored {
|
||||
getCmd = exec.Command(c.GoCmd, "mod", "tidy")
|
||||
getCmd = exec.Command(c.GoCmd, "mod", "tidy", "-v")
|
||||
} else {
|
||||
utils.Logger.Info("No vendor folder detected, not using dependency manager to import package", "package", pkgName)
|
||||
getCmd = exec.Command(c.GoCmd, "get", "-u", pkgName)
|
||||
|
||||
@@ -295,12 +295,11 @@ func (rp *RevelContainer) ResolveImportPath(importPath string) (string, error) {
|
||||
return filepath.Join(rp.SourcePath, importPath), nil
|
||||
}
|
||||
config := &packages.Config{
|
||||
// TODO: packages.LoadSyntax deprecated, Need instead
|
||||
//nolint:staticcheck
|
||||
Mode: packages.LoadSyntax,
|
||||
Dir: rp.AppPath,
|
||||
Mode: packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedImports |
|
||||
packages.NeedTypes | packages.NeedTypesSizes | packages.NeedSyntax | packages.NeedTypesInfo,
|
||||
Dir: rp.AppPath,
|
||||
}
|
||||
|
||||
config.Env = utils.ReducedEnv(false)
|
||||
pkgs, err := packages.Load(config, importPath)
|
||||
if len(pkgs) == 0 {
|
||||
return "", fmt.Errorf("%w %s using app path %s", ErrNoPackages, importPath, rp.AppPath)
|
||||
|
||||
@@ -108,6 +108,7 @@ func (s *SourceProcessor) addPackages() (err error) {
|
||||
// packages.LoadSyntax | packages.NeedDeps,
|
||||
Dir: s.revelContainer.AppPath,
|
||||
}
|
||||
config.Env = utils.ReducedEnv(false)
|
||||
s.packageList, err = packages.Load(config, allPackages...)
|
||||
s.log.Info("Loaded modules ", "len results", len(s.packageList), "error", err)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
const ErrNoSkeleton Error = "failed to find skeleton in filepath"
|
||||
|
||||
var cmdNew = &Command{
|
||||
UsageLine: "new -i [path] -s [skeleton]",
|
||||
UsageLine: "new -i [path] -s [skeleton] -p [package name]",
|
||||
Short: "create a skeleton Revel application",
|
||||
Long: `
|
||||
New creates a few files to get a new Revel application running quickly.
|
||||
@@ -127,7 +127,7 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintln(os.Stdout, "\nYou can run it with:\n revel run -a ", c.ImportPath)
|
||||
fmt.Fprintln(os.Stdout, "\nYou can run it with:\n revel run -a", c.ImportPath)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -133,7 +133,7 @@ func runApp(c *model.CommandConfig) (err error) {
|
||||
// If the app is run in "watched" mode, use the harness to run it.
|
||||
if revelPath.Config.BoolDefault("watch", true) && revelPath.Config.BoolDefault("watch.code", true) {
|
||||
utils.Logger.Info("Running in watched mode.")
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, revelPath.RunMode, c.Verbose)
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, revelPath.RunMode, c.Verbose[0])
|
||||
if c.HistoricMode {
|
||||
runMode = revelPath.RunMode
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func runApp(c *model.CommandConfig) (err error) {
|
||||
if len(app.PackagePathMap) > 0 {
|
||||
paths, _ = json.Marshal(app.PackagePathMap)
|
||||
}
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose, string(paths))
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose[0], string(paths))
|
||||
if c.HistoricMode {
|
||||
runMode = revelPath.RunMode
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
if len(app.PackagePathMap) > 0 {
|
||||
paths, _ = json.Marshal(app.PackagePathMap)
|
||||
}
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose, string(paths))
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose[0], string(paths))
|
||||
if c.HistoricMode {
|
||||
runMode = app.Paths.RunMode
|
||||
}
|
||||
|
||||
@@ -13,7 +13,16 @@ import (
|
||||
func CmdInit(c *exec.Cmd, addGoPath bool, basePath string) {
|
||||
c.Dir = basePath
|
||||
// Dep does not like paths that are not real, convert all paths in go to real paths
|
||||
// Fetch the rest of the env variables
|
||||
c.Env = ReducedEnv(addGoPath)
|
||||
|
||||
}
|
||||
|
||||
// ReducedEnv returns a list of environment vairables by using os.Env
|
||||
// it will remove the GOPATH, GOROOT if addGoPath is true
|
||||
func ReducedEnv(addGoPath bool) []string {
|
||||
realPath := &bytes.Buffer{}
|
||||
env := []string{}
|
||||
if addGoPath {
|
||||
for _, p := range filepath.SplitList(build.Default.GOPATH) {
|
||||
rp, _ := filepath.EvalSymlinks(p)
|
||||
@@ -23,14 +32,18 @@ func CmdInit(c *exec.Cmd, addGoPath bool, basePath string) {
|
||||
realPath.WriteString(rp)
|
||||
}
|
||||
// Go 1.8 fails if we do not include the GOROOT
|
||||
c.Env = []string{"GOPATH=" + realPath.String(), "GOROOT=" + os.Getenv("GOROOT")}
|
||||
env = []string{"GOPATH=" + realPath.String(), "GOROOT=" + os.Getenv("GOROOT")}
|
||||
}
|
||||
// Fetch the rest of the env variables
|
||||
|
||||
for _, e := range os.Environ() {
|
||||
pair := strings.Split(e, "=")
|
||||
if pair[0] == "GOPATH" || pair[0] == "GOROOT" {
|
||||
// Always exclude gomodcache
|
||||
if pair[0] == "GOMODCACHE" {
|
||||
continue
|
||||
} else if !addGoPath && (pair[0] == "GOPATH" || pair[0] == "GOROOT") {
|
||||
continue
|
||||
}
|
||||
c.Env = append(c.Env, e)
|
||||
env = append(env, e)
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
@@ -367,9 +367,10 @@ func findSrcPaths(appPath string, packagesList []string) (sourcePathsmap map[str
|
||||
// Use packages to fetch
|
||||
// by not specifying env, we will use the default env
|
||||
config := &packages.Config{
|
||||
Mode: packages.NeedName | packages.NeedFiles,
|
||||
Mode: packages.NeedName | packages.NeedFiles | packages.NeedDeps,
|
||||
Dir: appPath,
|
||||
}
|
||||
config.Env = ReducedEnv(false)
|
||||
sourcePathsmap = map[string]string{}
|
||||
Logger.Infof("Environment path %s root %s config env %s", os.Getenv("GOPATH"), os.Getenv("GOROOT"), config.Env)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ type Watcher struct {
|
||||
// Creates a new watched based on the container.
|
||||
func NewWatcher(paths *model.RevelContainer, eagerRefresh bool) *Watcher {
|
||||
return &Watcher{
|
||||
forceRefresh: false,
|
||||
forceRefresh: true,
|
||||
lastError: -1,
|
||||
paths: paths,
|
||||
refreshInterval: time.Duration(paths.Config.IntDefault("watch.rebuild.delay", 1000)) * time.Millisecond,
|
||||
|
||||
Reference in New Issue
Block a user