plugin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResultProvide = errors.New("no result provided")
View Source
var ErrNoVersionProvided = errors.New("no version number provided")
View Source
var ErrPluginNotFound = errors.New("plugin not found")
View Source
var (
	// HookFuncMap is a map of built-in hook functions.
	HookFuncMap = map[string]HookFunc{
		"Available":       {Name: "Available", Required: true, Filename: "available"},
		"PreInstall":      {Name: "PreInstall", Required: true, Filename: "pre_install"},
		"EnvKeys":         {Name: "EnvKeys", Required: true, Filename: "env_keys"},
		"PostInstall":     {Name: "PostInstall", Required: false, Filename: "post_install"},
		"PreUse":          {Name: "PreUse", Required: false, Filename: "pre_use"},
		"ParseLegacyFile": {Name: "ParseLegacyFile", Required: false, Filename: "parse_legacy_file"},
		"PreUninstall":    {Name: "PreUninstall", Required: false, Filename: "pre_uninstall"},
		"Fingerprint":     {Name: "Fingerprint", Required: false, Filename: "fingerprint"},
		"Detect":          {Name: "Detect", Required: false, Filename: "detect"},
	}
)

Functions

func CreateLuaPlugin added in v1.0.0

func CreateLuaPlugin(pluginDirPath string, envCtx *env.RuntimeEnvContext) (*LuaPlugin, *Metadata, error)

func RunDevelopmentHook added in v1.0.13

func RunDevelopmentHook(ctx context.Context, directory, hook string, input []byte, options DevelopmentOptions) (any, error)

RunDevelopmentHook calls exactly one hook, without SDK lifecycle orchestration.

func TestDevelopmentFile added in v1.0.13

func TestDevelopmentFile(ctx context.Context, directory, file string, options DevelopmentOptions) error

TestDevelopmentFile runs ordinary Lua assertions in a single fresh VM.

Types

type AvailableHookCtx added in v1.0.0

type AvailableHookCtx struct {
	Args []string `json:"args"`
}

type AvailableHookResultItem added in v1.0.0

type AvailableHookResultItem struct {
	Version string `json:"version"`
	Note    string `json:"note"`

	Addition []*PreInstallPackageItem `json:"addition"`
}

type CheckSumItem added in v1.0.0

type CheckSumItem struct {
	Sha256 string `json:"sha256"`
	Sha512 string `json:"sha512"`
	Sha1   string `json:"sha1"`
	Md5    string `json:"md5"`
}

func (*CheckSumItem) Checksum added in v1.0.0

func (c *CheckSumItem) Checksum() *shared.Checksum

type DetectHookCtx added in v1.1.0

type DetectHookCtx struct{}

DetectHookCtx is the context of the optional Detect hook.

type DetectHookResultItem added in v1.1.0

type DetectHookResultItem struct {
	Version string `json:"version"` // name to link the SDK under
	Path    string `json:"path"`    // SDK root directory
	Note    string `json:"note"`    // optional, additional note
}

DetectHookResultItem is an SDK found on this machine that vfox did not install.

type DevelopmentOptions added in v1.0.13

type DevelopmentOptions struct {
	RuntimeVersion string
	OS, Arch       string
	Online         bool
	Output         io.Writer
}

DevelopmentOptions affect only the temporary VM, never installed plugins or user/project configuration. The orchestration layer supplies RuntimeVersion.

type EnvKeysHookCtx added in v1.0.0

type EnvKeysHookCtx struct {
	Main    *InstalledPackageItem            `json:"main"`
	Path    string                           `json:"path"` // TODO Will be deprecated in future versions
	SdkInfo map[string]*InstalledPackageItem `json:"sdkInfo"`
}

type EnvKeysHookResultItem added in v1.0.0

type EnvKeysHookResultItem struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type FingerprintHookCtx added in v1.1.0

type FingerprintHookCtx struct {
	Path    string                           `json:"path"` // main runtime directory
	Version string                           `json:"version"`
	SdkInfo map[string]*InstalledPackageItem `json:"sdkInfo"`
}

FingerprintHookCtx is the context of the optional Fingerprint hook.

type FingerprintHookResult added in v1.1.0

type FingerprintHookResult struct {
	Facts map[string]string `json:"facts"`
}

FingerprintHookResult carries the facts that identify an installation, such as the commit an SDK checkout is at. vfox records them when the SDK is installed and compares them again later to notice an SDK that was modified in place.

