ccusage-tracker 0.1.5 → 0.1.6
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/index.js +17 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -419,10 +419,10 @@ Hook: ${hookInstalled ? "installed" : "not installed"}`);
|
|
|
419
419
|
const configDir = dirname(configPath);
|
|
420
420
|
const lastErrorPath = join3(configDir, "last-error.txt");
|
|
421
421
|
if (existsSync3(lastErrorPath)) {
|
|
422
|
+
const reason = readFileSync3(lastErrorPath, "utf-8").trim();
|
|
422
423
|
console.log(`
|
|
423
|
-
Last upload: FAILED - ${
|
|
424
|
-
console.log(
|
|
425
|
-
console.log(" time ccusage daily --json --since $(date +%Y%m%d)");
|
|
424
|
+
Last upload: FAILED - ${reason}`);
|
|
425
|
+
console.log(uploadFailureHint(reason));
|
|
426
426
|
} else {
|
|
427
427
|
console.log(`
|
|
428
428
|
Last upload: no recorded failure`);
|
|
@@ -438,6 +438,20 @@ Last upload: no recorded failure`);
|
|
|
438
438
|
const probe = probeCcusage();
|
|
439
439
|
console.log(probe ? `ccusage: installed (${probe})` : "ccusage: not found (install with: npx ccusage@latest)");
|
|
440
440
|
}
|
|
441
|
+
function uploadFailureHint(reason) {
|
|
442
|
+
if (reason.includes("ccusage")) {
|
|
443
|
+
return [
|
|
444
|
+
" 用量目前並未上報。請量測 ccusage 耗時,若接近 25s 需再放寬 timeout:",
|
|
445
|
+
" time ccusage daily --json --since $(date +%Y%m%d)"
|
|
446
|
+
].join(`
|
|
447
|
+
`);
|
|
448
|
+
}
|
|
449
|
+
return [
|
|
450
|
+
" 用量目前並未上報。ccusage 有取到數,卡在送出那一段 —— 先看上面的 Server 一行,",
|
|
451
|
+
" 再檢查網路 / VPN / proxy。當日快照是整日累計,下次 hook 跑成就會補齊"
|
|
452
|
+
].join(`
|
|
453
|
+
`);
|
|
454
|
+
}
|
|
441
455
|
function probeCcusage() {
|
|
442
456
|
try {
|
|
443
457
|
const r = spawnSync2("ccusage --version", { encoding: "utf8", shell: true, timeout: 1e4 });
|
package/package.json
CHANGED