plabtokens 1.0.23 → 1.0.24
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/credentials.d.ts.map +1 -1
- package/dist/credentials.js +1 -28
- package/dist/credentials.js.map +1 -1
- package/package.json +1 -1
- package/src/credentials.ts +1 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAcD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAM9D;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,WAAW,GAAG,IAAI,CAiBpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAU1C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
package/dist/credentials.js
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import * as os from "node:os";
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_DIR = path.join(os.homedir(), ".config", "plab");
|
|
10
|
-
const OLD_CREDENTIALS_FILE = path.join(OLD_CONFIG_DIR, "credentials.json");
|
|
8
|
+
const CONFIG_DIR = path.join(os.homedir(), ".config", "plabtokens");
|
|
11
9
|
const CREDENTIALS_FILE = path.join(CONFIG_DIR, "credentials.json");
|
|
12
10
|
/**
|
|
13
11
|
* Ensure the config directory exists
|
|
@@ -17,30 +15,6 @@ function ensureConfigDir() {
|
|
|
17
15
|
fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Migrate credentials from old path (~/.token-tracker) to new XDG path (~/.config/token-tracker)
|
|
22
|
-
*/
|
|
23
|
-
function migrateFromOldPath() {
|
|
24
|
-
try {
|
|
25
|
-
if (!fs.existsSync(CREDENTIALS_FILE) && fs.existsSync(OLD_CREDENTIALS_FILE)) {
|
|
26
|
-
ensureConfigDir();
|
|
27
|
-
fs.copyFileSync(OLD_CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
28
|
-
fs.chmodSync(CREDENTIALS_FILE, 0o600);
|
|
29
|
-
// Delete old file after successful migration
|
|
30
|
-
fs.unlinkSync(OLD_CREDENTIALS_FILE);
|
|
31
|
-
// Try to remove old directory if empty
|
|
32
|
-
try {
|
|
33
|
-
fs.rmdirSync(OLD_CONFIG_DIR);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// Directory not empty (cursor files may exist) - ignore
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Migration failed - continue with normal operation (old path may still work)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
18
|
/**
|
|
45
19
|
* Save credentials to disk
|
|
46
20
|
*/
|
|
@@ -56,7 +30,6 @@ export function saveCredentials(credentials) {
|
|
|
56
30
|
* Returns null if no credentials are stored or file is invalid
|
|
57
31
|
*/
|
|
58
32
|
export function loadCredentials() {
|
|
59
|
-
migrateFromOldPath();
|
|
60
33
|
try {
|
|
61
34
|
if (!fs.existsSync(CREDENTIALS_FILE)) {
|
|
62
35
|
return null;
|
package/dist/credentials.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAS9B,MAAM,
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAS9B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAEnE;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,WAAwB;IACtD,eAAe,EAAE,CAAC;IAClB,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QACvE,QAAQ,E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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plabtokens",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "AI Token Usage Tracker & Leaderboard CLI — Track, visualize, and compete on AI coding assistant token usage across Claude Code, Cursor, OpenCode, Codex, and Gemini.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
package/src/credentials.ts
CHANGED
|
@@ -14,9 +14,7 @@ export interface Credentials {
|
|
|
14
14
|
createdAt: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const CONFIG_DIR = path.join(os.homedir(), ".config", "plab");
|
|
19
|
-
const OLD_CREDENTIALS_FILE = path.join(OLD_CONFIG_DIR, "credentials.json");
|
|
17
|
+
const CONFIG_DIR = path.join(os.homedir(), ".config", "plabtokens");
|
|
20
18
|
const CREDENTIALS_FILE = path.join(CONFIG_DIR, "credentials.json");
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -28,29 +26,6 @@ function ensureConfigDir(): void {
|
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
/**
|
|
32
|
-
* Migrate credentials from old path (~/.token-tracker) to new XDG path (~/.config/token-tracker)
|
|
33
|
-
*/
|
|
34
|
-
function migrateFromOldPath(): void {
|
|
35
|
-
try {
|
|
36
|
-
if (!fs.existsSync(CREDENTIALS_FILE) && fs.existsSync(OLD_CREDENTIALS_FILE)) {
|
|
37
|
-
ensureConfigDir();
|
|
38
|
-
fs.copyFileSync(OLD_CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
39
|
-
fs.chmodSync(CREDENTIALS_FILE, 0o600);
|
|
40
|
-
// Delete old file after successful migration
|
|
41
|
-
fs.unlinkSync(OLD_CREDENTIALS_FILE);
|
|
42
|
-
// Try to remove old directory if empty
|
|
43
|
-
try {
|
|
44
|
-
fs.rmdirSync(OLD_CONFIG_DIR);
|
|
45
|
-
} catch {
|
|
46
|
-
// Directory not empty (cursor files may exist) - ignore
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
// Migration failed - continue with normal operation (old path may still work)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
29
|
/**
|
|
55
30
|
* Save credentials to disk
|
|
56
31
|
*/
|
|
@@ -67,7 +42,6 @@ export function saveCredentials(credentials: Credentials): void {
|
|
|
67
42
|
* Returns null if no credentials are stored or file is invalid
|
|
68
43
|
*/
|
|
69
44
|
export function loadCredentials(): Credentials | null {
|
|
70
|
-
migrateFromOldPath();
|
|
71
45
|
try {
|
|
72
46
|
if (!fs.existsSync(CREDENTIALS_FILE)) {
|
|
73
47
|
return null;
|