Moved skeleton to its own repository

This commit is contained in:
NotZippy
2018-09-30 14:42:21 -07:00
parent f4fb2ec091
commit 9ad0065f6c
25 changed files with 12 additions and 615 deletions

View File

@@ -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 {

View File

@@ -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")

View File

@@ -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"
)