refactor(cli): simplify updater, remove cache and confirmation

- Remove the 24h disk cache (State, readState/writeState, checkInterval)
  that served stale latest versions within the TTL window
- Remove file lock (Flock) and confirmation prompt (Prompt/Terminal)
- Every check now hits the npm registry directly
- Updates always auto-install on any version mismatch within the same
  major, including rollbacks where the registry version is lower
- Drop the interactive option from check() and the confirm/declined/
  dismissed action concepts
This commit is contained in:
Dax Raad 2026-06-27 20:52:03 -04:00
commit 11bf8d8a42
4 changed files with 38 additions and 95 deletions

View file

@ -8,18 +8,26 @@ describe("updater", () => {
expect(decodePolicy('{ "autoupdate": "invalid" }')).toBeUndefined()
})
test("automatically updates patches", () => {
expect(action("1.2.3", "1.2.4", true, false)).toBe("upgrade")
expect(action("1.2.3", "1.2.4", "notify", true)).toBe("confirm")
expect(action("1.2.3", "1.2.4", false, true)).toBe("none")
test("automatically updates patches and minors", () => {
expect(action("1.2.3", "1.2.4", true)).toBe("upgrade")
expect(action("1.2.3", "1.3.0", true)).toBe("upgrade")
expect(action("1.2.3", "1.2.4", "notify")).toBe("upgrade")
expect(action("1.2.3", "1.3.0", "notify")).toBe("upgrade")
})
test("requires an interactive confirmation for minors", () => {
expect(action("1.2.3", "1.3.0", true, true)).toBe("confirm")
expect(action("1.2.3", "1.3.0", true, false)).toBe("none")
test("skips when autoupdate is disabled", () => {
expect(action("1.2.3", "1.2.4", false)).toBe("none")
})
test("never automatically updates majors", () => {
expect(action("1.2.3", "2.0.0", true, true)).toBe("none")
expect(action("1.2.3", "2.0.0", true)).toBe("none")
})
test("reports up-to-date only when versions match", () => {
expect(action("1.2.3", "1.2.3", true)).toBe("none")
})
test("upgrades when latest is lower (rollback)", () => {
expect(action("1.2.4", "1.2.3", true)).toBe("upgrade")
})
})