mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Updated sourceinfo
Added packagepathmap to the SourceInfo, this in turn allows the RevelCLI app command to pass the source paths directly to Revel directly Added default to build to be "target" of the current folder Renamed source processor
This commit is contained in:
@@ -37,6 +37,12 @@ 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 len(args)==0 && c.Build.ImportPath!="" {
|
||||
return true
|
||||
}
|
||||
// If arguments were passed in then there must be two
|
||||
if len(args) < 2 {
|
||||
fmt.Fprintf(os.Stderr, "%s\n%s", cmdBuild.UsageLine, cmdBuild.Long)
|
||||
@@ -63,7 +69,7 @@ func buildApp(c *model.CommandConfig) (err error) {
|
||||
c.Build.Mode = mode
|
||||
c.Build.ImportPath = appImportPath
|
||||
|
||||
revel_paths, err := model.NewRevelPaths(mode, appImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
revel_paths, err := model.NewRevelPaths(mode, appImportPath, c.AppPath, model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -88,7 +94,7 @@ func buildApp(c *model.CommandConfig) (err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = buildCopyModules(c, revel_paths, packageFolders)
|
||||
err = buildCopyModules(c, revel_paths, packageFolders, app)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -148,7 +154,7 @@ func buildCopyFiles(c *model.CommandConfig, app *harness.App, revel_paths *model
|
||||
}
|
||||
|
||||
// Based on the section copy over the build modules
|
||||
func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer, packageFolders []string) (err error) {
|
||||
func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer, packageFolders []string, app *harness.App) (err error) {
|
||||
destPath := filepath.Join(c.Build.TargetPath, "src")
|
||||
// Find all the modules used and copy them over.
|
||||
config := revel_paths.Config.Raw()
|
||||
@@ -174,14 +180,10 @@ func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer,
|
||||
|
||||
}
|
||||
}
|
||||
modulePaths, err := utils.FindSrcPaths(c.AppPath, moduleImportList, c.PackageResolver)
|
||||
|
||||
if err != nil {
|
||||
utils.Logger.Fatalf("Failed to load modules ", "error", err)
|
||||
}
|
||||
|
||||
// Copy the the paths for each of the modules
|
||||
for importPath, fsPath := range modulePaths {
|
||||
for _,importPath := range moduleImportList {
|
||||
fsPath := app.PackagePathMap[importPath]
|
||||
utils.Logger.Info("Copy files ", "to", filepath.Join(destPath, importPath), "from", fsPath)
|
||||
if c.Build.CopySource {
|
||||
err = utils.CopyDir(filepath.Join(destPath, importPath), fsPath, nil)
|
||||
|
||||
@@ -37,6 +37,9 @@ 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!="" {
|
||||
return true
|
||||
}
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(os.Stderr, cmdClean.Long)
|
||||
return false
|
||||
|
||||
@@ -40,6 +40,9 @@ func init() {
|
||||
// Called when unable to parse the command line automatically and assumes an old launch
|
||||
func updatePackageConfig(c *model.CommandConfig, args []string) bool {
|
||||
c.Index = model.PACKAGE
|
||||
if len(args)==0 && c.Package.ImportPath!="" {
|
||||
return true
|
||||
}
|
||||
c.Package.ImportPath = args[0]
|
||||
if len(args) > 1 {
|
||||
c.Package.Mode = args[1]
|
||||
@@ -58,7 +61,7 @@ func packageApp(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
appImportPath := c.ImportPath
|
||||
revel_paths, err := model.NewRevelPaths(mode, appImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
revel_paths, err := model.NewRevelPaths(mode, appImportPath, c.AppPath, model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/revel/cmd/harness"
|
||||
"github.com/revel/cmd/model"
|
||||
@@ -159,7 +159,11 @@ func runApp(c *model.CommandConfig) (err error) {
|
||||
utils.Logger.Errorf("Failed to build app: %s", err)
|
||||
}
|
||||
app.Port = revel_path.HTTPPort
|
||||
runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, app.Paths.RunMode, c.Verbose)
|
||||
var paths []byte
|
||||
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))
|
||||
if c.HistoricMode {
|
||||
runMode = revel_path.RunMode
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ 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!="" {
|
||||
return true
|
||||
}
|
||||
|
||||
// The full test runs
|
||||
// revel test <import path> (run mode) (suite(.function))
|
||||
if len(args) < 1 {
|
||||
@@ -78,7 +82,7 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
}
|
||||
|
||||
// Find and parse app.conf
|
||||
revel_path, err := model.NewRevelPaths(mode, c.ImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
revel_path, err := model.NewRevelPaths(mode, c.ImportPath, c.AppPath, model.NewWrappedRevelCallback(nil, c.PackageResolver))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -104,11 +108,16 @@ func testApp(c *model.CommandConfig) (err error) {
|
||||
if reverr != nil {
|
||||
return utils.NewBuildIfError(reverr, "Error building: ")
|
||||
}
|
||||
runMode := fmt.Sprintf(`{"mode":"%s","testModeFlag":true, "specialUseFlag":%v}`, app.Paths.RunMode, c.Verbose)
|
||||
var paths []byte
|
||||
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))
|
||||
if c.HistoricMode {
|
||||
runMode = app.Paths.RunMode
|
||||
}
|
||||
cmd := app.Cmd(runMode)
|
||||
cmd.Dir=c.AppPath
|
||||
|
||||
cmd.Stderr = io.MultiWriter(cmd.Stderr, file)
|
||||
cmd.Stdout = io.MultiWriter(cmd.Stderr, file)
|
||||
|
||||
Reference in New Issue
Block a user