stew

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileHash added in v0.4.0

func CalculateFileHash(filePath string) (string, error)

func CatchAndExit

func CatchAndExit(err error)

CatchAndExit will catch errors and immediately exit

func Contains

func Contains[T comparable](slice []T, target T) (int, bool)

Contains checks if a string slice contains a given target

func DeleteAssetAndBinary

func DeleteAssetAndBinary(stewPkgPath, stewBinPath, asset, binary string) error

DeleteAssetAndBinary will delete the asset from the ~/.stew/pkg path and delete the binary from the ~/.stew/bin path

func DetectAsset

func DetectAsset(userOS string, userArch string, releaseAssets []string) (string, error)

DetectAsset will automatically detect a release asset matching your systems OS/arch or prompt you to manually select an asset

func DownloadFile

func DownloadFile(downloadPath string, url string) error

DownloadFile will download a file from url to a given path

func FindBinaryInLockFile added in v0.4.0

func FindBinaryInLockFile(lockFile LockFile, binaryName string) (int, bool)

func FormatSearchResults added in v0.2.0

func FormatSearchResults(ghSearch GithubSearch) []string

FormatSearchResults formats the GitHub search results for the terminal UI

func GetDefaultStewBinPath added in v0.3.0

func GetDefaultStewBinPath(userOS string) (string, error)

GetDefaultStewBinPath will return the default path where binaries are installed by stew

func GetDefaultStewPath added in v0.3.0

func GetDefaultStewPath(userOS string) (string, error)

GetDefaultStewPath will return the default path to the top-level stew directory

func GetGithubReleasesAssets

func GetGithubReleasesAssets(ghProject GithubProject, tag string) ([]string, error)

GetGithubReleasesAssets gets a string slice of the assets for a GithubRelease

func GetGithubReleasesTags

func GetGithubReleasesTags(ghProject GithubProject) ([]string, error)

GetGithubReleasesTags gets a string slice of the releases for a GithubProject

func GetStewConfigFilePath added in v0.3.0

func GetStewConfigFilePath(userOS string) (string, error)

GetStewConfigFilePath will return the stew config file path

func Initialize added in v0.3.0

func Initialize() (string, string, StewConfig, SystemInfo, error)

Initialize returns pertinent initialization information like OS, arch, configuration, and system info

func InstallBinary

func InstallBinary(downloadedFilePath string, repo string, systemInfo SystemInfo, lockFile *LockFile, overwriteFromUpgrade bool, desiredBinaryRename, expectedBinaryHash string) (string, string, error)

InstallBinary will extract the binary and copy it to the ~/.stew/bin path

func PathExists

func PathExists(path string) (bool, error)

PathExists checks if a given path exists

func PromptConfig added in v0.3.0

func PromptConfig(suggestedStewPath, suggestedStewBinPath string) (string, string, error)

PromptConfig launches an interactive UI for setting the stew config values. It returns the resolved stewPath and stewBinPath.

func PromptInput added in v0.3.0

func PromptInput(message string, defaultInput string) (string, error)

PromptInput launches the input UI

func PromptRenameBinary added in v0.3.0

func PromptRenameBinary(originalBinaryName string) (string, error)

PromptRenameBinary takes in the original name of the binary and will return the new name of the binary.

func PromptSelect

func PromptSelect(message string, options []string) (string, error)

PromptSelect launches the selection UI

func ResolvePath added in v0.3.0

func ResolvePath(filePath string) (string, error)

ResolvePath will resolve the full path for an input path

func ValidateCLIInput

func ValidateCLIInput(cliInput string) error

ValidateCLIInput makes sure the CLI input isn't empty

func ValidateGithubSearchQuery added in v0.2.0

func ValidateGithubSearchQuery(searchQuery string) error

ValidateGithubSearchQuery makes sure the GitHub search query is valid

func ValidateStewBinPath added in v0.3.0

func ValidateStewBinPath(stewBinPath, pathVariable string) bool

func WarningPromptConfirm

func WarningPromptConfirm(message string) (bool, error)

WarningPromptConfirm launches the confirm UI with a warning styling

func WarningPromptSelect

func WarningPromptSelect(message string, options []string) (string, error)

WarningPromptSelect launches the selection UI with a warning styling

func WriteLockFileJSON

func WriteLockFileJSON(lockFileJSON LockFile, outputPath string) error

WriteLockFileJSON will write the lockfile JSON file

func WriteStewConfigJSON added in v0.3.0

func WriteStewConfigJSON(stewConfigFileJSON StewConfig, outputPath string) error

