pluginstore

package
v7.2.38 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRegistryURL = "https://raw.githubusercontent.com/router-for-me/CLIProxyAPI-Plugins-Store/main/registry.json"
	DefaultSourceID    = "official"
	DefaultSourceName  = "Official"
	SchemaVersion      = 1
)

Variables

View Source
var ErrLoadedPluginLocked = errors.New("loaded plugin library cannot be overwritten while the server is running")

ErrLoadedPluginLocked is returned when an install would overwrite a plugin library that is loaded by the running process on Windows.

Functions

func ArchiveName

func ArchiveName(id, version, goos, goarch string) string

func GitHubRepositoryParts

func GitHubRepositoryParts(repository string) (string, string, error)

func ParseChecksums

func ParseChecksums(data []byte) (map[string]string, error)

func ReleaseVersion added in v7.1.72

func ReleaseVersion(release Release) (string, error)

ReleaseVersion derives the plugin version from the release tag, stripping a leading "v"/"V" and validating the result.

func SelectReleaseAssets

func SelectReleaseAssets(release Release, id, version, goos, goarch string) (ReleaseAsset, ReleaseAsset, error)

func SourceID added in v7.2.2

func SourceID(registryURL string) string

func SourceName added in v7.2.2

func SourceName(registryURL string) string

func UpdateAvailable

func UpdateAvailable(installed, latest string) bool

UpdateAvailable reports whether latest should be offered as an upgrade over installed. A leading "v"/"V" is ignored on both sides. Versions are compared numerically when both are dotted release numbers, so an installed version newer than the registry one is not reported as an update; otherwise any difference counts as an update.

func ValidatePlugin

func ValidatePlugin(plugin Plugin) error

func ValidateRegistry

func ValidateRegistry(registry Registry) error

func VerifyChecksum

func VerifyChecksum(name string, data []byte, checksums map[string]string) error

Types

type Client

type Client struct {
	HTTPClient  HTTPDoer
	RegistryURL string
	UserAgent   string
}

func (Client) DownloadAsset

func (c Client) DownloadAsset(ctx context.Context, asset ReleaseAsset) ([]byte, error)

func (Client) FetchLatestRelease added in v7.1.72

func (c Client) FetchLatestRelease(ctx context.Context, plugin Plugin) (Release, error)

FetchLatestRelease returns the latest published release of the plugin's GitHub repository, mirroring the WebUI panel update check.

func (Client) FetchRegistry

func (c Client) FetchRegistry(ctx context.Context) (Registry, error)

func (Client) FetchReleaseByTag added in v7.2.28

func (c Client) FetchReleaseByTag(ctx context.Context, plugin Plugin, tag string) (Release, error)

FetchReleaseByTag returns a published release by its exact GitHub tag.

func (Client) Install

func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error)

func (Client) InstallVersion added in v7.2.28

func (c Client) InstallVersion(ctx context.Context, plugin Plugin, releaseTag string, version string, options InstallOptions) (InstallResult, error)

InstallVersion installs a plugin artifact from a fixed release tag/version.

type HTTPDoer

type HTTPDoer = httpfetch.Doer

HTTPDoer abstracts the HTTP client used to execute requests.

type InstallOptions

type InstallOptions struct {
	PluginsDir string
	GOOS       string
	GOARCH     string
	// PluginLoaded reports whether the plugin's dynamic library is currently
	// loaded by the running host. Windows installs are rejected only when they
	// would overwrite an existing target file while it returns true.
	PluginLoaded func() bool
	// BeforeWrite runs after the archive has been downloaded and verified, but
	// before an existing target plugin file is replaced.
	BeforeWrite func() error
}

type InstallResult

type InstallResult struct {
	ID          string `json:"id"`
	Version     string `json:"version"`
	Path        string `json:"path"`
	Overwritten bool   `json:"overwritten"`
	Skipped     bool   `json:"skipped"`
}

func InstallArchive

func InstallArchive(archiveData []byte, plugin Plugin, options InstallOptions) (InstallResult, error)

type Plugin

type Plugin struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Author      string   `json:"author"`
	Version     string   `json:"version"`
	Repository  string   `json:"repository"`
	Homepage    string   `json:"homepage,omitempty"`
	License     string   `json:"license,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

type Registry

type Registry struct {
	SchemaVersion int      `json:"schema_version"`
	Plugins       []Plugin `json:"plugins"`
}

func ParseRegistry

func ParseRegistry(data []byte) (Registry, error)

func (Registry) PluginByID

func (r Registry) PluginByID(id string) (Plugin, bool)

type Release

type Release struct {
	TagName string         `json:"tag_name"`
	Assets  []ReleaseAsset `json:"assets"`
}

type ReleaseAsset

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

type Source added in v7.2.2

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

func DefaultSource added in v7.2.2

func DefaultSource() Source

func NormalizeSources added in v7.2.2

func NormalizeSources(registryURLs []string) ([]Source, error)

Jump to

Keyboard shortcuts

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