internal

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const RuntimeVersion = "0.5.1"

Variables

View Source
var ErrNoVersionProvided = errors.New("no version number provided")
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"},
	}
)
View Source
var (
	ManifestNotFound = errors.New("manifest not found")
)
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"`
	Headers  map[string]string `luai:"headers"`
	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) ParseLegacyFile added in v0.4.0

func (l *LuaPlugin) ParseLegacyFile(path string, installedVersions func() []Version) (Version, error)

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) PreUninstall added in v0.4.0

func (l *LuaPlugin) PreUninstall(p *Package) error

PreUninstall executes the PreUninstall hook function.

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) ShowNotes added in v0.4.0

func (l *LuaPlugin) ShowNotes()

ShowNotes prints the notes of the plugin.

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"`
	LegacyFilenames   []string `luai:"legacyFilenames"`
}

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

Add a plugin to plugin home directory 1. If the plugin is an official plugin, fetch the plugin manifest from the registry. 2. If the plugin is a custom plugin, install the plugin from the specified URL. 3. Validate the plugin and install it to the plugin home directory. examples:

vfox add nodejs
vfox add --alias node nodejs
vfox add --source /path/to/plugin.zip
vfox add --source /path/to/plugin.zip --alias node [nodejs]

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) (SdkEnvs, 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) ParseLegacyFile added in v0.4.0

func (m *Manager) ParseLegacyFile(output func(sdkname, version string)) error

ParseLegacyFile parse legacy file and output the sdkname and version

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 ParseLegacyFileHookCtx added in v0.4.0

type ParseLegacyFileHookCtx struct {
	Filepath             string         `luai:"filepath"`
	Filename             string         `luai:"filename"`
	GetInstalledVersions lua.LGFunction `luai:"getInstalledVersions"`
}

type ParseLegacyFileResult added in v0.4.0

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

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
	GlobalShimsPath  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"`
	Headers  map[string]string                   `luai:"headers"`
	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"`
	Headers map[string]string `luai:"headers"`
	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 PreUninstallHookCtx added in v0.4.0

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

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, pluginPath string) (*Sdk, error)

NewSdk creates a new SDK instance.

func (*Sdk) Available

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

func (*Sdk) CheckExists added in v0.4.0

func (b *Sdk) CheckExists(version Version) bool

func (*Sdk) ClearCurrentEnv added in v0.5.0

func (b *Sdk) ClearCurrentEnv() 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, headers map[string]string) (string, error)

func (*Sdk) EnvKeys

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

func (*Sdk) GetLocalSdkPackage added in v0.4.0

func (b *Sdk) GetLocalSdkPackage(version Version) (*Package, error)

func (*Sdk) Install

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

func (*Sdk) List

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

func (*Sdk) ParseLegacyFile added in v0.4.0

func (b *Sdk) ParseLegacyFile(path string) (Version, error)

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) (err error)

func (*Sdk) Use

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

func (*Sdk) VersionPath

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

type SdkEnv added in v0.5.0

type SdkEnv struct {
	Sdk *Sdk
	Env *env.Envs
}

func (*SdkEnv) LinkToInstallPath added in v0.5.0

func (s *SdkEnv) LinkToInstallPath() (*env.Paths, error)

func (*SdkEnv) LinkToTargetPath added in v0.5.0

func (s *SdkEnv) LinkToTargetPath(targetDir string) (*env.Paths, error)

type SdkEnvs added in v0.5.0

type SdkEnvs []*SdkEnv

func (*SdkEnvs) LinkCurrent added in v0.5.0

func (d *SdkEnvs) LinkCurrent(targetDir string) *env.Paths

LinkCurrent link the current sdk to the `current` directory of the target directory

func (*SdkEnvs) ToEnvs added in v0.5.0

func (d *SdkEnvs) ToEnvs() *env.Envs

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