internal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const RuntimeVersion = "0.3.2"

Variables

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"},
	}
)
View Source
var NoneChecksum = &Checksum{
	Value: "",
	Type:  "none",
}

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Name    string
	Version string
}

type AvailableHookCtx added in v0.2.5

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

type AvailableHookResult added in v0.2.5

type AvailableHookResult = []*AvailableHookResultItem

type AvailableHookResultItem added in v0.2.5

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

	Addition []*Info `luai:"addition"`
}

type Checksum

type Checksum struct {
	Value string
	Type  string
}

type EnvKeysHookCtx added in v0.2.5

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

type EnvKeysHookResultItem added in v0.2.5

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

type HookFunc added in v0.3.0

type HookFunc struct {
	Name     string
	Required bool
	Filename string
}

type Info

type Info struct {
	Name     string  `luai:"name"`
	Version  Version `luai:"version"`
	Path     string  `luai:"path"`
	Note     string  `luai:"note"`
	Checksum *Checksum
}

type LuaCheckSum added in v0.2.5

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

func (*LuaCheckSum) Checksum added in v0.2.5

func (c *LuaCheckSum) Checksum() *Checksum

type LuaPlugin

type LuaPlugin struct {

	// plugin source path
	Path string
	// plugin filename, this is also alias name, sdk-name
	SdkName string
	*LuaPluginInfo
	// contains filtered or unexported fields
}

func NewLuaPlugin

func NewLuaPlugin(pluginDirPath string, manager *Manager) (*LuaPlugin, 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 (*LuaPlugin) Available

func (l *LuaPlugin) Available(args []string) ([]*Package, error)

func (*LuaPlugin) CallFunction added in v0.2.5

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

func (*LuaPlugin) Close

func (l *LuaPlugin) Close()

func (*LuaPlugin) EnvKeys

func (l *LuaPlugin) EnvKeys(sdkPackage *Package) (*env.Envs, error)

func (*LuaPlugin) HasFunction added in v0.2.5

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

func (*LuaPlugin) Label

func (l *LuaPlugin) Label(version string) string

func (*LuaPlugin) PostInstall

func (l *LuaPlugin) PostInstall(rootPath string, sdks []*Info) error

func (*LuaPlugin) PreInstall

func (l *LuaPlugin) PreInstall(version Version) (*Package, error)

func (*LuaPlugin) PreUse added in v0.2.5

func (l *LuaPlugin) PreUse(version Version, previousVersion Version, scope UseScope, cwd string, installedSdks []*Package) (Version, error)

func (*LuaPlugin) Validate added in v0.3.0

func (l *LuaPlugin) Validate() error

type LuaPluginInfo added in v0.2.5

type LuaPluginInfo struct {
	Name              string   `luai:"name"`
	Version           string   `luai:"version"`
	Description       string   `luai:"description"`
	UpdateUrl         string   `luai:"updateUrl"`
	ManifestUrl       string   `luai:"manifestUrl"`
	Homepage          string   `luai:"homepage"`
	License           string   `luai:"license"`
	MinRuntimeVersion string   `luai:"minRuntimeVersion"`
	Notes             []string `luai:"notes"`
}

type LuaRuntime added in v0.3.0

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

LuaRuntime represents the runtime information of the Lua environment.

type Manager

type Manager struct {
	PathMeta *PathMeta

	EnvManager env.Manager
	Config     *config.Config
	// contains filtered or unexported fields
}

func NewSdkManager

func NewSdkManager() *Manager

func (*Manager) Add

func (m *Manager) Add(pluginName, url, alias string) error

func (*Manager) Available

func (m *Manager) Available() (RegistryIndex, error)

func (*Manager) CleanTmp added in v0.2.3

func (m *Manager) CleanTmp()

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) EnvKeys

func (m *Manager) EnvKeys(tvs toolset.MultiToolVersions) (*env.Envs, error)

func (*Manager) GetRegistryAddress added in v0.3.0

func (m *Manager) GetRegistryAddress(uri string) string

func (*Manager) HttpClient added in v0.3.2

func (m *Manager) HttpClient() *http.Client

func (*Manager) LoadAllSdk

func (m *Manager) LoadAllSdk() (map[string]*Sdk, error)

func (*Manager) LookupSdk

func (m *Manager) LookupSdk(name string) (*Sdk, error)

LookupSdk lookup sdk by name

