installer

package module
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 13 Imported by: 0

README

tinywasm/installer

Single command to set up a complete tinywasm development environment.

Quick start

Linux / macOS
curl -fsSL https://raw.githubusercontent.com/tinywasm/installer/main/scripts/install.sh | bash
Windows (PowerShell as Admin)
irm https://raw.githubusercontent.com/tinywasm/installer/main/scripts/install.ps1 | iex

What it does

  1. Installs Go (version pinned in go_version.conf)
  2. Builds and runs the Go installer binary
  3. Shows an interactive checklist of optional tools
  4. Installs all required + selected tools with progress spinner
  5. Verifies each tool after installation

Tools

Tool Mode Required Depends on
tinygoinstall GoInstall yes
tinywasm-cli Binary no
tinywasm-server Binary no tinywasm-cli

Required tools install automatically. Optional tools are shown in an interactive checklist before installation begins.

Uninstall

# Remove a specific tool
UNINSTALL=tinygo curl -fsSL .../install.sh | bash

# Remove all tools
UNINSTALL=all curl -fsSL .../install.sh | bash

Requirements

  • Linux / macOS: bash, curl
  • Windows: PowerShell 5.1+
  • Internet connection

Go is installed automatically — no need to have it pre-installed.

Adding a new tool

Add one entry to the tools slice in installer.go:

var tools = []Tool{
    // existing tools...
    {Mode: Binary, Name: "mytool", Source: "https://github.com/org/mytool", Version: "1.0.0", Required: false},
}

If the tool depends on another:

{Mode: Binary, Name: "gh", Source: "https://github.com/cli/cli", Version: "2.65.0", Required: false, DependsOn: "git"},

How it works

Phase 1: bash / ps1
├── Read Go version from go_version.conf
├── Install Go via goinstall script
└── go install tinywasm/installer → run installer

Phase 2: Go binary
├── Show checklist of optional tools
├── Install required + selected tools
├── Verify each tool
└── Print summary

Testing

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoVersion string
View Source
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

func DefaultDownload(url string) ([]byte, error)

DefaultDownload is a production implementation of Download

func ResolveTools added in v0.0.25

func ResolveTools(tools []Tool, flag string) []int

ResolveTools translates the -tools flag value into optional tool indices.

""    → no optional tools (required only)
"all" → all optional tools
"a,b" → optional tools whose Name matches

func RunWithSpinner

func RunWithSpinner(name, version string, fn func() error) error

RunWithSpinner runs the given function while displaying a spinner. version is shown in the success line: "✅ name — version"

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
}

Deps — all external operations behind interfaces for testability

type InstallResult

type InstallResult struct {
	Installed int
	Failed    int
	Skipped   int
}

InstallResult holds counts for the summary line.

type Installer

type Installer struct{}

func New

func New() *Installer

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

func (ins *Installer) InstallBinary(t Tool, d *Deps) error

InstallBinary handles the installation of tools from GitHub releases.

func (*Installer) InstallGoInstall

func (i *Installer) InstallGoInstall(t Tool, d *Deps) error

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).

func (*Installer) Uninstall

func (ins *Installer) Uninstall(tools []Tool, d *Deps) error

Uninstall removes tools according to the UNINSTALL environment variable.

func (*Installer) Verify

func (i *Installer) Verify(t Tool, d *Deps) error

Verify checks if the tool is correctly installed and has the expected version. If VerifyBinary is set, it is used instead of Name to run the version check.

type Mode

type Mode int
const (
	Script    Mode = iota // download + exec external script
	GoInstall             // go install source@version
	Binary                // download GitHub release
)

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
}

Directories

Path Synopsis
cmd
installer command

Jump to

Keyboard shortcuts

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