Skip to content

Commit

Permalink
revel/revel#1057 code improvements docs, errcheck, cyclo, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Jun 9, 2016
1 parent 5a57eaa commit e009988
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 126 deletions.
4 changes: 4 additions & 0 deletions harness/app.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package harness

import (
Expand Down
4 changes: 4 additions & 0 deletions harness/build.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package harness

import (
Expand Down
9 changes: 6 additions & 3 deletions harness/harness.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// The Harness for a Revel program.
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

// Package harness for a Revel Framework.
//
// It has a couple responsibilities:
// It has a following responsibilities:
// 1. Parse the user program, generating a main.go file that registers
// controller classes and starts the user's server.
// 2. Build and run the user program. Show compile errors.
// 3. Monitor the user source and re-build / restart the program when necessary.
//
// Source files are generated in the app/tmp directory.

package harness

import (
Expand Down
4 changes: 4 additions & 0 deletions harness/reflect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package harness

// This file handles the app code introspection.
Expand Down
4 changes: 4 additions & 0 deletions harness/reflect_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package harness

import (
Expand Down
23 changes: 16 additions & 7 deletions revel/build.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
Expand Down Expand Up @@ -40,7 +44,7 @@ func buildApp(args []string) {
return
}

appImportPath, destPath, mode := args[0], args[1], "dev"
appImportPath, destPath, mode := args[0], args[1], DefaultRunMode
if len(args) >= 3 {
mode = args[2]
}
Expand All @@ -55,8 +59,13 @@ func buildApp(args []string) {
errorf("Abort: %s exists and does not look like a build directory.", destPath)
}

os.RemoveAll(destPath)
os.MkdirAll(destPath, 0777)
if err := os.RemoveAll(destPath); err != nil && !os.IsNotExist(err) {
revel.ERROR.Fatalln(err)
}

if err := os.MkdirAll(destPath, 0777); err != nil {
revel.ERROR.Fatalln(err)
}

app, reverr := harness.Build()
panicOnError(reverr, "Failed to build")
Expand All @@ -73,9 +82,9 @@ func buildApp(args []string) {
tmpRevelPath := filepath.Join(srcPath, filepath.FromSlash(revel.RevelImportPath))
mustCopyFile(destBinaryPath, app.BinaryPath)
mustChmod(destBinaryPath, 0755)
mustCopyDir(filepath.Join(tmpRevelPath, "conf"), filepath.Join(revel.RevelPath, "conf"), nil)
mustCopyDir(filepath.Join(tmpRevelPath, "templates"), filepath.Join(revel.RevelPath, "templates"), nil)
mustCopyDir(filepath.Join(srcPath, filepath.FromSlash(appImportPath)), revel.BasePath, nil)
_ = mustCopyDir(filepath.Join(tmpRevelPath, "conf"), filepath.Join(revel.RevelPath, "conf"), nil)
_ = mustCopyDir(filepath.Join(tmpRevelPath, "templates"), filepath.Join(revel.RevelPath, "templates"), nil)
_ = mustCopyDir(filepath.Join(srcPath, filepath.FromSlash(appImportPath)), revel.BasePath, nil)

// Find all the modules used and copy them over.
config := revel.Config.Raw()
Expand All @@ -98,7 +107,7 @@ func buildApp(args []string) {
}
}
for importPath, fsPath := range modulePaths {
mustCopyDir(filepath.Join(srcPath, importPath), fsPath, nil)
_ = mustCopyDir(filepath.Join(srcPath, importPath), fsPath, nil)
}

tmplData, runShPath := map[string]interface{}{
Expand Down
4 changes: 4 additions & 0 deletions revel/clean.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
Expand Down
6 changes: 5 additions & 1 deletion revel/new.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
Expand Down Expand Up @@ -199,7 +203,7 @@ func copyNewAppFiles() {
err = os.MkdirAll(appPath, 0777)
panicOnError(err, "Failed to create directory "+appPath)

mustCopyDir(appPath, skeletonPath, map[string]interface{}{
_ = mustCopyDir(appPath, skeletonPath, map[string]interface{}{
// app.conf
"AppName": appName,
"BasePath": basePath,
Expand Down
10 changes: 8 additions & 2 deletions revel/package.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
Expand Down Expand Up @@ -38,7 +42,7 @@ func packageApp(args []string) {
}

// Determine the run mode.
mode := "dev"
mode := DefaultRunMode
if len(args) >= 2 {
mode = args[1]
}
Expand All @@ -48,7 +52,9 @@ func packageApp(args []string) {

// Remove the archive if it already exists.
destFile := filepath.Base(revel.BasePath) + ".tar.gz"
os.Remove(destFile)
if err := os.Remove(destFile); err != nil && !os.IsNotExist(err) {
revel.ERROR.Fatal(err)
}

// Collect stuff in a temp directory.
tmpDir, err := ioutil.TempDir("", filepath.Base(revel.BasePath))
Expand Down
8 changes: 8 additions & 0 deletions revel/rev.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

// The command line tool for running Revel apps.
package main

Expand All @@ -15,12 +19,16 @@ import (
"github.com/agtorre/gocolorize"
)

// DefaultRunMode for revel's application
const DefaultRunMode = "dev"

// Command structure cribbed from the genius organization of the "go" command.
type Command struct {
Run func(args []string)
UsageLine, Short, Long string
}

// Name returns command name from usage line
func (cmd *Command) Name() string {
name := cmd.UsageLine
i := strings.Index(name, " ")
Expand Down
4 changes: 4 additions & 0 deletions revel/run.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
// Revel Framework source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
Expand Down
Loading

0 comments on commit e009988

Please sign in to comment.