ai-worktool 1.0.71 → 1.0.72
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/CHANGELOG.md +2 -1
- package/dist/program.js +23 -4
- package/dist/tools/file.js +8 -21
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## 1.0.
|
|
1
|
+
## 1.0.72 (2025-08-20)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
* **plugin:** 更新插件版本和功能描述 ([f3773d6](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f3773d675fcb274080339cd0274a1a7aff8415a9))
|
|
117
117
|
* **program:** 增加代码覆盖率报告展示功能 ([60da9b5](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/60da9b59e4b913695daa8697dd9aeec16cf78a5f))
|
|
118
118
|
* **program:** 增加代码覆盖率报告展示功能 ([f693e27](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/f693e272ef0fe7e58083d2589339af17e45cff95))
|
|
119
|
+
* **program:** 增加代码覆盖率的 web 报表展示功能 ([cccf58d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/cccf58d2bfdcf2016fee011b1623821598d97e21))
|
|
119
120
|
* **program:** 添加测试配置文件选项并优化 Jest 命令生成 ([5f16c21](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/5f16c21da3a12e46a49611dbd5b2a6e3c7cdcf24))
|
|
120
121
|
* **project:** 优化项目类型检测逻辑 ([9bc024d](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/9bc024deeed239c05c9cab810f9f12a6a3306aab))
|
|
121
122
|
* **project:** 增加加载 aicoder 配置文件功能 ([b4dc70b](https://codeup.aliyun.com/666cf9ed29ecbe23053513a3/JianGuoKe/ai-worktools/commits/b4dc70b3afa88cf45135cf56e63cbb2ffa2fed82))
|
package/dist/program.js
CHANGED
|
@@ -12,6 +12,7 @@ const testAgent_1 = require("./testAgent");
|
|
|
12
12
|
const tools_1 = require("./tools");
|
|
13
13
|
const view_1 = require("./view");
|
|
14
14
|
const user_1 = require("./user");
|
|
15
|
+
const report_1 = require("./report");
|
|
15
16
|
const program = new commander_1.Command();
|
|
16
17
|
program.name('testAgent').description('吃豆豆:单测智能体').version('1.0.1');
|
|
17
18
|
// 屏蔽调试日志
|
|
@@ -138,14 +139,32 @@ program
|
|
|
138
139
|
.description('监控代码覆盖率报告')
|
|
139
140
|
.option('--projectRoot <directory>', '源代码文件夹', (txt) => path_1.default.resolve(txt), process.cwd())
|
|
140
141
|
.option('--coverageDir <string>', '覆盖率报告文件夹', 'coverage')
|
|
141
|
-
.option('
|
|
142
|
+
.option('--web <boolean>', '是否打开web报表页面', (txt) => txt === 'false', false)
|
|
143
|
+
.option('--retest <boolean>', '是否重新生成测试报表', (txt) => txt !== 'false', true)
|
|
144
|
+
.option('-w, --watch <boolean>', '是否监控代码覆盖率报告变化', (txt) => txt !== 'false', false)
|
|
142
145
|
.action(async (projectRoot, options) => {
|
|
143
|
-
|
|
146
|
+
if (options.retest) {
|
|
147
|
+
const result = await (0, tools_1.runJestTests)(projectRoot || options.projectRoot);
|
|
148
|
+
if (!result.success) {
|
|
149
|
+
console.error(result.stderr);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
144
153
|
if (options.watch) {
|
|
145
|
-
|
|
154
|
+
if (options.web) {
|
|
155
|
+
await (0, report_1.openLcovReport)(path_1.default.basename(projectRoot || options.projectRoot), path_1.default.join(projectRoot || options.projectRoot, options.coverageDir));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
await (0, view_1.showCoverageView)(path_1.default.join(projectRoot || options.projectRoot, options.coverageDir));
|
|
159
|
+
}
|
|
146
160
|
}
|
|
147
161
|
else {
|
|
148
|
-
|
|
162
|
+
if (options.web) {
|
|
163
|
+
await (0, tools_1.openLcovReport)(projectRoot || options.projectRoot, options.coverageDir);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
await (0, view_1.loadAndDisplayCoverage)(path_1.default.join(projectRoot || options.projectRoot, options.coverageDir, view_1.COVERAGE_FILE_PATH));
|
|
167
|
+
}
|
|
149
168
|
}
|
|
150
169
|
});
|
|
151
170
|
program
|
package/dist/tools/file.js
CHANGED
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.init = init;
|
|
39
40
|
exports.parseOperations = parseOperations;
|
|
40
41
|
exports.searchFilesByExtension = searchFilesByExtension;
|
|
41
42
|
exports.searchFilesByText = searchFilesByText;
|
|
@@ -50,16 +51,10 @@ exports.batchModifyLines = batchModifyLines;
|
|
|
50
51
|
exports.deleteFolder = deleteFolder;
|
|
51
52
|
const fs = __importStar(require("fs/promises"));
|
|
52
53
|
const path_1 = __importDefault(require("path"));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
added: cli_color_1.default.green, // 新增内容 - 绿色
|
|
58
|
-
removed: cli_color_1.default.red, // 删除内容 - 红色
|
|
59
|
-
unchanged: cli_color_1.default.white, // 未变更内容 - 白色
|
|
60
|
-
header: cli_color_1.default.cyan.bold, // 标题 - 青色加粗
|
|
61
|
-
timestamp: cli_color_1.default.yellow // 时间戳 - 黄色
|
|
62
|
-
};
|
|
54
|
+
let onChanged;
|
|
55
|
+
function init(callback) {
|
|
56
|
+
onChanged = callback;
|
|
57
|
+
}
|
|
63
58
|
/**
|
|
64
59
|
* 解析操作字符串为内部操作对象
|
|
65
60
|
* @param operations 操作字符串,格式:操作类型:行号范围:内容(仅增/改需要),多操作用逗号分隔
|
|
@@ -297,18 +292,10 @@ async function writeFile(filePath, content, encoding = 'utf8', overwrite = true)
|
|
|
297
292
|
await fs.mkdir(dir, { recursive: true });
|
|
298
293
|
}
|
|
299
294
|
const data = content.replace(/\r\n/g, '\n');
|
|
300
|
-
const old =
|
|
295
|
+
const old = !!onChanged && exists ? await fs.readFile(filePath, encoding) : '';
|
|
301
296
|
await fs.writeFile(filePath, data, encoding);
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
let logContent = '';
|
|
305
|
-
const diff = (0, diff_1.diffLines)(old, data);
|
|
306
|
-
diff.forEach((part) => {
|
|
307
|
-
const prefix = part.added ? '+' : part.removed ? '-' : ' ';
|
|
308
|
-
const colorFn = part.added ? colors.added : part.removed ? colors.removed : colors.unchanged;
|
|
309
|
-
logContent += colorFn(`${prefix} ${part.value}`);
|
|
310
|
-
});
|
|
311
|
-
console.log(logContent);
|
|
297
|
+
if (!!onChanged) {
|
|
298
|
+
await onChanged(filePath, old, data);
|
|
312
299
|
}
|
|
313
300
|
}
|
|
314
301
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-worktool",
|
|
3
3
|
"displayName": "吃豆豆:单测智能体",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.72",
|
|
5
5
|
"description": "单元测试智能体,帮你开发单元测试用例代码直到100%单测覆盖通过。",
|
|
6
6
|
"author": "jianguoke.cn",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"createup": "node ./uposs.js create-local-folder",
|
|
29
29
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
30
30
|
"puball": "yarn ver && yarn exepack && yarn vspack && yarn pubvs && yarn pubovsx && yarn puboss && yarn pubnpm",
|
|
31
|
-
"exepack": "yarn createup && cross-env PKG_CACHE_PATH=./binaries pkg -o packages/aicoder-1.0.
|
|
31
|
+
"exepack": "yarn createup && cross-env PKG_CACHE_PATH=./binaries pkg -o packages/aicoder-1.0.72 . && yarn upicon",
|
|
32
32
|
"pubvs": "yarn remove-deps && yarn changelog && vsce publish --yarn --baseContentUrl https://aicoder.jianguoke.cn/assets && yarn restore-deps",
|
|
33
33
|
"pubovsx": "yarn remove-deps && ovsx publish -p 47621ff6-be56-4814-865e-d2a8e8a76f86 --yarn --baseContentUrl https://aicoder.jianguoke.cn/assets && yarn restore-deps",
|
|
34
34
|
"patch": "yarn remove-deps && vsce publish patch --yarn && yarn restore-deps",
|
|
35
|
-
"vspack": "yarn createup && yarn remove-deps && vsce package -o packages/aicoder-1.0.
|
|
35
|
+
"vspack": "yarn createup && yarn remove-deps && vsce package -o packages/aicoder-1.0.72.vsix --yarn --baseContentUrl https://aicoder.jianguoke.cn/assets && yarn restore-deps",
|
|
36
36
|
"puboss": "node ./uposs.js upload",
|
|
37
37
|
"pubnpm": "npm publish --registry=https://registry.npmjs.org",
|
|
38
38
|
"prepare": "husky"
|