type HookFunc added in v1.0.0

type HookFunc struct {
	Name     string
	Required bool
	Filename string
}

type InstalledPackageItem added in v1.0.0

type InstalledPackageItem struct {
	Path    string `json:"path"`
	Version string `json:"version"`
	Name    string `json:"name"`
	Note    string `json:"note"` // optional, additional note from PreInstall
}

InstalledPackageItem represents the installed SDK base information to export to the plugins.

type LuaPlugin added in v1.0.0

type LuaPlugin struct {
	// contains filtered or unexported fields
}

func (*LuaPlugin) Available added in v1.0.0

func (l *LuaPlugin) Available(ctx *AvailableHookCtx) ([]*AvailableHookResultItem, error)

func (*LuaPlugin) CallFunction added in v1.0.0

func (l *LuaPlugin) CallFunction(funcName string, args ...lua.LValue) (lua.LValue, error)

func (*LuaPlugin) Close added in v1.0.0

func (l *LuaPlugin) Close()

func (*LuaPlugin) Detect added in v1.1.0

func (l *LuaPlugin) Detect(ctx *DetectHookCtx) ([]*DetectHookResultItem, error)

func (*LuaPlugin) EnvKeys added in v1.0.0

func (l *LuaPlugin) EnvKeys(ctx *EnvKeysHookCtx) ([]*EnvKeysHookResultItem, error)

func (*LuaPlugin) Fingerprint added in v1.1.0

func (l *LuaPlugin) Fingerprint(ctx *FingerprintHookCtx) (*FingerprintHookResult, error)

func (*LuaPlugin) HasFunction added in v1.0.0

func (l *LuaPlugin) HasFunction(name string) bool

func (*LuaPlugin) ParseLegacyFile added in v1.0.0

func (l *LuaPlugin) ParseLegacyFile(ctx *ParseLegacyFileHookCtx) (*ParseLegacyFileResult, error)

func (*LuaPlugin) PostInstall added in v1.0.0

func (l *LuaPlugin) PostInstall(ctx *PostInstallHookCtx) error

func (*LuaPlugin) PreInstall added in v1.0.0

func (l *LuaPlugin) PreInstall(ctx *PreInstallHookCtx) (*PreInstallHookResult, error)

func (*LuaPlugin) PreUninstall added in v1.0.0

func (l *LuaPlugin) PreUninstall(ctx *PreUninstallHookCtx) error

func (*LuaPlugin) PreUse added in v1.0.0

func (l *LuaPlugin) PreUse(ctx *PreUseHookCtx) (*PreUseHookResult, error)

type Metadata added in v1.0.0

type Metadata struct {
	Name              string   `json:"name"`
	Version           string   `json:"version"`
	Description       string   `json:"description"`
	UpdateUrl         string   `json:"updateUrl"`
	ManifestUrl       string   `json:"manifestUrl"`
	Homepage          string   `json:"homepage"`
	License           string   `json:"license"`
	MinRuntimeVersion string   `json:"minRuntimeVersion"`
	Notes             []string `json:"notes"`
	LegacyFilenames   []string `json:"legacyFilenames"`
	// ShadowHints explain, per shadowing executable, how to get the SDK's
	// commands back in front of PATH. Optional.
	ShadowHints []ShadowHint `json:"shadowHints"`
}

Metadata represents the metadata of a plugin.

func (*Metadata) ShowNotes added in v1.0.0

func (l *Metadata) ShowNotes()

ShowNotes prints the notes of the plugin.

type ParseLegacyFileHookCtx added in v1.0.0

type ParseLegacyFileHookCtx struct {
	Filepath             string          `json:"filepath"`
	Filename             string          `json:"filename"`
	GetInstalledVersions func() []string `json:"getInstalledVersions"`
	// Support three strategies:
	// 1. latest_installed: use the latest installed version
	// 2. latest_available: use the latest available version
	// 3. specified: use the specified version in the legacy file
	// default: specified
	Strategy string `json:"strategy"`
}

type ParseLegacyFileResult added in v1.0.0

type ParseLegacyFileResult struct {
	Version string `json:"version"`
}

type Plugin added in v1.0.0

