usrbin

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 2

README

usrbin-go

This is the Go SDK for usrbin.app.

Design Goals

  • High compatibility with go projects. Avoid the go mod hell that some find themselves in.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownArchiveType        = errors.New("unknown archive type")
	ErrNoMatchingArchitectures   = errors.New("no matching architectures")
	ErrNoAssets                  = errors.New("no assets")
	ErrChecksumMismatch          = errors.New("checksum mismatch")
	ErrUnsupportedChecksumFormat = errors.New("unsupported checksum format")
)
View Source
var ErrReleaseNotFound = errors.New("release not found")

Functions

This section is empty.

Types

type ExternalPackageManager

type ExternalPackageManager interface {
	IsInstalled() (bool, error)
	UpgradeCommand() string
}

func NewHomebrewExternalPackageManager

func NewHomebrewExternalPackageManager(formula string) ExternalPackageManager

type GitHubUpdateChecker

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

func (GitHubUpdateChecker) DownloadVersion

func (c GitHubUpdateChecker) DownloadVersion(version string, requireChecksumMatch bool) (string, error)

DownloadVersion will download and extract the specific version, returning a path to the extracted file in the archive it's the responsibility of the caller to clean up the extracted file

func (GitHubUpdateChecker) GetLatestVersion

func (c GitHubUpdateChecker) GetLatestVersion() (*VersionInfo, error)

GetLatestVersion will return the latest version from the git repository

type HomebrewExternalPackageManager

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

func (HomebrewExternalPackageManager) IsInstalled

func (m HomebrewExternalPackageManager) IsInstalled() (bool, error)

IsInstalled will return true if the formula is installed using homebrew

func (HomebrewExternalPackageManager) UpgradeCommand

func (m HomebrewExternalPackageManager) UpgradeCommand() string

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Option

type Option func(*SDK) error

Option is a functional option for configuring the client

func UsingGitHubUpdateChecker

func UsingGitHubUpdateChecker(repo string) Option

Using GitHubUpdateChecker will cause the repo passed in to be the source of truth when checking for new updates

func UsingHomebrewFormula

func UsingHomebrewFormula(formula string) Option

UsingHomebrewFormula will cause the formula passed in to be used when checking if this CLI was installed using homebrew

func UsingLogger

func UsingLogger(logger Logger) Option

UsingLogger can be set if you want to get log output from this sdk By default no log output is emitted.

type SDK

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

func New

func New(version string, opts ...Option) (*SDK, error)

func (SDK) CanSupportUpgrade

func (s SDK) CanSupportUpgrade() (bool, error)

CanSupportUpgrade

func (SDK) ExternalUpgradeCommand

func (s SDK) ExternalUpgradeCommand() string

func (SDK) GetUpdateInfo

func (s SDK) GetUpdateInfo() (*UpdateInfo, error)

GetUpdateInfo will return the latest version

func (SDK) Upgrade

func (s SDK) Upgrade() error

Upgrade is the entrypoint that the app will use to perform an in-place upgrade we need to assume that the app is running and we are running in the main thread

type UpdateChecker

type UpdateChecker interface {
	GetLatestVersion() (*VersionInfo, error)
	DownloadVersion(version string, requireChecksumMatch bool) (string, error)
}

func NewGitHubUpdateChecker

func NewGitHubUpdateChecker(fqRepo string) UpdateChecker

type UpdateInfo

type UpdateInfo struct {
	LatestVersion   string    `json:"latestVersion"`
	LatestReleaseAt time.Time `json:"latestReleaseAt"`

	CheckedAt *time.Time `json:"checkedAt"`

	CanUpgradeInPlace      bool   `json:"canUpgradeInPlace"`
	ExternalUpgradeCommand string `json:"externalUpgradeCommand"`
}

type VersionInfo

type VersionInfo struct {
	Version    string    `json:"version"`
	ReleasedAt time.Time `json:"releasedAt"`
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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