@juejin-opensource/jusage 0.1.8 → 0.1.10

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 (30) hide show
  1. package/dist/args.d.ts +8 -0
  2. package/dist/args.js +28 -4
  3. package/dist/dashboard/assets/dashboard-BR6dGzRU.js +60 -0
  4. package/dist/dashboard/assets/download-BUH6YifV.js +6 -0
  5. package/dist/dashboard/assets/{downloads-dKq4xNjC.js → downloads-DtzcmlGG.js} +1 -1
  6. package/dist/dashboard/assets/index-B_TGKfQG.css +1 -0
  7. package/dist/dashboard/assets/index-BishKKQ3.js +151 -0
  8. package/dist/dashboard/assets/index-tHASxOXL.js +1 -0
  9. package/dist/dashboard/assets/{model-provider-0f_aGOIG.js → model-provider-DFqk09Xz.js} +1 -1
  10. package/dist/dashboard/assets/pricing-Vc67jZDX.js +1 -0
  11. package/dist/dashboard/assets/qwenwork-CW5htBDs.ico +0 -0
  12. package/dist/dashboard/assets/rank-DBiAEOR5.js +16 -0
  13. package/dist/dashboard/assets/{settings-KbZOVhnT.js → settings-BvNehDGa.js} +1 -1
  14. package/dist/dashboard/assets/useLocalStorage-CmdvKOoP.js +16 -0
  15. package/dist/dashboard/brand-logos/command-code.svg +4 -0
  16. package/dist/dashboard/brand-logos/qwenwork.ico +0 -0
  17. package/dist/dashboard/index.html +2 -2
  18. package/dist/index.js +12 -3
  19. package/dist/service-linux.js +5 -3
  20. package/dist/service-windows.js +5 -1
  21. package/dist/service.js +21 -2
  22. package/package.json +3 -3
  23. package/dist/dashboard/assets/dashboard-BcYn7CaU.js +0 -55
  24. package/dist/dashboard/assets/download-CteP_gYs.js +0 -6
  25. package/dist/dashboard/assets/index-BfeJy_UY.js +0 -1
  26. package/dist/dashboard/assets/index-CWwN4M6h.css +0 -1
  27. package/dist/dashboard/assets/index-flWmwEjH.js +0 -143
  28. package/dist/dashboard/assets/pricing-OObJBgJw.js +0 -1
  29. package/dist/dashboard/assets/rank-CuAJ5i73.js +0 -16
  30. package/dist/dashboard/assets/useLocalStorage-BdF6kE3i.js +0 -1
package/dist/args.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  export declare const DEFAULT_HOST = "127.0.0.1";
2
+ /** `--source` 的合法取值提示,从 sync registry 生成,避免帮助与实现脱节。 */
3
+ export declare function formatSyncSourceList(): string;
4
+ /**
5
+ * 校验 `--source`:未传 / `all` 表示全量;别名与大小写归一为标准 id;
6
+ * 未知值抛错(由 main 打印并以非零码退出),绝不静默跳过。
7
+ */
8
+ export declare function resolveSyncSource(raw?: string): string | undefined;
2
9
  export declare function isWildcardListenHost(host: string): boolean;
3
10
  export declare function formatListenUrl(host: string, port: number): string;
4
11
  export interface ParsedArgs {
@@ -15,6 +22,7 @@ export interface ParsedArgs {
15
22
  days?: number;
16
23
  }
17
24
  export declare function normalizeListenHost(raw: string): string;
25
+ export declare function normalizeListenPort(raw: string): number;
18
26
  export declare function parseArgs(argv: string[]): ParsedArgs;
19
27
  export declare function resolveDaysAgo(days: number | undefined): number | undefined;
20
28
  export declare function printHelp(): void;
package/dist/args.js CHANGED
@@ -1,5 +1,19 @@
1
- import { DEFAULT_PORT } from '@juejin-opensource/jusage-core';
1
+ import { DEFAULT_PORT, SYNC_SOURCE_IDS, normalizeSyncSource, } from '@juejin-opensource/jusage-core';
2
2
  export const DEFAULT_HOST = '127.0.0.1';
3
+ /** `--source` 的合法取值提示,从 sync registry 生成,避免帮助与实现脱节。 */
4
+ export function formatSyncSourceList() {
5
+ return ['all', ...SYNC_SOURCE_IDS].join(' | ');
6
+ }
7
+ /**
8
+ * 校验 `--source`:未传 / `all` 表示全量;别名与大小写归一为标准 id;
9
+ * 未知值抛错(由 main 打印并以非零码退出),绝不静默跳过。
10
+ */
11
+ export function resolveSyncSource(raw) {
12
+ const resolved = normalizeSyncSource(raw);
13
+ if (resolved !== null)
14
+ return resolved;
15
+ throw new Error(`未知的数据源: ${raw}\n可用值: ${formatSyncSourceList()}`);
16
+ }
3
17
  export function isWildcardListenHost(host) {
4
18
  return host === '0.0.0.0' || host === '::';
5
19
  }
@@ -18,6 +32,13 @@ export function normalizeListenHost(raw) {
18
32
  }
19
33
  return host;
20
34
  }
35
+ export function normalizeListenPort(raw) {
36
+ const port = Number(raw);
37
+ if (!Number.isInteger(port) || port < 1 || port > 65_535) {
38
+ throw new Error(`无效的 --port: ${raw},请输入 1 到 65535 之间的整数`);
39
+ }
40
+ return port;
41
+ }
21
42
  function isFlagToken(value) {
22
43
  return value != null && value.startsWith('-') && value !== '-';
23
44
  }
@@ -42,8 +63,11 @@ export function parseArgs(argv) {
42
63
  serviceAction = args[1];
43
64
  }
44
65
  for (let i = 0; i < args.length; i++) {
45
- if (args[i] === '--port' && args[i + 1]) {
46
- port = Number(args[i + 1]) || DEFAULT_PORT;
66
+ if (args[i] === '--port') {
67
+ if (isFlagToken(args[i + 1]) || args[i + 1] == null) {
68
+ throw new Error('--port 需要端口号,例如 8452');
69
+ }
70
+ port = normalizeListenPort(args[i + 1]);
47
71
  i += 1;
48
72
  }
49
73
  else if (args[i] === '--host') {
@@ -105,7 +129,7 @@ Commands:
105
129
  Options:
106
130
  --port <number> 面板端口(默认 ${DEFAULT_PORT})
107
131
  --host <address> 面板监听地址(默认 ${DEFAULT_HOST};局域网访问用 0.0.0.0)
108
- --source <name> sync 数据源:claude | codex | cursor | qoder | trae | gemini | opencode | copilot | antigravity | openclaw | hermes | zcode | pi | kimi | roocode | droid | kiro | cline | amp | qwen | codebuddy | workbuddy | grok | mimo | every-code | omp | kilo-cli | kilocode | goose | zed | warp | all
132
+ --source <name> sync 数据源:${formatSyncSourceList()}
109
133
  --force upload 时忽略云端同步开关,强制上报
110
134
  --reconcile upload 时做全量对账
111
135
  -h, --help 显示帮助