WriteStewConfigJSON will write the config JSON file

Types

type AbortBinaryOverwriteError

type AbortBinaryOverwriteError struct {
	Binary string
}

AbortBinaryOverwriteError occurs if the overwrite of a binary is aborted

func (AbortBinaryOverwriteError) Error

type AlreadyInstalledLatestTagError

type AlreadyInstalledLatestTagError struct {
	Tag string
}

AlreadyInstalledLatestTagError occurs if you try to upgrade a binary but the latest version is already installed

func (AlreadyInstalledLatestTagError) Error

type AssetsNotFoundError

type AssetsNotFoundError struct {
	Tag string
}

AssetsNotFoundError occurs if no assets are found for a GitHub release

func (AssetsNotFoundError) Error

func (e AssetsNotFoundError) Error() string

type BinaryMismatchError added in v0.4.0

type BinaryMismatchError struct {
	BinaryName string
}

func (BinaryMismatchError) Error added in v0.4.0

func (e BinaryMismatchError) Error() string

type BinaryNotInstalledError

type BinaryNotInstalledError struct {
	Binary string
}

BinaryNotInstalledError occurs if you try to operate on a binary that is not installed

func (BinaryNotInstalledError) Error

func (e BinaryNotInstalledError) Error() string

type CLIFlagAndInputError added in v0.2.0

type CLIFlagAndInputError struct {
}

CLIFlagAndInputError occurs if you try to use a CLI flag with a CLI input at the same time

func (CLIFlagAndInputError) Error added in v0.2.0

func (e CLIFlagAndInputError) Error() string

type EmptyCLIInputError

type EmptyCLIInputError struct {
}

EmptyCLIInputError occurs if the CLI input is empty

func (EmptyCLIInputError) Error

func (e EmptyCLIInputError) Error() string

type ExecutableFileInfo added in v0.4.0

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

type ExitUserSelectionError

type ExitUserSelectionError struct {
	Err error
}

ExitUserSelectionError occurs when exiting from the terminal UI

func (ExitUserSelectionError) Error

func (e ExitUserSelectionError) Error() string

type GithubAPIResponse

type GithubAPIResponse []GithubRelease

GithubAPIResponse is the response from the GitHub releases API

type GithubAsset

type GithubAsset struct {
	Name        string `json:"name"`
	DownloadURL string `json:"url"`
	Size        int    `json:"size"`
	ContentType string `json:"content_type"`
}

GithubAsset contains information about a specific GitHub asset

type GithubProject

type GithubProject struct {
	Owner    string
	Repo     string
	Releases GithubAPIResponse
}

GithubProject contains information about the GitHub project including GitHub releases

func NewGithubProject

func NewGithubProject(owner, repo string) (GithubProject, error)

NewGithubProject creates a new instance of the GithubProject struct

type GithubRelease

type GithubRelease struct {
	TagName string        `json:"tag_name"`
	Assets  []GithubAsset `json:"assets"`
}

GithubRelease contains information about a GitHub release, including the associated assets

type GithubSearch added in v0.2.0

type GithubSearch struct {
	SearchQuery string
	Count       int                  `json:"total_count"`
	Items       []GithubSearchResult `json:"items"`
}

GithubSearch contains information about the GitHub search including the GitHub search results

func NewGithubSearch added in v0.2.0

func NewGithubSearch(searchQuery string) (GithubSearch, error)

NewGithubSearch creates a new instance of the GithubSearch struct

type GithubSearchResult added in v0.2.0

type GithubSearchResult struct {
	FullName    string `json:"full_name"`
	Stars       int    `json:"stargazers_count"`
	Language    string `json:"language"`
	Description string `json:"description"`
}

GithubSearchResult contains information about the GitHub search result

type IndexOutOfBoundsInLockfileError

type IndexOutOfBoundsInLockfileError struct {
}

IndexOutOfBoundsInLockfileError occurs if you try to access an out-of-bounds index in the lockfile packages

func (IndexOutOfBoundsInLockfileError) Error

type InstalledFromURLError

type InstalledFromURLError struct {
	Binary string
}

InstalledFromURLError occurs if you try to perform GitHub specific actions on a binary installed directly from a URL

func (InstalledFromURLError) Error

func (e InstalledFromURLError) Error() string

type InvalidGithubSearchQueryError added in v0.2.0

type InvalidGithubSearchQueryError struct {
	SearchQuery string
}

InvalidGithubSearchQueryError occurs if the GitHub search query contains invalid characters

