@abaplint/cli 2.84.1 → 2.84.5

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.
@@ -1,74 +1,86 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyFixes = void 0;
3
+ exports.ApplyFixes = void 0;
4
4
  const core_1 = require("@abaplint/core");
5
- function applyFixes(inputIssues, reg, fs, bar) {
6
- let changed = [];
7
- let iteration = 1;
8
- let issues = inputIssues;
9
- const MAX_ITERATIONS = 50000;
10
- bar === null || bar === void 0 ? void 0 : bar.set(MAX_ITERATIONS, "Apply Fixes");
11
- while (iteration <= MAX_ITERATIONS) {
12
- bar === null || bar === void 0 ? void 0 : bar.tick("Apply Fixes, iteration " + iteration + ", " + issues.length + " candidates");
13
- changed = applyList(issues, reg, fs);
14
- if (changed.length === 0) {
15
- break;
5
+ class ApplyFixes {
6
+ constructor() {
7
+ this.changedFiles = new Set();
8
+ }
9
+ applyFixes(inputIssues, reg, fs, bar) {
10
+ let changed = [];
11
+ let iteration = 1;
12
+ let issues = inputIssues;
13
+ this.changedFiles.clear();
14
+ const MAX_ITERATIONS = 50000;
15
+ bar === null || bar === void 0 ? void 0 : bar.set(MAX_ITERATIONS, "Apply Fixes");
16
+ while (iteration <= MAX_ITERATIONS) {
17
+ bar === null || bar === void 0 ? void 0 : bar.tick("Apply Fixes, iteration " + iteration + ", " + issues.length + " candidates");
18
+ changed = this.applyList(issues, reg);
19
+ if (changed.length === 0) {
20
+ break;
21
+ }
22
+ iteration++;
23
+ issues = reg.parse().findIssues();
24
+ }
25
+ this.writeChangesToFS(fs, reg);
26
+ // always end the progress indicator at 100%
27
+ while (iteration <= MAX_ITERATIONS) {
28
+ bar === null || bar === void 0 ? void 0 : bar.tick("Fixes Applied");
29
+ iteration++;
16
30
  }
17
- iteration++;
18
- issues = reg.parse().findIssues();
31
+ return issues;
19
32
  }
20
- // always end the progress indicator at 100%
21
- while (iteration <= MAX_ITERATIONS) {
22
- bar === null || bar === void 0 ? void 0 : bar.tick("Fixes Applied");
23
- iteration++;
33
+ writeChangesToFS(fs, reg) {
34
+ for (const filename of this.changedFiles.values()) {
35
+ const file = reg.getFileByName(filename);
36
+ if (file === undefined) {
37
+ continue;
38
+ }
39
+ fs.writeFileSync(file.getFilename(), file.getRaw());
40
+ }
24
41
  }
25
- return issues;
26
- }
27
- exports.applyFixes = applyFixes;
28
- function possibleOverlap(edit, list) {
29
- // only checks if the edits have changes in the same rows
30
- for (const e of list) {
31
- for (const file1 of Object.keys(e)) {
32
- for (const file2 of Object.keys(edit)) {
33
- if (file1 === file2) {
34
- for (const list1 of e[file1]) {
35
- for (const list2 of edit[file2]) {
36
- if (list2.range.start.getRow() <= list1.range.start.getRow()
37
- && list2.range.end.getRow() >= list1.range.start.getRow()) {
38
- return true;
39
- }
40
- if (list2.range.start.getRow() <= list1.range.start.getRow()
41
- && list2.range.end.getRow() >= list1.range.end.getRow()) {
42
- return true;
42
+ possibleOverlap(edit, list) {
43
+ // only checks if the edits have changes in the same rows
44
+ for (const e of list) {
45
+ for (const file1 of Object.keys(e)) {
46
+ for (const file2 of Object.keys(edit)) {
47
+ if (file1 === file2) {
48
+ for (const list1 of e[file1]) {
49
+ for (const list2 of edit[file2]) {
50
+ if (list2.range.start.getRow() <= list1.range.start.getRow()
51
+ && list2.range.end.getRow() >= list1.range.start.getRow()) {
52
+ return true;
53
+ }
54
+ if (list2.range.start.getRow() <= list1.range.start.getRow()
55
+ && list2.range.end.getRow() >= list1.range.end.getRow()) {
56
+ return true;
57
+ }
43
58
  }
44
59
  }
45
60
  }
46
61
  }
47
62
  }
48
63
  }
64
+ return false;
49
65
  }
50
- return false;
51
- }
52
- function applyList(issues, reg, fs) {
53
- const edits = [];
54
- for (const i of issues) {
55
- const edit = i.getFix();
56
- if (edit === undefined) {
57
- continue;
58
- }
59
- else if (possibleOverlap(edit, edits) === true) {
60
- continue;
66
+ applyList(issues, reg) {
67
+ const edits = [];
68
+ for (const i of issues) {
69
+ const edit = i.getFix();
70
+ if (edit === undefined) {
71
+ continue;
72
+ }
73
+ else if (this.possibleOverlap(edit, edits) === true) {
74
+ continue;
75
+ }
76
+ edits.push(edit);
61
77
  }
62
- edits.push(edit);
63
- }
64
- const changed = (0, core_1.applyEditList)(reg, edits);
65
- for (const filename of changed) {
66
- const file = reg.getFileByName(filename);
67
- if (file === undefined) {
68
- continue;
78
+ const changed = (0, core_1.applyEditList)(reg, edits);
79
+ for (const filename of changed) {
80
+ this.changedFiles.add(filename);
69
81
  }
70
- fs.writeFileSync(file.getFilename(), file.getRaw());
82
+ return changed;
71
83
  }
72
- return changed;
73
84
  }
85
+ exports.ApplyFixes = ApplyFixes;
74
86
  //# sourceMappingURL=fixes.js.map
@@ -186,7 +186,7 @@ async function run(arg) {
186
186
  }
187
187
  let extra = "";
188
188
  if (arg.runFix === true && reg) {
189
- issues = (0, fixes_1.applyFixes)(issues, reg, fs, progress);
189
+ issues = new fixes_1.ApplyFixes().applyFixes(issues, reg, fs, progress);
190
190
  extra = "Fixes applied";
191
191
  }
192
192
  else if (arg.runRename === true && reg) {
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
- {
2
- "name": "@abaplint/cli",
3
- "version": "2.84.1",
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.84.1",
43
- "@types/chai": "^4.3.0",
44
- "@types/glob": "^7.2.0",
45
- "@types/minimist": "^1.2.2",
46
- "@types/mocha": "^9.0.0",
47
- "@types/node": "^17.0.9",
48
- "@types/progress": "^2.0.5",
49
- "chai": "^4.3.4",
50
- "chalk": "=4.1.2",
51
- "eslint": "^8.7.0",
52
- "glob": "^7.2.0",
53
- "json5": "^2.2.0",
54
- "memfs": "^3.4.1",
55
- "minimist": "^1.2.5",
56
- "mocha": "^9.1.4",
57
- "progress": "^2.0.3",
58
- "typescript": "^4.5.4",
59
- "webpack": "^5.66.0",
60
- "webpack-cli": "^4.9.1",
61
- "xml-js": "^1.6.11"
62
- },
63
- "dependencies": {}
64
- }
1
+ {
2
+ "name": "@abaplint/cli",
3
+ "version": "2.84.5",
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.84.5",
43
+ "@types/chai": "^4.3.0",
44
+ "@types/glob": "^7.2.0",
45
+ "@types/minimist": "^1.2.2",
46
+ "@types/mocha": "^9.1.0",
47
+ "@types/node": "^17.0.12",
48
+ "@types/progress": "^2.0.5",
49
+ "chai": "^4.3.5",
50
+ "chalk": "=4.1.2",
51
+ "eslint": "^8.7.0",
52
+ "glob": "^7.2.0",
53
+ "json5": "^2.2.0",
54
+ "memfs": "^3.4.1",
55
+ "minimist": "^1.2.5",
56
+ "mocha": "^9.2.0",
57
+ "progress": "^2.0.3",
58
+ "typescript": "^4.5.5",
59
+ "webpack": "^5.67.0",
60
+ "webpack-cli": "^4.9.2",
61
+ "xml-js": "^1.6.11"
62
+ },
63
+ "dependencies": {}
64
+ }