@cnbcool/cnb-api-generate 2.7.1 → 2.7.3

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.
@@ -1,5 +1,5 @@
1
1
  import { helpData } from './help-data';
2
- import { tryParseJSON } from './parsers';
2
+ import { tryParseJSON, tryReadFileRef } from './parsers';
3
3
  import { buildNestedFieldMap } from '../utils/build-nested-field-map';
4
4
  import type { NestedFieldMapping } from '../utils/build-nested-field-map';
5
5
  import { restoreOriginalKeys } from '../utils/restore-original-keys';
@@ -156,7 +156,8 @@ export function formatParams(
156
156
  } else if (bodyProps[key].type === 'string') {
157
157
  // schema 定义为 string 类型时,保持原始字符串,不做 JSON 解析
158
158
  // 避免纯数字字符串(如 "123")被转为 number
159
- formatted.data[key] = value;
159
+ // 支持 @file 语法:从文件读取长文本内容(避免 shell 长参数截断)
160
+ formatted.data[key] = tryReadFileRef(value as string);
160
161
  } else {
161
162
  formatted.data[key] = tryParseJSON(value as string);
162
163
  }
@@ -19,6 +19,7 @@ export async function refreshAccessToken(store: TokenStore): Promise<string> {
19
19
  form.set('refresh_token', store.refresh_token);
20
20
  form.set('client_id', clientID);
21
21
 
22
+ const nowSec = Math.floor(Date.now() / 1000);
22
23
  const resp = await fetch(tokenURL, {
23
24
  method: 'POST',
24
25
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
@@ -31,7 +32,6 @@ export async function refreshAccessToken(store: TokenStore): Promise<string> {
31
32
  }
32
33
 
33
34
  const tok: TokenResponse = await resp.json();
34
- const nowSec = Math.floor(Date.now() / 1000);
35
35
 
36
36
  const newStore: TokenStore = {
37
37
  access_token: tok.access_token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnbcool/cnb-api-generate",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "main": "./built/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -16,6 +16,7 @@ description: CNB 平台交互命令,支持仓库、Issue、PR、流水线、
16
16
  - **参数自动识别**:快捷命令中的 Issue/PR 编号会自动从环境变量识别,无需额外传递。
17
17
  - **默认仅需摘要**:默认会精简响应输出结果,只返回核心字段。添加 `--verbose` 输出完整数据。
18
18
  - **单引号传参**:传递多行文本参数时,使用单引号可防止命令注入攻击,并减少不必要的转义。
19
+ - **长文本传参**:当 `--body` 内容超过 3 行或包含复杂格式时,**必须**先将内容写入临时文件,再用 `--body @/tmp/comment.md` 文件引用方式传递,避免 shell 参数截断或转义问题。
19
20
  - **快捷命令适用范围**: 快捷命令只能操作当前仓库的当前 Issue/PR,跨仓库或跨编号操作请参考 `更多 API`。
20
21
  - **npc提及和召唤的区别**: 评论中直接 @npc 会召唤 npc 干活,如果只提及不召唤,应该去掉 `@` 符号,或使用反引号包裹 `@npc`。
21
22