feat(04-01): generate model, migration, and command artifacts

Add make:model, make:migration and make:command with plugin-id
inference, duplicate rejection, and a deterministic registry refresh
that leaves handwritten plugin.go untouched.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-18 13:39:03 +02:00
parent 1edf9d7e4c
commit d8c56509f2
8 changed files with 1050 additions and 4 deletions

View File

@@ -0,0 +1,61 @@
{{define "model.go"}}// Code generated by summer make. DO NOT EDIT.
package models
import "time"
// {{.Ident}} is a generated GORM model for {{.PluginID}}.
type {{.Ident}} struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
}
func ({{.Ident}}) TableName() string { return {{printf "%q" .Table}} }
{{end}}
{{define "migration.go"}}// Code generated by summer make. DO NOT EDIT.
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// {{.Func}} returns the {{.MigrationID}} gormigrate entry.
func {{.Func}}() *gormigrate.Migration {
return &gormigrate.Migration{
ID: {{printf "%q" .MigrationID}},
Migrate: func(tx *gorm.DB) error {
return tx.Exec({{printf "%q" .UpSQL}}).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec({{printf "%q" .DownSQL}}).Error
},
}
}
{{end}}
{{define "command.go"}}// Code generated by summer make. DO NOT EDIT.
package console
import (
"context"
"git.golem15.com/golem15/summercms/bonfire"
)
// {{.Func}} returns the {{.CommandName}} console command.
func {{.Func}}() bonfire.Command {
return bonfire.Command{
Name: {{printf "%q" .CommandName}},
Description: {{printf "%q" .Description}},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
out.Printf({{printf "%q" .CommandName}} + "\n")
return nil
},
}
}
{{end}}