Copy over the white label page template

This commit is contained in:
Achim Rohn
2025-09-14 01:07:00 +02:00
parent 35ee289765
commit 92488618a9
3 changed files with 147 additions and 116 deletions
+31 -1
View File
@@ -7,6 +7,7 @@ import (
"log"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
@@ -99,6 +100,15 @@ func (s StarterCreator) Create() {
s.copyFile("../.gitignore", ".gitignore")
s.createEnvironment()
directories := []string{
"index",
"page",
"routes",
"static",
}
for _, dir := range directories {
s.copyDirectoryRecursive(path.Join(s.thisDir, "..", dir), path.Join(s.params.ProjectDir, dir))
}
}
func (s StarterCreator) createEnvironment() {
@@ -144,6 +154,26 @@ func (s StarterCreator) copyFile(src string, dst string) {
must(os.WriteFile(filepath.Join(s.params.ProjectDir, dst), content, 0o644))
}
func (s StarterCreator) copyDirectoryRecursive(src string, dst string) {
must(os.MkdirAll(dst, 0o755))
entries, err := os.ReadDir(src)
Debug()
must(err)
for _, entry := range entries {
srcPath := filepath.Join(src, entry.Name())
dstPath := filepath.Join(dst, entry.Name())
Debug("copying srcPath: ", srcPath, " to dstPath: ", dstPath)
if entry.IsDir() {
s.copyDirectoryRecursive(srcPath, dstPath)
return
}
content, err := os.ReadFile(srcPath)
content = s.replaceImports(content)
must(err)
must(os.WriteFile(filepath.Join(dstPath), content, 0o644))
}
}
func (s StarterCreator) copySchema() {
content, err := os.ReadFile(filepath.Join(s.thisDir, "../../schema_template.prisma"))
must(err)
@@ -200,7 +230,7 @@ func (s StarterCreator) executeGetPrismaClient() {
func (s StarterCreator) replaceImports(content []byte) []byte {
contentString := string(content)
contentString = strings.ReplaceAll(contentString, "\"ersteller-lib/starter/env\"", fmt.Sprint("\"", s.params.ModuleName, "/env\""))
contentString = strings.ReplaceAll(contentString, "\"ersteller-lib/starter/", fmt.Sprint("\"", s.params.ModuleName, "/"))
return []byte(contentString)
}