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
This commit is contained in:
Jakub Zych
2026-10-28 19:04:39 +01:00
parent a95a014b52
commit 70e4b4183c
18 changed files with 355 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
// Code generated by summer make. DO NOT EDIT.
//summer:make command
package console

View File

@@ -1,4 +1,4 @@
// Code generated by summer make. DO NOT EDIT.
//summer:make admin-controller
package controllers

View File

@@ -1,4 +1,4 @@
// Code generated by summer make. DO NOT EDIT.
//summer:make model
package models

View File

@@ -72,10 +72,11 @@ func (p *Plugin) AdminControllers() []pact.AdminController {
return generatedAdminControllers()
}
// Commands returns the generated commands plus blog:publish, which needs the
// database and so is built here with the plugin's withDB.
// Commands returns the generated commands, which receive the application
// kept in Boot, plus blog:publish. That one takes the narrower withDB, which
// its tests replace, so it is added here by hand.
func (p *Plugin) Commands() []bonfire.Command {
return append(generatedCommands(), console.PublishCommand(p.withDB))
return append(generatedCommands(p.app), console.PublishCommand(p.withDB))
}
// AdminFS is the admin YAML the controllers read: controllers/posts and

View File

@@ -6,6 +6,7 @@ import (
"git.golem15.com/golem15/summercms/docs/examples/blog/controllers"
"git.golem15.com/golem15/summercms/docs/examples/blog/models"
"git.golem15.com/golem15/summercms/docs/examples/blog/updates"
"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"
@@ -24,7 +25,9 @@ func generatedMigrations() []*gormigrate.Migration {
}
}
func generatedCommands() []bonfire.Command {
// 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 {
return nil
}

View File

@@ -1,4 +1,4 @@
// Code generated by summer make. DO NOT EDIT.
//summer:make migration
package updates

View File

@@ -1,4 +1,4 @@
// Code generated by summer make. DO NOT EDIT.
//summer:make migration
package updates