Documentation
¶
Index ¶
- Variables
- func CalculateDirSize(dirPath string) int64
- func FindToolVersionFiles(rootDirs []string) ([]string, error)
- func FindToolVersionFilesWithProgress(rootDirs []string, onProgress func(currentDir string, foundCount int)) ([]string, error)
- func GetASDFDataDir(homeDir string) string
- func ParseASDFListOutput(output string) (map[string][]string, error)
- func ParseAndMergeToolVersions(filePaths []string) (ToolVersions, []FileProtectionSummary, error)
- func WriteToolVersions(filePath string, tv ToolVersions) error
- type CleanupTarget
- type FileProtectionSummary
- type MissingRequirement
- type ToolVersions
Constants ¶
This section is empty.
Variables ¶
var DefaultIgnoredDirs = []string{
".git",
".github",
".vscode",
".idea",
"node_modules",
"vendor",
".venv",
"venv",
"target",
"dist",
"build",
".cache",
".asdf",
".cargo",
}
DefaultIgnoredDirs is a list of directory names to skip during recursive scanning for .tool-versions.
Functions ¶
func CalculateDirSize ¶
CalculateDirSize recursively calculates the size in bytes of a directory, ignoring symbolic links to prevent double counting.
func FindToolVersionFiles ¶
FindToolVersionFiles recursively scans the given root directories for .tool-versions files, skipping common build, dependency, and VCS directories.
func FindToolVersionFilesWithProgress ¶ added in v1.40.0
func FindToolVersionFilesWithProgress( rootDirs []string, onProgress func(currentDir string, foundCount int), ) ([]string, error)
FindToolVersionFilesWithProgress recursively scans the given root directories for .tool-versions files, invoking onProgress (if non-nil) whenever a directory is inspected or a file is found.
func GetASDFDataDir ¶
GetASDFDataDir resolves the location of the asdf data directory.
func ParseASDFListOutput ¶
ParseASDFListOutput parses the text output of `asdf list` into a map of plugin names to slices of installed versions.
func ParseAndMergeToolVersions ¶
func ParseAndMergeToolVersions(filePaths []string) (ToolVersions, []FileProtectionSummary, error)
ParseAndMergeToolVersions parses a list of .tool-versions files and merges all protected versions into a single ToolVersions map. It also returns per-file protection summaries.
func WriteToolVersions ¶
func WriteToolVersions(filePath string, tv ToolVersions) error
WriteToolVersions updates or rewrites a .tool-versions file with the specified ToolVersions map.
Types ¶
type CleanupTarget ¶
CleanupTarget represents an installed plugin version eligible for removal.
func FilterRemovableVersions ¶
func FilterRemovableVersions( installed map[string][]string, protected ToolVersions, targetPlugin, asdfDataDir string, ) []CleanupTarget
FilterRemovableVersions compares installed versions against protected versions in .tool-versions and returns a list of CleanupTargets eligible for removal. If targetPlugin is non-empty, only versions for that specific plugin are returned. If asdfDataDir is non-empty, disk size for each removable target will be calculated.
func (CleanupTarget) FormatSize ¶
func (c CleanupTarget) FormatSize() string
FormatSize returns a human-readable string representation of SizeBytes (e.g., "12.4 MB").
func (CleanupTarget) FormatTargetLabel ¶
func (c CleanupTarget) FormatTargetLabel() string
FormatTargetLabel returns a user-friendly label for a CleanupTarget including disk size, e.g. "nodejs @ 20.19.5 (112.4 MB)".
type FileProtectionSummary ¶
type FileProtectionSummary struct {
FilePath string
Protected ToolVersions
}
FileProtectionSummary tracks versions protected by a specific .tool-versions file.
func (FileProtectionSummary) FormatFileSummary ¶
func (s FileProtectionSummary) FormatFileSummary(homeDir string) string
FormatFileSummary returns a formatted label describing protected versions in a file.
type MissingRequirement ¶
MissingRequirement represents a version required by a .tool-versions file that is not installed.
func CheckMissingRequirements ¶
func CheckMissingRequirements(summaries []FileProtectionSummary, installed map[string][]string) []MissingRequirement
CheckMissingRequirements compares requirements across all discovered .tool-versions files against installed versions, returning any missing requirements.
func (MissingRequirement) FormatSource ¶
func (m MissingRequirement) FormatSource(homeDir string) string
FormatSource returns a user-friendly display path for the source file.
type ToolVersions ¶
ToolVersions maps plugin names to their protected version strings as defined in .tool-versions.
func ParseToolVersions ¶
func ParseToolVersions(r io.Reader) (ToolVersions, error)
ParseToolVersions reads from an io.Reader (such as a .tool-versions file) and returns a ToolVersions map of plugin -> protected versions.
func ParseToolVersionsFile ¶
func ParseToolVersionsFile(filePath string) (ToolVersions, error)
ParseToolVersionsFile reads a .tool-versions file from the given path and returns a ToolVersions map of plugin -> protected versions.