mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Add plugin init. Update plugin signature.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v3/internal/flags"
|
||||
|
||||
"github.com/leaanthony/gosod"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
//go:embed template
|
||||
var pluginTemplate embed.FS
|
||||
|
||||
type TemplateOptions struct {
|
||||
*flags.PluginInit
|
||||
}
|
||||
|
||||
func Install(options *flags.PluginInit) error {
|
||||
|
||||
if options.OutputDir == "." || options.OutputDir == "" {
|
||||
options.OutputDir = filepath.Join(lo.Must(os.Getwd()), options.Name)
|
||||
}
|
||||
fmt.Printf("Creating plugin '%s' into '%s'\n", options.Name, options.OutputDir)
|
||||
tfs, err := fs.Sub(pluginTemplate, "template")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return gosod.New(tfs).Extract(options.OutputDir, options)
|
||||
}
|
||||
Reference in New Issue
Block a user