internal

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HookCurTmpPath = "__VFOX_CURTMPPATH"

	HOME_DIR = ".version-fox"

	PLUGIN_DIR = "plugin"
	CACHE_DIR  = "cache"
	TEMP_DIR   = "temp"
)
View Source
const RuntimeVersion = "0.9.2"

Variables

View Source
var (
	ManifestNotFound = errors.New("manifest not found")
)

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Name    string
	Version string
}

type LocationPackage added in v0.5.3

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

LocationPackage represents a package that needs to be linked

func (*LocationPackage) ConvertLocation added in v0.5.3

func (l *LocationPackage) ConvertLocation() *base.Package
func (l *LocationPackage) Link() (*base.Package, error)

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, location base.Location) (SdkEnvs, error)

func (*Manager) GetRegistryAddress added in v0.3.0

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

func (*Manager) GlobalEnvKeys added in v0.6.2

func (m *Manager) GlobalEnvKeys() (SdkEnvs, error)

func (*Manager) HttpClient added in v0.3.2

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

func (*Manager) LoadAllSdk

func (m *Manager) LoadAllSdk() ([]*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, autoConfirm bool) (*Sdk, error)

func (*Manager) Remove

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

func (*Manager) ResolveVersion added in v0.7.0

func (m *Manager) ResolveVersion(sdkName string, version base.Version) base.Version

func (*Manager) SessionEnvKeys added in v0.6.2

func (m *Manager) SessionEnvKeys(opt SessionEnvOptions) (SdkEnvs, error)

SessionEnvKeys returns the environment variables that need to be set and/or unset by the shell. This is determined by the contents of any .tool-versions files in the following locations, in the following order of precedence:

  1. Current working directory (in this directory, any legacy version files are also considered)
  2. vfox home directory (only if the WithGlobalEnv option is set to true)
  3. Current session's vfox temp directory

The function maintains environment state through two mechanisms:

  • Updates the .tool-versions file in the current session's temp directory to track active SDK versions
  • Uses a "flush_env.cache" file in the current session's temp directory to prevent redundant environment variable updates

Parameters:

  • opt: SessionEnvOptions controlling whether global environment variables should be included

Returns:

  • SdkEnvs: A slice of SDK environment configurations that need to be applied
  • error: Any error encountered during processing

The returned environment configurations remain valid for the entire shell session until one of the following conditions is met:

  • A new .tool-versions file is encountered
  • The environment is explicitly modified via the `use` command

func (*Manager) Update

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

func (*Manager) WorkspaceToolVersion added in v0.7.0

func (m *Manager) WorkspaceToolVersion() (*toolset.ToolVersion, 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 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 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 {
	Name string

	Plugin *plugin.PluginWrapper
	// 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) ([]*base.Package, error)

func (*Sdk) CheckExists added in v0.4.0

func (b *Sdk) CheckExists(version base.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() base.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 base.Version, location base.Location) (*env.Envs, error)

EnvKeys will make symlink according base.Location.

func (*Sdk) GetLinkPackage added in v0.5.3

func (b *Sdk) GetLinkPackage(version base.Version, location base.Location) (*LocationPackage, error)

GetLinkPackage will make symlink according base.Location and return the sdk package.

func (*Sdk) GetLocalSdkPackage added in v0.4.0

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

func (*Sdk) Install

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

func (*Sdk) Label added in v0.6.7

func (b *Sdk) Label(version base.Version) string

func (*Sdk) List

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

func (*Sdk) MockEnvKeys added in v0.5.3

func (b *Sdk) MockEnvKeys(version base.Version, location base.Location) (*env.Envs, error)

MockEnvKeys It just simulates to get the environment configuration information, if the corresponding location of the package does not exist, then it will return the empty environment information, without calling the EnvKeys hook.

func (*Sdk) ParseLegacyFile added in v0.4.0

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

func (*Sdk) PreUse added in v0.2.5

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

func (*Sdk) ToLinkPackage added in v0.5.3

func (b *Sdk) ToLinkPackage(version base.Version, location base.Location) error

func (*Sdk) Uninstall

func (b *Sdk) Uninstall(version base.Version) (err error)

func (*Sdk) Unuse added in v0.9.1

func (b *Sdk) Unuse(scope base.UseScope) error

Unuse removes the version setting for the SDK from the specified scope

func (*Sdk) Use

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

func (*Sdk) VersionPath

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

type SdkEnv added in v0.5.0

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

type SdkEnvs added in v0.5.0

type SdkEnvs []*SdkEnv

func (*SdkEnvs) ToEnvs added in v0.5.0

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

func (*SdkEnvs) ToExportEnvs added in v0.6.2

func (d *SdkEnvs) ToExportEnvs() env.Vars

type SessionEnvOptions added in v0.6.2

type SessionEnvOptions struct {
	WithGlobalEnv bool
}

type VersionNotExistsError added in v0.6.7

type VersionNotExistsError struct {
	Label string
}

func (*VersionNotExistsError) Error added in v0.6.7

func (e *VersionNotExistsError) Error() string

Jump to

Keyboard shortcuts

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