@cnbcool/cnb-cli 1.2.1 → 1.2.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnbcool/cnb-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "CNB OpenAPI 命令行工具,基于 CNB 平台 Swagger 自动生成,支持 Issues、PR、Git、组织管理等全部 API 操作",
|
|
5
5
|
"main": "skills/cnb-api/scripts/core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
"author": "",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@cnbcool/cnb-api-generate": "^2.1.1",
|
|
38
37
|
"skills": "^1.4.4"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@cnbcool/cnb-api-generate": "^2.2.0"
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -27,10 +27,8 @@ function getToolParamDefs(moduleName, toolName) {
|
|
|
27
27
|
* @returns 格式化后的参数对象,包含 module, tool, path, query, data 等
|
|
28
28
|
*/
|
|
29
29
|
function formatParams(params) {
|
|
30
|
-
console.log(JSON.stringify(params));
|
|
31
30
|
// 先将 CLI 带 '-' 的参数名还原为原始 '_'/'@' 参数名
|
|
32
31
|
params = (0, _restoreOriginalKeys.restoreOriginalKeys)(params);
|
|
33
|
-
console.log(params);
|
|
34
32
|
const formatted = {
|
|
35
33
|
module: params.module,
|
|
36
34
|
tool: params.tool
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.printJSON = printJSON;
|
|
7
|
+
var _toon = require("@toon-format/toon");
|
|
7
8
|
/**
|
|
8
9
|
* 将数据转换为格式化的 JSON 字符串
|
|
9
10
|
* @param data 要序列化的数据(可以是任意类型)缩进)
|
|
@@ -11,5 +12,13 @@ exports.printJSON = printJSON;
|
|
|
11
12
|
* @returns 格式化的 JSON 字符串,如果序列化失败则返回错误信息的 JSON
|
|
12
13
|
*/
|
|
13
14
|
function printJSON(data, verbose = false) {
|
|
14
|
-
|
|
15
|
+
if (verbose) {
|
|
16
|
+
return JSON.stringify(data, null, 2);
|
|
17
|
+
} else {
|
|
18
|
+
try {
|
|
19
|
+
return (0, _toon.encode)(data);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return JSON.stringify(data);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
15
24
|
}
|