feat(kiosk): resolve constant plugin IDs, overrides and the CheckT helper
- kiosk.ReadIdentity: ID()/Requires() as literals or constants across packages and modules, read with go/parser, never run - plugin minimums from go.mod requires; v0.0.0 is an error, a pseudo-version warns - kiosk.Validate, kiosk.CheckT (no testing import) - plugin:add reads IDs through kiosk.ReadIdentity, so const-ID plugins register
This commit is contained in:
@@ -32,13 +32,13 @@ overrides:
|
||||
| Field | Comes from |
|
||||
|-------|------------|
|
||||
| `schema` | The format version (`kiosk.SchemaVersion`). A reader that knows an older schema refuses the file and asks you to update `summer`. |
|
||||
| `id` | What `ID()` in `plugin.go` returns. |
|
||||
| `id` | What `ID()` in `plugin.go` returns: a string literal or a constant (of the same package, of another package of the module, or of a required module). The command reads the source and never runs it; any other expression, such as a function call or a variable, is an error naming `ID()`. |
|
||||
| `module` | The `module` line of the nearest `go.mod`: what `go get` takes. |
|
||||
| `package` | The plugin's import path: what `summer.yaml` lists. It differs from `module` for a plugin in a subdirectory. |
|
||||
| `name` | The README's H1, or the `--name` override. |
|
||||
| `description` | The first paragraph after the README's H1 (the one-sentence summary of the standard README structure), or the `--description` override. |
|
||||
| `framework` | The version `go.mod` requires the framework (`git.golem15.com/golem15/summercms`) at: the oldest framework release the plugin works with. |
|
||||
| `requires` | Each plugin ID `Requires()` returns, with the version `go.mod` requires its module at. The value is empty for a plugin in the same module, and for one whose module is not a `go.mod` require. Left out when `Requires()` returns none. |
|
||||
| `requires` | Each plugin ID `Requires()` returns (literals or constants, as for `id`), with the version `go.mod` requires its module at. A requirement at `v0.0.0` is an error, because nobody can install that version; a pseudo-version is accepted with a warning. The value is empty for a plugin in the same module, and for one whose module is not a `go.mod` require. Left out when `Requires()` returns none. |
|
||||
| `overrides` | The `--name` and `--description` values, kept across regenerations. Left out when neither is set. |
|
||||
|
||||
Versions are minimums in Go's sense (`v0.6.0` means "v0.6.0 or newer"), never ranges: Go's minimal version selection picks the version, and a major version change moves the module path.
|
||||
@@ -72,3 +72,18 @@ summer plugin:manifest --check
|
||||
```
|
||||
|
||||
Run it before tagging a release, so the tag carries a manifest that matches its code.
|
||||
|
||||
## Testing the manifest in your plugin
|
||||
|
||||
Add one test to the plugin, so `go test` fails as soon as `plugin.yaml` no longer matches the code. It imports `git.golem15.com/golem15/summercms/modules/kiosk` and passes the plugin directory, which is `"."` in a plugin's own package (the framework's copy below checks a fixture):
|
||||
|
||||
```go src=modules/kiosk/checkt_test.go#TestPluginManifest
|
||||
// TestPluginManifest is the test a plugin repository adds next to its
|
||||
// plugin.go, with "." as the directory. Here it guards the committed
|
||||
// manifest of the literal fixture.
|
||||
func TestPluginManifest(t *testing.T) {
|
||||
kiosk.CheckT(t, "testdata/literal")
|
||||
}
|
||||
```
|
||||
|
||||
`kiosk.CheckT` runs the same check as `summer plugin:manifest --check` and names the command to rerun. A nested plugin gets its own test in its own directory.
|
||||
|
||||
Reference in New Issue
Block a user