@cnbcool/cnb-api-generate 2.20.0 → 2.21.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.
|
@@ -32,15 +32,17 @@ const AUTO_INJECTED_DISPLAY_KEYS = new Set(['repo', 'number', 'review-id']);
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* 为不走 registerToolOptions 的快捷命令(upload / CI 自定义命令)注册
|
|
35
|
-
* 由环境变量自动注入的 path
|
|
36
|
-
* - repo
|
|
37
|
-
* - number
|
|
35
|
+
* 由环境变量自动注入的 path 参数,使其可被显式覆盖(未传时由 autoPath 从环境变量回填)。
|
|
36
|
+
* - repo:所有快捷命令都注册
|
|
37
|
+
* - number:对所有快捷命令都注册,但只有接口真的消费 number 时才有意义
|
|
38
|
+
*
|
|
39
|
+
* number 的注册遵循「统一接口形态」:Issue 与 PR 两侧的快捷命令参数保持一致,
|
|
40
|
+
* 便于 NPC 用同一套写法(`--repo x/y --number 99`)在两种场景间迁移。
|
|
41
|
+
* 消费方(upload / CI 分支)只取自己需要的字段,多传不会改变任何请求。
|
|
38
42
|
*/
|
|
39
|
-
function registerAutoInjectedPathOptions(cmd: Command
|
|
43
|
+
function registerAutoInjectedPathOptions(cmd: Command): void {
|
|
40
44
|
cmd.option('--repo <string>', '仓库名称(可选,默认取 CNB_REPO_SLUG)');
|
|
41
|
-
|
|
42
|
-
cmd.option('--number <string>', '编号(可选,默认取 CNB_ISSUE_IID / CNB_PULL_REQUEST_IID)');
|
|
43
|
-
}
|
|
45
|
+
cmd.option('--number <string>', '编号(可选,默认取 CNB_ISSUE_IID / CNB_PULL_REQUEST_IID)');
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -201,19 +203,18 @@ export function registerModuleCommands(program: Command): void {
|
|
|
201
203
|
// 按命令类别注册选项:upload / ci 自定义 / 普通 swagger 命令
|
|
202
204
|
if (shortcut.upload) {
|
|
203
205
|
shortcutCmd.requiredOption('--file <string>', '本地文件路径。必填。');
|
|
204
|
-
//
|
|
206
|
+
// --number 一律注册,但只有 issue 评论上传会消费:
|
|
205
207
|
// - post-issue-comment-*-asset-upload-url(issue 评论上传):path 为 repo + number
|
|
206
208
|
// - post-asset-group(创建 issue 时上传):path 只有 repo,number 传了也会被忽略
|
|
207
209
|
// - pull 侧 upload-files / upload-imgs:按仓库维度上传,同样不需要 number
|
|
208
|
-
|
|
209
|
-
registerAutoInjectedPathOptions(shortcutCmd, needNumber);
|
|
210
|
+
registerAutoInjectedPathOptions(shortcutCmd);
|
|
210
211
|
} else if (
|
|
211
212
|
shortcut.realTool === '__get-ci-logs__' ||
|
|
212
213
|
shortcut.realTool === '__get-ci-timing__'
|
|
213
214
|
) {
|
|
214
215
|
shortcutCmd.option('--sn <string>', '构建号(可选,默认自动从环境变量或 PR 状态获取)');
|
|
215
|
-
// CI
|
|
216
|
-
shortcutCmd
|
|
216
|
+
// CI 命令按 PR 维度查询,同样注册 --number 保持两侧参数形态一致
|
|
217
|
+
registerAutoInjectedPathOptions(shortcutCmd);
|
|
217
218
|
} else {
|
|
218
219
|
registerToolOptions(shortcutCmd, moduleName, shortcut.realTool, true);
|
|
219
220
|
}
|
package/package.json
CHANGED
package/skills-template/SKILL.md
CHANGED
|
@@ -13,6 +13,7 @@ description: CNB 平台交互命令,支持代码仓库、Issue、PR、CI、制
|
|
|
13
13
|
|
|
14
14
|
- **默认摘要省流**:默认精简输出,加 `--verbose` 输出完整数据。
|
|
15
15
|
- **多行用单引号**:bash 参数为多行文本时用单引号,降低命令注入风险。
|
|
16
|
+
- **创建 issue 默认带 `--work-mode`**:`cnb issues create-issue` 已默认注入 `work_mode: true`,不必再传;`--work-mode` 也仍可从 `--help` 看到并显式覆盖。
|
|
16
17
|
|
|
17
18
|
## issue/pr 访问说明
|
|
18
19
|
|