Remove prisma client for starter

This commit is contained in:
Achim Rohn
2025-09-22 23:46:46 +02:00
parent 17eb9ec97d
commit 262f0f7bab
2 changed files with 4 additions and 32 deletions
+3 -31
View File
@@ -17,7 +17,7 @@ type DatabaseType string
const (
DatabaseTypePostgres DatabaseType = "postgres"
DataBaseTypeSqlite DatabaseType = "sqlite"
DatabaseTypeSqlite DatabaseType = "sqlite"
)
type Params struct {
@@ -88,17 +88,15 @@ func (s StarterCreator) Create() {
s.copyFile("../../template.air.toml", ".air.toml")
//s.copyGoMod()
//s.executeGoModTidy()
s.executeGetPrismaClient()
if s.params.DbType == DataBaseTypeSqlite {
if s.params.DbType == DatabaseTypeSqlite {
must(os.MkdirAll(filepath.Join(s.params.ProjectDir, "db"), 0o755))
}
s.copySchema()
must(os.MkdirAll(filepath.Join(s.params.ProjectDir, "scripts"), 0o755))
s.copyFile("../../scripts/db-push.sh", "scripts/db-push.sh")
if s.params.DbType == DataBaseTypeSqlite {
if s.params.DbType == DatabaseTypeSqlite {
s.executeDbPush()
}
@@ -188,23 +186,6 @@ func (s StarterCreator) copyDirectoryRecursive(src string, dst string) {
}
}
func (s StarterCreator) copySchema() {
content, err := os.ReadFile(filepath.Join(s.thisDir, "../../schema_template.prisma"))
must(err)
if s.params.DbType == DataBaseTypeSqlite {
pgBlock := "datasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n"
sqliteBlock := "datasource db {\n provider = \"sqlite\"\n url = \"file:./db/sqlite.db\"\n}\n"
contentStr := string(content)
contentStr = strings.Replace(contentStr, pgBlock, sqliteBlock, 1)
contentStr = strings.ReplaceAll(contentStr, " @db.Timestamptz(3)", "")
contentStr = strings.ReplaceAll(contentStr, " @db.Timestamp(6)", "")
content = []byte(contentStr)
}
must(os.WriteFile(filepath.Join(s.params.ProjectDir, "schema.prisma"), content, 0o644))
}
func (s StarterCreator) copyGoMod() {
content, err := os.ReadFile(filepath.Join(s.thisDir, "../go.mod.template"))
must(err)
@@ -233,15 +214,6 @@ func (s StarterCreator) getGoCommand() string {
return goCommand
}
func (s StarterCreator) executeGetPrismaClient() {
goCommand := s.getGoCommand()
cmd := exec.Command(goCommand, "get", "github.com/steebchen/prisma-client-go")
cmd.Dir = s.params.ProjectDir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
must(cmd.Run())
}
func (s StarterCreator) replaceImports(content []byte) []byte {
contentString := string(content)
contentString = strings.ReplaceAll(contentString, "\"ersteller-lib/starter/", fmt.Sprint("\"", s.params.ModuleName, "/"))