lib

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireInstallLock added in v0.1.4

func AcquireInstallLock() func()

AcquireInstallLock creates an exclusive lock file to prevent concurrent installations. Returns a release function that removes the lock.

func AddRecent

func AddRecent(version, installPath string)

AddRecent adds version to the RECENT file (capped at maxRecentVersions).

func CheckSymlink(path string) bool

CheckSymlink returns true if the given path is a symlink.

func ConvertExecutableExt

func ConvertExecutableExt(path string) string

ConvertExecutableExt appends ".exe" on Windows if not already present.

func CreateDirIfNotExist

func CreateDirIfNotExist(path string)

CreateDirIfNotExist creates a directory (and all parents) if it does not exist.

func CreateSymlink(src, dest string)

CreateSymlink creates a symlink from src to dest using absolute paths.

func DirExists

func DirExists(path string) bool

DirExists returns true if a directory exists at the given path.

func FileExists

func FileExists(path string) bool

FileExists returns true if a file exists at the given path.

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory returns the current working directory.

func GetHomeDirectory

func GetHomeDirectory() string

GetHomeDirectory returns the current user's home directory.

func GetInstallLocation

func GetInstallLocation() string

GetInstallLocation returns (and creates if necessary) the directory where versioned terramate binaries are stored (~/.terramate.versions/).

func GetInstallLocationWithBase

func GetInstallLocationWithBase(installPath string) string

GetInstallLocationWithBase returns the directory where versioned terramate binaries are stored, rooted at installPath or the user's home when empty.

func GetRecentVersions

func GetRecentVersions() ([]string, error)

GetRecentVersions returns the recently used versions with a " *recent" suffix.

func GetRecentVersionsFrom

func GetRecentVersionsFrom(installPath string) ([]string, error)

GetRecentVersionsFrom returns recently used versions from a custom install base.

func GetVersionList

func GetVersionList(includePrerelease bool) ([]string, error)

GetVersionList fetches the list of available terramate versions from the GitHub Releases API and returns them sorted newest-first. Set includePrerelease to true to also include pre-release / RC versions.

func GetVersionListFromURL

func GetVersionListFromURL(url string, includePrerelease bool) ([]string, error)

GetVersionListFromURL fetches versions from a custom releases API URL.

func Install

func Install(version, binPath string) string

Install downloads (if necessary) and activates the requested version. It returns the path to the active symlink.

func InstallWithOptions

func InstallWithOptions(version string, options InstallOptions) string

InstallWithOptions downloads (if necessary) and activates the requested version.

func InstallableBinLocation

func InstallableBinLocation(userBinPath string) string

InstallableBinLocation returns the effective install path for the terramate binary symlink. It tries each candidate in order, falling back to ~/bin (creating it if necessary) when the primary location is not writable.

func IsDirWritable

func IsDirWritable(path string) bool

IsDirWritable returns true if the given directory is writable.

func IsInPath added in v0.1.4

func IsInPath(dir string) bool

IsInPath reports whether dir is present in the current PATH environment.

func LatestMatchingVersion

func LatestMatchingVersion(list []string, requested string) (string, error)

LatestMatchingVersion returns the newest version matching a prefix or exact version.

func LatestVersion

func LatestVersion(list []string) (string, error)

LatestVersion returns the newest version from the provided list.

func Path

func Path(p string) string

Path returns the directory component of the given file path.

func ReadLines

func ReadLines(path string) ([]string, error)

ReadLines reads all lines from a file, trimming whitespace.

func RemoveFile

func RemoveFile(path string)

RemoveFile removes a file at the given path.

func RemoveSymlink(path string)

RemoveSymlink removes the symlink at the given path.

func RenameFile

func RenameFile(src, dest string)

RenameFile renames src to dest.

func RetrieveFileContents

func RetrieveFileContents(path string) string

RetrieveFileContents reads the first non-empty line from a file.

func ValidVersionFormat

func ValidVersionFormat(version string) bool

ValidVersionFormat returns true if the given string looks like a valid semver.

func VersionExist

func VersionExist(version string, list []string) bool

VersionExist returns true if the given version is present in the list.

func WriteLines

func WriteLines(lines []string, path string)

WriteLines writes a slice of strings to a file, one per line.

Types

type InstallOptions

type InstallOptions struct {
	Arch            string
	BinPath         string
	DownloadBaseURL string
	DryRun          bool
	InstallPath     string
}

InstallOptions customizes version download and activation.

Jump to

Keyboard shortcuts

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