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:
3
modules/kiosk/testdata/consts/README.md
vendored
Normal file
3
modules/kiosk/testdata/consts/README.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Consts
|
||||
|
||||
A fixture plugin whose identity is spread over constants.
|
||||
12
modules/kiosk/testdata/consts/go.mod
vendored
Normal file
12
modules/kiosk/testdata/consts/go.mod
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
module example.test/sm-consts-plugin
|
||||
|
||||
go 1.27.0
|
||||
|
||||
require (
|
||||
example.test/sm-other-plugin v0.2.0
|
||||
git.golem15.com/golem15/summercms v0.5.3
|
||||
)
|
||||
|
||||
replace git.golem15.com/golem15/summercms => ../framework
|
||||
|
||||
replace example.test/sm-other-plugin => ../other
|
||||
5
modules/kiosk/testdata/consts/ids/ids.go
vendored
Normal file
5
modules/kiosk/testdata/consts/ids/ids.go
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// Package ids holds plugin ID constants for the consts fixture.
|
||||
package ids
|
||||
|
||||
// Translate is a plugin ID no module of the fixture provides.
|
||||
const Translate = "acme.translate"
|
||||
3
modules/kiosk/testdata/consts/nested/README.md
vendored
Normal file
3
modules/kiosk/testdata/consts/nested/README.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Nested consts
|
||||
|
||||
The nested fixture plugin of the consts module.
|
||||
14
modules/kiosk/testdata/consts/nested/plugin.go
vendored
Normal file
14
modules/kiosk/testdata/consts/nested/plugin.go
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Package nested is a test fixture: a second plugin in a subdirectory of
|
||||
// the consts module, requiring the root plugin. It is never built.
|
||||
package nested
|
||||
|
||||
import root "example.test/sm-consts-plugin"
|
||||
|
||||
// Plugin is the fixture plugin.
|
||||
type Plugin struct{}
|
||||
|
||||
// ID returns the plugin ID.
|
||||
func (*Plugin) ID() string { return "acme.constsnested" }
|
||||
|
||||
// Requires the root plugin of the same module.
|
||||
func (*Plugin) Requires() []string { return []string{root.PluginID} }
|
||||
24
modules/kiosk/testdata/consts/plugin.go
vendored
Normal file
24
modules/kiosk/testdata/consts/plugin.go
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Package consts is a test fixture: ID() and Requires() return constants
|
||||
// of the same package, of another package in the module and of a package
|
||||
// in another module. kiosk reads it with go/parser; it is never built.
|
||||
package consts
|
||||
|
||||
import (
|
||||
"example.test/sm-consts-plugin/ids"
|
||||
"example.test/sm-other-plugin"
|
||||
)
|
||||
|
||||
// PluginID is the plugin ID, built from two constants.
|
||||
const PluginID = vendor + ".consts"
|
||||
|
||||
// Plugin is the fixture plugin.
|
||||
type Plugin struct{}
|
||||
|
||||
// ID returns PluginID.
|
||||
func (*Plugin) ID() string { return PluginID }
|
||||
|
||||
// Requires a plugin whose module is not required (acme.translate) and the
|
||||
// plugin of the other module.
|
||||
func (*Plugin) Requires() []string {
|
||||
return []string{ids.Translate, other.PluginID}
|
||||
}
|
||||
3
modules/kiosk/testdata/consts/vendor.go
vendored
Normal file
3
modules/kiosk/testdata/consts/vendor.go
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
package consts
|
||||
|
||||
const vendor = "acme"
|
||||
5
modules/kiosk/testdata/framework/go.mod
vendored
Normal file
5
modules/kiosk/testdata/framework/go.mod
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// A stub of the framework module: fixture go.mod files replace the
|
||||
// framework with this directory, so go list runs offline.
|
||||
module git.golem15.com/golem15/summercms
|
||||
|
||||
go 1.27.0
|
||||
8
modules/kiosk/testdata/literal/plugin.yaml
vendored
Normal file
8
modules/kiosk/testdata/literal/plugin.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Generated by summer plugin:manifest. Do not edit; rerun the command.
|
||||
schema: 1
|
||||
id: acme.blog
|
||||
module: example.test/sm-acme-plugin
|
||||
package: example.test/sm-acme-plugin
|
||||
name: Blog
|
||||
description: Posts and categories for an acme application, with a feed.
|
||||
framework: v0.5.3
|
||||
3
modules/kiosk/testdata/other/README.md
vendored
Normal file
3
modules/kiosk/testdata/other/README.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Other
|
||||
|
||||
A plugin in another module that the consts fixture requires.
|
||||
7
modules/kiosk/testdata/other/go.mod
vendored
Normal file
7
modules/kiosk/testdata/other/go.mod
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
module example.test/sm-other-plugin
|
||||
|
||||
go 1.27.0
|
||||
|
||||
require git.golem15.com/golem15/summercms v0.5.3
|
||||
|
||||
replace git.golem15.com/golem15/summercms => ../framework
|
||||
15
modules/kiosk/testdata/other/plugin.go
vendored
Normal file
15
modules/kiosk/testdata/other/plugin.go
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Package other is a test fixture: a plugin in its own module that the
|
||||
// consts fixture requires. It is never built.
|
||||
package other
|
||||
|
||||
// PluginID is the plugin ID.
|
||||
const PluginID = "acme.other"
|
||||
|
||||
// Plugin is the fixture plugin.
|
||||
type Plugin struct{}
|
||||
|
||||
// ID returns PluginID.
|
||||
func (*Plugin) ID() string { return PluginID }
|
||||
|
||||
// Requires returns no plugins.
|
||||
func (*Plugin) Requires() []string { return []string{} }
|
||||
Reference in New Issue
Block a user