feat(14.3-01): add summer new with a starter route and relative go.work

- build.NewApp writes sm-<name>-app: go.mod with a relative framework
  replace, go.work, summer.yaml, config/ and a starter plugin
- make:plugin gains an opt-in starter route (GET /{$}) in the same
  routes.go template; plain make:plugin output is unchanged
- plugin:add writes go.work use paths relative to the go.work directory
- bonfire accepts new as a bare tool command name
This commit is contained in:
Jakub Zych
2026-10-08 11:37:53 +02:00
parent 86fcd5d4fd
commit 7bc955a0c2
10 changed files with 423 additions and 15 deletions

View File

@@ -61,13 +61,35 @@ func init() {
{{end}}
{{define "routes.go"}}package {{.Package}}
{{if .StarterRoute}}
import (
"encoding/json"
"net/http"
"git.golem15.com/golem15/summercms/modules/pact"
)
var _ pact.HasRoutes = (*Plugin)(nil)
// Routes registers the starter route: GET / answers with a JSON greeting
// naming this plugin.
func (p *Plugin) Routes(r pact.Router) error {
r.Get("/{$}", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]string{
"message": "Hello from SummerCMS",
"plugin": p.ID(),
})
})
return nil
}
{{else}}
import "git.golem15.com/golem15/summercms/modules/pact"
var _ pact.HasRoutes = (*Plugin)(nil)
func (p *Plugin) Routes(pact.Router) error { return nil }
{{end}}
{{end}}{{end}}
{{define "go.mod"}}module {{.Module}}