type Plugin interface {
	Available(ctx *AvailableHookCtx) ([]*AvailableHookResultItem, error)
	PreInstall(ctx *PreInstallHookCtx) (*PreInstallHookResult, error)
	PostInstall(ctx *PostInstallHookCtx) error
	PreUninstall(ctx *PreUninstallHookCtx) error
	PreUse(ctx *PreUseHookCtx) (*PreUseHookResult, error)
	ParseLegacyFile(ctx *ParseLegacyFileHookCtx) (*ParseLegacyFileResult, error)
	EnvKeys(ctx *EnvKeysHookCtx) ([]*EnvKeysHookResultItem, error)
	Fingerprint(ctx *FingerprintHookCtx) (*FingerprintHookResult, error)
	Detect(ctx *DetectHookCtx) ([]*DetectHookResultItem, error)
	HasFunction(name string) bool
	Close()
}

Plugin is the interface that all plugins must implement.

type PostInstallHookCtx added in v1.0.0

type PostInstallHookCtx struct {
	RootPath string                           `json:"rootPath"`
	SdkInfo  map[string]*InstalledPackageItem `json:"sdkInfo"`
}

type PreInstallHookCtx added in v1.0.0

type PreInstallHookCtx struct {
	Version string `json:"version"`
}

type PreInstallHookResult added in v1.0.0

type PreInstallHookResult struct {
	*PreInstallPackageItem
	Addition []*PreInstallPackageItem `json:"addition"`
}

type PreInstallPackageItem added in v1.0.0

type PreInstallPackageItem struct {
	Name          string            `json:"name"`
	Version       string            `json:"version"`
	Path          string            `json:"url"`     // optional, remote URL or local file path
	Headers       map[string]string `json:"headers"` // optional, request headers for downloading
	Note          string            `json:"note"`    // optional, additional note
	*CheckSumItem                   // optional, checksum information
}

PreInstallPackageItem represents the package information returned by PreInstall hook

func (*PreInstallPackageItem) Checksum added in v1.0.1

func (p *PreInstallPackageItem) Checksum() *shared.Checksum

Checksum returns the checksum for this package, or NoneChecksum if no checksum is provided

func (*PreInstallPackageItem) Label added in v1.0.0

func (p *PreInstallPackageItem) Label() string

type PreUninstallHookCtx added in v1.0.0

type PreUninstallHookCtx struct {
	Main    *InstalledPackageItem            `json:"main"`
	SdkInfo map[string]*InstalledPackageItem `json:"sdkInfo"`
}

type PreUseHookCtx added in v1.0.0

type PreUseHookCtx struct {
	Cwd             string                           `json:"cwd"`
	Scope           string                           `json:"scope"`
	Version         string                           `json:"version"`
	PreviousVersion string                           `json:"previousVersion"`
	InstalledSdks   map[string]*InstalledPackageItem `json:"installedSdks"`
}

type PreUseHookResult added in v1.0.0

type PreUseHookResult struct {
	Version string `json:"version"`
}

type RuntimeInfo added in v1.0.0

type RuntimeInfo struct {
	OsType        string `json:"osType"`
	ArchType      string `json:"archType"`
	Version       string `json:"version"`
	PluginDirPath string `json:"pluginDirPath"`
}

RuntimeInfo represents the runtime information of the current exec environment.

type ShadowHint added in v1.1.0

type ShadowHint struct {
	Match   string `json:"match"`
	Message string `json:"message"`
	URL     string `json:"url"`
}

ShadowHint is a plugin-declared explanation for a command of the SDK being shadowed by an executable somewhere else in PATH. Match is a case-insensitive substring of the shadowing executable's path.

type Wrapper added in v1.0.0

type Wrapper struct {
	*Metadata            // Metadata is the metadata of the plugin
	Plugin               // Plugin is the plugin instance
	InstalledPath string // InstalledPath is the path where the plugin is installed
}

Wrapper wraps a Plugin with its metadata and installed path.

func CreatePlugin added in v1.0.0

func CreatePlugin(tempInstallPath string, runtimeEnvCtx *env.RuntimeEnvContext) (*Wrapper, error)

func NewLuaPlugin

func NewLuaPlugin(pluginDirPath string, ctx *env.RuntimeEnvContext) (*Wrapper, error)

NewLuaPlugin creates a new LuaPlugin instance from the specified directory path. The plugin directory must meet one of the following conditions: - The directory must contain a metadata.lua file and a hooks directory that includes all must be implemented hook functions. - The directory contain a main.lua file that defines the plugin object and all hook functions.

func (*Wrapper) IsNoResultProvided added in v1.0.0

func (l *Wrapper) IsNoResultProvided(err error) bool

IsNoResultProvided checks if the error indicates that no result was provided.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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