install

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstallModePortable  = "portable"
	InstallModeInstaller = "installer"
)

Variables

This section is empty.

Functions

func APICacheFilePath added in v1.5.1

func APICacheFilePath(cacheDir, rawURL string) string

func CacheFilePath

func CacheFilePath(cacheDir, url string) string

func Cast

func Cast[T any](value any) (T, error)

func ClientOptions added in v1.5.2

func ClientOptions(opts Options) client.Options

func DetectGUIInstallMode added in v1.5.2

func DetectGUIInstallMode(isGUI bool, fileName string) string

func Download

func Download(url string, out io.Writer, getbar func(size int64) *pb.ProgressBar, opts Options) error

func Get

func Get(url string, disableSSL bool) (*http.Response, error)

func GetWithOptions

func GetWithOptions(url string, opts Options) (*http.Response, error)

func IsGitHubURL

func IsGitHubURL(s string) bool

func IsLocalFile

func IsLocalFile(s string) bool

func IsURL

func IsURL(s string) bool

func NormalizeRepoTarget

func NormalizeRepoTarget(target string) (string, error)

func SelectExtractorAs

func SelectExtractorAs[T any](s *Service, url, tool string, opts *Options) (T, error)

func SetVerbose

func SetVerbose(enabled bool, writer io.Writer)

func VerboseEnabledForTest

func VerboseEnabledForTest() bool

Types

type Archive

type Archive interface {
	Next() (File, error)
	ReadAll() ([]byte, error)
}

func NewSevenZipArchive added in v1.5.1

func NewSevenZipArchive(data []byte, d DecompFn) (Archive, error)

func NewTarArchive

func NewTarArchive(data []byte, decompress DecompFn) (Archive, error)

func NewZipArchive

func NewZipArchive(data []byte, d DecompFn) (Archive, error)

type ArchiveExtractor

type ArchiveExtractor struct {
	File       Chooser
	Ar         ArchiveFn
	Decompress DecompFn
}

func NewArchiveExtractor

func NewArchiveExtractor(file Chooser, ar ArchiveFn, decompress DecompFn) *ArchiveExtractor

func (*ArchiveExtractor) Extract

func (a *ArchiveExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

type ArchiveFn

type ArchiveFn func(data []byte, decomp DecompFn) (Archive, error)

type BinaryChooser

type BinaryChooser struct {
	Tool string
}

func NewBinaryChooser

func NewBinaryChooser(tool string) *BinaryChooser

func (*BinaryChooser) Choose

func (b *BinaryChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*BinaryChooser) String

func (b *BinaryChooser) String() string

type Chooser

type Chooser interface {
	Choose(name string, dir bool, mode fs.FileMode) (direct bool, possible bool)
}

func NewFileChooser added in v1.5.1

func NewFileChooser(expr string) (Chooser, error)

type ConfirmFunc added in v1.5.2

type ConfirmFunc func(file string) (bool, error)

type DecompFn

type DecompFn func(r io.Reader) (io.Reader, error)

type DefaultInstallerLauncher added in v1.5.2

type DefaultInstallerLauncher struct {
	GOOS string
}

func (DefaultInstallerLauncher) LaunchInstaller added in v1.5.2

func (l DefaultInstallerLauncher) LaunchInstaller(path string, kind InstallerKind) error

type Detector

type Detector interface {
	Detect(assets []string) (string, []string, error)
}

type DirectAssetFinder

type DirectAssetFinder struct {
	URL string
}

func (*DirectAssetFinder) Find

func (f *DirectAssetFinder) Find() ([]string, error)

type ExtractedFile

type ExtractedFile struct {
	Name        string
	ArchiveName string

	Extract func(to string) error
	Dir     bool
	// contains filtered or unexported fields
}

func (ExtractedFile) Mode

func (e ExtractedFile) Mode() fs.FileMode

func (ExtractedFile) String

func (e ExtractedFile) String() string

type Extractor

type Extractor interface {
	Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)
}

func NewExtractor

func NewExtractor(filename string, tool string, chooser Chooser) Extractor

type File

type File struct {
	Name     string
	LinkName string
	Mode     fs.FileMode
	Type     FileType
}

func (File) Dir

func (f File) Dir() bool

type FileType

type FileType byte
const (
	TypeNormal FileType = iota
	TypeDir
	TypeLink
	TypeSymlink
	TypeOther
)

type Finder

type Finder interface {
	Find() ([]string, error)
}

type GlobChooser

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

func NewGlobChooser

func NewGlobChooser(gl string) (*GlobChooser, error)

func (*GlobChooser) Choose

func (g *GlobChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*GlobChooser) String

func (g *GlobChooser) String() string

type HTTPGetterFunc

type HTTPGetterFunc func(url string) (*http.Response, error)

func NewHTTPGetter

func NewHTTPGetter(opts Options) HTTPGetterFunc

func (HTTPGetterFunc) Get

func (f HTTPGetterFunc) Get(url string) (*http.Response, error)

type InstallRunner

type InstallRunner struct {
	Service                *Service
	InstalledLoad          func() (map[string]string, map[string]string, error)
	Prompt                 PromptFunc
	ConfirmLaunchInstaller ConfirmFunc
	InstallerLauncher      InstallerLauncher
	Stdout                 io.Writer
	Stderr                 io.Writer
}

func NewRunner

func NewRunner(service *Service) *InstallRunner

func (*InstallRunner) Run

func (r *InstallRunner) Run(target string, opts Options) (RunResult, error)

type InstallerKind added in v1.5.2

