ccclub 0.2.30 → 0.2.32
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 +52 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -513,7 +513,7 @@ async function initCommand() {
|
|
|
513
513
|
console.log(chalk3.cyan.bold(`
|
|
514
514
|
${data.groupCode}
|
|
515
515
|
`));
|
|
516
|
-
console.log(chalk3.dim(" Share with friends: ") + chalk3.white(`
|
|
516
|
+
console.log(chalk3.dim(" Share with friends: ") + chalk3.white(`npm i -g ccclub && ccclub join ${data.groupCode}`));
|
|
517
517
|
if (hookOk) {
|
|
518
518
|
console.log(chalk3.dim(" Auto-sync: on (via Claude Code hook)"));
|
|
519
519
|
} else {
|
|
@@ -632,6 +632,49 @@ async function joinCommand(inviteCode) {
|
|
|
632
632
|
import chalk5 from "chalk";
|
|
633
633
|
import Table from "cli-table3";
|
|
634
634
|
import ora4 from "ora";
|
|
635
|
+
|
|
636
|
+
// src/update-check.ts
|
|
637
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4 } from "fs";
|
|
638
|
+
import { join as join5 } from "path";
|
|
639
|
+
import { homedir as homedir5 } from "os";
|
|
640
|
+
var CHECK_INTERVAL_MS = 12 * 60 * 60 * 1e3;
|
|
641
|
+
var CHECK_FILE = join5(homedir5(), CCCLUB_CONFIG_DIR, "last-update-check");
|
|
642
|
+
var pendingCheck = null;
|
|
643
|
+
function startUpdateCheck(currentVersion) {
|
|
644
|
+
if (process.argv.includes("--silent") || process.argv.includes("-s")) return;
|
|
645
|
+
try {
|
|
646
|
+
if (existsSync4(CHECK_FILE)) {
|
|
647
|
+
const ts = parseInt(readFileSync3(CHECK_FILE, "utf-8").trim(), 10);
|
|
648
|
+
if (Date.now() - ts < CHECK_INTERVAL_MS) return;
|
|
649
|
+
}
|
|
650
|
+
} catch {
|
|
651
|
+
}
|
|
652
|
+
pendingCheck = (async () => {
|
|
653
|
+
try {
|
|
654
|
+
const res = await fetch("https://registry.npmjs.org/ccclub/latest", {
|
|
655
|
+
signal: AbortSignal.timeout(3e3)
|
|
656
|
+
});
|
|
657
|
+
if (!res.ok) return null;
|
|
658
|
+
const data = await res.json();
|
|
659
|
+
try {
|
|
660
|
+
writeFileSync2(CHECK_FILE, String(Date.now()));
|
|
661
|
+
} catch {
|
|
662
|
+
}
|
|
663
|
+
if (data.version !== currentVersion) {
|
|
664
|
+
return { latest: data.version, current: currentVersion };
|
|
665
|
+
}
|
|
666
|
+
return null;
|
|
667
|
+
} catch {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
})();
|
|
671
|
+
}
|
|
672
|
+
async function getUpdateResult() {
|
|
673
|
+
if (!pendingCheck) return null;
|
|
674
|
+
return pendingCheck;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// src/commands/rank.ts
|
|
635
678
|
async function rankCommand(options) {
|
|
636
679
|
const config = await requireConfig();
|
|
637
680
|
if (!isHookInstalled()) await installHook();
|
|
@@ -673,6 +716,10 @@ async function rankCommand(options) {
|
|
|
673
716
|
if (i < codes.length - 1) console.log("");
|
|
674
717
|
}
|
|
675
718
|
console.log(chalk5.dim("\n Tokens = input + output ") + chalk5.yellow("(cache excluded)") + chalk5.dim(". Use ") + chalk5.white("--cache") + chalk5.dim(" to include cache tokens."));
|
|
719
|
+
const update = await getUpdateResult();
|
|
720
|
+
if (update) {
|
|
721
|
+
console.log(chalk5.yellow("\n Update available") + chalk5.dim(`: ${update.current} \u2192 ${update.latest} Run `) + chalk5.cyan("npm i -g ccclub@latest"));
|
|
722
|
+
}
|
|
676
723
|
} catch (err) {
|
|
677
724
|
spinner.fail(`Error: ${err instanceof Error ? err.message : err}`);
|
|
678
725
|
}
|
|
@@ -925,7 +972,7 @@ async function createGroupCommand() {
|
|
|
925
972
|
spinner.succeed(`Created "${data.groupName}"`);
|
|
926
973
|
console.log(chalk8.bold(`
|
|
927
974
|
Invite code: `) + chalk8.cyan.bold(data.groupCode));
|
|
928
|
-
console.log(chalk8.dim(` Share:
|
|
975
|
+
console.log(chalk8.dim(` Share: npm i -g ccclub && ccclub join ${data.groupCode}`));
|
|
929
976
|
console.log(chalk8.dim(` Dashboard: ${config.apiUrl}/g/${data.groupCode}`));
|
|
930
977
|
} finally {
|
|
931
978
|
rl.close();
|
|
@@ -951,8 +998,10 @@ async function hookCommand() {
|
|
|
951
998
|
}
|
|
952
999
|
|
|
953
1000
|
// src/index.ts
|
|
1001
|
+
var VERSION = "0.2.32";
|
|
1002
|
+
startUpdateCheck(VERSION);
|
|
954
1003
|
var program = new Command();
|
|
955
|
-
program.name("ccclub").description("CCClub - Compare Claude Code usage with friends").version(
|
|
1004
|
+
program.name("ccclub").description("CCClub - Compare Claude Code usage with friends").version(VERSION);
|
|
956
1005
|
program.command("init").description("Initialize CCClub (one-time setup)").action(initCommand);
|
|
957
1006
|
program.command("join").description("Join a friend's group").argument("<invite-code>", "6-character invite code").action(joinCommand);
|
|
958
1007
|
program.command("sync").description("Sync local usage data to server").option("-s, --silent", "No output (used by auto-sync hook)").option("-f, --full", "Force full re-sync of all data").action(syncCommand);
|