@abaplint/cli 2.82.1 → 2.82.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.
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rename = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+ const file_operations_1 = require("./file_operations");
8
+ class Rename {
9
+ constructor(reg) {
10
+ this.reg = reg;
11
+ }
12
+ run(config, base) {
13
+ const rconfig = config.get().rename;
14
+ if (rconfig === undefined) {
15
+ return;
16
+ }
17
+ this.skip(rconfig);
18
+ this.rename(rconfig);
19
+ this.write(rconfig, base);
20
+ }
21
+ ////////////////////////
22
+ write(rconfig, base) {
23
+ const outputFolder = base + path.sep + rconfig.output;
24
+ console.log("Base: " + base);
25
+ console.log("Output folder: " + outputFolder);
26
+ file_operations_1.FileOperations.deleteFolderRecursive(outputFolder);
27
+ for (const o of this.reg.getObjects()) {
28
+ if (this.reg.isDependency(o) === true) {
29
+ continue;
30
+ }
31
+ for (const f of o.getFiles()) {
32
+ const n = outputFolder + f.getFilename().replace(base, "");
33
+ console.log("Write " + n);
34
+ fs.mkdirSync(path.dirname(n), { recursive: true });
35
+ fs.writeFileSync(n, f.getRaw());
36
+ }
37
+ }
38
+ }
39
+ rename(rconfig) {
40
+ const renamer = new abaplint.Rename(this.reg);
41
+ for (const o of this.reg.getObjects()) {
42
+ if (this.reg.isDependency(o) === true) {
43
+ continue;
44
+ }
45
+ for (const p of rconfig.patterns || []) {
46
+ if (!(o.getType().match(p.type))) {
47
+ continue;
48
+ }
49
+ const regex = new RegExp(p.oldName, "i");
50
+ const match = regex.exec(o.getName());
51
+ if (!match) {
52
+ continue;
53
+ }
54
+ const newStr = o.getName().replace(regex, p.newName);
55
+ console.log("Renaming " + o.getName().padEnd(30, " ") + " -> " + newStr);
56
+ renamer.rename(o.getType(), o.getName(), newStr);
57
+ }
58
+ }
59
+ }
60
+ skip(rconfig) {
61
+ if (rconfig.skip) {
62
+ for (const s of rconfig.skip) {
63
+ const all = [];
64
+ for (const f of this.reg.getFiles()) {
65
+ all.push(f);
66
+ }
67
+ for (const n of all) {
68
+ if (n.getFilename().match(s)) {
69
+ console.log(n.getFilename() + " skipped");
70
+ this.reg.removeFile(n);
71
+ }
72
+ }
73
+ }
74
+ this.reg.parse();
75
+ }
76
+ }
77
+ }
78
+ exports.Rename = Rename;
79
+ //# sourceMappingURL=rename.js.map
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.82.1",
3
+ "version": "2.82.5",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "bin": {
6
6
  "abaplint": "./abaplint"
7
7
  },
8
+ "main": "./build/src/index.js",
9
+ "types": "./build/src/index.d.ts",
8
10
  "scripts": {
9
11
  "lint": "eslint src/**/*.ts test/**/*.ts --format unix",
10
12
  "compile": "tsc",
@@ -37,7 +39,7 @@
37
39
  },
38
40
  "homepage": "https://abaplint.org",
39
41
  "devDependencies": {
40
- "@abaplint/core": "^2.82.1",
42
+ "@abaplint/core": "^2.82.5",
41
43
  "@types/chai": "^4.2.22",
42
44
  "@types/glob": "^7.2.0",
43
45
  "@types/minimist": "^1.2.2",
@@ -45,7 +47,7 @@
45
47
  "@types/node": "^16.11.10",
46
48
  "@types/progress": "^2.0.5",
47
49
  "chai": "^4.3.4",
48
- "chalk": "^4.1.2",
50
+ "chalk": "=4.1.2",
49
51
  "eslint": "^8.3.0",
50
52
  "glob": "^7.2.0",
51
53
  "json5": "^2.2.0",
@@ -54,7 +56,7 @@
54
56
  "mocha": "^9.1.3",
55
57
  "progress": "^2.0.3",
56
58
  "typescript": "^4.5.2",
57
- "webpack": "^5.64.3",
59
+ "webpack": "^5.64.4",
58
60
  "webpack-cli": "^4.9.1",
59
61
  "xml-js": "^1.6.11"
60
62
  },