type InstallerKind string
const (
	InstallerKindUnknown InstallerKind = ""
	InstallerKindMSI     InstallerKind = "msi"
	InstallerKindEXE     InstallerKind = "exe"
)

func DetectInstallerKind added in v1.5.2

func DetectInstallerKind(fileName string) InstallerKind

type InstallerLauncher added in v1.5.2

type InstallerLauncher interface {
	LaunchInstaller(path string, kind InstallerKind) error
}

type LiteralFileChooser

type LiteralFileChooser struct {
	File string
}

func (*LiteralFileChooser) Choose

func (l *LiteralFileChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*LiteralFileChooser) String

func (l *LiteralFileChooser) String() string

type MultiChooser added in v1.5.1

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

func (*MultiChooser) Choose added in v1.5.1

func (m *MultiChooser) Choose(name string, dir bool, mode fs.FileMode) (bool, bool)

func (*MultiChooser) String added in v1.5.1

func (m *MultiChooser) String() string

type Options

type Options struct {
	Tag               string
	Prerelease        bool
	Name              string
	Verbose           bool
	Source            bool
	Output            string
	OutputExplicit    bool
	GuiTarget         string
	IsGUI             bool
	InstallMode       string
	CacheDir          string
	ProxyURL          string
	APICacheEnabled   bool
	APICacheDir       string
	APICacheTime      int
	GhproxyEnabled    bool
	GhproxyHostURL    string
	GhproxySupportAPI bool
	GhproxyFallbacks  []string
	System            string
	ExtractFile       string
	All               bool
	Quiet             bool
	DownloadOnly      bool
	UpgradeOnly       bool
	Asset             []string
	Hash              bool
	Verify            string
	DisableSSL        bool
}

type PromptFunc

type PromptFunc func(choices []string) (int, error)

type RateLimit

type RateLimit = client.RateLimit

func GetRateLimit

func GetRateLimit(opts Options) (RateLimit, error)

type RunResult

type RunResult struct {
	URL            string
	Tool           string
	Asset          string
	ExtractedFiles []string
	IsGUI          bool
	InstallMode    string
	InstallerFile  string
}

type Runner

type Runner interface {
	Run(target string, opts Options) (RunResult, error)
}

type Service

type Service struct {
	BinaryModTime       func(tool, output string) time.Time
	GitHubGetter        sourcegithub.HTTPGetter
	GitHubGetterFactory func(opts Options) sourcegithub.HTTPGetter

	AllDetectorFactory    func() Detector
	SystemDetectorFactory func(goos, goarch string) (Detector, error)
	AssetDetectorFactory  func(asset string, anti bool, re *regexp.Regexp) Detector
	DetectorChainFactory  func(detectors []Detector, system Detector) Detector

	Sha256VerifierFactory      func(expected string) (Verifier, error)
	Sha256AssetVerifierFactory func(assetURL string, opts Options) Verifier
	Sha256PrinterFactory       func() Verifier
	NoVerifierFactory          func() Verifier

	DownloadOnlyExtractorFactory func(name string) any
	GlobChooserFactory           func(pattern string) (any, error)
	BinaryChooserFactory         func(tool string) any
	ExtractorFactory             func(filename, tool string, chooser any) any
}

func NewDefaultService

func NewDefaultService(githubGetter sourcegithub.HTTPGetter, binaryModTime func(tool, output string) time.Time) *Service

func NewService

func NewService() *Service

func (*Service) SelectDetector

func (s *Service) SelectDetector(opts *Options) (Detector, error)

func (*Service) SelectExtractor

func (s *Service) SelectExtractor(url, tool string, opts *Options) (any, error)

func (*Service) SelectFinder

func (s *Service) SelectFinder(target string, opts *Options) (Finder, string, error)

func (*Service) SelectVerifier

func (s *Service) SelectVerifier(sumAsset string, opts *Options) (Verifier, error)

type SevenZipArchive added in v1.5.1

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

func (*SevenZipArchive) Next added in v1.5.1

func (z *SevenZipArchive) Next() (File, error)

func (*SevenZipArchive) ReadAll added in v1.5.1

func (z *SevenZipArchive) ReadAll() ([]byte, error)

type SingleFileExtractor

type SingleFileExtractor struct {
	Rename     string
	Name       string
	Decompress func(r io.Reader) (io.Reader, error)
}

func NewDownloadOnlyExtractor

func NewDownloadOnlyExtractor(name string) *SingleFileExtractor

func (*SingleFileExtractor) Extract

func (s *SingleFileExtractor) Extract(data []byte, multiple bool) (ExtractedFile, []ExtractedFile, error)

type TarArchive

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

func (*TarArchive) Next

func (t *TarArchive) Next() (File, error)

func (*TarArchive) ReadAll

func (t *TarArchive) ReadAll() ([]byte, error)

type TargetKind

type TargetKind string
const (
	TargetUnknown   TargetKind = "unknown"
	TargetRepo      TargetKind = "repo"
	TargetGitHubURL TargetKind = "github_url"
	TargetDirectURL TargetKind = "direct_url"
	TargetLocalFile TargetKind = "local_file"
)

func DetectTargetKind

func DetectTargetKind(target string) TargetKind

type Verifier

type Verifier interface {
	Verify(b []byte) error
}

type ZipArchive

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

func (*ZipArchive) Next

func (z *ZipArchive) Next() (File, error)

func (*ZipArchive) ReadAll

func (z *ZipArchive) ReadAll() ([]byte, error)

Jump to

Keyboard shortcuts

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