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:
61
internal/build/stubs/artifacts.tmpl
Normal file
61
internal/build/stubs/artifacts.tmpl
Normal 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}}
|
||||
Reference in New Issue
Block a user