mirror of
https://github.com/thegeeklab/wp-matrix.git
synced 2024-11-21 04:20:38 +00:00
chore: migrate to wp-plugin-go v3 (#116)
This commit is contained in:
parent
dc41f2d9ff
commit
76f5076b0a
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/microcosm-cc/bluemonday v1.0.26
|
github.com/microcosm-cc/bluemonday v1.0.26
|
||||||
github.com/rs/zerolog v1.32.0
|
github.com/rs/zerolog v1.32.0
|
||||||
github.com/stretchr/testify v1.9.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
|
github.com/urfave/cli/v2 v2.27.2
|
||||||
maunium.net/go/mautrix v0.18.1
|
maunium.net/go/mautrix v0.18.1
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@ -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.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 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
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/v3 v3.0.2 h1:Mv5i8S1WY+BUNjTjX6lOnB3p8S9mvM+XwfY4R98gx0g=
|
||||||
github.com/thegeeklab/wp-plugin-go/v2 v2.3.1/go.mod h1:0t8M8txtEFiaB6RqLX8vLrxkqAo5FT5Hx7dztN592D4=
|
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.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
|
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
|
||||||
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/thegeeklab/wp-matrix/plugin"
|
"github.com/thegeeklab/wp-matrix/plugin"
|
||||||
"github.com/thegeeklab/wp-plugin-go/v2/docs"
|
plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs"
|
||||||
"github.com/thegeeklab/wp-plugin-go/v2/template"
|
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -23,7 +23,7 @@ func main() {
|
|||||||
|
|
||||||
p := plugin.New(nil)
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/thegeeklab/wp-matrix/matrix"
|
"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")
|
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.
|
// CreateMessage generates a message string based on the plugin's template and metadata.
|
||||||
func (p *Plugin) CreateMessage() (string, error) {
|
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)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"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) {
|
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 := New(func(_ context.Context) error { return nil })
|
||||||
p.Network = wp.Network{
|
p.Network = plugin_base.Network{
|
||||||
Context: context.Background(),
|
Context: context.Background(),
|
||||||
Client: &http.Client{},
|
Client: &http.Client{},
|
||||||
}
|
}
|
||||||
p.Metadata = wp.Metadata{
|
p.Metadata = plugin_base.Metadata{
|
||||||
Curr: wp.Commit{
|
Curr: plugin_base.Commit{
|
||||||
Branch: "main",
|
Branch: "main",
|
||||||
Title: "feat: demo commit title",
|
Title: "feat: demo commit title",
|
||||||
URL: "https://git.example.com",
|
URL: "https://git.example.com",
|
||||||
Author: wp.Author{
|
Author: plugin_base.Author{
|
||||||
Name: "octobot",
|
Name: "octobot",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Pipeline: wp.Pipeline{
|
Pipeline: plugin_base.Pipeline{
|
||||||
Status: "success",
|
Status: "success",
|
||||||
URL: "https://ci.example.com",
|
URL: "https://ci.example.com",
|
||||||
},
|
},
|
||||||
Repository: wp.Repository{
|
Repository: plugin_base.Repository{
|
||||||
Slug: "octocat/demo",
|
Slug: "octocat/demo",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ package plugin
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"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"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ Message: {{ .Curr.Title }}{{ if .Curr.URL }} ([source]({{ .Curr.URL }})){{ end }
|
|||||||
|
|
||||||
// Plugin implements provide the plugin.
|
// Plugin implements provide the plugin.
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
*wp.Plugin
|
*plugin_base.Plugin
|
||||||
Settings *Settings
|
Settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +40,15 @@ type Settings struct {
|
|||||||
TemplateUnsafe bool
|
TemplateUnsafe bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(e wp.ExecuteFunc, build ...string) *Plugin {
|
func New(e plugin_base.ExecuteFunc, build ...string) *Plugin {
|
||||||
p := &Plugin{
|
p := &Plugin{
|
||||||
Settings: &Settings{},
|
Settings: &Settings{},
|
||||||
}
|
}
|
||||||
|
|
||||||
options := wp.Options{
|
options := plugin_base.Options{
|
||||||
Name: "wp-matrix",
|
Name: "wp-matrix",
|
||||||
Description: "Send messages to a Matrix room",
|
Description: "Send messages to a Matrix room",
|
||||||
Flags: Flags(p.Settings, wp.FlagsPluginCategory),
|
Flags: Flags(p.Settings, plugin_base.FlagsPluginCategory),
|
||||||
Execute: p.run,
|
Execute: p.run,
|
||||||
HideWoodpeckerFlags: true,
|
HideWoodpeckerFlags: true,
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ func New(e wp.ExecuteFunc, build ...string) *Plugin {
|
|||||||
options.Execute = e
|
options.Execute = e
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Plugin = wp.New(options)
|
p.Plugin = plugin_base.New(options)
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user