mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-30 16:28:23 -05:00
feat(plugins): add rudimentary plugin system
This commit is contained in:
24
magefile.go
24
magefile.go
@@ -73,6 +73,7 @@ var (
|
||||
"dev:make-event": Dev.MakeEvent,
|
||||
"dev:make-listener": Dev.MakeListener,
|
||||
"dev:make-notification": Dev.MakeNotification,
|
||||
"plugins:build": Plugins.Build,
|
||||
"lint": Check.Golangci,
|
||||
"lint:fix": Check.GolangciFix,
|
||||
"generate:config-yaml": Generate.ConfigYAML,
|
||||
@@ -1393,3 +1394,26 @@ func generateConfigYAMLFromJSON(yamlPath string, commented bool) {
|
||||
func (Generate) ConfigYAML(commented bool) {
|
||||
generateConfigYAMLFromJSON(DefaultConfigYAMLSamplePath, commented)
|
||||
}
|
||||
|
||||
type Plugins mg.Namespace
|
||||
|
||||
// Build compiles a Go plugin at the provided path.
|
||||
func (Plugins) Build(pathToSourceFiles string) error {
|
||||
mg.Deps(initVars)
|
||||
if pathToSourceFiles == "" {
|
||||
return fmt.Errorf("please provide a plugin path")
|
||||
}
|
||||
|
||||
// Convert relative path to absolute path
|
||||
if !strings.HasPrefix(pathToSourceFiles, "/") {
|
||||
absPath, err := filepath.Abs(pathToSourceFiles)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to resolve absolute path: %v", err)
|
||||
}
|
||||
pathToSourceFiles = absPath
|
||||
}
|
||||
|
||||
out := filepath.Join(RootPath, "plugins", filepath.Base(pathToSourceFiles)+".so")
|
||||
runAndStreamOutput("go", "build", "-buildmode=plugin", "-o", out, pathToSourceFiles)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user