Files
summercms/internal/build/stubs/registry.tmpl
Jakub Zych 70e4b4183c feat(build): mark scaffolded files with //summer:make and pass the app to generated commands (quick-261028-pq8)
- model, migration, command, job and admin-controller stubs start with
  //summer:make <kind>; registry.gen.go keeps its generated-code header
- the registry scan accepts the directive and the older header
- command functions may take one *backpack.App; generatedCommands takes a
  variadic app, so plugin.go files calling generatedCommands() still compile
- scaffolded plugins keep the app from Boot and return generatedCommands(p.app)
- make:command notes the nil app for an older plugin.go
- docs, help text and the blog example follow
2026-10-28 19:04:39 +01:00

83 lines
1.6 KiB
Cheetah

{{define "registry.go"}}// Code generated by summer make. DO NOT EDIT.
package {{.Package}}
import (
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/bonfire"
"git.golem15.com/golem15/summercms/modules/pact"
"github.com/go-gormigrate/gormigrate/v2"
{{- range .Imports}}
{{printf "%q" .}}
{{- end}}
)
func generatedModels() []any {
{{- if .Models}}
return []any{
{{- range .Models}}
&{{.Package}}.{{.Ident}}{},
{{- end}}
}
{{- else}}
return nil
{{- end}}
}
func generatedMigrations() []*gormigrate.Migration {
{{- if .Migrations}}
return []*gormigrate.Migration{
{{- range .Migrations}}
{{.Package}}.{{.Ident}}(),
{{- end}}
}
{{- else}}
return nil
{{- end}}
}
// generatedCommands returns the plugin's console commands. Commands that
// take a *backpack.App receive the first app passed in, or nil when none is.
func generatedCommands(app ...*backpack.App) []bonfire.Command {
{{- if .Commands}}
{{- if .AppCommands}}
var bootApp *backpack.App
if len(app) > 0 {
bootApp = app[0]
}
{{- end}}
return []bonfire.Command{
{{- range .Commands}}
{{.Package}}.{{.Ident}}({{if .TakesApp}}bootApp{{end}}),
{{- end}}
}
{{- else}}
return nil
{{- end}}
}
func generatedJobs() []pact.Job {
{{- if .Jobs}}
return []pact.Job{
{{- range .Jobs}}
{{.Package}}.{{.Ident}}(),
{{- end}}
}
{{- else}}
return nil
{{- end}}
}
func generatedAdminControllers() []pact.AdminController {
{{- if .AdminControllers}}
return []pact.AdminController{
{{- range .AdminControllers}}
{{.Package}}.{{.Ident}}(),
{{- end}}
}
{{- else}}
return nil
{{- end}}
}
{{end}}