- party.Info, party.Installed, party.Describe (additive; Plugin and Activate unchanged) - summer build resolves plugin dirs with one go list, reads plugin.yaml, versions per D-07 (module version, git describe without --dirty, none for in-app plugins) - build.EffectiveFramework: newest tag of a locally replaced or used framework checkout, else the go.mod require - generated main calls party.Describe(app, PluginInfo, FrameworkVersion) before Activate; metadata failures warn and fall back to IDs - summer new goldens and examples/hello regenerated
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package party
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
)
|
|
|
|
// Where an installed plugin's source came from at build time.
|
|
const (
|
|
// SourceModule is a plugin built from the Go module cache (go get).
|
|
SourceModule = "module"
|
|
// SourceSubmodule is a plugin directory that is its own git repository,
|
|
// such as a git submodule; its version is git describe output.
|
|
SourceSubmodule = "submodule"
|
|
// SourceLocal is a plugin directory inside the application repository;
|
|
// it has no version of its own.
|
|
SourceLocal = "local"
|
|
)
|
|
|
|
// Info is the metadata summer build bakes into plugins.gen.go for one
|
|
// plugin: its ID, Go module and package, the name and description from its
|
|
// plugin.yaml, its version and where it came from (SourceModule,
|
|
// SourceSubmodule or SourceLocal). A plugin without plugin.yaml has no
|
|
// name or description.
|
|
type Info struct {
|
|
ID string
|
|
Module string
|
|
Package string
|
|
Name string
|
|
Description string
|
|
Version string
|
|
Source string
|
|
}
|
|
|
|
// Installed is what the application was built with: the effective
|
|
// framework version and the plugin metadata in summer.yaml order. Describe
|
|
// publishes it; look it up with app.Lookup[party.Installed]().
|
|
type Installed struct {
|
|
Framework string
|
|
Plugins []Info
|
|
}
|
|
|
|
// Describe publishes the build-time plugin metadata and framework version
|
|
// as Installed. The generated main calls it before Activate.
|
|
func Describe(app *backpack.App, plugins []Info, framework string) error {
|
|
if app == nil {
|
|
return fmt.Errorf("party: app is nil")
|
|
}
|
|
list := make([]Info, len(plugins))
|
|
copy(list, plugins)
|
|
if err := app.Publish(Installed{Framework: framework, Plugins: list}); err != nil {
|
|
return fmt.Errorf("party: %w", err)
|
|
}
|
|
return nil
|
|
}
|