From ab793d204399ea0b46ec1938cc23a4d84ea045b4 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 00:42:19 -0800 Subject: adding a build step: vendor all addon files - requires a change in way we currently copy files & dirs around --- cmd/ponzu/options.go | 129 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 38 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 7c93130..142302f 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -127,8 +126,8 @@ func createProjInDir(path string) error { } } - // create a 'vendor' directory in $path/cmd/ponzu and move 'content', - // 'management' and 'system' packages into it + // create an internal vendor directory in ./cmd/ponzu and move content, + // management and system packages into it err = vendorCorePackages(path) if err != nil { return err @@ -148,7 +147,6 @@ func vendorCorePackages(path string) error { vendorPath := filepath.Join(path, "cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu") err := os.MkdirAll(vendorPath, os.ModeDir|os.ModePerm) if err != nil { - // TODO: rollback, remove ponzu project from path return err } @@ -156,76 +154,131 @@ func vendorCorePackages(path string) error { for _, dir := range dirs { err = os.Rename(filepath.Join(path, dir), filepath.Join(vendorPath, dir)) if err != nil { - // TODO: rollback, remove ponzu project from path return err } } - // create a user 'content' package + // create a user content directory contentPath := filepath.Join(path, "content") err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) if err != nil { - // TODO: rollback, remove ponzu project from path return err } return nil } -func buildPonzuServer(args []string) error { - // copy all ./content .go files to $vendor/content - // check to see if any file exists, move on to next file if so, - // and report this conflict to user for them to fix & re-run build - pwd, err := os.Getwd() +type copyPlan struct { + srcPath string + dstPath string + reservedFileNames []string + reservedDirNames []string + ignoreRootDir bool +} + +func copyFile(info os.FileInfo, src string, dst string) error { + dstFile, err := os.Create(filepath.Join(dst, info.Name())) if err != nil { return err } - contentSrcPath := filepath.Join(pwd, "content") - contentDstPath := filepath.Join(pwd, "cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") + srcFile, err := os.Open(filepath.Join(src, info.Name())) + if err != nil { + return err + } - srcFiles, err := ioutil.ReadDir(contentSrcPath) + _, err = io.Copy(dstFile, srcFile) if err != nil { return err } - var conflictFiles = []string{"item.go", "types.go"} - var mustRenameFiles = []string{} - for _, srcFileInfo := range srcFiles { - // check srcFile exists in contentDstPath - for _, conflict := range conflictFiles { - if srcFileInfo.Name() == conflict { + return nil +} + +func copyDirWithPlan(plan copyPlan) error { + err := filepath.Walk(plan.srcPath, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if info.IsDir() { + path := plan.srcPath + if plan.ignoreRootDir { + dirs := strings.Split(plan.srcPath, string(filepath.Separator))[1:] + filepath.Join(dirs...) + } + + dirPath := filepath.Join(path, info.Name()) + err := os.MkdirAll(dirPath, os.ModeDir|os.ModePerm) + if err != nil { + return err + } + + return nil + } + + var mustRenameFiles = []string{} + for _, conflict := range plan.reservedFileNames { + if info.Name() == conflict { mustRenameFiles = append(mustRenameFiles, conflict) continue } } - dstFile, err := os.Create(filepath.Join(contentDstPath, srcFileInfo.Name())) - if err != nil { - return err - } + if len(mustRenameFiles) > 1 { + fmt.Println("Ponzu couldn't fully build your project:") + fmt.Println("You must rename the following files, as they conflict with Ponzu core:") + for _, file := range mustRenameFiles { + fmt.Println(file) + } - srcFile, err := os.Open(filepath.Join(contentSrcPath, srcFileInfo.Name())) - if err != nil { - return err + fmt.Println("Once the files above have been renamed, run '$ ponzu build' to retry.") + return errors.New("Ponzu has very few internal conflicts, sorry for the inconvenience.") } - _, err = io.Copy(dstFile, srcFile) + src := filepath.Join(plan.srcPath, info.Name()) + dst := filepath.Join(plan.dstPath, info.Name()) + + err = copyFile(info, src, dst) if err != nil { return err } + + return nil + }) + if err != nil { + return err } - if len(mustRenameFiles) > 1 { - fmt.Println("Ponzu couldn't fully build your project:") - fmt.Println("Some of your files in the content directory exist in the vendored directory.") - fmt.Println("You must rename the following files, as they conflict with Ponzu core:") - for _, file := range mustRenameFiles { - fmt.Println(file) - } + return nil +} - fmt.Println("Once the files above have been renamed, run '$ ponzu build' to retry.") - return errors.New("Ponzu has very few internal conflicts, sorry for the inconvenience.") +func buildPonzuServer(args []string) error { + pwd, err := os.Getwd() + if err != nil { + return err + } + + // copy all ./content files to internal vendor directory + err = copyDirWithPlan(copyPlan{ + srcPath: filepath.Join(pwd, "content"), + dstPath: filepath.Join(pwd, "cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu"), + reservedFileNames: []string{"item.go", "types.go"}, + ignoreRootDir: false, + }) + if err != nil { + return err + } + + // copy all ./addons files & dirs to internal vendor directory + err = copyDirWithPlan(copyPlan{ + srcPath: filepath.Join(pwd, "addons"), + dstPath: filepath.Join(pwd, "cmd", "ponzu", "vendor"), + reservedFileNames: []string{}, + ignoreRootDir: true, + }) + if err != nil { + return err } // execute go build -o ponzu-cms cmd/ponzu/*.go -- cgit v1.2.3 From 024dcc13733c55722cbd65a5fd9c42d63664f889 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 00:54:53 -0800 Subject: add debug for build step --- cmd/ponzu/options.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 142302f..dc2a573 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -178,17 +178,22 @@ type copyPlan struct { func copyFile(info os.FileInfo, src string, dst string) error { dstFile, err := os.Create(filepath.Join(dst, info.Name())) + defer dstFile.Close() if err != nil { + fmt.Println("Error in os.Create", src, dst) return err } srcFile, err := os.Open(filepath.Join(src, info.Name())) + defer srcFile.Close() if err != nil { + fmt.Println("Error in os.Open", src, dst) return err } _, err = io.Copy(dstFile, srcFile) if err != nil { + fmt.Println("Error in io.Copy", src, dst) return err } @@ -205,7 +210,7 @@ func copyDirWithPlan(plan copyPlan) error { path := plan.srcPath if plan.ignoreRootDir { dirs := strings.Split(plan.srcPath, string(filepath.Separator))[1:] - filepath.Join(dirs...) + path = filepath.Join(dirs...) } dirPath := filepath.Join(path, info.Name()) -- cgit v1.2.3 From 101aa9c8607f7449159d73e36b4026bca9609832 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 00:57:04 -0800 Subject: add debug for build step --- cmd/ponzu/options.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index dc2a573..beaa26d 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -204,6 +204,7 @@ func copyDirWithPlan(plan copyPlan) error { err := filepath.Walk(plan.srcPath, func(path string, info os.FileInfo, err error) error { if err != nil { return err + fmt.Println("Error in walkFn", plan) } if info.IsDir() { @@ -217,6 +218,7 @@ func copyDirWithPlan(plan copyPlan) error { err := os.MkdirAll(dirPath, os.ModeDir|os.ModePerm) if err != nil { return err + fmt.Println("Error in os.MkdirAll", plan) } return nil @@ -246,12 +248,14 @@ func copyDirWithPlan(plan copyPlan) error { err = copyFile(info, src, dst) if err != nil { + fmt.Println("Error in copyFile", plan, info, src, dst) return err } return nil }) if err != nil { + fmt.Println("Error in copyDirWithPlan", plan) return err } -- cgit v1.2.3 From f6f682c3f89166abd54db83655ff86c2d27df908 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 01:02:58 -0800 Subject: add debug for build step --- cmd/ponzu/options.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index beaa26d..12cb4b9 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -203,8 +203,8 @@ func copyFile(info os.FileInfo, src string, dst string) error { func copyDirWithPlan(plan copyPlan) error { err := filepath.Walk(plan.srcPath, func(path string, info os.FileInfo, err error) error { if err != nil { - return err fmt.Println("Error in walkFn", plan) + return err } if info.IsDir() { @@ -217,8 +217,8 @@ func copyDirWithPlan(plan copyPlan) error { dirPath := filepath.Join(path, info.Name()) err := os.MkdirAll(dirPath, os.ModeDir|os.ModePerm) if err != nil { - return err fmt.Println("Error in os.MkdirAll", plan) + return err } return nil -- cgit v1.2.3 From 398ea18e2efcc64c18726387fa5d1667c3aef52a Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 01:15:16 -0800 Subject: add debug for build step --- cmd/ponzu/options.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 12cb4b9..f8bf4e8 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -270,8 +270,8 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory err = copyDirWithPlan(copyPlan{ - srcPath: filepath.Join(pwd, "content"), - dstPath: filepath.Join(pwd, "cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu"), + srcPath: "content", + dstPath: filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu"), reservedFileNames: []string{"item.go", "types.go"}, ignoreRootDir: false, }) @@ -281,8 +281,8 @@ func buildPonzuServer(args []string) error { // copy all ./addons files & dirs to internal vendor directory err = copyDirWithPlan(copyPlan{ - srcPath: filepath.Join(pwd, "addons"), - dstPath: filepath.Join(pwd, "cmd", "ponzu", "vendor"), + srcPath: "addons", + dstPath: filepath.Join("cmd", "ponzu", "vendor"), reservedFileNames: []string{}, ignoreRootDir: true, }) -- cgit v1.2.3 From ab39f0fcc2fadf0949676ae3388982a6cd16ef85 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:04:20 -0800 Subject: testing reimplementaion of build steps to copy addons and content --- cmd/ponzu/options.go | 73 +++++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 55 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index f8bf4e8..c8082de 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -168,94 +168,63 @@ func vendorCorePackages(path string) error { return nil } -type copyPlan struct { - srcPath string - dstPath string - reservedFileNames []string - reservedDirNames []string - ignoreRootDir bool -} - func copyFile(info os.FileInfo, src string, dst string) error { dstFile, err := os.Create(filepath.Join(dst, info.Name())) defer dstFile.Close() if err != nil { - fmt.Println("Error in os.Create", src, dst) return err } srcFile, err := os.Open(filepath.Join(src, info.Name())) defer srcFile.Close() if err != nil { - fmt.Println("Error in os.Open", src, dst) return err } _, err = io.Copy(dstFile, srcFile) if err != nil { - fmt.Println("Error in io.Copy", src, dst) return err } return nil } -func copyDirWithPlan(plan copyPlan) error { - err := filepath.Walk(plan.srcPath, func(path string, info os.FileInfo, err error) error { +func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { + err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { if err != nil { - fmt.Println("Error in walkFn", plan) return err } if info.IsDir() { - path := plan.srcPath - if plan.ignoreRootDir { - dirs := strings.Split(plan.srcPath, string(filepath.Separator))[1:] - path = filepath.Join(dirs...) - } - - dirPath := filepath.Join(path, info.Name()) - err := os.MkdirAll(dirPath, os.ModeDir|os.ModePerm) + path = path[len(srcDir)+1:] + dir := filepath.Join(dstDir, path) + err := os.MkdirAll(dir, os.ModeDir|os.ModePerm) if err != nil { - fmt.Println("Error in os.MkdirAll", plan) return err } return nil } - var mustRenameFiles = []string{} - for _, conflict := range plan.reservedFileNames { + for _, conflict := range conflicts { if info.Name() == conflict { - mustRenameFiles = append(mustRenameFiles, conflict) - continue - } - } + fmt.Println("Ponzu couldn't fully build your project:") + fmt.Println("You must rename the following file, as it conflicts with Ponzu core:") + fmt.Println(path) - if len(mustRenameFiles) > 1 { - fmt.Println("Ponzu couldn't fully build your project:") - fmt.Println("You must rename the following files, as they conflict with Ponzu core:") - for _, file := range mustRenameFiles { - fmt.Println(file) + fmt.Println("Once the files above have been renamed, run '$ ponzu build' to retry.") + return errors.New("Ponzu has very few internal conflicts, sorry for the inconvenience.") } - - fmt.Println("Once the files above have been renamed, run '$ ponzu build' to retry.") - return errors.New("Ponzu has very few internal conflicts, sorry for the inconvenience.") } - src := filepath.Join(plan.srcPath, info.Name()) - dst := filepath.Join(plan.dstPath, info.Name()) - - err = copyFile(info, src, dst) + err = copyFile(info, srcDir, dstDir) if err != nil { - fmt.Println("Error in copyFile", plan, info, src, dst) return err } return nil }) if err != nil { - fmt.Println("Error in copyDirWithPlan", plan) return err } @@ -269,23 +238,17 @@ func buildPonzuServer(args []string) error { } // copy all ./content files to internal vendor directory - err = copyDirWithPlan(copyPlan{ - srcPath: "content", - dstPath: filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu"), - reservedFileNames: []string{"item.go", "types.go"}, - ignoreRootDir: false, - }) + src := "content" + dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") + err = copyFilesWarnConflicts(src, dst, []string{"item.go", "types.go"}) if err != nil { return err } // copy all ./addons files & dirs to internal vendor directory - err = copyDirWithPlan(copyPlan{ - srcPath: "addons", - dstPath: filepath.Join("cmd", "ponzu", "vendor"), - reservedFileNames: []string{}, - ignoreRootDir: true, - }) + src = "addons" + dst = filepath.Join("cmd", "ponzu", "vendor") + err = copyFilesWarnConflicts(src, dst, nil) if err != nil { return err } -- cgit v1.2.3 From 8a27fbfda5bbf64c0d971c71b973a6fa92e5a772 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:07:55 -0800 Subject: debug --- cmd/ponzu/options.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index c8082de..e921b8e 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -196,6 +196,7 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { } if info.IsDir() { + fmt.Println(path, srcDir) path = path[len(srcDir)+1:] dir := filepath.Join(dstDir, path) err := os.MkdirAll(dir, os.ModeDir|os.ModePerm) -- cgit v1.2.3 From ecfe2f8c59109712eeb9a0eb17f91fcb5beab79e Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:11:45 -0800 Subject: debug --- cmd/ponzu/options.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index e921b8e..ab129d3 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -191,13 +191,16 @@ func copyFile(info os.FileInfo, src string, dst string) error { func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { + fmt.Println(path) if err != nil { return err } if info.IsDir() { fmt.Println(path, srcDir) - path = path[len(srcDir)+1:] + if len(path) >= len(srcDir) { + path = path[len(srcDir)+1:] + } dir := filepath.Join(dstDir, path) err := os.MkdirAll(dir, os.ModeDir|os.ModePerm) if err != nil { -- cgit v1.2.3 From f4f2b5a26d3209ae7f8c09e682f8ffad49e10b9f Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:12:22 -0800 Subject: debug --- cmd/ponzu/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index ab129d3..e14c5b4 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -198,7 +198,7 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { if info.IsDir() { fmt.Println(path, srcDir) - if len(path) >= len(srcDir) { + if len(path) > len(srcDir) { path = path[len(srcDir)+1:] } dir := filepath.Join(dstDir, path) -- cgit v1.2.3 From 743743d35e598de23ede74a4e173c35e607901e4 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:26:01 -0800 Subject: debug --- cmd/ponzu/options.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index e14c5b4..1076d93 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -168,14 +168,16 @@ func vendorCorePackages(path string) error { return nil } -func copyFile(info os.FileInfo, src string, dst string) error { - dstFile, err := os.Create(filepath.Join(dst, info.Name())) +func copyFile(src, dst string) error { + noRoot := strings.Split(src, string(filepath.Separator))[1:] + path := filepath.Join(noRoot...) + dstFile, err := os.Create(filepath.Join(dst, path)) defer dstFile.Close() if err != nil { return err } - srcFile, err := os.Open(filepath.Join(src, info.Name())) + srcFile, err := os.Open(src) defer srcFile.Close() if err != nil { return err @@ -221,7 +223,7 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { } } - err = copyFile(info, srcDir, dstDir) + err = copyFile(path, dstDir) if err != nil { return err } -- cgit v1.2.3 From c3452d5e8b7e12eb0f9ab7ac6d65a518f1fdd91b Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:30:31 -0800 Subject: debug --- cmd/ponzu/options.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 1076d93..948aeeb 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -171,12 +171,14 @@ func vendorCorePackages(path string) error { func copyFile(src, dst string) error { noRoot := strings.Split(src, string(filepath.Separator))[1:] path := filepath.Join(noRoot...) + fmt.Println("dstFile:", filepath.Join(dst, path)) dstFile, err := os.Create(filepath.Join(dst, path)) defer dstFile.Close() if err != nil { return err } + fmt.Println("srcFile:", src) srcFile, err := os.Open(src) defer srcFile.Close() if err != nil { @@ -193,13 +195,12 @@ func copyFile(src, dst string) error { func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { - fmt.Println(path) + fmt.Println("hit:", path) if err != nil { return err } if info.IsDir() { - fmt.Println(path, srcDir) if len(path) > len(srcDir) { path = path[len(srcDir)+1:] } -- cgit v1.2.3 From ce896a424cbaad963602c47bd26ba1261ad25842 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:34:53 -0800 Subject: debug --- cmd/ponzu/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 948aeeb..aa173d4 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -201,7 +201,7 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { } if info.IsDir() { - if len(path) > len(srcDir) { + if len(path) > len(srcDir) && path != srcDir { path = path[len(srcDir)+1:] } dir := filepath.Join(dstDir, path) -- cgit v1.2.3 From cf6227c71b9c2354fc0c0e4e93b5808acd616104 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 02:41:27 -0800 Subject: removing debug --- cmd/ponzu/options.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index aa173d4..8b62b1a 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -171,14 +171,12 @@ func vendorCorePackages(path string) error { func copyFile(src, dst string) error { noRoot := strings.Split(src, string(filepath.Separator))[1:] path := filepath.Join(noRoot...) - fmt.Println("dstFile:", filepath.Join(dst, path)) dstFile, err := os.Create(filepath.Join(dst, path)) defer dstFile.Close() if err != nil { return err } - fmt.Println("srcFile:", src) srcFile, err := os.Open(src) defer srcFile.Close() if err != nil { @@ -195,13 +193,16 @@ func copyFile(src, dst string) error { func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { - fmt.Println("hit:", path) if err != nil { return err } if info.IsDir() { - if len(path) > len(srcDir) && path != srcDir { + if path == srcDir { + return nil + } + + if len(path) > len(srcDir) { path = path[len(srcDir)+1:] } dir := filepath.Join(dstDir, path) @@ -218,7 +219,7 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { fmt.Println("Ponzu couldn't fully build your project:") fmt.Println("You must rename the following file, as it conflicts with Ponzu core:") fmt.Println(path) - + fmt.Println("") fmt.Println("Once the files above have been renamed, run '$ ponzu build' to retry.") return errors.New("Ponzu has very few internal conflicts, sorry for the inconvenience.") } -- cgit v1.2.3 From d4b94e4b37bb4b28dae2a91bf4a9872e0a801c1a Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 06:05:07 -0800 Subject: moving reference into content package and testing API based approach --- cmd/ponzu/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 8b62b1a..6384b47 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -248,7 +248,7 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory src := "content" dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") - err = copyFilesWarnConflicts(src, dst, []string{"item.go", "types.go"}) + err = copyFilesWarnConflicts(src, dst, []string{"item.go", "types.go", "references.go"}) if err != nil { return err } -- cgit v1.2.3 From 7d87d40f8d0550331d1b19dea2c374ecfbc77d48 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 12:13:08 -0800 Subject: adding beginning of addon api (cooresponding to previous commit w/ reference addon) --- cmd/ponzu/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index ebcbbad..4ae3bcc 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -291,7 +291,14 @@ func main() { tls.Enable() } - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) + // save the port the system is listening on so internal system can make + // HTTP api calls while in dev or production w/o adding more cli flags + err := db.PutConfig("http_port", fmt.Sprintf("%d", port)) + if err != nil { + log.Fatalln("System failed to save config. Please try to run again.") + } + + log.Fatalln(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) case "": fmt.Println(usage) -- cgit v1.2.3 From e187d5ee6354acf40ac8178b0a8a631e80e35e8e Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 15:06:25 -0800 Subject: moving item and types into system/item package and updating throughout codebase --- cmd/ponzu/contentType.tmpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/contentType.tmpl b/cmd/ponzu/contentType.tmpl index af60e57..1804555 100644 --- a/cmd/ponzu/contentType.tmpl +++ b/cmd/ponzu/contentType.tmpl @@ -4,10 +4,11 @@ import ( "fmt" "github.com/bosssauce/ponzu/management/editor" + "github.com/bosssauce/ponzu/system/item" ) type {{ .Name }} struct { - Item + item.Item editor editor.Editor {{ range .Fields }}{{ .Name }} {{ .TypeName }} `json:"{{ .JSONName }}"` @@ -38,7 +39,7 @@ func ({{ .Initial }} *{{ .Name }}) MarshalEditor() ([]byte, error) { } func init() { - Types["{{ .Name }}"] = func() interface{} { return new({{ .Name }}) } + item.Types["{{ .Name }}"] = func() interface{} { return new({{ .Name }}) } } // Editor is a buffer of bytes for the Form function to write input views -- cgit v1.2.3 From da2ec11664c48ba9dced011e66a13a75ed417640 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 15:30:06 -0800 Subject: make sure user content dir exists in new project --- cmd/ponzu/options.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 6384b47..b22f0d2 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -150,6 +150,13 @@ func vendorCorePackages(path string) error { return err } + // create a user content directory + contentPath := filepath.Join(path, "content") + err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) + if err != nil { + return err + } + dirs := []string{"content", "management", "system"} for _, dir := range dirs { err = os.Rename(filepath.Join(path, dir), filepath.Join(vendorPath, dir)) @@ -158,13 +165,6 @@ func vendorCorePackages(path string) error { } } - // create a user content directory - contentPath := filepath.Join(path, "content") - err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) - if err != nil { - return err - } - return nil } @@ -248,7 +248,7 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory src := "content" dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") - err = copyFilesWarnConflicts(src, dst, []string{"item.go", "types.go", "references.go"}) + err = copyFilesWarnConflicts(src, dst, []string{}) if err != nil { return err } -- cgit v1.2.3 From fa7b9089f8ccba22b8a17bda58437eda459217b8 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 15:47:57 -0800 Subject: adding content dir in at proj root after its vendored --- cmd/ponzu/options.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index b22f0d2..e0fb8fc 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -150,7 +150,7 @@ func vendorCorePackages(path string) error { return err } - // create a user content directory + // create a user content directory to be vendored contentPath := filepath.Join(path, "content") err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) if err != nil { @@ -165,6 +165,13 @@ func vendorCorePackages(path string) error { } } + // create a user content directory at project root + contentPath = filepath.Join(path, "content") + err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) + if err != nil { + return err + } + return nil } -- cgit v1.2.3 From 746ebe782d51ff6114b6873b021fdc3ebb5bbe06 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 16:18:34 -0800 Subject: update empty slice to nil --- cmd/ponzu/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index e0fb8fc..389c667 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -255,7 +255,7 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory src := "content" dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") - err = copyFilesWarnConflicts(src, dst, []string{}) + err = copyFilesWarnConflicts(src, dst, nil) if err != nil { return err } -- cgit v1.2.3 From f802a2f0730ca25f5f2114ac9db246778e739aca Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 16:40:33 -0800 Subject: removing possible bug source --- cmd/ponzu/options.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 389c667..a7eee35 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -205,10 +205,6 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { } if info.IsDir() { - if path == srcDir { - return nil - } - if len(path) > len(srcDir) { path = path[len(srcDir)+1:] } -- cgit v1.2.3 From 5495e347ba5563397734168fffc04791a20064d2 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 18 Dec 2016 17:25:13 -0800 Subject: adding _ import to register content types for item.Types --- cmd/ponzu/main.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd') diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index 4ae3bcc..b2b5e75 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -15,6 +15,9 @@ import ( "github.com/bosssauce/ponzu/system/api/analytics" "github.com/bosssauce/ponzu/system/db" "github.com/bosssauce/ponzu/system/tls" + + // import registers content types + _ "github.com/bosssauce/ponzu/content" ) var year = fmt.Sprintf("%d", time.Now().Year()) -- cgit v1.2.3 From 6a49024e0ba2f03578164bf64a7d15ac056e591b Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 19 Dec 2016 09:17:53 -0800 Subject: contin. debugging host port issue in config --- cmd/ponzu/main.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd') diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index b2b5e75..b77b7c9 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -296,6 +296,7 @@ func main() { // save the port the system is listening on so internal system can make // HTTP api calls while in dev or production w/o adding more cli flags + fmt.Println(port, "port from main") err := db.PutConfig("http_port", fmt.Sprintf("%d", port)) if err != nil { log.Fatalln("System failed to save config. Please try to run again.") -- cgit v1.2.3 From a51c5e9b64b379e32ef15226c4bb90337af288eb Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 19 Dec 2016 10:39:22 -0800 Subject: contin. debugging host port issue in config --- cmd/ponzu/main.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd') diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index b77b7c9..c03a4df 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -302,6 +302,9 @@ func main() { log.Fatalln("System failed to save config. Please try to run again.") } + cfg, _ := db.ConfigAll() + fmt.Println(string(cfg)) + log.Fatalln(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) case "": -- cgit v1.2.3 From 43fd3472dd9d19aa1f602ce3fd3555f03312b99b Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 19 Dec 2016 11:04:20 -0800 Subject: adding http port to config and removing hardcoded url from addons api --- cmd/ponzu/main.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index c03a4df..b2b5e75 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -296,15 +296,11 @@ func main() { // save the port the system is listening on so internal system can make // HTTP api calls while in dev or production w/o adding more cli flags - fmt.Println(port, "port from main") err := db.PutConfig("http_port", fmt.Sprintf("%d", port)) if err != nil { log.Fatalln("System failed to save config. Please try to run again.") } - cfg, _ := db.ConfigAll() - fmt.Println(string(cfg)) - log.Fatalln(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) case "": -- cgit v1.2.3 From 268dc651e2d319f8c733f82d4d8694f01ea6030b Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 19 Dec 2016 11:06:54 -0800 Subject: possibly redundant mkdir for content pre-vendor --- cmd/ponzu/options.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index a7eee35..9c2767f 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -150,12 +150,12 @@ func vendorCorePackages(path string) error { return err } - // create a user content directory to be vendored - contentPath := filepath.Join(path, "content") - err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) - if err != nil { - return err - } + // // create a user content directory to be vendored + // contentPath := filepath.Join(path, "content") + // err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) + // if err != nil { + // return err + // } dirs := []string{"content", "management", "system"} for _, dir := range dirs { @@ -166,7 +166,7 @@ func vendorCorePackages(path string) error { } // create a user content directory at project root - contentPath = filepath.Join(path, "content") + contentPath := filepath.Join(path, "content") err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) if err != nil { return err @@ -251,7 +251,7 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory src := "content" dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "bosssauce", "ponzu", "content") - err = copyFilesWarnConflicts(src, dst, nil) + err = copyFilesWarnConflicts(src, dst, []string{"doc.go"}) if err != nil { return err } -- cgit v1.2.3