Skip to content

fix(cli): implement nodeup list and add JSON envelope#80

Merged
dipto0321 merged 1 commit into
mainfrom
fix/cli/implement-nodeup-list
Jul 3, 2026
Merged

fix(cli): implement nodeup list and add JSON envelope#80
dipto0321 merged 1 commit into
mainfrom
fix/cli/implement-nodeup-list

Conversation

@dipto0321

Copy link
Copy Markdown
Owner

Summary

nodeup list was a stub printing "not yet implemented (Phase 1)". It now does the obvious thing — resolve every detected manager via DetectAll, call each one's ListInstalled(), and render the union either as a JSON envelope (--json) or a one-line-per-manager table. Versions are sorted ascending (semver — pre-release tags order correctly). The currently-active version, when at least one manager answers Current(), is surfaced alongside the listing in both renderers.

A new --manager flag narrows the listing to a single manager (case-insensitive), matching the same flag on nodeup upgrade and nodeup check. Per-manager errors from ListInstalled are captured in the JSON envelope's error field rather than aborting the whole listing, mirroring the soft-fail policy already on check.

Closes #45.

Linked issues

Type of change

  • fix — bug fix (PATCH bump) (filling in for the long-broken stub)

Checklist

  • Title follows Conventional Commits (fix(scope): subject)
  • I ran make ci locally and it passes (fmt, vet, test pass locally; make lint fails on the v2→v1 schema mismatch tracked in build(lint): .golangci.yml v1 schema incompatible with golangci-lint v2 (brew installs v2, make lint fails to even parse config) #62 — pre-existing on main, independent of this fix; CI runs golangci-lint v1.64.8 per .github/workflows/ci.yml and parses the config fine)
  • I added or updated tests for the change (new internal/cli/list_test.go — JSON envelope happy-path + omits-on-nil current/error, table renderer empty + mixed-states, --manager resolution helper incl. case-insensitive, formatListVersions, lower, registryNames)
  • I updated relevant docs (README, docs/, inline godoc)
  • No new linter warnings
  • If breaking: I documented the migration path in the PR body and updated CHANGELOG.md (N/A — no CLI surface breaking; previously the command was a no-op stub)

Scope notes

  • The shape of nodeup list --json (top-level envelope with installed: [{manager, versions, error?}] and an optional current) is intentionally similar to — but not identical to — nodeup check --json. check reports what nodejs.org offers; list reports what's installed locally. The per-entry field names (manager, versions, error) match so a jq pipeline collecting both commands doesn't have to special-case.
  • Versions is rendered as strings (semver) rather than numbers because pre-release tags (20.0.0-rc.1, ...) are not valid JSON numbers and would otherwise be silently dropped on the wire.
  • Current is first manager that answers Current() — there is typically one manager-owned node on PATH per machine, so this is a best-effort signal rather than a strict contract. Managers that don't implement Current (e.g., nvm-windows — returns ErrNVMWindowsNotImplemented) are skipped silently.
  • I deliberately did NOT plumb Current through the table renderer unconditionally: it prints only when probeable. The empty-state line "No Node.js version manager detected." mirrors check.go's wording exactly.
  • The new helper findManagerByName is case-insensitive (matches by lowercased names) so --manager FNM works the same as --manager fnm. The error message lists every detected manager in registration order — registryNames keeps that ordering consistent with the rest of the CLI.

Out of scope (separate issues)

Screenshots / output

User-visible behaviour change:

  • Before: nodeup list printed nodeup list — not yet implemented (Phase 1) and exited 0.
  • After: nodeup list enumerates installed versions across every detected manager:
    
      fnm:    20.18.0, 22.11.0
      volta:  18.20.4
      Active: 22.11.0
    
    And with --manager fnm:
    
      fnm:    20.18.0, 22.11.0
      Active: 22.11.0
    
    And with --json:
    {
      "installed": [
        {"manager": "fnm",   "versions": ["20.18.0", "22.11.0"]},
        {"manager": "volta", "versions": ["18.20.4"]}
      ],
      "current": "22.11.0"
    }

Verification path: nodeup list, nodeup list --json, nodeup list --manager fnm on a machine with at least one manager installed; go test -race ./internal/cli/... for the unit-test surface.

`nodeup list` was a stub printing "not yet implemented (Phase 1)".
Replace with a real implementation mirroring `nodeup check`'s
per-manager loop: ResolveAll / per-manager ListInstalled / JSON-or-
table rendering. Versions are sorted ascending (semver); the active
version (first manager that answers Current()) is surfaced in both
the JSON envelope and a trailing line of the table. The new
--manager flag narrows the listing to a single manager (case-
insensitive) for parity with upgrade/check. Per-manager errors are
captured in the JSON envelope instead of aborting the whole listing.

Closes #45.

Co-Authored-By: puku-ai-2.8 <noreply@puku.sh>
@cocogitto-bot

cocogitto-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

✔️ 61400dd - Conventional commits check succeeded.

@dipto0321 dipto0321 merged commit e12ef77 into main Jul 3, 2026
10 checks passed
@dipto0321 dipto0321 deleted the fix/cli/implement-nodeup-list branch July 3, 2026 02:24
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.

bug(cli): nodeup list is an unimplemented stub, contradicts README and breaks --json scripting

1 participant