From 69e59efb14710769a543180687a60092692aeb61 Mon Sep 17 00:00:00 2001 From: NotZippy Date: Fri, 21 Sep 2018 10:08:37 -0700 Subject: [PATCH] New Enhancement Added ability to create a new revel applicaiton without any sources. Automatically download all sources required --- harness/app.go | 2 +- revel/new.go | 24 +++++++++++++++++++----- revel/skeleton/messages/sample.en | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/harness/app.go b/harness/app.go index 81262e6a..2765918b 100644 --- a/harness/app.go +++ b/harness/app.go @@ -73,7 +73,7 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error { return errors.New("revel/harness: app died reason: " + exitState) case <-time.After(60 * time.Second): - log.Println("Killing revel server process did not respond after wait timeout.", "processid", cmd.Process.Pid) + utils.Logger.Error("Killing revel server process did not respond after wait timeout.", "processid", cmd.Process.Pid) cmd.Kill() return errors.New("revel/harness: app timed out") diff --git a/revel/new.go b/revel/new.go index 69c2dc7d..f6489128 100644 --- a/revel/new.go +++ b/revel/new.go @@ -108,8 +108,6 @@ func newApp(c *model.CommandConfig) { if err != nil { utils.Logger.Fatal(string(getOutput)) } - - // TODO build.Default.GOPATH = build.Default.GOPATH + string(os.PathListSeparator) + c.ImportPath } @@ -164,8 +162,12 @@ func setApplicationPath(c *model.CommandConfig) { _, err = build.Import(model.RevelImportPath, "", build.FindOnly) if err != nil { // Go get the revel project - - utils.Logger.Fatal("Abort: Could not find Revel source code:", "error", err) + getCmd := exec.Command(c.GoCmd, "get", model.RevelImportPath) + utils.Logger.Info("Exec:" + c.GoCmd, "args", getCmd.Args) + getOutput, err := getCmd.CombinedOutput() + if err != nil { + utils.Logger.Fatal("Failed to fetch revel " + model.RevelImportPath, "getOutput", string(getOutput)) + } } } @@ -208,7 +210,19 @@ func setSkeletonPath(c *model.CommandConfig) { // use the revel default revelCmdPkg, err := build.Import(RevelCmdImportPath, "", build.FindOnly) if err != nil { - utils.Logger.Fatalf("Abort: Could not find Revel Cmd source code: %s\n", err) + if err != nil { + // Go get the revel project + getCmd := exec.Command(c.GoCmd, "get", RevelCmdImportPath + "/revel") + utils.Logger.Info("Exec:" + c.GoCmd, "args", getCmd.Args) + getOutput, err := getCmd.CombinedOutput() + if err != nil { + utils.Logger.Fatal("Failed to fetch revel cmd " + RevelCmdImportPath, "getOutput", string(getOutput)) + } + revelCmdPkg, err = build.Import(RevelCmdImportPath, "", build.FindOnly) + if err!= nil { + utils.Logger.Fatal("Failed to find source of revel cmd " + RevelCmdImportPath, "getOutput", string(getOutput), "error",err, "dir", revelCmdPkg.Dir) + } + } } c.SkeletonPath = filepath.Join(revelCmdPkg.Dir, "revel", "skeleton") diff --git a/revel/skeleton/messages/sample.en b/revel/skeleton/messages/sample.en index fc447f96..32f3f6ba 100644 --- a/revel/skeleton/messages/sample.en +++ b/revel/skeleton/messages/sample.en @@ -4,4 +4,5 @@ # See also: # - http://www.rfc-editor.org/rfc/bcp/bcp47.txt # - http://www.w3.org/International/questions/qa-accept-lang-locales +[DEFAULT]