plugin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(code, content string) string

AppendToFile appends content to the end of the code, ensuring a newline separator.

func CheckConflicts

func CheckConflicts(m *Manifest) []string

CheckConflicts checks if generated files already exist in the project. Returns a list of conflicting file paths.

func InsertBeforeClosingBrace

func InsertBeforeClosingBrace(code, content string) string

InsertBeforeClosingBrace inserts content before the last closing brace `}` in the code. This is the same pattern used by scaffold route injection.

func InsertLineAfter

func InsertLineAfter(code, after, content string) string

InsertLineAfter finds the first line containing `after` and inserts `content` on the next line.

func Install

func Install(pluginDir string, m *Manifest, vars map[string]string) error

Install orchestrates the full plugin installation: dirs → files → injections → env vars → dependencies.

func ResolveSource

func ResolveSource(source string) (pluginDir string, cleanup func(), err error)

ResolveSource determines the plugin source type and returns the local path to the plugin directory (downloading if needed).

Supported sources:

  • Local path: ./local-plugin or /absolute/path
  • Git URL: github.com/user/repo
  • Short name: "auth" (resolved via registry)

func TrackInstall

func TrackInstall(m *Manifest) error

TrackInstall records a plugin installation in .catuaba/plugins.yaml.

func Validate

func Validate(m *Manifest) error

Validate checks the manifest for required fields and potential conflicts against the current project.

Types

type EnvVar

type EnvVar struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

EnvVar is an environment variable to append to .env files.

type File

type File struct {
	Template string `yaml:"template"`
	Output   string `yaml:"output"`
}

File maps a template to an output path.

type Injection

type Injection struct {
	File      string `yaml:"file"`
	Action    string `yaml:"action"`
	Import    string `yaml:"import"`
	Method    string `yaml:"method"`
	Attribute string `yaml:"attribute"`
	Content   string `yaml:"content"`
	After     string `yaml:"after"`
}

Injection describes a code modification to an existing file.

type Manifest

type Manifest struct {
	Name         string      `yaml:"name"`
	Version      string      `yaml:"version"`
	Description  string      `yaml:"description"`
	Author       string      `yaml:"author"`
	Repository   string      `yaml:"repository"`
	Variables    []Variable  `yaml:"variables"`
	Dependencies []string    `yaml:"dependencies"`
	Directories  []string    `yaml:"directories"`
	Files        []File      `yaml:"files"`
	Injections   []Injection `yaml:"injections"`
	EnvVars      []EnvVar    `yaml:"env_vars"`
	PostInstall  []string    `yaml:"post_install"`
}

Manifest represents the declarative plugin.yaml file.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads and parses a plugin.yaml from the given path.

type PluginData

type PluginData struct {
	Name       string
	AppName    string
	ModuleName string
	Variables  map[string]string
}

PluginData is the data available to plugin templates.

type Registry

type Registry struct {
	Plugins map[string]RegistryEntry `yaml:"plugins"`
}

Registry holds the list of available plugins.

func LoadRegistry

func LoadRegistry(refresh bool) (*Registry, error)

LoadRegistry fetches the plugin registry, using a local cache with 24h TTL. If refresh is true, the cache is bypassed.

type RegistryEntry

type RegistryEntry struct {
	Repository  string `yaml:"repository"`
	Description string `yaml:"description"`
	Version     string `yaml:"version"`
}

RegistryEntry is a single plugin entry in the registry.

type Tracker

type Tracker struct {
	Installed map[string]TrackerEntry `yaml:"installed"`
}

Tracker stores which plugins are installed in the project.

func LoadTracker

func LoadTracker() (*Tracker, error)

LoadTracker reads the tracker file from the current project.

type TrackerEntry

type TrackerEntry struct {
	Version      string   `yaml:"version"`
	InstalledAt  string   `yaml:"installed_at"`
	FilesCreated []string `yaml:"files_created"`
}

TrackerEntry records metadata about an installed plugin.

type Variable

type Variable struct {
	Name    string `yaml:"name"`
	Default string `yaml:"default"`
}

Variable is a configurable plugin variable with a default value.

Jump to

Keyboard shortcuts

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