@kyubiware/commit-mint 0.6.6 → 0.7.2
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 +324 -8
- package/dist/cli.mjs.map +1 -1
- package/package.json +4 -2
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { cli, command } from "cleye";
|
|
|
3
3
|
import Groq from "groq-sdk";
|
|
4
4
|
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
|
-
import { extname, join } from "node:path";
|
|
6
|
+
import { dirname, extname, join } from "node:path";
|
|
7
7
|
import { bold, cyan, dim, green, red, yellow } from "kolorist";
|
|
8
8
|
import { access, constants, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
9
|
import { execa } from "execa";
|
|
@@ -13,6 +13,7 @@ import { createHash } from "node:crypto";
|
|
|
13
13
|
import * as p from "@clack/prompts";
|
|
14
14
|
import { intro, isCancel, log, outro, spinner } from "@clack/prompts";
|
|
15
15
|
import { spawn } from "node:child_process";
|
|
16
|
+
import semver from "semver";
|
|
16
17
|
//#region \0rolldown/runtime.js
|
|
17
18
|
var __defProp = Object.defineProperty;
|
|
18
19
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -28,7 +29,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
28
29
|
//#region package.json
|
|
29
30
|
var package_default = {
|
|
30
31
|
name: "@kyubiware/commit-mint",
|
|
31
|
-
version: "0.
|
|
32
|
+
version: "0.7.2",
|
|
32
33
|
description: "🌿 AI-powered git commit tool — auto-group changed files, generate messages, run pre-commit checks",
|
|
33
34
|
type: "module",
|
|
34
35
|
bin: { "cmint": "./dist/cli.mjs" },
|
|
@@ -74,11 +75,13 @@ var package_default = {
|
|
|
74
75
|
"ini": "^5.0.0",
|
|
75
76
|
"jiti": "^2.7.0",
|
|
76
77
|
"kolorist": "^1.8.0",
|
|
77
|
-
"picomatch": "^4.0.4"
|
|
78
|
+
"picomatch": "^4.0.4",
|
|
79
|
+
"semver": "^7.7.2"
|
|
78
80
|
},
|
|
79
81
|
devDependencies: {
|
|
80
82
|
"@biomejs/biome": "^2.0.0",
|
|
81
83
|
"@types/ini": "^4.1.1",
|
|
84
|
+
"@types/semver": "^7.7.1",
|
|
82
85
|
"@vitest/coverage-v8": "^3.2.4",
|
|
83
86
|
"tsdown": "^0.22.0",
|
|
84
87
|
"tsx": "^4.22.2",
|
|
@@ -1385,7 +1388,7 @@ const CACHE_DIR = join(os.homedir(), ".cache", "commit-mint");
|
|
|
1385
1388
|
function repoHash(repoPath) {
|
|
1386
1389
|
return createHash("sha256").update(repoPath).digest("hex").slice(0, 12);
|
|
1387
1390
|
}
|
|
1388
|
-
function cachePath(repoPath) {
|
|
1391
|
+
function cachePath$1(repoPath) {
|
|
1389
1392
|
return join(CACHE_DIR, `${repoHash(repoPath)}.json`);
|
|
1390
1393
|
}
|
|
1391
1394
|
async function saveCachedCommit(repoPath, message) {
|
|
@@ -1395,12 +1398,12 @@ async function saveCachedCommit(repoPath, message) {
|
|
|
1395
1398
|
timestamp: Date.now(),
|
|
1396
1399
|
repoPath
|
|
1397
1400
|
};
|
|
1398
|
-
const path = cachePath(repoPath);
|
|
1401
|
+
const path = cachePath$1(repoPath);
|
|
1399
1402
|
debug("saveCachedCommit: saving to %s", path);
|
|
1400
1403
|
await writeFile(path, JSON.stringify(data, null, 2), "utf8");
|
|
1401
1404
|
}
|
|
1402
1405
|
async function loadCachedCommit(repoPath) {
|
|
1403
|
-
const path = cachePath(repoPath);
|
|
1406
|
+
const path = cachePath$1(repoPath);
|
|
1404
1407
|
debug("loadCachedCommit: loading from %s", path);
|
|
1405
1408
|
try {
|
|
1406
1409
|
const raw = await readFile(path, "utf8");
|
|
@@ -1494,9 +1497,11 @@ function tryCopy(cmd, args, content) {
|
|
|
1494
1497
|
//#region src/ui/check-failure-menu.ts
|
|
1495
1498
|
const MAX_TSC_DIAGNOSTICS = 3;
|
|
1496
1499
|
const MAX_ESLINT_DIAGNOSTICS = 3;
|
|
1500
|
+
const MAX_TEST_FAILURES = 3;
|
|
1497
1501
|
const MAX_SUMMARY_LINE_LENGTH = 120;
|
|
1498
1502
|
const TSC_DIAGNOSTIC = /^(.+?\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs))\((\d+),(\d+)\):\s+error\s+(TS\d+):\s+(.+)$/;
|
|
1499
1503
|
const ESLINT_ERROR_LINE = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+)\s{2,}(\S+)\s*$/;
|
|
1504
|
+
const TEST_FILE_FAIL = /^\s*FAIL\s+(.+?\.(?:test|spec)\.[^\s>]+)\s*>\s*(.+)$/;
|
|
1500
1505
|
function formatCheckFailureSummary(errors) {
|
|
1501
1506
|
if (errors.length === 0) return "No check error details were parsed. View full output for details.";
|
|
1502
1507
|
return errors.map((error) => formatCheckErrorSummary(error)).join("\n");
|
|
@@ -1510,6 +1515,10 @@ function formatCheckErrorSummary(error) {
|
|
|
1510
1515
|
const diagnostics = extractEslintDiagnostics(error.raw || error.message);
|
|
1511
1516
|
if (diagnostics.length > 0) return formatEslintSummary(diagnostics);
|
|
1512
1517
|
}
|
|
1518
|
+
if (error.tool === "vitest" || error.tool === "jest") {
|
|
1519
|
+
const failures = extractTestFailures(error.raw || error.message);
|
|
1520
|
+
if (failures.length > 0) return formatTestFailureSummary(failures, error.tool);
|
|
1521
|
+
}
|
|
1513
1522
|
const message = firstMeaningfulLine(error.message || error.raw);
|
|
1514
1523
|
return ` ${red("•")} [${error.tool}] ${truncate(message, MAX_SUMMARY_LINE_LENGTH)}`;
|
|
1515
1524
|
}
|
|
@@ -1554,6 +1563,46 @@ function extractEslintDiagnostics(raw) {
|
|
|
1554
1563
|
}
|
|
1555
1564
|
return diagnostics;
|
|
1556
1565
|
}
|
|
1566
|
+
function extractTestFailures(raw) {
|
|
1567
|
+
const failures = [];
|
|
1568
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1569
|
+
for (const line of raw.split("\n")) {
|
|
1570
|
+
const match = TEST_FILE_FAIL.exec(line);
|
|
1571
|
+
if (!match) continue;
|
|
1572
|
+
const file = (match[1] ?? "").trim();
|
|
1573
|
+
const name = (match[2] ?? "").trim();
|
|
1574
|
+
if (!file || !name) continue;
|
|
1575
|
+
const key = `${file}\u0000${name}`;
|
|
1576
|
+
if (seen.has(key)) continue;
|
|
1577
|
+
seen.add(key);
|
|
1578
|
+
failures.push({
|
|
1579
|
+
file,
|
|
1580
|
+
name
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
return failures;
|
|
1584
|
+
}
|
|
1585
|
+
function formatTestFailureSummary(failures, tool) {
|
|
1586
|
+
const total = failures.length;
|
|
1587
|
+
const visible = failures.slice(0, MAX_TEST_FAILURES);
|
|
1588
|
+
const hidden = total - visible.length;
|
|
1589
|
+
const fileCount = new Set(failures.map((f) => f.file)).size;
|
|
1590
|
+
const testNoun = total === 1 ? "test" : "tests";
|
|
1591
|
+
const fileNoun = fileCount === 1 ? "file" : "files";
|
|
1592
|
+
const lines = [` ${red("•")} [${tool}] ${total} failed ${testNoun} in ${fileCount} ${fileNoun}`];
|
|
1593
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
1594
|
+
for (const failure of visible) {
|
|
1595
|
+
const names = byFile.get(failure.file) ?? [];
|
|
1596
|
+
names.push(failure.name);
|
|
1597
|
+
byFile.set(failure.file, names);
|
|
1598
|
+
}
|
|
1599
|
+
for (const [file, names] of byFile) {
|
|
1600
|
+
lines.push(` ${truncate(file, MAX_SUMMARY_LINE_LENGTH)}`);
|
|
1601
|
+
for (const name of names) lines.push(` ${red("×")} ${truncate(name, MAX_SUMMARY_LINE_LENGTH)}`);
|
|
1602
|
+
}
|
|
1603
|
+
if (hidden > 0) lines.push(dim(` +${hidden} more failed ${hidden === 1 ? "test" : "tests"}. View full output for details.`));
|
|
1604
|
+
return lines.join("\n");
|
|
1605
|
+
}
|
|
1557
1606
|
function formatEslintSummary(diagnostics) {
|
|
1558
1607
|
const visible = diagnostics.slice(0, MAX_ESLINT_DIAGNOSTICS);
|
|
1559
1608
|
const hidden = diagnostics.length - visible.length;
|
|
@@ -2260,6 +2309,272 @@ async function agentCommand(flags) {
|
|
|
2260
2309
|
});
|
|
2261
2310
|
}
|
|
2262
2311
|
//#endregion
|
|
2312
|
+
//#region src/services/update-check.ts
|
|
2313
|
+
const REGISTRY_URL = "https://registry.npmjs.org/-/package/@kyubiware/commit-mint/dist-tags";
|
|
2314
|
+
const PACKAGE_NAME = "@kyubiware/commit-mint";
|
|
2315
|
+
const TTL_MS = 1440 * 60 * 1e3;
|
|
2316
|
+
const FETCH_TIMEOUT_MS = 5e3;
|
|
2317
|
+
let cachePath = join(os.homedir(), ".cache", "commit-mint", "update-check.json");
|
|
2318
|
+
let fetchImpl = globalThis.fetch;
|
|
2319
|
+
/**
|
|
2320
|
+
* Returns true when the notifier must not run: env opt-out, CI, test env,
|
|
2321
|
+
* non-TTY stderr, or an invalid/missing current version.
|
|
2322
|
+
*/
|
|
2323
|
+
function shouldSkip(currentVersion) {
|
|
2324
|
+
const noUpdate = process.env.NO_UPDATE_NOTIFIER;
|
|
2325
|
+
if (noUpdate !== void 0 && noUpdate !== "") return true;
|
|
2326
|
+
const ci = process.env.CI;
|
|
2327
|
+
if (ci !== void 0 && ci !== "" && ci !== "0") return true;
|
|
2328
|
+
if (process.env.NODE_ENV === "test") return true;
|
|
2329
|
+
if (process.stderr.isTTY !== true) return true;
|
|
2330
|
+
if (currentVersion === void 0) return true;
|
|
2331
|
+
if (currentVersion === "") return true;
|
|
2332
|
+
if (semver.valid(currentVersion) === null) return true;
|
|
2333
|
+
return false;
|
|
2334
|
+
}
|
|
2335
|
+
function loadCache() {
|
|
2336
|
+
try {
|
|
2337
|
+
const raw = readFileSync(cachePath, "utf8");
|
|
2338
|
+
const parsed = JSON.parse(raw);
|
|
2339
|
+
if (parsed !== null && typeof parsed === "object" && typeof parsed.latest === "string" && typeof parsed.checkedAt === "number") {
|
|
2340
|
+
const entry = parsed;
|
|
2341
|
+
const ageH = ((Date.now() - entry.checkedAt) / 36e5).toFixed(2);
|
|
2342
|
+
debug("loadCache: hit — latest=%s, age=%sh", entry.latest, ageH);
|
|
2343
|
+
return Promise.resolve(entry);
|
|
2344
|
+
}
|
|
2345
|
+
debug("loadCache: miss — malformed entry");
|
|
2346
|
+
return Promise.resolve(null);
|
|
2347
|
+
} catch {
|
|
2348
|
+
debug("loadCache: miss — %s does not exist", cachePath);
|
|
2349
|
+
return Promise.resolve(null);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
function saveCache(entry) {
|
|
2353
|
+
try {
|
|
2354
|
+
mkdirSync(dirname(cachePath), { recursive: true });
|
|
2355
|
+
writeFileSync(cachePath, JSON.stringify(entry), "utf8");
|
|
2356
|
+
debug("saveCache: wrote latest=%s to %s", entry.latest, cachePath);
|
|
2357
|
+
} catch (err) {
|
|
2358
|
+
debug("saveCache: failed — %s", err instanceof Error ? err.message : String(err));
|
|
2359
|
+
}
|
|
2360
|
+
return Promise.resolve();
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Fetch latest version from the registry. Aborts on FETCH_TIMEOUT_MS or when
|
|
2364
|
+
* `parentSignal` aborts (user keypress). Returns null on any failure so the
|
|
2365
|
+
* caller can degrade silently.
|
|
2366
|
+
*/
|
|
2367
|
+
async function fetchLatest(parentSignal) {
|
|
2368
|
+
debug("fetchLatest: GET %s (timeout=%dms)", REGISTRY_URL, FETCH_TIMEOUT_MS);
|
|
2369
|
+
try {
|
|
2370
|
+
const controller = new AbortController();
|
|
2371
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
2372
|
+
const onParentAbort = () => controller.abort();
|
|
2373
|
+
if (parentSignal) if (parentSignal.aborted) controller.abort();
|
|
2374
|
+
else parentSignal.addEventListener("abort", onParentAbort, { once: true });
|
|
2375
|
+
try {
|
|
2376
|
+
const response = await fetchImpl(REGISTRY_URL, { signal: controller.signal });
|
|
2377
|
+
if (!response.ok) {
|
|
2378
|
+
debug("fetchLatest: HTTP %d — returning null", response.status);
|
|
2379
|
+
return null;
|
|
2380
|
+
}
|
|
2381
|
+
const data = await response.json();
|
|
2382
|
+
if (typeof data.latest !== "string") {
|
|
2383
|
+
debug("fetchLatest: response missing 'latest' field — returning null");
|
|
2384
|
+
return null;
|
|
2385
|
+
}
|
|
2386
|
+
debug("fetchLatest: ok — latest=%s", data.latest);
|
|
2387
|
+
return data.latest;
|
|
2388
|
+
} finally {
|
|
2389
|
+
clearTimeout(timer);
|
|
2390
|
+
if (parentSignal) parentSignal.removeEventListener("abort", onParentAbort);
|
|
2391
|
+
}
|
|
2392
|
+
} catch (err) {
|
|
2393
|
+
debug("fetchLatest: error — %s", err instanceof Error ? err.message : String(err));
|
|
2394
|
+
return null;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
function displayNag(current, latest) {
|
|
2398
|
+
debug("displayNag: %s → %s", current, latest);
|
|
2399
|
+
const message = `Update available: ${yellow(current)} → ${green(latest)}\nRun ${cyan(`npm update -g ${PACKAGE_NAME}`)} to update`;
|
|
2400
|
+
log.warn(message);
|
|
2401
|
+
}
|
|
2402
|
+
/**
|
|
2403
|
+
* Run the full update check. Exported for tests; the public surface is
|
|
2404
|
+
* {@link checkForUpdatesUpfront}. Accepts an optional AbortSignal that
|
|
2405
|
+
* propagates to the underlying fetch — used by the cancellable spinner.
|
|
2406
|
+
*
|
|
2407
|
+
* Returns an {@link UpdateCheckStatus} so the caller can distinguish a
|
|
2408
|
+
* real fetch that found the user current (eligible for "You are on the
|
|
2409
|
+
* latest version" feedback) from a silent cache hit.
|
|
2410
|
+
*/
|
|
2411
|
+
async function runUpdateCheck(currentVersion, parentSignal) {
|
|
2412
|
+
debug("runUpdateCheck: currentVersion=%s", currentVersion);
|
|
2413
|
+
if (shouldSkip(currentVersion)) {
|
|
2414
|
+
debug("runUpdateCheck: skipped (NO_UPDATE_NOTIFIER / CI / NODE_ENV=test / non-TTY / invalid version)");
|
|
2415
|
+
return "skipped";
|
|
2416
|
+
}
|
|
2417
|
+
try {
|
|
2418
|
+
const cached = await loadCache();
|
|
2419
|
+
if (cached && Date.now() - cached.checkedAt < TTL_MS) {
|
|
2420
|
+
debug("runUpdateCheck: cache fresh (<%dh), skipping fetch", TTL_MS / 36e5);
|
|
2421
|
+
if (semver.gt(cached.latest, currentVersion)) {
|
|
2422
|
+
displayNag(currentVersion, cached.latest);
|
|
2423
|
+
return "cache-update";
|
|
2424
|
+
}
|
|
2425
|
+
debug("runUpdateCheck: current >= latest, no nag");
|
|
2426
|
+
return "cache-current";
|
|
2427
|
+
}
|
|
2428
|
+
if (cached) debug("runUpdateCheck: cache stale, refetching");
|
|
2429
|
+
else debug("runUpdateCheck: no cache, fetching");
|
|
2430
|
+
const latest = await fetchLatest(parentSignal);
|
|
2431
|
+
if (latest === null) {
|
|
2432
|
+
debug("runUpdateCheck: fetch returned null, not saving cache");
|
|
2433
|
+
return "fetch-failed-or-aborted";
|
|
2434
|
+
}
|
|
2435
|
+
await saveCache({
|
|
2436
|
+
latest,
|
|
2437
|
+
checkedAt: Date.now()
|
|
2438
|
+
});
|
|
2439
|
+
if (semver.gt(latest, currentVersion)) {
|
|
2440
|
+
displayNag(currentVersion, latest);
|
|
2441
|
+
return "fetch-update";
|
|
2442
|
+
}
|
|
2443
|
+
debug("runUpdateCheck: current >= latest, no nag");
|
|
2444
|
+
return "fetch-current";
|
|
2445
|
+
} catch (err) {
|
|
2446
|
+
debug("runUpdateCheck: unexpected error — %s", err instanceof Error ? err.message : String(err));
|
|
2447
|
+
return "error";
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Run the update check at startup. Silent when:
|
|
2452
|
+
* - skip conditions match (CI, NO_UPDATE_NOTIFIER, NODE_ENV=test, non-TTY
|
|
2453
|
+
* stderr, invalid version)
|
|
2454
|
+
* - cache is fresh (< 24h old) — only displays nag if update available.
|
|
2455
|
+
* A cache-hit-current result produces NO output (no "latest version"
|
|
2456
|
+
* message), because no actual check was performed.
|
|
2457
|
+
* - stdin is non-interactive (piped) — runs silently without spinner, but
|
|
2458
|
+
* still shows "You are on the latest version" after a successful fetch
|
|
2459
|
+
*
|
|
2460
|
+
* On a stale/missing cache with interactive stdin, shows a spinner that the
|
|
2461
|
+
* user can dismiss by pressing any key. Ctrl+C restores the terminal and
|
|
2462
|
+
* exits with conventional code 130.
|
|
2463
|
+
*/
|
|
2464
|
+
async function checkForUpdatesUpfront(currentVersion) {
|
|
2465
|
+
debug("checkForUpdatesUpfront: currentVersion=%s", currentVersion);
|
|
2466
|
+
if (shouldSkip(currentVersion)) {
|
|
2467
|
+
debug("checkForUpdatesUpfront: skipped (NO_UPDATE_NOTIFIER / CI / NODE_ENV=test / non-TTY / invalid version)");
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
const cached = await loadCache();
|
|
2471
|
+
if (cached && Date.now() - cached.checkedAt < TTL_MS) {
|
|
2472
|
+
debug("checkForUpdatesUpfront: cache fresh (<%dh), skipping fetch", TTL_MS / 36e5);
|
|
2473
|
+
if (semver.gt(cached.latest, currentVersion)) displayNag(currentVersion, cached.latest);
|
|
2474
|
+
else debug("checkForUpdatesUpfront: current >= latest, no nag");
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
if (cached) debug("checkForUpdatesUpfront: cache stale, refetching");
|
|
2478
|
+
else debug("checkForUpdatesUpfront: no cache, fetching");
|
|
2479
|
+
const stdin = process.stdin;
|
|
2480
|
+
if (stdin.isTTY !== true || typeof stdin.setRawMode !== "function") {
|
|
2481
|
+
debug("checkForUpdatesUpfront: stdin not interactive, running silent check");
|
|
2482
|
+
reportFetchCurrent(await runUpdateCheck(currentVersion));
|
|
2483
|
+
return;
|
|
2484
|
+
}
|
|
2485
|
+
await runCheckWithSpinner(currentVersion);
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Surface "You are on the latest version" feedback only when the check
|
|
2489
|
+
* actually performed a fetch and the user is current. Silent on cache hits,
|
|
2490
|
+
* skips, failures, and aborts.
|
|
2491
|
+
*/
|
|
2492
|
+
function reportFetchCurrent(status) {
|
|
2493
|
+
if (status === "fetch-current") log.info(green("You are on the latest version"));
|
|
2494
|
+
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Attach a "press any key to skip" listener to stdin. Returns a cleanup
|
|
2497
|
+
* function that restores raw mode + pauses stdin; safe to call multiple times.
|
|
2498
|
+
* Returns `failed: true` if raw mode could not be enabled (caller should fall
|
|
2499
|
+
* back to a silent check).
|
|
2500
|
+
*
|
|
2501
|
+
* On any keypress: aborts `controller`. On Ctrl+C (byte 0x03): runs cleanup,
|
|
2502
|
+
* stops the spinner with `spinnerMsg`, and exits with conventional code 130.
|
|
2503
|
+
*/
|
|
2504
|
+
function attachStdinSkip(controller, spinner, spinnerMsg) {
|
|
2505
|
+
const stdin = process.stdin;
|
|
2506
|
+
let cleanedUp = false;
|
|
2507
|
+
const cleanup = () => {
|
|
2508
|
+
if (cleanedUp) return;
|
|
2509
|
+
cleanedUp = true;
|
|
2510
|
+
stdin.off("data", onData);
|
|
2511
|
+
try {
|
|
2512
|
+
stdin.setRawMode(false);
|
|
2513
|
+
} catch (err) {
|
|
2514
|
+
debug("attachStdinSkip: setRawMode(false) failed — %s", err instanceof Error ? err.message : String(err));
|
|
2515
|
+
}
|
|
2516
|
+
try {
|
|
2517
|
+
stdin.pause();
|
|
2518
|
+
} catch {}
|
|
2519
|
+
};
|
|
2520
|
+
function onData(buffer) {
|
|
2521
|
+
const byte = buffer[0];
|
|
2522
|
+
debug("attachStdinSkip: stdin byte=0x%s", byte.toString(16).padStart(2, "0"));
|
|
2523
|
+
if (byte === 3) {
|
|
2524
|
+
debug("attachStdinSkip: Ctrl+C (0x03), exiting");
|
|
2525
|
+
cleanup();
|
|
2526
|
+
spinner.stop(spinnerMsg);
|
|
2527
|
+
process.exit(130);
|
|
2528
|
+
}
|
|
2529
|
+
debug("attachStdinSkip: user pressed key, aborting check");
|
|
2530
|
+
controller.abort();
|
|
2531
|
+
}
|
|
2532
|
+
try {
|
|
2533
|
+
stdin.setRawMode(true);
|
|
2534
|
+
stdin.resume();
|
|
2535
|
+
stdin.on("data", onData);
|
|
2536
|
+
return {
|
|
2537
|
+
cleanup,
|
|
2538
|
+
failed: false
|
|
2539
|
+
};
|
|
2540
|
+
} catch (err) {
|
|
2541
|
+
debug("attachStdinSkip: setRawMode failed — %s", err instanceof Error ? err.message : String(err));
|
|
2542
|
+
return {
|
|
2543
|
+
cleanup: () => {},
|
|
2544
|
+
failed: true
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
/**
|
|
2549
|
+
* Show a cancellable spinner while the check runs. Puts stdin in raw mode to
|
|
2550
|
+
* capture individual keypresses via {@link attachStdinSkip}.
|
|
2551
|
+
*/
|
|
2552
|
+
async function runCheckWithSpinner(currentVersion) {
|
|
2553
|
+
debug("runCheckWithSpinner: showing cancellable spinner");
|
|
2554
|
+
const s = spinner();
|
|
2555
|
+
s.start("Checking for updates (press any key to skip)");
|
|
2556
|
+
const controller = new AbortController();
|
|
2557
|
+
const handler = attachStdinSkip(controller, s, "Cancelled");
|
|
2558
|
+
if (handler.failed) {
|
|
2559
|
+
s.stop("");
|
|
2560
|
+
reportFetchCurrent(await runUpdateCheck(currentVersion));
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
let status;
|
|
2564
|
+
try {
|
|
2565
|
+
status = await runUpdateCheck(currentVersion, controller.signal);
|
|
2566
|
+
} finally {
|
|
2567
|
+
handler.cleanup();
|
|
2568
|
+
}
|
|
2569
|
+
if (controller.signal.aborted) {
|
|
2570
|
+
debug("runCheckWithSpinner: spinner dismissed by user");
|
|
2571
|
+
s.stop("Skipped");
|
|
2572
|
+
} 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");
|
|
2575
|
+
else s.stop("");
|
|
2576
|
+
}
|
|
2577
|
+
//#endregion
|
|
2263
2578
|
//#region src/commands/commit-utils.ts
|
|
2264
2579
|
/** Shared recovery menu factory — avoids repeating the same callback set */
|
|
2265
2580
|
function makeRecoveryCallbacks(message) {
|
|
@@ -2694,13 +3009,14 @@ async function restageFormatterModifications(stagedFileList) {
|
|
|
2694
3009
|
}
|
|
2695
3010
|
//#endregion
|
|
2696
3011
|
//#region src/commands/commit.ts
|
|
2697
|
-
async function commitCommand(flags) {
|
|
3012
|
+
async function commitCommand(flags, version) {
|
|
2698
3013
|
debug("commitCommand called", { flags });
|
|
2699
3014
|
await assertGitRepo();
|
|
2700
3015
|
if (flags.retry) return handleRetry();
|
|
2701
3016
|
const repoRoot = await getRepoRoot();
|
|
2702
3017
|
await runPreflightSetupPrompt(repoRoot);
|
|
2703
3018
|
intro("🌿 commit-mint");
|
|
3019
|
+
await checkForUpdatesUpfront(version);
|
|
2704
3020
|
const status = await getStatusShort();
|
|
2705
3021
|
debug("Git status:", status || "(empty)");
|
|
2706
3022
|
if (!status) {
|
|
@@ -3120,7 +3436,7 @@ cli({
|
|
|
3120
3436
|
writeSessionHeader();
|
|
3121
3437
|
setDebug(argv.flags.debug);
|
|
3122
3438
|
if (argv.flags.agent) agentCommand(argv.flags);
|
|
3123
|
-
else commitCommand(argv.flags);
|
|
3439
|
+
else commitCommand(argv.flags, version);
|
|
3124
3440
|
});
|
|
3125
3441
|
//#endregion
|
|
3126
3442
|
export {};
|