mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Updated formating
Ran through testing individually for vendored Revel applications
This commit is contained in:
@@ -37,10 +37,10 @@ func init() {
|
||||
// The update config updates the configuration command so that it can run
|
||||
func updateBuildConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.BUILD
|
||||
if c.Build.TargetPath=="" {
|
||||
c.Build.TargetPath="target"
|
||||
if c.Build.TargetPath == "" {
|
||||
c.Build.TargetPath = "target"
|
||||
}
|
||||
if len(args)==0 && c.Build.ImportPath!="" {
|
||||
if len(args) == 0 && c.Build.ImportPath != "" {
|
||||
return true
|
||||
}
|
||||
// If arguments were passed in then there must be two
|
||||
@@ -176,13 +176,13 @@ func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer,
|
||||
if moduleImportPath == "" {
|
||||
continue
|
||||
}
|
||||
moduleImportList =append(moduleImportList,moduleImportPath)
|
||||
moduleImportList = append(moduleImportList, moduleImportPath)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the the paths for each of the modules
|
||||
for _,importPath := range moduleImportList {
|
||||
for _, importPath := range moduleImportList {
|
||||
fsPath := app.PackagePathMap[importPath]
|
||||
utils.Logger.Info("Copy files ", "to", filepath.Join(destPath, importPath), "from", fsPath)
|
||||
if c.Build.CopySource {
|
||||
|
||||
@@ -37,7 +37,7 @@ func init() {
|
||||
// Update the clean command configuration, using old method
|
||||
func updateCleanConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.CLEAN
|
||||
if len(args)==0 && c.Clean.ImportPath!="" {
|
||||
if len(args) == 0 && c.Clean.ImportPath != "" {
|
||||
return true
|
||||
}
|
||||
if len(args) == 0 {
|
||||
|
||||
48
revel/new.go
48
revel/new.go
@@ -46,13 +46,13 @@ func init() {
|
||||
// Called when unable to parse the command line automatically and assumes an old launch
|
||||
func updateNewConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.NEW
|
||||
if len(c.New.Package)>0 {
|
||||
if len(c.New.Package) > 0 {
|
||||
c.New.NotVendored = false
|
||||
}
|
||||
c.Vendored = !c.New.NotVendored
|
||||
|
||||
if len(args) == 0 {
|
||||
if len(c.New.ImportPath)==0 {
|
||||
if len(c.New.ImportPath) == 0 {
|
||||
fmt.Fprintf(os.Stderr, cmdNew.Long)
|
||||
return false
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
// checking and setting skeleton
|
||||
if err=setSkeletonPath(c);err!=nil {
|
||||
if err = setSkeletonPath(c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,18 +90,20 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// At this point the versions can be set
|
||||
c.SetVersions()
|
||||
// This kicked off the download of the revel app, not needed for vendor
|
||||
if !c.Vendored {
|
||||
// At this point the versions can be set
|
||||
c.SetVersions()
|
||||
}
|
||||
|
||||
// copy files to new app directory
|
||||
if err = copyNewAppFiles(c);err != nil {
|
||||
if err = copyNewAppFiles(c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Run the vendor tool if needed
|
||||
println("********** here",c.Vendored)
|
||||
if c.Vendored {
|
||||
if err=createModVendor(c); err!=nil {
|
||||
if err = createModVendor(c); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -120,13 +122,15 @@ func newApp(c *model.CommandConfig) (err error) {
|
||||
func createModVendor(c *model.CommandConfig) (err error) {
|
||||
|
||||
utils.Logger.Info("Creating a new mod app")
|
||||
goModCmd := exec.Command("go", "mod", "init", filepath.Join(c.New.Package,c.AppName))
|
||||
goModCmd := exec.Command("go", "mod", "init", filepath.Join(c.New.Package, c.AppName))
|
||||
|
||||
utils.CmdInit(goModCmd, !c.Vendored, c.AppPath)
|
||||
|
||||
utils.CmdInit(goModCmd, c.AppPath)
|
||||
|
||||
utils.Logger.Info("Exec:", "args", goModCmd.Args, "env", goModCmd.Env, "workingdir",goModCmd.Dir)
|
||||
utils.Logger.Info("Exec:", "args", goModCmd.Args, "env", goModCmd.Env, "workingdir", goModCmd.Dir)
|
||||
getOutput, err := goModCmd.CombinedOutput()
|
||||
if c.New.Callback != nil {
|
||||
err = c.New.Callback()
|
||||
}
|
||||
if err != nil {
|
||||
return utils.NewBuildIfError(err, string(getOutput))
|
||||
}
|
||||
@@ -141,7 +145,7 @@ func createDepVendor(c *model.CommandConfig) (err error) {
|
||||
if !utils.DirExists(vendorPath) {
|
||||
|
||||
if err := os.MkdirAll(vendorPath, os.ModePerm); err != nil {
|
||||
return utils.NewBuildError("Failed to create "+vendorPath, "error", err)
|
||||
return utils.NewBuildError("Failed to create " + vendorPath, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,11 +154,11 @@ func createDepVendor(c *model.CommandConfig) (err error) {
|
||||
utils.Logger.Info("Checking for temp folder for source code", "path", tempPath)
|
||||
if !utils.DirExists(tempPath) {
|
||||
if err := os.MkdirAll(tempPath, os.ModePerm); err != nil {
|
||||
return utils.NewBuildIfError(err, "Failed to create "+vendorPath)
|
||||
return utils.NewBuildIfError(err, "Failed to create " + vendorPath)
|
||||
}
|
||||
|
||||
if err = utils.GenerateTemplate(filepath.Join(tempPath, "main.go"), NEW_MAIN_FILE, nil); err != nil {
|
||||
return utils.NewBuildIfError(err, "Failed to create main file "+vendorPath)
|
||||
return utils.NewBuildIfError(err, "Failed to create main file " + vendorPath)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,9 +175,9 @@ func createDepVendor(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
getCmd := exec.Command("dep", "ensure", "-v")
|
||||
utils.CmdInit(getCmd, c.AppPath)
|
||||
utils.CmdInit(getCmd, !c.Vendored, c.AppPath)
|
||||
|
||||
utils.Logger.Info("Exec:", "args", getCmd.Args, "env", getCmd.Env, "workingdir",getCmd.Dir)
|
||||
utils.Logger.Info("Exec:", "args", getCmd.Args, "env", getCmd.Env, "workingdir", getCmd.Dir)
|
||||
getOutput, err := getCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return utils.NewBuildIfError(err, string(getOutput))
|
||||
@@ -211,7 +215,7 @@ func setApplicationPath(c *model.CommandConfig) (err error) {
|
||||
//// Go get the revel project
|
||||
err = c.PackageResolver(model.RevelImportPath)
|
||||
if err != nil {
|
||||
return utils.NewBuildIfError(err, "Failed to fetch revel "+model.RevelImportPath)
|
||||
return utils.NewBuildIfError(err, "Failed to fetch revel " + model.RevelImportPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,13 +239,13 @@ func setSkeletonPath(c *model.CommandConfig) (err error) {
|
||||
switch strings.ToLower(sp.Scheme) {
|
||||
// TODO Add support for ftp, sftp, scp ??
|
||||
case "" :
|
||||
sp.Scheme="file"
|
||||
sp.Scheme = "file"
|
||||
fallthrough
|
||||
case "file" :
|
||||
fullpath := sp.String()[7:]
|
||||
if !filepath.IsAbs(fullpath) {
|
||||
fullpath, err = filepath.Abs(fullpath)
|
||||
if err!=nil {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -276,11 +280,11 @@ func newLoadFromGit(c *model.CommandConfig, sp *url.URL) (err error) {
|
||||
targetPath := filepath.Join(os.TempDir(), "revel", "skeleton")
|
||||
os.RemoveAll(targetPath)
|
||||
pathpart := strings.Split(sp.Path, ":")
|
||||
getCmd := exec.Command("git", "clone", sp.Scheme+"://"+sp.Host+pathpart[0], targetPath)
|
||||
getCmd := exec.Command("git", "clone", sp.Scheme + "://" + sp.Host + pathpart[0], targetPath)
|
||||
utils.Logger.Info("Exec:", "args", getCmd.Args)
|
||||
getOutput, err := getCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
utils.Logger.Fatal("Abort: could not clone the Skeleton source code: ","output", string(getOutput), "path", c.New.SkeletonPath)
|
||||
utils.Logger.Fatal("Abort: could not clone the Skeleton source code: ", "output", string(getOutput), "path", c.New.SkeletonPath)
|
||||
}
|
||||
outputPath := targetPath
|
||||
if len(pathpart) > 1 {
|
||||
|
||||
@@ -3,95 +3,42 @@ package main_test
|
||||
import (
|
||||
"github.com/revel/cmd/model"
|
||||
"github.com/revel/cmd/revel"
|
||||
"github.com/revel/cmd/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// test the commands
|
||||
func TestNew(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
gopath := setup("revel-test-new", a)
|
||||
gopath := setup("revel-test-new", a)
|
||||
|
||||
t.Run("New", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("new-test", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New failed")
|
||||
})
|
||||
t.Run("Path", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("new/test/a", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed")
|
||||
})
|
||||
t.Run("Path-Duplicate", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("new/test/b", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed")
|
||||
c = newApp("new/test/b", model.NEW, nil, a)
|
||||
a.NotNil(main.Commands[model.NEW].RunWith(c), "Duplicate path Did Not failed")
|
||||
})
|
||||
t.Run("Skeleton-Git", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("new/test/c/1", model.NEW, nil, a)
|
||||
c.New.SkeletonPath = "git://github.com/revel/skeletons:basicnsadnsak"
|
||||
a.NotNil(main.Commands[model.NEW].RunWith(c), "Expected Failed to run with new")
|
||||
// We need to pick a different path
|
||||
c = newApp("new/test/c/2", model.NEW, nil, a)
|
||||
c.New.SkeletonPath = "git://github.com/revel/skeletons:basic/bootstrap4"
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "Failed to run with new skeleton git")
|
||||
})
|
||||
if !t.Failed() {
|
||||
if err := os.RemoveAll(gopath); err != nil {
|
||||
a.Fail("Failed to remove test path")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test the commands
|
||||
func TestNewVendor(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
gopath := setup("revel-test-new-vendor", a)
|
||||
precall := func(c *model.CommandConfig) {
|
||||
c.New.DepVendored = true
|
||||
}
|
||||
t.Run("New", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("onlyone/v/a", model.NEW, precall, a)
|
||||
c.New.DepVendored = true
|
||||
c := newApp("new-test", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New failed")
|
||||
})
|
||||
t.Run("Test", func(t *testing.T) {
|
||||
t.Run("Path", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("onlyone/v/a", model.TEST, nil, a)
|
||||
a.Nil(main.Commands[model.TEST].RunWith(c), "Test failed")
|
||||
c := newApp("new/test/a", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed")
|
||||
})
|
||||
t.Run("Build", func(t *testing.T) {
|
||||
t.Run("Path-Duplicate", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("onlyone/v/a", model.BUILD, nil, a)
|
||||
c.Index = model.BUILD
|
||||
c.Build.TargetPath = filepath.Join(gopath, "src/onlyone/v/a", "target")
|
||||
a.Nil(main.Commands[model.BUILD].RunWith(c), " Build failed")
|
||||
a.True(utils.DirExists(c.Build.TargetPath), "Target folder not made", c.Build.TargetPath)
|
||||
c := newApp("new/test/b", model.NEW, nil, a)
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed")
|
||||
c = newApp("new/test/b", model.NEW, nil, a)
|
||||
a.NotNil(main.Commands[model.NEW].RunWith(c), "Duplicate path Did Not failed")
|
||||
})
|
||||
t.Run("Package", func(t *testing.T) {
|
||||
t.Run("Skeleton-Git", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("onlyone/v/a", model.PACKAGE, nil, a)
|
||||
c.Package.TargetPath = filepath.Join(gopath, "src/onlyone/v/a", "target.tar.gz")
|
||||
a.Nil(main.Commands[model.PACKAGE].RunWith(c), "Package Failed")
|
||||
a.True(utils.Exists(c.Package.TargetPath), "Target package not made", c.Package.TargetPath)
|
||||
})
|
||||
t.Run("TestVendorDir", func(t *testing.T) {
|
||||
// Check to see that no additional packages were downloaded outside the vendor folder
|
||||
files, err := ioutil.ReadDir(gopath)
|
||||
a.Nil(err, "Failed to read gopath folder")
|
||||
// bin/ onlyone/ pkg/ src/
|
||||
a.Equal(3, len(files), "Expected single file in "+gopath)
|
||||
files, err = ioutil.ReadDir(filepath.Join(gopath, "src"))
|
||||
a.Nil(err, "Failed to read src folder")
|
||||
a.Equal(1, len(files), "Expected single file in source folder", filepath.Join(gopath, "src"))
|
||||
c := newApp("new/test/c/1", model.NEW, nil, a)
|
||||
c.New.SkeletonPath = "git://github.com/revel/skeletons:basicnsadnsak"
|
||||
a.NotNil(main.Commands[model.NEW].RunWith(c), "Expected Failed to run with new")
|
||||
// We need to pick a different path
|
||||
c = newApp("new/test/c/2", model.NEW, nil, a)
|
||||
c.New.SkeletonPath = "git://github.com/revel/skeletons:basic/bootstrap4"
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "Failed to run with new skeleton git")
|
||||
})
|
||||
if !t.Failed() {
|
||||
if err := os.RemoveAll(gopath); err != nil {
|
||||
@@ -99,3 +46,4 @@ func TestNewVendor(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,27 +71,27 @@ func main() {
|
||||
wd, _ := os.Getwd()
|
||||
|
||||
utils.InitLogger(wd, logger.LvlError)
|
||||
parser := flags.NewParser(c, flags.HelpFlag|flags.PassDoubleDash)
|
||||
if len(os.Args)<2 {
|
||||
parser := flags.NewParser(c, flags.HelpFlag | flags.PassDoubleDash)
|
||||
if len(os.Args) < 2 {
|
||||
parser.WriteHelp(os.Stdout)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := ParseArgs(c, parser, os.Args[1:]); err != nil {
|
||||
fmt.Fprint(os.Stderr, err.Error() +"\n")
|
||||
fmt.Fprint(os.Stderr, err.Error() + "\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Switch based on the verbose flag
|
||||
if len(c.Verbose)>1 {
|
||||
if len(c.Verbose) > 1 {
|
||||
utils.InitLogger(wd, logger.LvlDebug)
|
||||
} else if len(c.Verbose)>0 {
|
||||
} else if len(c.Verbose) > 0 {
|
||||
utils.InitLogger(wd, logger.LvlInfo)
|
||||
} else {
|
||||
utils.InitLogger(wd, logger.LvlWarn)
|
||||
}
|
||||
|
||||
if err := c.UpdateImportPath();err!=nil {
|
||||
if err := c.UpdateImportPath(); err != nil {
|
||||
utils.Logger.Error(err.Error())
|
||||
parser.WriteHelp(os.Stdout)
|
||||
os.Exit(1)
|
||||
@@ -107,7 +107,7 @@ func main() {
|
||||
c.InitPackageResolver()
|
||||
|
||||
if err := command.RunWith(c); err != nil {
|
||||
utils.Logger.Error("Unable to execute","error",err)
|
||||
utils.Logger.Error("Unable to execute", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func updateRunConfig(c *model.CommandConfig, args []string) bool {
|
||||
}
|
||||
case 0:
|
||||
// Attempt to set the import path to the current working director.
|
||||
if c.Run.ImportPath=="" {
|
||||
if c.Run.ImportPath == "" {
|
||||
c.Run.ImportPath, _ = os.Getwd()
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func updateRunConfig(c *model.CommandConfig, args []string) bool {
|
||||
|
||||
// Returns true if this is an absolute path or a relative gopath
|
||||
func runIsImportPath(pathToCheck string) bool {
|
||||
if _, err := build.Import(pathToCheck, "", build.FindOnly);err==nil {
|
||||
if _, err := build.Import(pathToCheck, "", build.FindOnly); err == nil {
|
||||
return true
|
||||
}
|
||||
return filepath.IsAbs(pathToCheck)
|
||||
@@ -160,7 +160,7 @@ func runApp(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
app.Port = revel_path.HTTPPort
|
||||
var paths []byte
|
||||
if len(app.PackagePathMap)>0 {
|
||||
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))
|
||||
|
||||
@@ -55,7 +55,7 @@ func init() {
|
||||
// Called to update the config command with from the older stype
|
||||
func updateTestConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.TEST
|
||||
if len(args)==0 && c.Test.ImportPath!="" {
|
||||
if len(args) == 0 && c.Test.ImportPath != "" {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
// Direct all the output into a file in the test-results directory.
|
||||
file, err := os.OpenFile(filepath.Join(resultPath, "app.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
file, err := os.OpenFile(filepath.Join(resultPath, "app.log"), os.O_CREATE | os.O_WRONLY | os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
return utils.NewBuildError("Failed to create test result log file: ", "error", err)
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
return utils.NewBuildIfError(reverr, "Error building: ")
|
||||
}
|
||||
var paths []byte
|
||||
if len(app.PackagePathMap)>0 {
|
||||
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))
|
||||
@@ -117,7 +117,7 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
runMode = app.Paths.RunMode
|
||||
}
|
||||
cmd := app.Cmd(runMode)
|
||||
cmd.Dir=c.AppPath
|
||||
cmd.Dir = c.AppPath
|
||||
|
||||
cmd.Stderr = io.MultiWriter(cmd.Stderr, file)
|
||||
cmd.Stdout = io.MultiWriter(cmd.Stderr, file)
|
||||
@@ -234,7 +234,7 @@ func filterTestSuites(suites *[]tests.TestSuiteDesc, suiteArgument string) *[]te
|
||||
// in case it hasn't finished starting up yet.
|
||||
func getTestsList(baseURL string) (*[]tests.TestSuiteDesc, error) {
|
||||
var (
|
||||
err error
|
||||
err error
|
||||
resp *http.Response
|
||||
testSuites []tests.TestSuiteDesc
|
||||
)
|
||||
|
||||
@@ -29,10 +29,10 @@ import (
|
||||
type (
|
||||
// The version container
|
||||
VersionCommand struct {
|
||||
Command *model.CommandConfig // The command
|
||||
revelVersion *model.Version // The Revel framework version
|
||||
modulesVersion *model.Version // The Revel modules version
|
||||
cmdVersion *model.Version // The tool version
|
||||
Command *model.CommandConfig // The command
|
||||
revelVersion *model.Version // The Revel framework version
|
||||
modulesVersion *model.Version // The Revel modules version
|
||||
cmdVersion *model.Version // The tool version
|
||||
}
|
||||
)
|
||||
|
||||
@@ -74,10 +74,10 @@ func (v *VersionCommand) RunWith(c *model.CommandConfig) (err error) {
|
||||
versionInfo := ""
|
||||
for x := 0; x < 2 && needsUpdates; x++ {
|
||||
needsUpdates = false
|
||||
versionInfo, needsUpdates = v.doRepoCheck(x==0)
|
||||
versionInfo, needsUpdates = v.doRepoCheck(x == 0)
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n\nGo Location:%s\n\n",versionInfo,c.GoCmd)
|
||||
fmt.Printf("%s\n\nGo Location:%s\n\n", versionInfo, c.GoCmd)
|
||||
cmd := exec.Command(c.GoCmd, "version")
|
||||
cmd.Stdout = os.Stdout
|
||||
if e := cmd.Start(); e != nil {
|
||||
@@ -112,7 +112,7 @@ func (v *VersionCommand) doRepoCheck(updateLibs bool) (versionInfo string, needs
|
||||
// Only do an update on the first loop, and if specified to update
|
||||
shouldUpdate := updateLibs && v.Command.Version.Update
|
||||
if v.Command.Version.Update {
|
||||
if localVersion == nil || (versonFromRepo != nil && versonFromRepo.Newer(localVersion)) {
|
||||
if localVersion == nil || (versonFromRepo != nil && versonFromRepo.Newer(localVersion)) {
|
||||
needsUpdate = true
|
||||
if shouldUpdate {
|
||||
v.doUpdate(title, repo, localVersion, versonFromRepo)
|
||||
@@ -127,7 +127,7 @@ func (v *VersionCommand) doRepoCheck(updateLibs bool) (versionInfo string, needs
|
||||
|
||||
// Checks for updates if needed
|
||||
func (v *VersionCommand) doUpdate(title, repo string, local, remote *model.Version) {
|
||||
utils.Logger.Info("Updating package", "package", title, "repo",repo)
|
||||
utils.Logger.Info("Updating package", "package", title, "repo", repo)
|
||||
fmt.Println("Attempting to update package", title)
|
||||
if err := v.Command.PackageResolver(repo); err != nil {
|
||||
utils.Logger.Error("Unable to update repo", "repo", repo, "error", err)
|
||||
@@ -228,15 +228,15 @@ func (v *VersionCommand) versionFromBytes(sourceStream []byte) (version *model.V
|
||||
}
|
||||
|
||||
// Fetch the local version of revel from the file system
|
||||
func (v *VersionCommand) updateLocalVersions() {
|
||||
func (v *VersionCommand) updateLocalVersions() {
|
||||
v.cmdVersion = &model.Version{}
|
||||
v.cmdVersion.ParseVersion(cmd.Version)
|
||||
v.cmdVersion.BuildDate = cmd.BuildDate
|
||||
v.cmdVersion.MinGoVersion = cmd.MinimumGoVersion
|
||||
|
||||
pathMap, err := utils.FindSrcPaths(v.Command.AppPath,[]string{model.RevelImportPath,model.RevelModulesImportPath}, v.Command.PackageResolver)
|
||||
pathMap, err := utils.FindSrcPaths(v.Command.AppPath, []string{model.RevelImportPath, model.RevelModulesImportPath}, v.Command.PackageResolver)
|
||||
if err != nil {
|
||||
utils.Logger.Warn("Unable to extract version information from Revel library", "path",pathMap[model.RevelImportPath], "error",err)
|
||||
utils.Logger.Warn("Unable to extract version information from Revel library", "path", pathMap[model.RevelImportPath], "error", err)
|
||||
return
|
||||
}
|
||||
utils.Logger.Info("Fullpath to revel modules", "dir", pathMap[model.RevelImportPath])
|
||||
|
||||
Reference in New Issue
Block a user