@openxiaobu/codexl 0.1.4 → 0.1.5

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/cli.js +22 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -13,6 +13,27 @@ const config_1 = require("./config");
13
13
  const login_1 = require("./login");
14
14
  const status_1 = require("./status");
15
15
  const usage_sync_1 = require("./usage-sync");
16
+ /**
17
+ * 读取当前 CLI 的发布版本号,优先与 npm 包元数据保持一致。
18
+ *
19
+ * @returns string,当前包版本号;当 package.json 不可读或字段缺失时返回 `0.0.0`。
20
+ * @throws 无显式抛出;内部异常会被吞掉并回退到默认版本号。
21
+ */
22
+ function getCliVersion() {
23
+ try {
24
+ const packageJsonPath = node_path_1.default.resolve(__dirname, "../package.json");
25
+ // 直接读取发布包内的 package.json,避免 CLI 版本号与 npm 发布版本脱节。
26
+ const packageJsonContent = node_fs_1.default.readFileSync(packageJsonPath, "utf8");
27
+ const packageJson = JSON.parse(packageJsonContent);
28
+ if (typeof packageJson.version === "string" && packageJson.version.trim().length > 0) {
29
+ return packageJson.version;
30
+ }
31
+ }
32
+ catch {
33
+ // 读取失败时使用保底版本,避免 `-V` 命令直接异常退出。
34
+ }
35
+ return "0.0.0";
36
+ }
16
37
  /**
17
38
  * 刷新所有已录入账号的远端额度,并输出最新状态表格。
18
39
  *
@@ -296,7 +317,7 @@ async function main() {
296
317
  program
297
318
  .name("codexl")
298
319
  .description("本地 Codex 多账号切换与状态管理工具")
299
- .version("0.1.2");
320
+ .version(getCliVersion());
300
321
  program
301
322
  .command("add")
302
323
  .description("登录并新增一个账号或工作空间")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openxiaobu/codexl",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "本地 Codex 多账号切换与状态管理工具",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli.js",