From b3e687abe9cedcc8fba35a83a725731da079b7e7 Mon Sep 17 00:00:00 2001 From: Soju06 Date: Sat, 28 Feb 2026 00:51:01 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20show=20current=E2=86=92latest=20versio?= =?UTF-8?q?n=20in=20update=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Display "Update (0.4.0 → 0.4.1)" when update available - Display "Update (0.4.1 ✓)" when already on latest - Add getLatestVersion() to expose cached latest version --- src/cli.ts | 15 ++++++++------- src/core/version.ts | 6 ++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 143c716..bd75ab6 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -9,7 +9,7 @@ import { updateCommand } from "./commands/update.js"; import { getUpdateCommand } from "./core/package-manager.js"; import type { Scope } from "./core/paths.js"; import { detectInstallation } from "./core/status.js"; -import { checkForUpdate } from "./core/version.js"; +import { checkForUpdate, getLatestVersion } from "./core/version.js"; import { isInteractive } from "./ui/interactive.js"; import { COLORS, ICONS } from "./ui/palette.js"; @@ -115,13 +115,14 @@ if (process.argv.length <= 2) { console.log(); const allInstalled = installed.length === status.platforms.length; + const latest = newer ?? (await getLatestVersion()); + const updateLabel = newer + ? `Update ${COLORS.dim(`(${pkg.version} → ${newer})`)}` + : latest + ? `Update ${COLORS.dim(`(${pkg.version} ${ICONS.ok})`)}` + : `Update ${COLORS.dim(`(${pkg.version})`)}`; const choices: { name: string; value: Action }[] = [ - { - name: newer - ? `Update ${COLORS.dim(`(${pkg.version} → ${newer})`)}` - : `Update ${COLORS.dim(`(${pkg.version})`)}`, - value: "update", - }, + { name: updateLabel, value: "update" }, ]; if (!allInstalled) { choices.push({ diff --git a/src/core/version.ts b/src/core/version.ts index f3d0100..dc4f528 100644 --- a/src/core/version.ts +++ b/src/core/version.ts @@ -51,6 +51,12 @@ async function fetchLatest(): Promise { } } +/** Return the cached latest version (available after checkForUpdate has run). */ +export async function getLatestVersion(): Promise { + const cache = await readCache(); + return cache?.latestVersion ?? null; +} + /** Check npm registry for a newer version. Returns newer version string or null. */ export async function checkForUpdate( currentVersion: string,