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 }