@cnbcool/cnb-api-generate 2.10.1 → 2.11.0
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.
|
@@ -18,6 +18,18 @@ interface FlatOption {
|
|
|
18
18
|
isNestedField?: boolean;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 快捷命令下会由 shortcut.autoPath 从环境变量自动注入的 path 参数白名单。
|
|
23
|
+
* 这些参数在注册命令行选项时应被跳过,避免让 NPC 重复传递。
|
|
24
|
+
* 其余 path 参数(如 img_path / file_path)仍需 NPC 显式传入。
|
|
25
|
+
*
|
|
26
|
+
* - repo / repo_slug:CNB_REPO_SLUG
|
|
27
|
+
* - number:issues 走 CNB_ISSUE_IID,pulls 走 CNB_PULL_REQUEST_IID
|
|
28
|
+
* - review_id:CNB_REVIEW_ID(pulls comment 转 review 回复时启用)
|
|
29
|
+
*/
|
|
30
|
+
const AUTO_INJECTED_PATH_KEYS = new Set(['repo', 'number', 'review_id']);
|
|
31
|
+
const AUTO_INJECTED_DISPLAY_KEYS = new Set(['repo', 'number', 'review-id']);
|
|
32
|
+
|
|
21
33
|
/**
|
|
22
34
|
* 为单个 tool 子命令注册 Commander options
|
|
23
35
|
* 直接读取预生成的 flat-options.json 中已扁平化的参数定义,无需运行时计算
|
|
@@ -29,15 +41,23 @@ function registerToolOptions(toolCmd: Command, moduleName: string, toolName: str
|
|
|
29
41
|
if (!toolOptions) return;
|
|
30
42
|
|
|
31
43
|
for (const [, opt] of Object.entries(toolOptions) as [string, FlatOption][]) {
|
|
32
|
-
//
|
|
33
|
-
|
|
44
|
+
// 快捷命令下:仅跳过"由 shortcut.autoPath 从环境变量自动注入"的 path 参数
|
|
45
|
+
// (repo / number / review_id)。其余 path 参数(如 img_path、file_path)
|
|
46
|
+
// 仍需要 NPC 通过 --xxx 显式传入,因此保留注册且保留 required 标记。
|
|
47
|
+
if (
|
|
48
|
+
skipPathMandatory
|
|
49
|
+
&& opt.source === 'path'
|
|
50
|
+
&& (AUTO_INJECTED_PATH_KEYS.has(opt.optKey) || AUTO_INJECTED_DISPLAY_KEYS.has(opt.optKey))
|
|
51
|
+
) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
34
54
|
|
|
35
55
|
const option = new Option(
|
|
36
56
|
`--${opt.optKey} ${opt.valuePlaceholder}`.trim(),
|
|
37
57
|
opt.description,
|
|
38
58
|
);
|
|
39
59
|
|
|
40
|
-
if (opt.required && opt.source === 'path'
|
|
60
|
+
if (opt.required && opt.source === 'path') {
|
|
41
61
|
option.makeOptionMandatory();
|
|
42
62
|
}
|
|
43
63
|
|
package/package.json
CHANGED
package/quick-commands.json
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
{ "shortName": "upload-file", "realTool": "post-issue-comment-file-asset-upload-url", "description": "上传 issue 评论文件", "upload": true, "kind": "file", "dataTip": "--file 文件路径" },
|
|
13
13
|
{ "shortName": "upload-image", "realTool": "post-issue-comment-image-asset-upload-url","description": "上传 issue 评论图片", "upload": true, "kind": "image", "dataTip": "--file 图片路径" },
|
|
14
14
|
{ "shortName": "create-upload-file", "realTool": "post-asset-group", "description": "创建 issue 时上传文件", "upload": true, "kind": "file", "dataTip": "--file 文件路径" },
|
|
15
|
-
{ "shortName": "create-upload-image", "realTool": "post-asset-group", "description": "创建 issue 时上传图片", "upload": true, "kind": "image", "dataTip": "--file 图片路径" }
|
|
15
|
+
{ "shortName": "create-upload-image", "realTool": "post-asset-group", "description": "创建 issue 时上传图片", "upload": true, "kind": "image", "dataTip": "--file 图片路径" },
|
|
16
|
+
{ "shortName": "get-imgs", "realTool": "get-issue-imgs", "description": "获取 issue 图片", "repoOnly": true, "dataTip": "--img-path 图片路径" },
|
|
17
|
+
{ "shortName": "get-files", "realTool": "get-issue-files", "description": "获取 issue 附件", "repoOnly": true, "dataTip": "--file-path 附件路径" }
|
|
16
18
|
],
|
|
17
19
|
"pulls": [
|
|
18
20
|
{ "shortName": "get", "realTool": "get-pull", "description": "获取详情" },
|
|
@@ -28,6 +30,8 @@
|
|
|
28
30
|
{ "shortName": "upload-file", "realTool": "upload-files", "description": "上传文件", "repoOnly": true, "upload": true, "dataTip": "--file 文件路径" },
|
|
29
31
|
{ "shortName": "upload-image", "realTool": "upload-imgs", "description": "上传图片", "repoOnly": true, "upload": true, "dataTip": "--file 图片路径" },
|
|
30
32
|
{ "shortName": "get-ci-logs", "realTool": "__get-ci-logs__", "description": "获取 CI 失败日志", "repoOnly": true, "custom": true, "dataTip": "--sn 构建号(可选)" },
|
|
31
|
-
{ "shortName": "get-ci-timing", "realTool": "__get-ci-timing__", "description": "分析 CI 耗时瓶颈", "repoOnly": true, "custom": true, "dataTip": "--sn 构建号(可选)" }
|
|
33
|
+
{ "shortName": "get-ci-timing", "realTool": "__get-ci-timing__", "description": "分析 CI 耗时瓶颈", "repoOnly": true, "custom": true, "dataTip": "--sn 构建号(可选)" },
|
|
34
|
+
{ "shortName": "get-imgs", "realTool": "get-pr-imgs", "description": "获取 PR 图片", "repoOnly": true, "dataTip": "--img-path 图片路径" },
|
|
35
|
+
{ "shortName": "get-files", "realTool": "get-pr-files", "description": "获取 PR 附件", "repoOnly": true, "dataTip": "--file-path 附件路径" }
|
|
32
36
|
]
|
|
33
37
|
}
|