ccgather 1.3.35 → 1.3.37

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.
Files changed (2) hide show
  1. package/dist/index.js +57 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -549,7 +549,7 @@ function getCurrentProjectName() {
549
549
 
550
550
  // src/lib/ui.ts
551
551
  var import_chalk = __toESM(require("chalk"));
552
- var VERSION = true ? "1.3.35" : "0.0.0";
552
+ var VERSION = true ? "1.3.37" : "0.0.0";
553
553
  var colors = {
554
554
  primary: import_chalk.default.hex("#DA7756"),
555
555
  // Claude coral
@@ -996,15 +996,65 @@ async function displayNewBadges(badges) {
996
996
  }
997
997
  }
998
998
  }
999
+ async function verifyToken() {
1000
+ const apiUrl = getApiUrl();
1001
+ const config = getConfig();
1002
+ const apiToken = config.get("apiToken");
1003
+ if (!apiToken) {
1004
+ return { valid: false };
1005
+ }
1006
+ try {
1007
+ const response = await fetch(`${apiUrl}/cli/verify`, {
1008
+ method: "POST",
1009
+ headers: {
1010
+ "Content-Type": "application/json",
1011
+ Authorization: `Bearer ${apiToken}`
1012
+ }
1013
+ });
1014
+ if (!response.ok) {
1015
+ return { valid: false };
1016
+ }
1017
+ const data = await response.json();
1018
+ return { valid: true, username: data.username };
1019
+ } catch {
1020
+ return { valid: false };
1021
+ }
1022
+ }
999
1023
  async function submit(options) {
1000
1024
  console.log(header("Submit Usage Data", "\u{1F4E4}"));
1001
- if (!isAuthenticated()) {
1002
- console.log(`
1003
- ${error("Not authenticated.")}`);
1004
- process.exit(1);
1005
- }
1006
1025
  const config = getConfig();
1007
- const username = config.get("username");
1026
+ const verifySpinner = (0, import_ora2.default)({
1027
+ text: "Verifying authentication...",
1028
+ color: "cyan"
1029
+ }).start();
1030
+ const tokenCheck = await verifyToken();
1031
+ if (!tokenCheck.valid) {
1032
+ verifySpinner.stop();
1033
+ config.delete("apiToken");
1034
+ config.delete("userId");
1035
+ config.delete("username");
1036
+ console.log();
1037
+ console.log(` ${colors.warning("\u{1F510}")} ${colors.muted("Authentication required")}`);
1038
+ console.log();
1039
+ const { startAuth } = await import_inquirer2.default.prompt([
1040
+ {
1041
+ type: "confirm",
1042
+ name: "startAuth",
1043
+ message: "Would you like to authenticate now?",
1044
+ default: true
1045
+ }
1046
+ ]);
1047
+ if (startAuth) {
1048
+ const { auth: auth2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
1049
+ await auth2({});
1050
+ console.log();
1051
+ console.log(` ${colors.muted("Please run")} ${colors.primary("npx ccgather")} ${colors.muted("again to submit.")}`);
1052
+ console.log();
1053
+ }
1054
+ process.exit(0);
1055
+ }
1056
+ verifySpinner.succeed(colors.success("Authenticated"));
1057
+ const username = tokenCheck.username || config.get("username");
1008
1058
  if (username) {
1009
1059
  console.log(`
1010
1060
  ${colors.muted("Logged in as:")} ${colors.white(username)}`);
@@ -1159,24 +1209,6 @@ async function submit(options) {
1159
1209
  console.log(
1160
1210
  ` ${colors.warning("\u23F3")} ${colors.muted("Try again in")} ${colors.white(`${result.retryAfterMinutes} minute${result.retryAfterMinutes !== 1 ? "s" : ""}`)}`
1161
1211
  );
1162
- } else if (result.error?.includes("auth") || result.error?.includes("token")) {
1163
- console.log();
1164
- const { startAuth } = await import_inquirer2.default.prompt([
1165
- {
1166
- type: "confirm",
1167
- name: "startAuth",
1168
- message: "Would you like to authenticate now?",
1169
- default: true
1170
- }
1171
- ]);
1172
- if (startAuth) {
1173
- const { auth: auth2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
1174
- await auth2({});
1175
- console.log();
1176
- console.log(` ${colors.muted("Please run")} ${colors.primary("npx ccgather")} ${colors.muted("again to submit.")}`);
1177
- console.log();
1178
- process.exit(0);
1179
- }
1180
1212
  }
1181
1213
  console.log();
1182
1214
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccgather",
3
- "version": "1.3.35",
3
+ "version": "1.3.37",
4
4
  "description": "CLI tool for syncing Claude Code usage data to CCgather leaderboard",
5
5
  "bin": {
6
6
  "ccgather": "dist/index.js",