ccclub 0.2.70 → 0.2.72
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 +11 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -392,8 +392,10 @@ function formatFetchError(err) {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
// src/usage-limits.ts
|
|
395
|
-
import { execSync as execSync2 } from "child_process";
|
|
395
|
+
import { execSync as execSync2, exec } from "child_process";
|
|
396
|
+
import { promisify } from "util";
|
|
396
397
|
import { userInfo as userInfo2 } from "os";
|
|
398
|
+
var execAsync = promisify(exec);
|
|
397
399
|
function parseUtilization(value) {
|
|
398
400
|
if (typeof value === "number") return Math.round(value * 100) / 100;
|
|
399
401
|
if (typeof value === "string") {
|
|
@@ -412,15 +414,11 @@ async function fetchUsageLimits() {
|
|
|
412
414
|
const credentials = JSON.parse(raw);
|
|
413
415
|
const accessToken = credentials?.claudeAiOauth?.accessToken;
|
|
414
416
|
if (!accessToken || typeof accessToken !== "string") return null;
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
signal: AbortSignal.timeout(8e3)
|
|
421
|
-
});
|
|
422
|
-
if (!res.ok) return null;
|
|
423
|
-
const data = await res.json();
|
|
417
|
+
const curlCmd = `curl -sf --max-time 8 "https://api.anthropic.com/api/oauth/usage" -H "Authorization: Bearer ${accessToken}" -H "anthropic-beta: oauth-2025-04-20" -H "User-Agent: claude-code/2.1.5"`;
|
|
418
|
+
const { stdout: stdout5 } = await execAsync(curlCmd, { timeout: 9e3 });
|
|
419
|
+
if (!stdout5) return null;
|
|
420
|
+
const data = JSON.parse(stdout5);
|
|
421
|
+
if (data.error) return null;
|
|
424
422
|
const fiveHourRaw = data.five_hour?.utilization;
|
|
425
423
|
const sevenDayRaw = data.seven_day?.utilization;
|
|
426
424
|
return {
|
|
@@ -548,11 +546,11 @@ async function doSync(firstSync = false, silent = false) {
|
|
|
548
546
|
}
|
|
549
547
|
|
|
550
548
|
// src/global-install.ts
|
|
551
|
-
import { exec } from "child_process";
|
|
549
|
+
import { exec as exec2 } from "child_process";
|
|
552
550
|
import chalk3 from "chalk";
|
|
553
551
|
function run(cmd) {
|
|
554
552
|
return new Promise((resolve) => {
|
|
555
|
-
|
|
553
|
+
exec2(cmd, (err, stdout5) => resolve(err ? "" : stdout5.trim()));
|
|
556
554
|
});
|
|
557
555
|
}
|
|
558
556
|
async function ensureGlobalInstall() {
|
|
@@ -1309,7 +1307,7 @@ async function hookCommand() {
|
|
|
1309
1307
|
}
|
|
1310
1308
|
|
|
1311
1309
|
// src/index.ts
|
|
1312
|
-
var VERSION = "0.2.
|
|
1310
|
+
var VERSION = "0.2.72";
|
|
1313
1311
|
startUpdateCheck(VERSION);
|
|
1314
1312
|
var program = new Command();
|
|
1315
1313
|
program.name("ccclub").description("Claude Code leaderboard among friends").version(VERSION, "-v, -V, --version");
|