Documentation
¶
Overview ¶
Package mise bootstraps the mise binary and runs mise operations.
Index ¶
- Constants
- func CompareVersions(a, b string) (int, error)
- func GenerateApplyConfig(plan *resolve.Plan, profileRoot string, f *facts.Facts, interactive bool) string
- func GenerateConfig(plan *resolve.Plan) string
- func GenerateDotfiles(entries []resolve.DotfileEntry) string
- func GenerateHookTasks(hooks resolve.HooksStep, profileRoot string, f *facts.Facts, interactive bool) string
- func GenerateTools(versions map[string]string) string
- type DotfilesStep
- type DotfilesSystemStep
- type ExecMise
- func (e *ExecMise) DotfilesApply(ctx context.Context, configPath string, yes, force bool) error
- func (e *ExecMise) DotfilesApplySudo(ctx context.Context, configPath string, yes bool) error
- func (e *ExecMise) EnsureAndInstall(ctx context.Context, configPath string) error
- func (e *ExecMise) RunTask(ctx context.Context, configPath, taskName string) error
- type FakeRunner
- type HooksStep
- type InstallKind
- type Mise
- type Runner
- type ToolsStep
Constants ¶
const InstallerURL = "https://mise.run"
InstallerURL is the official mise installer.
const MinMiseVersion = "2025.1.0"
MinMiseVersion is the hardcoded minimum mise version required by dotdrift.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
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, interactive bool) 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. interactive flows through to GenerateHookTasks.
func GenerateConfig ¶
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, interactive bool) 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. When interactive is true each task is marked `interactive = true` so mise connects it to the terminal's stdin/stdout/ stderr — a hook running an interactive command (e.g. sudo) can then reach a controlling terminal and disable echo instead of echoing the password. Returns "" when both lists are empty.
func GenerateTools ¶
GenerateTools emits a mise.toml [tools] section from the resolved plan.
Types ¶
type DotfilesStep ¶
DotfilesStep runs mise dotfiles apply for the dotfiles in the resolved plan.
func (*DotfilesStep) Name ¶
func (s *DotfilesStep) Name() string
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
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 ¶
NewExecMise creates a Runner backed by a Mise instance.
func (*ExecMise) DotfilesApply ¶
func (*ExecMise) DotfilesApplySudo ¶ added in v0.2.0
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 ¶
type FakeRunner ¶
FakeRunner records mise invocations for tests.
func (*FakeRunner) DotfilesApply ¶
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.
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
// Verbose streams operation subprocesses (install/dotfiles/tasks) live
// to Out/Err instead of capturing and discarding their output, echoing
// each command line set -x-style ("+ argv") to Err before it runs. Only
// the ExecMise operation calls stream: version probes and the mise.run
// bootstrap always stay captured and unechoed (their output is parsed
// or one-time).
Verbose bool
// Out/Err are the Verbose streaming destinations; nil defaults to
// os.Stdout/os.Stderr.
Out io.Writer
Err io.Writer
// 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.