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>
62 lines
1.4 KiB
Cheetah
62 lines
1.4 KiB
Cheetah
{{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}}
|