0
0
mirror of https://github.com/thegeeklab/wp-matrix.git synced 2024-06-02 18:39:40 +02:00

chore: migrate to wp-plugin-go v3 (#116)

This commit is contained in:
Robert Kaussow 2024-05-17 21:50:20 +02:00 committed by GitHub
parent dc41f2d9ff
commit 76f5076b0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 21 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.26
github.com/rs/zerolog v1.32.0
github.com/stretchr/testify v1.9.0
github.com/thegeeklab/wp-plugin-go/v2 v2.3.1
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2
github.com/urfave/cli/v2 v2.27.2
maunium.net/go/mautrix v0.18.1
)

4
go.sum
View File

@ -60,8 +60,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/thegeeklab/wp-plugin-go/v2 v2.3.1 h1:ARwYgTPZ5iPsmOenmqcCf8TjiEe8wBOHKO7H/Xshe48=
github.com/thegeeklab/wp-plugin-go/v2 v2.3.1/go.mod h1:0t8M8txtEFiaB6RqLX8vLrxkqAo5FT5Hx7dztN592D4=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2 h1:Mv5i8S1WY+BUNjTjX6lOnB3p8S9mvM+XwfY4R98gx0g=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2/go.mod h1:ij1iJcAVgzerBTqXnmq0bu1VA+hhVVwzXKqiqfoGjjg=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=

View File

@ -11,8 +11,8 @@ import (
"time"
"github.com/thegeeklab/wp-matrix/plugin"
"github.com/thegeeklab/wp-plugin-go/v2/docs"
"github.com/thegeeklab/wp-plugin-go/v2/template"
plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs"
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
)
func main() {
@ -23,7 +23,7 @@ func main() {
p := plugin.New(nil)
out, err := template.Render(context.Background(), client, tmpl, docs.GetTemplateData(p.App))
out, err := plugin_template.Render(context.Background(), client, tmpl, plugin_docs.GetTemplateData(p.App))
if err != nil {
panic(err)
}

View File

@ -13,7 +13,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/thegeeklab/wp-matrix/matrix"
"github.com/thegeeklab/wp-plugin-go/v2/template"
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
)
var ErrAuthSourceNotSet = errors.New("either username and password or userid and accesstoken are required")
@ -78,5 +78,5 @@ func (p *Plugin) Execute() error {
// CreateMessage generates a message string based on the plugin's template and metadata.
func (p *Plugin) CreateMessage() (string, error) {
return template.RenderTrim(p.Network.Context, *p.Network.Client, p.Settings.Template, p.Metadata)
return plugin_template.RenderTrim(p.Network.Context, *p.Network.Client, p.Settings.Template, p.Metadata)
}

View File

@ -6,7 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
wp "github.com/thegeeklab/wp-plugin-go/v2/plugin"
plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin"
)
func Test_messageContent(t *testing.T) {
@ -29,24 +29,24 @@ func Test_messageContent(t *testing.T) {
}
p := New(func(_ context.Context) error { return nil })
p.Network = wp.Network{
p.Network = plugin_base.Network{
Context: context.Background(),
Client: &http.Client{},
}
p.Metadata = wp.Metadata{
Curr: wp.Commit{
p.Metadata = plugin_base.Metadata{
Curr: plugin_base.Commit{
Branch: "main",
Title: "feat: demo commit title",
URL: "https://git.example.com",
Author: wp.Author{
Author: plugin_base.Author{
Name: "octobot",
},
},
Pipeline: wp.Pipeline{
Pipeline: plugin_base.Pipeline{
Status: "success",
URL: "https://ci.example.com",
},
Repository: wp.Repository{
Repository: plugin_base.Repository{
Slug: "octocat/demo",
},
}

View File

@ -9,7 +9,7 @@ package plugin
import (
"fmt"
wp "github.com/thegeeklab/wp-plugin-go/v2/plugin"
plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin"
"github.com/urfave/cli/v2"
)
@ -24,7 +24,7 @@ Message: {{ .Curr.Title }}{{ if .Curr.URL }} ([source]({{ .Curr.URL }})){{ end }
// Plugin implements provide the plugin.
type Plugin struct {
*wp.Plugin
*plugin_base.Plugin
Settings *Settings
}
@ -40,15 +40,15 @@ type Settings struct {
TemplateUnsafe bool
}
func New(e wp.ExecuteFunc, build ...string) *Plugin {
func New(e plugin_base.ExecuteFunc, build ...string) *Plugin {
p := &Plugin{
Settings: &Settings{},
}
options := wp.Options{
options := plugin_base.Options{
Name: "wp-matrix",
Description: "Send messages to a Matrix room",
Flags: Flags(p.Settings, wp.FlagsPluginCategory),
Flags: Flags(p.Settings, plugin_base.FlagsPluginCategory),
Execute: p.run,
HideWoodpeckerFlags: true,
}
@ -65,7 +65,7 @@ func New(e wp.ExecuteFunc, build ...string) *Plugin {
options.Execute = e
}
p.Plugin = wp.New(options)
p.Plugin = plugin_base.New(options)
return p
}