mise

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mise bootstraps the mise binary and runs mise operations.

Index

Constants

View Source
const InstallerURL = "https://mise.run"

InstallerURL is the official mise installer.

View Source
const MinMiseVersion = "2025.1.0"

MinMiseVersion is the hardcoded minimum mise version required by dotdrift.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) (int, error)

CompareVersions compares calendar-style versions like 2026.6.6. Returns -1 if a < b, 0 if equal, 1 if a > b. A version carrying a pre-release/build suffix (e.g. "2025.1.0-rc1", "2025.1.0+build.5") compares below the plain release. Unparseable input is an error.

func GenerateApplyConfig added in v0.2.0

func GenerateApplyConfig(plan *resolve.Plan, profileRoot string, f *facts.Facts) string

GenerateApplyConfig emits the full apply-time mise.toml: tools, dotfiles, and hook tasks. The hook tasks need facts and the absolute profile root, so only apply uses this; onboard keeps using GenerateConfig.

func GenerateConfig

func GenerateConfig(plan *resolve.Plan) string

GenerateConfig emits a complete mise.toml with tools and dotfiles sections.

func GenerateDotfiles

func GenerateDotfiles(entries []resolve.DotfileEntry) string

GenerateDotfiles emits a mise.toml [dotfiles] section from the resolved plan.

func GenerateHookTasks added in v0.2.0

func GenerateHookTasks(hooks resolve.HooksStep, profileRoot string, f *facts.Facts) string

GenerateHookTasks emits a [tasks] section with one mise task per non-empty hook list ("hooks:pre" and/or "hooks:post"). Each task runs its commands in order from dir (the absolute profile root) with the DOTDRIFT_* facts environment. Returns "" when both lists are empty.

func GenerateTools

func GenerateTools(versions map[string]string) string

GenerateTools emits a mise.toml [tools] section from the resolved plan.

func MiseDotfileMode added in v0.2.0

func MiseDotfileMode(mode string) string

MiseDotfileMode translates dotdrift's dotfile mode vocabulary into mise's at the config-generation boundary. dotdrift keeps `link` as its documented default mode, but real mise only accepts `symlink` — verified against mise 2026.7.10, where `mode = "link"` is ignored ("unknown mode 'link', ignoring entry") with exit code 0 and no file created. All other dotdrift modes (copy, template, symlink-each) are already valid mise vocabulary.

Types

type DotfilesStep

type DotfilesStep struct {
	Runner     Runner
	Plan       *resolve.Plan
	ConfigPath string
	Yes        bool
}

DotfilesStep runs mise dotfiles apply for the dotfiles in the resolved plan.

func (*DotfilesStep) Name

func (s *DotfilesStep) Name() string

func (*DotfilesStep) Run

func (s *DotfilesStep) Run(ctx context.Context) error

type DotfilesSystemStep added in v0.2.0

type DotfilesSystemStep struct {
	Exec       *ExecMise
	Entries    []resolve.DotfileEntry
	ConfigPath string
	Yes        bool
}

DotfilesSystemStep applies system-scope dotfile entries with root privileges. It takes the concrete ExecMise (like HooksStep) because the sudo-aware entry point is deliberately not part of the Runner interface. cmd/apply.go only constructs it when at least one system-scope entry exists; Run also no-ops on an empty list as a second line of defense.

func (*DotfilesSystemStep) Name added in v0.2.0

func (s *DotfilesSystemStep) Name() string

func (*DotfilesSystemStep) Run added in v0.2.0

type ExecMise

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

ExecMise wraps a Mise value so it can be used as a Runner by step code.

func NewExecMise

func NewExecMise(m *Mise) *ExecMise

NewExecMise creates a Runner backed by a Mise instance.

func (*ExecMise) DotfilesApply

func (e *ExecMise) DotfilesApply(ctx context.Context, configPath string, yes bool) error

func (*ExecMise) DotfilesApplySudo added in v0.2.0

func (e *ExecMise) DotfilesApplySudo(ctx context.Context, configPath string, yes bool) error

