@abaplint/cli 2.84.4 → 2.84.8
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 +21 -21
- package/abaplint +2 -2
- package/build/cli.js +76 -76
- package/build/src/fixes.js +68 -56
- package/build/src/index.js +1 -1
- package/build/src/rename.js +20 -1
- package/package.json +64 -64
package/build/src/fixes.js
CHANGED
|
@@ -1,74 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ApplyFixes = void 0;
|
|
4
4
|
const core_1 = require("@abaplint/core");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
18
|
-
issues = reg.parse().findIssues();
|
|
31
|
+
return issues;
|
|
19
32
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
82
|
+
return changed;
|
|
71
83
|
}
|
|
72
|
-
return changed;
|
|
73
84
|
}
|
|
85
|
+
exports.ApplyFixes = ApplyFixes;
|
|
74
86
|
//# sourceMappingURL=fixes.js.map
|
package/build/src/index.js
CHANGED
|
@@ -186,7 +186,7 @@ async function run(arg) {
|
|
|
186
186
|
}
|
|
187
187
|
let extra = "";
|
|
188
188
|
if (arg.runFix === true && reg) {
|
|
189
|
-
issues =
|
|
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/build/src/rename.js
CHANGED
|
@@ -7,6 +7,8 @@ const fs = require("fs");
|
|
|
7
7
|
const file_operations_1 = require("./file_operations");
|
|
8
8
|
class Rename {
|
|
9
9
|
constructor(reg) {
|
|
10
|
+
this.deletedFiles = [];
|
|
11
|
+
this.addedFiles = [];
|
|
10
12
|
this.reg = reg;
|
|
11
13
|
}
|
|
12
14
|
run(config, base) {
|
|
@@ -16,7 +18,21 @@ class Rename {
|
|
|
16
18
|
}
|
|
17
19
|
this.skip(rconfig);
|
|
18
20
|
this.rename(rconfig);
|
|
19
|
-
|
|
21
|
+
if (rconfig.output === undefined || rconfig.output === "") {
|
|
22
|
+
// write changes inline
|
|
23
|
+
this.deletedFiles.forEach(f => {
|
|
24
|
+
console.log("rm " + f);
|
|
25
|
+
fs.rmSync(f);
|
|
26
|
+
});
|
|
27
|
+
this.addedFiles.forEach(f => {
|
|
28
|
+
console.log("write " + f.getFilename());
|
|
29
|
+
fs.writeFileSync(f.getFilename(), f.getRaw());
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// output full registry contents to output folder
|
|
34
|
+
this.write(rconfig, base);
|
|
35
|
+
}
|
|
20
36
|
}
|
|
21
37
|
////////////////////////
|
|
22
38
|
write(rconfig, base) {
|
|
@@ -51,9 +67,12 @@ class Rename {
|
|
|
51
67
|
if (!match) {
|
|
52
68
|
continue;
|
|
53
69
|
}
|
|
70
|
+
o.getFiles().forEach(f => this.deletedFiles.push(f.getFilename()));
|
|
54
71
|
const newStr = o.getName().replace(regex, p.newName);
|
|
55
72
|
console.log("Renaming " + o.getName().padEnd(30, " ") + " -> " + newStr);
|
|
56
73
|
renamer.rename(o.getType(), o.getName(), newStr);
|
|
74
|
+
const newObject = this.reg.getObject(o.getType(), newStr);
|
|
75
|
+
newObject === null || newObject === void 0 ? void 0 : newObject.getFiles().forEach(f => this.addedFiles.push(f));
|
|
57
76
|
}
|
|
58
77
|
}
|
|
59
78
|
}
|
package/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.84.
|
|
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.
|
|
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.
|
|
48
|
-
"@types/progress": "^2.0.5",
|
|
49
|
-
"chai": "^4.3.
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/cli",
|
|
3
|
+
"version": "2.84.8",
|
|
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.8",
|
|
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.6",
|
|
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
|
+
}
|