Skip to content

feat(detector): implement Mise detection#5

Merged
dipto0321 merged 1 commit into
mainfrom
feat/detector/add-mise
Jun 29, 2026
Merged

feat(detector): implement Mise detection#5
dipto0321 merged 1 commit into
mainfrom
feat/detector/add-mise

Conversation

@dipto0321

Copy link
Copy Markdown
Owner

Summary

Add the Mise (https://mise.jdx.dev) detector — the 5th of 8 Node.js version managers in the Phase 1 detection rollout.

Unlike ASDF, Mise requires the CLI to be authoritative: we look at mise ls --installed --json node rather than walking $MISE_DATA_DIR/installs/node/, because the CLI handles active-vs-installed, symlinks, and config-resolved versions in one shot.

Changes

  • internal/detector/mise.go (full implementation):
    • Detect(): platform.LookupManagerBinary("mise") != ""
    • Version(): mise --version, first whitespace-separated token with optional v prefix stripped (CalVer like 2026.6.15)
    • ListInstalled(): mise ls --installed --json node, JSON-decoded into a struct that mirrors upstream JSONToolVersion (defensively skipped fields: requested_version, source, sources, symlinked_to, installed, active)
    • Mutation methods return ErrMiseNotImplemented sentinel (matches the ASDF pattern from PR feat(detector): implement ASDF detection #4)
  • internal/detector/mise_test.go (27 mocked tests):
    • parseMiseVersion: CalVer output, v prefix, leading/trailing whitespace, empty, whitespace-only
    • parseMiseInstalled: real JSON output, unsorted input → sorted ascending, empty array, empty stdout, skips installed:false, skips empty version, skips non-semver versions, malformed JSON hard error, ignores unknown future fields
    • Method tests: Name, Version (success/V-prefixed/runShell error/parsing error), ListInstalled (success/empty array/empty stdout/runShell error/JSON parse error)
    • Detect: PATH-without-binary, PATH-with-binary on the stub (Windows-safe via mise.exe)
    • MutationMethods_NotImplemented sentinel test

Design notes

  • The miseToolVersion struct uses omitempty on optional fields so future upstream additions never break parsing (covered by IgnoresExtraFields test).
  • We filter on Installed: true after JSON decode as a defense-in-depth check, since we pass --installed upstream — if Mise ever ignores that flag (bug or design change), we still return a clean list.
  • CalVer (2026.6.15) is intentionally NOT validated as semver in parseMiseVersion — matching ASDF's policy of returning the raw token for the caller to handle.

Test plan

  • go test ./... — all packages green
  • go vet ./... — clean
  • gofmt -l — clean
  • CI matrix: lint (ubuntu), test on ubuntu/macos/windows, build on 5 platforms — pending

Phase 1 detector: PATH lookup for the mise binary, parses
`mise --version` (CalVer such as 2026.6.15), and lists installed
Node versions via `mise ls --installed --json node` (decoded from
a JSON array of JSONToolVersion-like objects). 27 mocked tests
cover all paths including empty/garbage input, defensive skipped
fields, and Windows .exe binary naming.
@cocogitto-bot

cocogitto-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

✔️ 3540de0 - Conventional commits check succeeded.

@dipto0321 dipto0321 merged commit dab9f8e into main Jun 29, 2026
10 checks passed
@dipto0321 dipto0321 deleted the feat/detector/add-mise branch June 29, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant