@ai-dev-tools/test-copilot-core 1.0.19 → 1.0.21
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 +14 -0
- package/out/core/utils/lint.d.ts.map +1 -1
- package/out/core/utils/lint.js +15 -19
- package/out/core/utils/lint.js.map +1 -1
- package/out/core/valid/execEslint.d.ts +2 -0
- package/out/core/valid/execEslint.d.ts.map +1 -0
- package/out/core/valid/execEslint.js +33 -0
- package/out/core/valid/execEslint.js.map +1 -0
- package/package.json +3 -3
- /package/{package_devops.json → devops/package.json} +0 -0
package/README.md
CHANGED
|
@@ -4,3 +4,17 @@
|
|
|
4
4
|
$ npm run setup-npm-auth
|
|
5
5
|
$ npm i
|
|
6
6
|
```
|
|
7
|
+
|
|
8
|
+
# publish to npmjs
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm logout
|
|
12
|
+
npm login --registry=https://registry.npmjs.org/
|
|
13
|
+
npm publish --registry https://registry.npmjs.org/ --access public
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
# del published package within 72 hours
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm unpublish @ai-dev-tools/test-copilot-core@1.0.19
|
|
20
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/core/utils/lint.ts"],"names":[],"mappings":"AAYA,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,iBAM/D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/core/utils/lint.ts"],"names":[],"mappings":"AAYA,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,iBAM/D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;GAiE3H"}
|
package/out/core/utils/lint.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.runLint = runLint;
|
|
|
7
7
|
exports.runLintWithAutofix = runLintWithAutofix;
|
|
8
8
|
const eslintRuleHandler_1 = require("./eslintRuleHandler");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
|
-
const
|
|
10
|
+
const execEslint_1 = require("../valid/execEslint");
|
|
11
11
|
const lintFix_1 = require("../features/lintFix");
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
13
|
const config_1 = require("../config");
|
|
@@ -19,25 +19,21 @@ async function runLint(filePath, rootDir) {
|
|
|
19
19
|
const cwd = rootDir ?? path_1.default.dirname(filePath);
|
|
20
20
|
(0, console_1.getConsole)().log(`Running lint for ${filePath}`);
|
|
21
21
|
// run twice to make sure the lint is correct
|
|
22
|
-
await (0,
|
|
22
|
+
await (0, execEslint_1.ensureExecLint)(filePath, cwd);
|
|
23
23
|
(0, console_1.getConsole)().log(`Lint done for ${filePath}`);
|
|
24
24
|
}
|
|
25
25
|
async function runLintWithAutofix(filePath, testFramework, abortSignal, rootDir) {
|
|
26
26
|
const cwd = rootDir ?? path_1.default.dirname(filePath);
|
|
27
27
|
(0, console_1.getConsole)().log(`Running lint for ${filePath}`);
|
|
28
28
|
let originalTestCode = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
29
|
-
let originalLintErrors;
|
|
30
29
|
const isCustomizedLint = !!(0, config_1.getConfig)().common.customizedLintCmd;
|
|
31
30
|
let lastestLintErrors;
|
|
32
31
|
for (let i = 0; i <= constants_1.DEFAULT_RETRY_TIMES; i++) {
|
|
33
|
-
lastestLintErrors = isCustomizedLint ? await (0, customizedLint_1.runCustomizedLint)(filePath, abortSignal) : await (0,
|
|
32
|
+
lastestLintErrors = isCustomizedLint ? await (0, customizedLint_1.runCustomizedLint)(filePath, abortSignal) : await (0, execEslint_1.ensureExecLint)(filePath, cwd);
|
|
34
33
|
if (!lastestLintErrors || lastestLintErrors.length === 0) {
|
|
35
34
|
(0, console_1.getConsole)().log(`Lint Fix done for ${filePath}`);
|
|
36
35
|
return { success: true };
|
|
37
36
|
}
|
|
38
|
-
if (!originalLintErrors) {
|
|
39
|
-
originalLintErrors = lastestLintErrors;
|
|
40
|
-
}
|
|
41
37
|
// if last iteration, break
|
|
42
38
|
if (i === constants_1.DEFAULT_RETRY_TIMES) {
|
|
43
39
|
break;
|
|
@@ -52,18 +48,18 @@ async function runLintWithAutofix(filePath, testFramework, abortSignal, rootDir)
|
|
|
52
48
|
(0, console_1.getConsole)().log(`Generate fixed test code for lint issues successfully for ${filePath}`);
|
|
53
49
|
// run test to verify the fix
|
|
54
50
|
fs_1.default.writeFileSync(filePath, fixedTestCode, 'utf-8');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
const testResult = await (0, valid_1.runTest)(testFramework, filePath, {
|
|
52
|
+
projectFolder: rootDir,
|
|
53
|
+
abortSignal
|
|
54
|
+
});
|
|
55
|
+
if (testResult?.success) {
|
|
56
|
+
// use the fixed code for next iteration
|
|
57
|
+
(0, console_1.getConsole)().log(`Test passed for lint fixed code`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
fs_1.default.writeFileSync(filePath, originalTestCode, 'utf-8');
|
|
61
|
+
(0, console_1.getConsole)().log(`Test is not passed for lint fixed code, write back original code`);
|
|
62
|
+
}
|
|
67
63
|
}
|
|
68
64
|
(0, console_1.getConsole)().error(`Failed to fix lint errors by LLM for ${filePath}`);
|
|
69
65
|
const ruleErrors = (0, eslintRuleHandler_1.getRuleErrors)(lastestLintErrors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/core/utils/lint.ts"],"names":[],"mappings":";;;;;AAYA,0BAMC;AAED,
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/core/utils/lint.ts"],"names":[],"mappings":";;;;;AAYA,0BAMC;AAED,gDAiEC;AArFD,2DAAsE;AAEtE,4CAAmD;AACnD,oDAAqD;AACrD,iDAAoD;AACpD,4CAAoB;AACpB,sCAAsC;AACtC,uCAAuC;AACvC,gDAAwB;AACxB,4DAA4D;AAC5D,oCAAmC;AAE5B,KAAK,UAAU,OAAO,CAAC,QAAgB,EAAE,OAAgB;IAC5D,MAAM,GAAG,GAAG,OAAO,IAAI,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAA,oBAAU,GAAE,CAAC,GAAG,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;IACjD,6CAA6C;IAC7C,MAAM,IAAA,2BAAc,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACpC,IAAA,oBAAU,GAAE,CAAC,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;AAClD,CAAC;AAEM,KAAK,UAAU,kBAAkB,CAAC,QAAgB,EAAE,aAAqB,EAAE,WAAwB,EAAE,OAAgB;IACxH,MAAM,GAAG,GAAG,OAAO,IAAI,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAA,oBAAU,GAAE,CAAC,GAAG,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;IAEjD,IAAI,gBAAgB,GAAG,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAA,kBAAS,GAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAChE,IAAI,iBAAiB,CA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,CAAC,+CAA+C,QAAQ,KAAK,aAAa,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;AACzD,CAAC;AAGD,2LAA2L;AAC3L,2NAA2N;AAC3N,8PAA8P;AAC9P,mLAAmL;AACnL,wNAAwN;AACxN,oEAAoE;AACpE,6MAA6M;AAC7M,sFAAsF;AACtF,oNAAoN;AACpN,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execEslint.d.ts","sourceRoot":"","sources":["../../../src/core/valid/execEslint.ts"],"names":[],"mappings":"AAIA,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,gBAMlE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ensureExecLint = ensureExecLint;
|
|
7
|
+
const system_1 = require("../utils/system");
|
|
8
|
+
const console_1 = require("../utils/console");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
async function ensureExecLint(filePath, cwd) {
|
|
11
|
+
let lintError;
|
|
12
|
+
for (let i = 0; i < 2; i++) {
|
|
13
|
+
lintError = await execLint(filePath, cwd);
|
|
14
|
+
}
|
|
15
|
+
return lintError;
|
|
16
|
+
}
|
|
17
|
+
async function execLint(filePath, cwd) {
|
|
18
|
+
try {
|
|
19
|
+
const res = await (0, system_1.execAsync)('npx', ['eslint', '--fix', filePath], {
|
|
20
|
+
cwd: cwd || path_1.default.dirname(filePath),
|
|
21
|
+
});
|
|
22
|
+
if (res.stdout) {
|
|
23
|
+
(0, console_1.getConsole)().error(`Run lint error: ${res.stdout}`);
|
|
24
|
+
}
|
|
25
|
+
const normalizedLintErrors = res.stdout?.split(/\r?\n/).map(line => line.trim()).filter(line => line !== '').slice(1, -1);
|
|
26
|
+
return normalizedLintErrors;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
(0, console_1.getConsole)().error(`Run lint error: ${error}`);
|
|
30
|
+
return error.toString();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=execEslint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execEslint.js","sourceRoot":"","sources":["../../../src/core/valid/execEslint.ts"],"names":[],"mappings":";;;;;AAIA,wCAMC;AAVD,4CAA4C;AAC5C,8CAA8C;AAC9C,gDAAwB;AAEjB,KAAK,UAAU,cAAc,CAAC,QAAgB,EAAE,GAAY;IAC/D,IAAI,SAAS,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,SAAS,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,GAAY;IAClD,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,IAAA,kBAAS,EACvB,KAAK,EACL,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAC7B;YACI,GAAG,EAAE,GAAG,IAAI,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;SACrC,CAAC,CAAC;QAEP,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACb,IAAA,oBAAU,GAAE,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1H,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAA,oBAAU,GAAE,CAAC,KAAK,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-dev-tools/test-copilot-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "Core library for test-copilot",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"typings": "out/index.d.ts",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"@types/node": "18.19.101",
|
|
27
27
|
"eslint": "9.25.1",
|
|
28
28
|
"jest": "29.0.0",
|
|
29
|
-
"ts-node": "10.0.0"
|
|
30
|
-
"typescript": "5.8.3"
|
|
29
|
+
"ts-node": "10.0.0"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
32
|
"@azure/identity": "^4.11.1",
|
|
34
33
|
"applicationinsights": "1.8.10",
|
|
35
34
|
"fs-extra": "^11.3.0",
|
|
36
35
|
"ts-morph": "25.0.1",
|
|
36
|
+
"typescript": "5.8.3",
|
|
37
37
|
"yargs": "17.7.2"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
File without changes
|