plugin

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluginCacheDir = getPluginCacheDir()

PluginCacheDir is the directory where external plugins are cached.

Functions

func Register

func Register(p Plugin)

Register registers a plugin with GoSPA. This function is thread-safe and can be called from multiple goroutines.

func RunCommand

func RunCommand(name string, args []string) (bool, error)

RunCommand executes a custom command from a plugin.

func TriggerHook

func TriggerHook(hook Hook, ctx map[string]interface{}) error

TriggerHook triggers a lifecycle hook for all registered CLI plugins.

Types

type CLIPlugin

type CLIPlugin interface {
	Plugin
	// OnHook is called when a lifecycle hook is triggered.
	OnHook(hook Hook, ctx map[string]interface{}) error
	// Commands returns custom CLI commands provided by the plugin.
	Commands() []Command
}

CLIPlugin extends Plugin with CLI-specific functionality.

func GetCLIPlugins

func GetCLIPlugins() []CLIPlugin

GetCLIPlugins returns all registered CLI plugins. This function is thread-safe.

type Command

type Command struct {
	Name        string
	Alias       string
	Description string
	Action      func(args []string) error
}

Command represents a custom CLI command.

type Dependency

type Dependency struct {
	// Type is the dependency type (go or bun).
	Type DependencyType
	// Name is the package name (e.g., "golang.org/x/oauth2" or "valibot").
	Name string
	// Version is the version constraint (e.g., "latest", "v1.2.3").
	Version string
}

Dependency represents a plugin dependency.

type DependencyType

type DependencyType string

DependencyType represents the type of dependency (Go or Bun/JS).

const (
	// DepGo is a Go module dependency.
	DepGo DependencyType = "go"
	// DepBun is a Bun/JavaScript package dependency.
	DepBun DependencyType = "bun"
)

type Hook

type Hook string

Hook represents a lifecycle event in GoSPA.

const (
	// BeforeGenerate is triggered before code generation starts.
	BeforeGenerate Hook = "before:generate"
	// AfterGenerate is triggered after code generation completes.
	AfterGenerate Hook = "after:generate"
	// BeforeDev is triggered before the development server starts.
	BeforeDev Hook = "before:dev"
	// AfterDev is triggered after the development server starts.
	AfterDev Hook = "after:dev"
	// BeforeBuild is triggered before the production build starts.
	BeforeBuild Hook = "before:build"
	// AfterBuild is triggered after the production build completes.
	AfterBuild Hook = "after:build"
)

type Plugin

type Plugin interface {
	Name() string
	Init() error
	// Dependencies returns the list of dependencies required by this plugin.
	// This includes both Go modules and Bun packages.
	Dependencies() []Dependency
}

Plugin is the base interface for all GoSPA extensions.

func GetPlugins

func GetPlugins() []Plugin

GetPlugins returns all registered plugins. This function is thread-safe and returns a copy of the registry.

Directories

Path Synopsis
Package auth provides authentication for GoSPA projects.
Package auth provides authentication for GoSPA projects.
Package image provides image optimization for GoSPA projects.
Package image provides image optimization for GoSPA projects.
Package postcss provides a PostCSS plugin for GoSPA with Tailwind CSS v4 support.
Package postcss provides a PostCSS plugin for GoSPA with Tailwind CSS v4 support.
Package qrcode provides QR code generation for GoSPA applications.
Package qrcode provides QR code generation for GoSPA applications.
Package seo provides SEO optimization for GoSPA projects.
Package seo provides SEO optimization for GoSPA projects.
Package tailwind provides a Tailwind CSS v4 plugin for GoSPA.
Package tailwind provides a Tailwind CSS v4 plugin for GoSPA.
Package validation provides form validation for GoSPA projects.
Package validation provides form validation for GoSPA projects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL