installer

package module
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Jun 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. Downloads the latest tinywasm-installer binary for your platform
  2. Shows an interactive checklist of optional tools
  3. Installs all required + selected tools (including Go/TinyGo) with progress spinner
  4. Verifies each tool after installation

Tools

Tool Mode Required Depends on
tinygoinstall GoInstall yes
tinywasm Binary yes

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
├── Detect OS/Arch
└── Download tinywasm-installer-{os}-{arch} → run installer

Phase 2: Go binary (tinywasm-installer)
├── 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", Label: "TinyGo", Source: "github.com/tinywasm/tinygo/cmd/tinygoinstall", ModuleVersion: "v0.0.7", Version: "0.40.1", VerifyBinary: "tinygo", Required: true},
	{Mode: Binary, Name: "tinywasm", Source: "https://github.com/tinywasm/app", Version: "", Required: true},
}

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(label, version string, fn func() error) error

RunWithSpinner runs fn printing a simple status line. Uses plain text output — no ANSI codes — for compatibility with PowerShell, Windows Terminal, and SSH sessions.

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. Resolves the binary via LookPath first; on Windows also checks Scoop shims so verification works even when shims are not in the current process PATH.

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 // binary name used to invoke the tool
	Label         string // human-readable display name (shown during install); defaults to Name
	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

Jump to

Keyboard shortcuts

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