@abaplint/cli 2.91.2 → 2.91.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.
@@ -2,7 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Junit = void 0;
4
4
  const xml_js_1 = require("xml-js");
5
+ const fs = require("fs");
5
6
  class Junit {
7
+ constructor() {
8
+ this.currentFilename = "";
9
+ this.currentFileLinesCount = 0;
10
+ this.fileContent = [];
11
+ }
6
12
  output(issues, _fileCount) {
7
13
  const outputObj = {
8
14
  _declaration: {
@@ -34,10 +40,10 @@ class Junit {
34
40
  },
35
41
  failure: {
36
42
  _attributes: {
37
- message: issue.getKey(),
43
+ message: this.formatFailureMessage(issue.getMessage()),
38
44
  type: issue.getSeverity().toString(),
39
45
  },
40
- _cdata: `${issue.getMessage()}`,
46
+ _cdata: `${this.renderIssue(issue)}`,
41
47
  },
42
48
  });
43
49
  }
@@ -53,6 +59,33 @@ class Junit {
53
59
  const xml = (0, xml_js_1.js2xml)(outputObj, { compact: true, spaces: 2 });
54
60
  return xml;
55
61
  }
62
+ cacheFile(filename) {
63
+ if (filename !== this.currentFilename) {
64
+ this.currentFilename = filename;
65
+ this.fileContent = fs.readFileSync(filename, "utf8").split(/\r?\n/);
66
+ this.currentFileLinesCount = this.fileContent.length;
67
+ }
68
+ }
69
+ renderIssue(issue) {
70
+ this.cacheFile(issue.getFilename());
71
+ const frameSize = 1;
72
+ const lineFrom = Math.max(issue.getStart().getRow() - frameSize, 1);
73
+ const lineTo = Math.min(issue.getStart().getRow() + frameSize, this.currentFileLinesCount);
74
+ const issueLineIndex = issue.getStart().getRow() - 1;
75
+ const padSize = Math.ceil(Math.log10(lineTo)) + 4;
76
+ const code = [];
77
+ for (let lineIndex = lineFrom - 1; lineIndex < lineTo; lineIndex++) {
78
+ const prefix = `${" "}${lineIndex + 1} |`.padStart(padSize);
79
+ code.push(prefix + this.fileContent[lineIndex]);
80
+ if (lineIndex === issueLineIndex) {
81
+ code.push("|".padStart(padSize) + " ".repeat(issue.getStart().getCol() - 1) + "^");
82
+ }
83
+ }
84
+ return code.map(str => str).join("\n");
85
+ }
86
+ formatFailureMessage(message) {
87
+ return message.replace("<", "").replace(">", "");
88
+ }
56
89
  }
57
90
  exports.Junit = Junit;
58
91
  //# sourceMappingURL=junit.js.map
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
- {
2
- "name": "@abaplint/cli",
3
- "version": "2.91.2",
4
- "description": "abaplint - Command Line Interface",
5
- "bin": {
6
- "abaplint": "./abaplint"
7
- },
8
- "main": "./build/src/index.js",
9
- "types": "./build/src/index.d.ts",
10
- "scripts": {
11
- "lint": "eslint src/**/*.ts test/**/*.ts --format unix",
12
- "compile": "tsc",
13
- "test": "npm run compile && mocha && npm run lint && npm run webpack",
14
- "webpack": "webpack --progress",
15
- "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
16
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public"
17
- },
18
- "mocha": {
19
- "recursive": true,
20
- "reporter": "progress",
21
- "spec": "./build/test/*.js",
22
- "require": "source-map-support/register"
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://github.com/abaplint/abaplint.git"
27
- },
28
- "engines": {
29
- "node": ">=12.0.0"
30
- },
31
- "keywords": [
32
- "ABAP",
33
- "lint"
34
- ],
35
- "author": "Lars Hvam Petersen",
36
- "license": "MIT",
37
- "bugs": {
38
- "url": "https://github.com/abaplint/abaplint/issues"
39
- },
40
- "homepage": "https://abaplint.org",
41
- "devDependencies": {
42
- "@abaplint/core": "^2.91.2",
43
- "@types/chai": "^4.3.1",
44
- "@types/glob": "^7.2.0",
45
- "@types/minimist": "^1.2.2",
46
- "@types/mocha": "^9.1.1",
47
- "@types/node": "^17.0.40",
48
- "@types/progress": "^2.0.5",
49
- "chai": "^4.3.6",
50
- "chalk": "^5.0.1",
51
- "eslint": "^8.17.0",
52
- "glob": "^7.2.3",
53
- "json5": "^2.2.1",
54
- "memfs": "^3.4.4",
55
- "minimist": "^1.2.6",
56
- "mocha": "^10.0.0",
57
- "progress": "^2.0.3",
58
- "typescript": "^4.7.3",
59
- "webpack": "^5.73.0",
60
- "webpack-cli": "^4.9.2",
61
- "xml-js": "^1.6.11"
62
- },
63
- "dependencies": {}
64
- }
1
+ {
2
+ "name": "@abaplint/cli",
3
+ "version": "2.91.3",
4
+ "description": "abaplint - Command Line Interface",
5
+ "bin": {
6
+ "abaplint": "./abaplint"
7
+ },
8
+ "main": "./build/src/index.js",
9
+ "types": "./build/src/index.d.ts",
10
+ "scripts": {
11
+ "lint": "eslint src/**/*.ts test/**/*.ts --format unix",
12
+ "compile": "tsc",
13
+ "test": "npm run compile && mocha && npm run lint && npm run webpack",
14
+ "webpack": "webpack --progress",
15
+ "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
16
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public"
17
+ },
18
+ "mocha": {
19
+ "recursive": true,
20
+ "reporter": "progress",
21
+ "spec": "./build/test/*.js",
22
+ "require": "source-map-support/register"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/abaplint/abaplint.git"
27
+ },
28
+ "engines": {
29
+ "node": ">=12.0.0"
30
+ },
31
+ "keywords": [
32
+ "ABAP",
33
+ "lint"
34
+ ],
35
+ "author": "Lars Hvam Petersen",
36
+ "license": "MIT",
37
+ "bugs": {
38
+ "url": "https://github.com/abaplint/abaplint/issues"
39
+ },
40
+ "homepage": "https://abaplint.org",
41
+ "devDependencies": {
42
+ "@abaplint/core": "^2.91.3",
43
+ "@types/chai": "^4.3.1",
44
+ "@types/glob": "^7.2.0",
45
+ "@types/minimist": "^1.2.2",
46
+ "@types/mocha": "^9.1.1",
47
+ "@types/node": "^17.0.41",
48
+ "@types/progress": "^2.0.5",
49
+ "chai": "^4.3.6",
50
+ "chalk": "^5.0.1",
51
+ "eslint": "^8.17.0",
52
+ "glob": "^7.2.3",
53
+ "json5": "^2.2.1",
54
+ "memfs": "^3.4.4",
55
+ "minimist": "^1.2.6",
56
+ "mocha": "^10.0.0",
57
+ "progress": "^2.0.3",
58
+ "typescript": "^4.7.3",
59
+ "webpack": "^5.73.0",
60
+ "webpack-cli": "^4.9.2",
61
+ "xml-js": "^1.6.11"
62
+ },
63
+ "dependencies": {}
64
+ }