@kyubiware/commit-mint 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -29,7 +29,7 @@ var __exportAll = (all, no_symbols) => {
29
29
  //#region package.json
30
30
  var package_default = {
31
31
  name: "@kyubiware/commit-mint",
32
- version: "0.7.3",
32
+ version: "0.7.4",
33
33
  description: "🌿 AI-powered git commit tool — auto-group changed files, generate messages, run pre-commit checks",
34
34
  type: "module",
35
35
  bin: { "cmint": "./dist/cli.mjs" },
@@ -2311,7 +2311,6 @@ async function agentCommand(flags) {
2311
2311
  //#endregion
2312
2312
  //#region src/services/update-check.ts
2313
2313
  const REGISTRY_URL = "https://registry.npmjs.org/-/package/@kyubiware/commit-mint/dist-tags";
2314
- const PACKAGE_NAME$1 = "@kyubiware/commit-mint";
2315
2314
  const TTL_MS = 1440 * 60 * 1e3;
2316
2315
  const FETCH_TIMEOUT_MS = 5e3;
2317
2316
  let cachePath = join(os.homedir(), ".cache", "commit-mint", "update-check.json");
@@ -2396,7 +2395,7 @@ async function fetchLatest(parentSignal) {
2396
2395
  }
2397
2396
  function displayNag(current, latest) {
2398
2397
  debug("displayNag: %s → %s", current, latest);
2399
- const message = `Update available: ${yellow(current)} → ${green(latest)}\nRun ${cyan(`npm update -g ${PACKAGE_NAME$1}`)} to update`;
2398
+ const message = `Update available: ${yellow(current)} → ${green(latest)}\nRun ${cyan("cmint update")} to update`;
2400
2399
  log.warn(message);
2401
2400
  }
2402
2401
  /**
@@ -2404,11 +2403,16 @@ function displayNag(current, latest) {
2404
2403
  * {@link checkForUpdatesUpfront}. Accepts an optional AbortSignal that
2405
2404
  * propagates to the underlying fetch — used by the cancellable spinner.
2406
2405
  *
2406
+ * When an update is available, {@link onNag} is invoked (defaulting to
2407
+ * {@link displayNag}). The cancellable spinner path passes a capturing
2408
+ * callback so it can stop the spinner BEFORE the nag prints — otherwise
2409
+ * `log.warn` interleaves with the spinner line and leaves it on screen.
2410
+ *
2407
2411
  * Returns an {@link UpdateCheckStatus} so the caller can distinguish a
2408
2412
  * real fetch that found the user current (eligible for "You are on the
2409
2413
  * latest version" feedback) from a silent cache hit.
2410
2414
  */
2411
- async function runUpdateCheck(currentVersion, parentSignal) {
2415
+ async function runUpdateCheck(currentVersion, parentSignal, onNag = displayNag) {
2412
2416
  debug("runUpdateCheck: currentVersion=%s", currentVersion);
2413
2417
  if (shouldSkip(currentVersion)) {
2414
2418
  debug("runUpdateCheck: skipped (NO_UPDATE_NOTIFIER / CI / NODE_ENV=test / non-TTY / invalid version)");
@@ -2419,7 +2423,7 @@ async function runUpdateCheck(currentVersion, parentSignal) {
2419
2423
  if (cached && Date.now() - cached.checkedAt < TTL_MS) {
2420
2424
  debug("runUpdateCheck: cache fresh (<%dh), skipping fetch", TTL_MS / 36e5);
2421
2425
  if (semver.gt(cached.latest, currentVersion)) {
2422
- displayNag(currentVersion, cached.latest);
2426
+ onNag(currentVersion, cached.latest);
2423
2427
  return "cache-update";
2424
2428
  }
2425
2429
  debug("runUpdateCheck: current >= latest, no nag");
@@ -2437,7 +2441,7 @@ async function runUpdateCheck(currentVersion, parentSignal) {
2437
2441
  checkedAt: Date.now()
2438
2442
  });
2439
2443
  if (semver.gt(latest, currentVersion)) {
2440
- displayNag(currentVersion, latest);
2444
+ onNag(currentVersion, latest);
2441
2445
  return "fetch-update";
2442
2446
  }
2443
2447
  debug("runUpdateCheck: current >= latest, no nag");
@@ -2560,9 +2564,15 @@ async function runCheckWithSpinner(currentVersion) {
2560
2564
  reportFetchCurrent(await runUpdateCheck(currentVersion));
2561
2565
  return;
2562
2566
  }
2567
+ const captured = { nag: null };
2563
2568
  let status;
2564
2569
  try {
2565
- status = await runUpdateCheck(currentVersion, controller.signal);
2570
+ status = await runUpdateCheck(currentVersion, controller.signal, (current, latest) => {
2571
+ captured.nag = {
2572
+ current,
2573
+ latest
2574
+ };
2575
+ });
2566
2576
  } finally {
2567
2577
  handler.cleanup();
2568
2578
  }
@@ -2570,8 +2580,10 @@ async function runCheckWithSpinner(currentVersion) {
2570
2580
  debug("runCheckWithSpinner: spinner dismissed by user");
2571
2581
  s.stop("Skipped");
2572
2582
  } else if (status === "fetch-current") s.stop(green("You are on the latest version"));
2573
- else if (status === "fetch-update") s.stop("");
2574
- else if (status === "fetch-failed-or-aborted") s.stop("Update check failed");
2583
+ else if (status === "fetch-update" || status === "cache-update") {
2584
+ s.stop("");
2585
+ if (captured.nag) displayNag(captured.nag.current, captured.nag.latest);
2586
+ } else if (status === "fetch-failed-or-aborted") s.stop("Update check failed");
2575
2587
  else s.stop("");
2576
2588
  }
2577
2589
  //#endregion