func (*Manager) LookupSdkWithInstall added in v0.3.2

func (m *Manager) LookupSdkWithInstall(name string) (*Sdk, error)

func (*Manager) Remove

func (m *Manager) Remove(pluginName string) error

func (*Manager) Update

func (m *Manager) Update(pluginName string) error

type NotFoundError added in v0.3.2

type NotFoundError struct {
	Msg string
}

func (NotFoundError) Error added in v0.3.2

func (n NotFoundError) Error() string

type Package

type Package struct {
	Main      *Info
	Additions []*Info
}

type PathMeta

type PathMeta struct {
	TempPath string
	// Temporary directory for the current process
	CurTmpPath       string
	HomePath         string
	SdkCachePath     string
	PluginPath       string
	ExecutablePath   string
	WorkingDirectory string
}

type PostInstallHookCtx added in v0.2.5

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

type PreInstallHookCtx added in v0.2.5

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

type PreInstallHookResult added in v0.2.5

type PreInstallHookResult struct {
	Version  string                              `luai:"version"`
	Url      string                              `luai:"url"`
	Note     string                              `luai:"note"`
	Sha256   string                              `luai:"sha256"`
	Sha512   string                              `luai:"sha512"`
	Sha1     string                              `luai:"sha1"`
	Md5      string                              `luai:"md5"`
	Addition []*PreInstallHookResultAdditionItem `luai:"addition"`
}

func (*PreInstallHookResult) Info added in v0.2.5

func (i *PreInstallHookResult) Info() (*Info, error)

type PreInstallHookResultAdditionItem added in v0.2.5

type PreInstallHookResultAdditionItem struct {
	Name   string `luai:"name"`
	Url    string `luai:"url"`
	Note   string `luai:"note"`
	Sha256 string `luai:"sha256"`
	Sha512 string `luai:"sha512"`
	Sha1   string `luai:"sha1"`
	Md5    string `luai:"md5"`
}

func (*PreInstallHookResultAdditionItem) Info added in v0.2.5

type PreUseHookCtx added in v0.2.5

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

type PreUseHookResult added in v0.2.5

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

type RegistryIndex added in v0.3.0

type RegistryIndex []*RegistryIndexItem

RegistryIndex is the index of the registry

type RegistryIndexItem added in v0.3.0

type RegistryIndexItem struct {
	Name     string `json:"name"`
	Desc     string `json:"desc"`
	Homepage string `json:"homepage"`
}

RegistryIndexItem is the item in the registry index

type RegistryPluginManifest added in v0.3.0

type RegistryPluginManifest struct {
	Name              string `json:"name"`
	Version           string `json:"version"`
	License           string `json:"license"`
	Author            string `json:"author"`
	DownloadUrl       string `json:"downloadUrl"`
	MinRuntimeVersion string `json:"minRuntimeVersion"`
}

RegistryPluginManifest is the manifest of a remote plugin

type Sdk

type Sdk struct {
	Plugin *LuaPlugin
	// current sdk install path
	InstallPath string
	// contains filtered or unexported fields
}

func NewSdk

func NewSdk(manager *Manager, source *LuaPlugin) (*Sdk, error)

func (*Sdk) Available

func (b *Sdk) Available(args []string) ([]*Package, error)

func (*Sdk) Close

func (b *Sdk) Close()

func (*Sdk) Current

func (b *Sdk) Current() Version

Current returns the current version of the SDK. Lookup priority is: project > session > global

func (*Sdk) Download

func (b *Sdk) Download(u *url.URL) (string, error)

func (*Sdk) EnvKeys

func (b *Sdk) EnvKeys(version Version) (*env.Envs, error)

func (*Sdk) Install

func (b *Sdk) Install(version Version) error

func (*Sdk) List

func (b *Sdk) List() []Version

func (*Sdk) PreUse added in v0.2.5

func (b *Sdk) PreUse(version Version, scope UseScope) (Version, error)

func (*Sdk) Uninstall

func (b *Sdk) Uninstall(version Version) error

func (*Sdk) Use

func (b *Sdk) Use(version Version, scope UseScope) error

func (*Sdk) VersionPath

func (b *Sdk) VersionPath(version Version) string

type UseScope

type UseScope int
const (
	Global UseScope = iota
	Project
	Session
)

func (UseScope) String added in v0.2.5

func (s UseScope) String() string

type Version

type Version string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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