costgrep-cli 0.7.5 → 0.7.7
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/package.json +1 -1
- package/scripts/costgrep.mjs +12 -3
package/package.json
CHANGED
package/scripts/costgrep.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import { parseArgs } from 'node:util';
|
|
|
22
22
|
|
|
23
23
|
const API = process.env.COSTGREP_API || 'https://api.github.com'; // env override exists for local-mock verification only
|
|
24
24
|
const HTTP_TIMEOUT = Math.max(1_000, parseInt(process.env.COSTGREP_TIMEOUT_MS, 10) || 30_000);
|
|
25
|
-
const VERSION = '0.7.
|
|
25
|
+
const VERSION = '0.7.7'; // keep in sync with package.json
|
|
26
26
|
|
|
27
27
|
// ---------------------------------------------------------------------------
|
|
28
28
|
// Rate matrix — GitHub-hosted runners, list prices effective 2026-01-01.
|
|
@@ -183,7 +183,14 @@ async function gh(path, token) {
|
|
|
183
183
|
throw new Error(`GitHub API rate limited on ${path} (403/429). Pass --token or narrow --days/--max-runs.`);
|
|
184
184
|
}
|
|
185
185
|
if (!res.ok) throw new Error(`GitHub API ${res.status} on ${path}: ${(await res.text()).slice(0, 300)}`);
|
|
186
|
-
|
|
186
|
+
try {
|
|
187
|
+
return await res.json();
|
|
188
|
+
} catch (e) {
|
|
189
|
+
if (e.name === 'TimeoutError' || e.name === 'AbortError') {
|
|
190
|
+
throw new Error(`GitHub API timeout reading body of ${path} after ${HTTP_TIMEOUT / 1000}s (set COSTGREP_TIMEOUT_MS to override)`);
|
|
191
|
+
}
|
|
192
|
+
throw new Error(`invalid JSON from ${path}: ${e.message}`);
|
|
193
|
+
}
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
|
|
@@ -938,9 +945,11 @@ async function main() {
|
|
|
938
945
|
}
|
|
939
946
|
const jobsByRun = new Map();
|
|
940
947
|
let done = 0;
|
|
948
|
+
if (!args.quiet) console.error(` fetching jobs for ${runs.length} runs (progress every 50)…`);
|
|
941
949
|
for (const run of runs) {
|
|
942
950
|
jobsByRun.set(run.id, await listJobs(args.repo, run.id, token));
|
|
943
|
-
|
|
951
|
+
done++;
|
|
952
|
+
if (!args.quiet && (done === 10 || done % 50 === 0)) console.error(` ...fetched jobs for ${done}/${runs.length} runs`);
|
|
944
953
|
}
|
|
945
954
|
rep = buildReport(args.repo, runs, jobsByRun, cfg, args.days, vis);
|
|
946
955
|
}
|