installer

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 14 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", Version: "0.40.1", 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 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"

func ShowChecklist

func ShowChecklist(tools []Tool) []int

ShowChecklist displays optional tools and returns the selected indices. Uses raw terminal mode to capture ↑/↓/Space/Enter without buffering.

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

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 handles the installation of tools using `go install source@version`.

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.

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)
	Version   string // pinned in tool definition
	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