DotfilesApplySudo applies system-scope dotfiles with root privileges. When the process is not already root it invokes sudo (failing loudly if sudo is missing or authentication fails); as root it applies directly.

func (*ExecMise) EnsureAndInstall

func (e *ExecMise) EnsureAndInstall(ctx context.Context, configPath string) error

func (*ExecMise) RunTask added in v0.2.0

func (e *ExecMise) RunTask(ctx context.Context, configPath, taskName string) error

RunTask runs a named task (e.g. "hooks:pre") from the generated config.

type FakeRunner

type FakeRunner struct {
	InstallCalled  bool
	DotfilesCalled bool
	Yes            bool
	Err            error
}

FakeRunner records mise invocations for tests.

func (*FakeRunner) DotfilesApply

func (f *FakeRunner) DotfilesApply(ctx context.Context, configPath string, yes bool) error

func (*FakeRunner) EnsureAndInstall

func (f *FakeRunner) EnsureAndInstall(ctx context.Context, configPath string) error

type HooksStep

type HooksStep struct {
	Exec       *ExecMise
	Commands   []string
	ConfigPath string
	Task       string // mise task name, e.g. "hooks:pre"
	StepName   string // pipeline step name, e.g. "hooks-pre"
}

HooksStep runs one pre/post hook command list as a mise task from the// generated apply config. cmd/apply.go only constructs HooksSteps for non-empty command lists; Run also no-ops on an empty list as a second line of defense.

func (*HooksStep) Name

func (s *HooksStep) Name() string

func (*HooksStep) Run

func (s *HooksStep) Run(ctx context.Context) error

type InstallKind

type InstallKind int

InstallKind classifies how a mise binary is managed.

const (
	InstallKindUnknown InstallKind = iota
	InstallKindSystemWide
	InstallKindUserManaged
)

func ClassifyInstall

func ClassifyInstall(path string) InstallKind

ClassifyInstall determines whether a mise binary is system-wide or user-managed.

System-wide (no auto-upgrade):

  • DOTDRIFT_MISE_SYSTEM=1
  • path under /usr/bin, /usr/local/bin, /bin, /sbin, /usr/sbin, /opt
  • path under $HOME but not writable by the current user

User-managed (may auto-upgrade):

  • path under $HOME and writable by the current user

func (InstallKind) String

func (k InstallKind) String() string

type Mise

type Mise struct {
	LookPath   func(string) (string, error)
	Run        func(string, ...string) (string, error)
	RunContext func(context.Context, string, ...string) (string, error)
	Install    func() (string, error)
	Classify   func(string) InstallKind

	// Env is extra environment ("KEY=value") appended to the subprocess
	// environment on the real exec path; fakes (Run/RunContext) bypass it.
	Env []string
	// contains filtered or unexported fields
}

Mise finds, installs, or upgrades a mise binary.

RunContext is preferred over the legacy Run; both are kept so existing fakes that only set Run keep working. The result of the first Ensure call is memoized for the lifetime of the struct.

func DefaultMise

func DefaultMise() *Mise

DefaultMise returns a Mise configured with real OS dependencies. Run and RunContext stay nil so runner() uses the env-aware real exec path.

func (*Mise) Ensure

func (m *Mise) Ensure() (string, error)

Ensure finds or installs a mise binary meeting the minimum version. The result (success or failure) is computed once and memoized.

func (*Mise) EnsureContext added in v0.2.0

func (m *Mise) EnsureContext(ctx context.Context) (string, error)

EnsureContext is Ensure with ctx propagated to every subprocess.

type Runner

type Runner interface {
	EnsureAndInstall(ctx context.Context, configPath string) error
	DotfilesApply(ctx context.Context, configPath string, yes bool) error
}

Runner abstracts mise operations used by apply steps.

type ToolsStep

type ToolsStep struct {
	Runner     Runner
	Plan       *resolve.Plan
	ConfigPath string
}

ToolsStep runs mise install for the tools in the resolved plan.

func (*ToolsStep) Name

func (s *ToolsStep) Name() string

func (*ToolsStep) Run

func (s *ToolsStep) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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