mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Moved skeleton to its own repository
This commit is contained in:
37
revel/new.go
37
revel/new.go
@@ -205,7 +205,7 @@ func setApplicationPath(c *model.CommandConfig) (err error) {
|
||||
// Set the skeleton path
|
||||
func setSkeletonPath(c *model.CommandConfig) (err error) {
|
||||
if len(c.New.SkeletonPath) == 0 {
|
||||
c.New.SkeletonPath = RevelCmdImportPath + ":skeleton"
|
||||
c.New.SkeletonPath = "git://" + RevelSkeletonsImportPath + ":basic/bootstrap4"
|
||||
}
|
||||
|
||||
// First check to see the protocol of the string
|
||||
@@ -218,12 +218,13 @@ func setSkeletonPath(c *model.CommandConfig) (err error) {
|
||||
if err := newLoadFromGit(c, sp); err != nil {
|
||||
return err
|
||||
}
|
||||
case "":
|
||||
if err := newLoadFromGo(c, sp); err != nil {
|
||||
return err
|
||||
}
|
||||
//case "":
|
||||
|
||||
//if err := newLoadFromGo(c, sp); err != nil {
|
||||
// return err
|
||||
//}
|
||||
default:
|
||||
utils.Logger.Fatal("Unsupported")
|
||||
utils.Logger.Fatal("Unsupported skeleton schema ", "path", c.New.SkeletonPath)
|
||||
|
||||
}
|
||||
// TODO check to see if the path needs to be extracted
|
||||
@@ -259,30 +260,6 @@ func newLoadFromGit(c *model.CommandConfig, sp *url.URL) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Load from GO
|
||||
func newLoadFromGo(c *model.CommandConfig, sp *url.URL) (err error) {
|
||||
// Find the source paths, download packages automatically
|
||||
pathpart := strings.Split(sp.Path, ":")
|
||||
_, skeletonImportPath , err := utils.FindSrcPaths(c.ImportPath,sp.Host+pathpart[0],c.PackageResolver)
|
||||
if err!=nil {
|
||||
return
|
||||
}
|
||||
|
||||
skeletonImportPath = filepath.Join(skeletonImportPath,sp.Host,pathpart[0])
|
||||
// Add in anything after the "Root" path
|
||||
if len(pathpart) > 1 {
|
||||
pathpart[0] = skeletonImportPath
|
||||
newdir, _ := filepath.Abs(filepath.Join(pathpart...))
|
||||
if !strings.HasPrefix(newdir, skeletonImportPath) {
|
||||
utils.Logger.Fatal("Unusual target path outside root path", "target", newdir, "root", skeletonImportPath)
|
||||
}
|
||||
skeletonImportPath = newdir
|
||||
}
|
||||
|
||||
c.New.SkeletonPath = skeletonImportPath
|
||||
return
|
||||
}
|
||||
|
||||
func copyNewAppFiles(c *model.CommandConfig) (err error) {
|
||||
err = os.MkdirAll(c.AppPath, 0777)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,19 +36,13 @@ func TestNew(t *testing.T) {
|
||||
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/cmd:skeleton2"
|
||||
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/cmd:skeleton"
|
||||
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")
|
||||
})
|
||||
t.Run("Skeleton-Go", func(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
c := newApp("new/test/d", model.NEW, nil, a)
|
||||
c.New.SkeletonPath = "github.com/revel/cmd:skeleton"
|
||||
a.Nil(main.Commands[model.NEW].RunWith(c), "Failed to run with new from go")
|
||||
})
|
||||
if !t.Failed() {
|
||||
if err := os.RemoveAll(gopath); err != nil {
|
||||
a.Fail("Failed to remove test path")
|
||||
|
||||
@@ -26,6 +26,9 @@ const (
|
||||
// RevelCmdImportPath Revel framework cmd tool import path
|
||||
RevelCmdImportPath = "github.com/revel/cmd"
|
||||
|
||||
// RevelCmdImportPath Revel framework cmd tool import path
|
||||
RevelSkeletonsImportPath = "github.com/revel/skeletons"
|
||||
|
||||
// DefaultRunMode for revel's application
|
||||
DefaultRunMode = "dev"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user