pdlab-cli 0.2.0 → 0.2.2
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 +2 -2
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm install -g pdlab-cli
|
|
|
20
20
|
pdlab login
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
默认连官方部署 `https://1836.online`,装完直接就能用。
|
|
23
|
+
默认连官方部署 `https://www.1836.online`,装完直接就能用。
|
|
24
24
|
自建实例才需要指定地址,指定过一次之后会记在配置文件里:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
@@ -127,7 +127,7 @@ pdlab post review post_123 --action reject --comment "缺少数据来源,请
|
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
API 地址的解析顺序:`--api-url` 参数 > `PDLAB_API_URL` 环境变量 > 配置文件 > 默认地址
|
|
130
|
-
(`https://1836.online`)。所有命令都支持 `--api-url`,
|
|
130
|
+
(`https://www.1836.online`)。所有命令都支持 `--api-url`,
|
|
131
131
|
包括 `project` / `post` 这些资源命令。`pdlab config get` 会同时打出配置文件里写了什么、
|
|
132
132
|
以及这次实际会用哪个地址。
|
|
133
133
|
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
// src/index.ts
|
|
27
27
|
var import_fs2 = require("fs");
|
|
28
28
|
var import_path2 = require("path");
|
|
29
|
-
var
|
|
29
|
+
var import_commander2 = require("commander");
|
|
30
30
|
|
|
31
31
|
// src/commands/login.ts
|
|
32
32
|
var import_open = __toESM(require("open"));
|
|
@@ -48,7 +48,7 @@ var CliError = class extends Error {
|
|
|
48
48
|
// src/config.ts
|
|
49
49
|
var CONFIG_DIR = process.env.PDLAB_CONFIG_DIR ?? (0, import_path.join)((0, import_os.homedir)(), ".pdlab");
|
|
50
50
|
var CONFIG_FILE = (0, import_path.join)(CONFIG_DIR, "config.json");
|
|
51
|
-
var DEFAULT_API_URL = "https://1836.online";
|
|
51
|
+
var DEFAULT_API_URL = "https://www.1836.online";
|
|
52
52
|
function readConfig() {
|
|
53
53
|
if (!(0, import_fs.existsSync)(CONFIG_FILE)) return {};
|
|
54
54
|
try {
|
|
@@ -339,6 +339,7 @@ var postReviewSchema = import_zod3.z.object({
|
|
|
339
339
|
});
|
|
340
340
|
|
|
341
341
|
// src/errors.ts
|
|
342
|
+
var import_commander = require("commander");
|
|
342
343
|
var import_zod4 = require("zod");
|
|
343
344
|
var EXIT_CODES = {
|
|
344
345
|
ok: 0,
|
|
@@ -390,6 +391,8 @@ function handleCommandError(error, examples = []) {
|
|
|
390
391
|
};
|
|
391
392
|
} else if (error instanceof CliError) {
|
|
392
393
|
structured = { error: error.message, code: error.code, status: null, hint: "pdlab login" };
|
|
394
|
+
} else if (error instanceof import_commander.CommanderError) {
|
|
395
|
+
structured = { error: error.message.replace(/^error:\s*/, ""), code: "validation", status: null, hint: exampleHint(examples) };
|
|
393
396
|
} else {
|
|
394
397
|
structured = {
|
|
395
398
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -794,8 +797,11 @@ function registerSchemaCommand(program2) {
|
|
|
794
797
|
|
|
795
798
|
// src/index.ts
|
|
796
799
|
var pkg = JSON.parse((0, import_fs2.readFileSync)((0, import_path2.join)(__dirname, "../package.json"), "utf8"));
|
|
797
|
-
var program = new
|
|
800
|
+
var program = new import_commander2.Command();
|
|
798
801
|
program.name("pdlab").description("1836 \u5F00\u6E90\u5171\u5EFA\u5E73\u53F0\u547D\u4EE4\u884C\u5DE5\u5177\u2014\u2014\u662F\u73B0\u6709 REST API \u7684\u8584\u5C01\u88C5\u3002\u7ED9 agent/\u811A\u672C\u7528\uFF1Apdlab schema \u4E00\u6B21\u6027\u5217\u51FA\u5168\u90E8\u547D\u4EE4\u3001\u53C2\u6570\u4E0E\u9000\u51FA\u7801\u542B\u4E49\u3002").version(pkg.version);
|
|
802
|
+
program.exitOverride();
|
|
803
|
+
program.configureOutput({ writeErr: () => {
|
|
804
|
+
} });
|
|
799
805
|
registerLoginCommand(program);
|
|
800
806
|
registerRegisterCommand(program);
|
|
801
807
|
registerLogoutCommand(program);
|
|
@@ -805,5 +811,8 @@ registerProjectCommand(program);
|
|
|
805
811
|
registerPostCommand(program);
|
|
806
812
|
registerSchemaCommand(program);
|
|
807
813
|
program.parseAsync(process.argv).catch((error) => {
|
|
814
|
+
if (error instanceof import_commander2.CommanderError && error.exitCode === 0) {
|
|
815
|
+
process.exit(0);
|
|
816
|
+
}
|
|
808
817
|
handleCommandError(error);
|
|
809
818
|
});
|