@hecom/codearts 0.2.3 → 0.3.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.
- package/README.md +1 -1
- package/dist/bin/cli.js +10 -10
- package/dist/commands/bug.command.d.ts +1 -1
- package/dist/commands/bug.command.js +78 -96
- package/dist/commands/config.command.js +10 -16
- package/dist/commands/daily.command.js +155 -159
- package/dist/commands/work-hour.command.js +53 -120
- package/dist/services/business.service.d.ts +14 -19
- package/dist/services/business.service.js +28 -37
- package/dist/types/index.d.ts +13 -13
- package/dist/types/index.js +8 -17
- package/dist/utils/config-loader.d.ts +5 -5
- package/dist/utils/config-loader.js +1 -1
- package/dist/utils/console.d.ts +4 -0
- package/dist/{constant/index.js → utils/console.js} +18 -0
- package/dist/utils/csv-writer.d.ts +11 -2
- package/dist/utils/csv-writer.js +37 -5
- package/dist/utils/inquirer-theme.d.ts +13 -0
- package/dist/utils/inquirer-theme.js +29 -0
- package/dist/utils/logger.d.ts +0 -1
- package/package.json +4 -2
- package/dist/constant/index.d.ts +0 -1
package/dist/utils/csv-writer.js
CHANGED
|
@@ -33,17 +33,49 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.buildCsvRow = buildCsvRow;
|
|
37
|
+
exports.createHyperlinkFormula = createHyperlinkFormula;
|
|
37
38
|
exports.writeCsvFile = writeCsvFile;
|
|
38
39
|
const fs = __importStar(require("fs"));
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
/**
|
|
41
|
-
* CSV
|
|
42
|
+
* 转义 CSV 字段中的特殊字符
|
|
43
|
+
* RFC 4180 标准:包含逗号、引号或换行符的字段需要用双引号包围,内部引号转义为两个双引号
|
|
44
|
+
* @param value 字段值
|
|
45
|
+
* @returns 转义后的 CSV 字段
|
|
42
46
|
*/
|
|
43
|
-
function
|
|
47
|
+
function escapeField(value) {
|
|
44
48
|
if (!value)
|
|
45
|
-
return '';
|
|
46
|
-
|
|
49
|
+
return '""';
|
|
50
|
+
const needsQuoting = value.includes(',') || value.includes('"') || value.includes('\n');
|
|
51
|
+
const escaped = value.replace(/"/g, '""');
|
|
52
|
+
return needsQuoting ? `"${escaped}"` : escaped;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 转义公式字符串中的双引号
|
|
56
|
+
* @param text 文本
|
|
57
|
+
* @returns 转义后的文本
|
|
58
|
+
*/
|
|
59
|
+
function escapeFormulaString(text) {
|
|
60
|
+
return text.replace(/"/g, '""');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 构建 CSV 行
|
|
64
|
+
* @param fields CSV 字段数组
|
|
65
|
+
* @returns CSV 行字符串
|
|
66
|
+
*/
|
|
67
|
+
function buildCsvRow(fields) {
|
|
68
|
+
return fields.map((field) => escapeField(String(field ?? ''))).join(',');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 创建 Excel HYPERLINK 公式
|
|
72
|
+
* @param url 链接地址
|
|
73
|
+
* @param displayText 显示文本
|
|
74
|
+
* @returns Excel HYPERLINK 公式字符串
|
|
75
|
+
*/
|
|
76
|
+
function createHyperlinkFormula(url, displayText) {
|
|
77
|
+
const escapedText = escapeFormulaString(displayText);
|
|
78
|
+
return `=HYPERLINK("${url}","${escapedText}")`;
|
|
47
79
|
}
|
|
48
80
|
/**
|
|
49
81
|
* 写入 CSV 文件到当前工作目录
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inquirer prompts 的全局 theme 配置
|
|
4
|
+
* 用于统一所有交互式提示的视觉样式
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.globalTheme = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* 中文操作提示映射表
|
|
10
|
+
*/
|
|
11
|
+
const actionMap = {
|
|
12
|
+
navigate: '上下移动',
|
|
13
|
+
select: '选择/取消',
|
|
14
|
+
all: '全选',
|
|
15
|
+
invert: '反选',
|
|
16
|
+
submit: '提交',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 全局 theme 配置
|
|
20
|
+
* 适用于 checkbox 和 select 等交互式组件
|
|
21
|
+
*/
|
|
22
|
+
exports.globalTheme = {
|
|
23
|
+
style: {
|
|
24
|
+
keysHelpTip: (keys) => {
|
|
25
|
+
const tips = keys.map(([key, action]) => `${key} \x1b[90m${actionMap[action] || action}\x1b[0m`);
|
|
26
|
+
return tips.join(' • ');
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
package/dist/utils/logger.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hecom/codearts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "华为云 CodeArts 统计分析工具",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "
|
|
16
|
+
"build": "rimraf dist && tsc && npm link",
|
|
17
17
|
"test": "jest --passWithNoTests",
|
|
18
18
|
"test:coverage": "jest --coverage --passWithNoTests",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"axios": "^1.5.0",
|
|
48
48
|
"commander": "^14.0.3",
|
|
49
49
|
"inquirer": "^13.2.2",
|
|
50
|
+
"ora": "^9.3.0",
|
|
50
51
|
"picocolors": "^1.1.1"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"@types/inquirer": "^9.0.9",
|
|
55
56
|
"@types/jest": "^29.5.5",
|
|
56
57
|
"@types/node": "^20.19.33",
|
|
58
|
+
"@types/ora": "^3.1.0",
|
|
57
59
|
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
|
58
60
|
"@typescript-eslint/parser": "^6.7.2",
|
|
59
61
|
"eslint": "^8.49.0",
|
package/dist/constant/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function showLogo(): void;
|