func (InvalidGithubSearchQueryError) Error added in v0.2.0

type LockFile

type LockFile struct {
	Os       string        `json:"os"`
	Arch     string        `json:"arch"`
	Packages []PackageData `json:"packages"`
}

LockFile contains all the data for the lockfile

func NewLockFile

func NewLockFile(stewLockFilePath, userOS, userArch string) (LockFile, error)

NewLockFile creates a new instance of the LockFile struct

type NoBinariesInstalledError

type NoBinariesInstalledError struct {
}

NoBinariesInstalledError occurs if you try to operate on a binary but no binaries are installed

func (NoBinariesInstalledError) Error

func (e NoBinariesInstalledError) Error() string

type NoGithubSearchResultsError added in v0.2.0

type NoGithubSearchResultsError struct {
	SearchQuery string
}

NoGithubSearchResultsError occurs if the GitHub search API returns no items

func (NoGithubSearchResultsError) Error added in v0.2.0

type NoPackagesInLockfileError

type NoPackagesInLockfileError struct {
}

NoPackagesInLockfileError occurs if you try to remove packages from a lockfile without any packages

func (NoPackagesInLockfileError) Error

type NonZeroStatusCodeDownloadError

type NonZeroStatusCodeDownloadError struct {
	StatusCode int
}

NonZeroStatusCodeDownloadError occurs if a non-zero status code is received when trying to download a file

func (NonZeroStatusCodeDownloadError) Error

type NonZeroStatusCodeError

type NonZeroStatusCodeError struct {
	StatusCode int
}

NonZeroStatusCodeError occurs if a non-zero status code is received from an HTTP request

func (NonZeroStatusCodeError) Error

func (e NonZeroStatusCodeError) Error() string

type PackageData

type PackageData struct {
	Source     string `json:"source"`
	Owner      string `json:"owner"`
	Repo       string `json:"repo"`
	Tag        string `json:"tag"`
	Asset      string `json:"asset"`
	Binary     string `json:"binary"`
	URL        string `json:"url"`
	BinaryHash string `json:"binaryHash"`
}

PackageData contains the information for an installed binary

func ParseCLIInput

func ParseCLIInput(cliInput string) (PackageData, error)

ParseCLIInput creates a new instance of the PackageData struct

func ReadStewLockFileContents added in v0.4.0

func ReadStewLockFileContents(lockFilePath string) ([]PackageData, error)

ReadStewLockFileContents will read the contents of the Stewfile.lock.json

func ReadStewfileContents

func ReadStewfileContents(stewfilePath string) ([]PackageData, error)

ReadStewfileContents will read the contents of the Stewfile

func RemovePackage

func RemovePackage(pkgs []PackageData, index int) ([]PackageData, error)

RemovePackage will remove a package from a LockFile.Packages slice

type ReleasesNotFoundError

type ReleasesNotFoundError struct {
	Owner string
	Repo  string
}

ReleasesNotFoundError occurs if no releases are found for a GitHub repo

func (ReleasesNotFoundError) Error

func (e ReleasesNotFoundError) Error() string

type StewConfig added in v0.3.0

type StewConfig struct {
	StewPath    string `json:"stewPath"`
	StewBinPath string `json:"stewBinPath"`
}

StewConfig contains all the stew configuration data

func NewStewConfig added in v0.3.0

func NewStewConfig(userOS string) (StewConfig, error)

NewStewConfig creates a new instance of the StewConfig struct

func ReadStewConfigJSON added in v0.4.0

func ReadStewConfigJSON(stewConfigFilePath string) (StewConfig, error)

type StewpathNotFoundError added in v0.2.0

type StewpathNotFoundError struct {
	StewPath string
}

StewpathNotFoundError occurs if the ~/.stew path is not found

func (StewpathNotFoundError) Error added in v0.2.0

func (e StewpathNotFoundError) Error() string

type SystemInfo

type SystemInfo struct {
	StewPath         string
	StewBinPath      string
	StewPkgPath      string
	StewLockFilePath string
	StewTmpPath      string
}

SystemInfo contains system specific info like OS, arch, and ~/.stew paths

func NewSystemInfo

func NewSystemInfo(stewConfig StewConfig) SystemInfo

NewSystemInfo creates a new instance of the SystemInfo struct

type UnrecognizedInputError

type UnrecognizedInputError struct {
}

UnrecognizedInputError occurs if the input is not recognized as a URL or GitHub repo

func (UnrecognizedInputError) Error

func (e UnrecognizedInputError) Error() string

Jump to

Keyboard shortcuts

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