@token-dashboard/codex-usage-uploader 0.1.0 → 0.1.1
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/README.md +10 -18
- package/package.json +1 -1
- package/src/cli.js +22 -2
package/README.md
CHANGED
|
@@ -18,14 +18,6 @@ npx @token-dashboard/codex-usage-uploader init
|
|
|
18
18
|
|
|
19
19
|
安装过程中会自动读取 Codex 登录态(`~/.codex/auth.json`)获取身份信息。如果读取不到邮箱,会在终端交互式提示你手动填写。
|
|
20
20
|
|
|
21
|
-
如需跳过交互提示,可以直接指定邮箱:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npx @token-dashboard/codex-usage-uploader init \
|
|
25
|
-
--email you@company.com \
|
|
26
|
-
--yes
|
|
27
|
-
```
|
|
28
|
-
|
|
29
21
|
安装完成后,`codex-usage-uploader` 命令会被写入 `~/bin/`,后续可直接使用。
|
|
30
22
|
|
|
31
23
|
## 命令一览
|
|
@@ -82,16 +74,16 @@ codex-usage-uploader uninstall
|
|
|
82
74
|
|
|
83
75
|
## 常用选项
|
|
84
76
|
|
|
85
|
-
| 选项
|
|
86
|
-
|
|
|
87
|
-
| `--backend-url <url>`
|
|
88
|
-
| `--email <email>`
|
|
89
|
-
| `--employee-name <name>`
|
|
90
|
-
| `--employee-id <id>`
|
|
91
|
-
| `--interval <seconds>`
|
|
92
|
-
| `--yes`
|
|
93
|
-
| `--lines <n>`
|
|
94
|
-
| `-h, --help`
|
|
77
|
+
| 选项 | 说明 |
|
|
78
|
+
| ------------------------ | ------------------------------------------------------ |
|
|
79
|
+
| `--backend-url <url>` | Dashboard 后端地址(默认 `http://101.126.66.51:8086`) |
|
|
80
|
+
| `--email <email>` | 绑定邮箱 |
|
|
81
|
+
| `--employee-name <name>` | 绑定姓名 |
|
|
82
|
+
| `--employee-id <id>` | 绑定工号 |
|
|
83
|
+
| `--interval <seconds>` | 扫描间隔秒数(默认 30) |
|
|
84
|
+
| `--yes` | 跳过所有交互确认 |
|
|
85
|
+
| `--lines <n>` | `logs` 命令输出行数(默认 100) |
|
|
86
|
+
| `-h, --help` | 显示帮助 |
|
|
95
87
|
|
|
96
88
|
## 工作原理
|
|
97
89
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import { CodexUsageUploader } from './collector.js';
|
|
3
4
|
import { identityIsBound, promptConfirm } from './auth.js';
|
|
4
|
-
import { CLI_NAME, DEFAULT_CONFIG_FILE, PRODUCT_NAME } from './constants.js';
|
|
5
|
+
import { CLI_NAME, DEFAULT_BACKEND_URL, DEFAULT_CONFIG_FILE, PRODUCT_NAME } from './constants.js';
|
|
5
6
|
import { findPackageRoot, installCurrentPackage } from './install.js';
|
|
6
7
|
import { LaunchdServiceManager } from './launchd.js';
|
|
7
8
|
import { formatStatusOutput, mergeRuntimeConfig } from './runtime-config.js';
|
|
@@ -307,8 +308,26 @@ function wrapCatchUpFailure(error) {
|
|
|
307
308
|
);
|
|
308
309
|
}
|
|
309
310
|
|
|
311
|
+
function printPathHint(runtime) {
|
|
312
|
+
const linkDir = path.dirname(runtime.homeBinLink);
|
|
313
|
+
const dirs = (process.env.PATH || '').split(path.delimiter);
|
|
314
|
+
if (dirs.includes(linkDir)) return;
|
|
315
|
+
console.log('');
|
|
316
|
+
console.log(
|
|
317
|
+
`Note: ${linkDir} is not in your PATH. To use \`${CLI_NAME}\` directly, run:`,
|
|
318
|
+
);
|
|
319
|
+
console.log(` export PATH="${linkDir}:$PATH"`);
|
|
320
|
+
console.log(
|
|
321
|
+
'You can add this line to ~/.zshrc or ~/.bashrc to make it permanent.',
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
310
325
|
async function runInit(options) {
|
|
311
|
-
|
|
326
|
+
const overrides = runtimeOverrides(options);
|
|
327
|
+
if (!overrides.backendUrl) {
|
|
328
|
+
overrides.backendUrl = DEFAULT_BACKEND_URL;
|
|
329
|
+
}
|
|
330
|
+
let runtime = mergeRuntimeConfig(options.configFile, overrides);
|
|
312
331
|
if (!runtime.backendUrl) {
|
|
313
332
|
throw new Error(
|
|
314
333
|
'--backend-url is required for init unless already configured in config.json',
|
|
@@ -345,6 +364,7 @@ async function runInit(options) {
|
|
|
345
364
|
manager.start();
|
|
346
365
|
console.log(`${PRODUCT_NAME} initialized and started.`);
|
|
347
366
|
console.log(`Use \`${CLI_NAME} status\` to check the local service.`);
|
|
367
|
+
printPathHint(runtime);
|
|
348
368
|
} finally {
|
|
349
369
|
uploader.close();
|
|
350
370
|
}
|