Documentation
¶
Index ¶
- Variables
- func DefaultDownload(url string) ([]byte, error)
- func RunWithSpinner(name, version string, fn func() error) error
- func ShowChecklist(tools []Tool) []int
- type Deps
- type InstallResult
- type Installer
- func (ins *Installer) InstallAll(tools []Tool, selectedIdx []int, deps *Deps) InstallResult
- func (ins *Installer) InstallBinary(t Tool, d *Deps) error
- func (i *Installer) InstallGoInstall(t Tool, d *Deps) error
- func (ins *Installer) Uninstall(tools []Tool, d *Deps) error
- func (i *Installer) Verify(t Tool, d *Deps) error
- type Mode
- type Tool
Constants ¶
This section is empty.
Variables ¶
var GoVersion string
var Tools = []Tool{ {Mode: GoInstall, Name: "tinygoinstall", Source: "github.com/tinywasm/tinygo/cmd/tinygoinstall", ModuleVersion: "v0.0.7", Version: "0.40.1", VerifyBinary: "tinygo", Required: true}, {Mode: Binary, Name: "tinywasm-cli", Source: "https://github.com/tinywasm/tinywasm", Version: "0.1.0", Required: false}, {Mode: Binary, Name: "tinywasm-server", Source: "https://github.com/tinywasm/tinywasm", Version: "0.1.0", Required: false, DependsOn: "tinywasm-cli"}, }
Functions ¶
func DefaultDownload ¶
DefaultDownload is a production implementation of Download
func RunWithSpinner ¶
RunWithSpinner runs the given function while displaying a spinner. version is shown in the success line: "✅ name — version"
func ShowChecklist ¶
ShowChecklist displays optional tools as a numbered list and returns the selected indices. Reads plain text input — no ANSI codes or raw mode — so it works correctly in PowerShell, SSH sessions, and any terminal.
Types ¶
type Deps ¶
type Deps struct {
RunCmd func(name string, args ...string) ([]byte, error) // exec.Command
Download func(url string) ([]byte, error) // net/http GET
WriteFile func(path string, data []byte, perm os.FileMode) error // os.WriteFile
RemoveFile func(path string) error // os.Remove
LookPath func(name string) (string, error) // exec.LookPath
Checklist func(tools []Tool) []int // interactive checklist
}
Deps — all external operations behind interfaces for testability
type InstallResult ¶
InstallResult holds counts for the summary line.
type Installer ¶
type Installer struct{}
func (*Installer) InstallAll ¶
func (ins *Installer) InstallAll(tools []Tool, selectedIdx []int, deps *Deps) InstallResult
InstallAll installs required tools + the optional tools at the given indices. Returns counts for summary output. On required tool failure, writes to stderr and exits.
func (*Installer) InstallBinary ¶
InstallBinary handles the installation of tools from GitHub releases.
func (*Installer) InstallGoInstall ¶
InstallGoInstall installs a tool via `go install source@moduleVersion`, then runs the installed binary with `-version t.Version` to perform the actual tool installation (e.g. tinygoinstall installs TinyGo).
type Tool ¶
type Tool struct {
Mode Mode
Name string
Source string // module path (GoInstall) or GitHub repo (Binary)
ModuleVersion string // Go module version for go install (GoInstall only); defaults to "latest"
Version string // tool version to install and verify (e.g. TinyGo 0.40.1)
VerifyBinary string // binary to run for verification; defaults to Name if empty
Required bool // true = always install; false = prompt user
DependsOn string // "" = no dependency; "git" = requires git installed first
}