@abaplint/cli 2.113.118 → 2.113.119

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.
Files changed (2) hide show
  1. package/build/cli.js +257 -22
  2. package/package.json +5 -5
package/build/cli.js CHANGED
@@ -83,12 +83,15 @@ exports.CompressedFile = CompressedFile;
83
83
 
84
84
  Object.defineProperty(exports, "__esModule", ({ value: true }));
85
85
  exports.FileOperations = void 0;
86
- const fs = __webpack_require__(/*! fs */ "fs");
87
- const path = __webpack_require__(/*! path */ "path");
88
- const zlib = __webpack_require__(/*! zlib */ "zlib");
89
- const glob = __webpack_require__(/*! glob */ "./node_modules/glob/glob.js");
90
- const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
91
86
  const compressed_file_1 = __webpack_require__(/*! ./compressed_file */ "./build/src/compressed_file.js");
87
+ const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
88
+ const fs = __webpack_require__(/*! node:fs */ "node:fs");
89
+ const fsPromises = __webpack_require__(/*! node:fs/promises */ "node:fs/promises");
90
+ const glob = __webpack_require__(/*! glob */ "./node_modules/glob/glob.js");
91
+ const os = __webpack_require__(/*! node:os */ "node:os");
92
+ const path = __webpack_require__(/*! node:path */ "node:path");
93
+ const pLimit = __webpack_require__(/*! p-limit */ "./node_modules/p-limit/index.js");
94
+ const zlib = __webpack_require__(/*! node:zlib */ "node:zlib");
92
95
  class FileOperations {
93
96
  static deleteFolderRecursive(dir) {
94
97
  if (fs.existsSync(dir) === false) {
@@ -103,26 +106,54 @@ class FileOperations {
103
106
  }
104
107
  return files;
105
108
  }
109
+ static async readFile(filename, compress) {
110
+ // note that readFileSync is typically faster than async readFile,
111
+ // https://medium.com/@adamhooper/node-synchronous-code-runs-faster-than-asynchronous-code-b0553d5cf54e
112
+ const raw = await fsPromises.readFile(filename, { encoding: "utf8" });
113
+ if (compress === true) {
114
+ // todo, util.promisify(zlib.deflate) does not seem to work?
115
+ return new compressed_file_1.CompressedFile(filename, zlib.deflateSync(raw).toString("base64"));
116
+ }
117
+ else {
118
+ return new core_1.MemoryFile(filename, raw);
119
+ }
120
+ }
106
121
  static async loadFiles(compress, input, bar) {
107
- const files = [];
108
- bar.set(input.length, "Reading files");
109
- for (const filename of input) {
110
- bar.tick("Reading files - " + path.basename(filename));
122
+ let concurrency = os.cpus().length;
123
+ if (concurrency > 8) {
124
+ concurrency = 8;
125
+ }
126
+ else if (concurrency < 1) {
127
+ concurrency = 1;
128
+ }
129
+ const limit = pLimit(concurrency);
130
+ input = input.filter((filename) => {
111
131
  const base = filename.split("/").reverse()[0];
112
132
  if (base.split(".").length <= 2) {
113
- continue; // not a abapGit file
114
- }
115
- // note that readFileSync is typically faster than async readFile,
116
- // https://medium.com/@adamhooper/node-synchronous-code-runs-faster-than-asynchronous-code-b0553d5cf54e
117
- const raw = fs.readFileSync(filename, "utf8");
118
- if (compress === true) {
119
- // todo, util.promisify(zlib.deflate) does not seem to work?
120
- files.push(new compressed_file_1.CompressedFile(filename, zlib.deflateSync(raw).toString("base64")));
121
- }
122
- else {
123
- files.push(new core_1.MemoryFile(filename, raw));
133
+ return false;
124
134
  }
135
+ return true;
136
+ });
137
+ bar.set(input.length, "Reading files");
138
+ const promises = input.map((filename) => {
139
+ return limit(async () => {
140
+ bar.tick("Reading files - " + path.basename(filename));
141
+ return this.readFile(filename, compress);
142
+ });
143
+ });
144
+ const files = await Promise.all(promises);
145
+ /*
146
+ for (const filename of input) {
147
+ bar.tick("Reading files - " + path.basename(filename));
148
+
149
+ const base = filename.split("/").reverse()[0];
150
+ if (base.split(".").length <= 2) {
151
+ continue; // not a abapGit file
152
+ }
153
+
154
+ files.push(await this.readFile(filename, compress));
125
155
  }
156
+ */
126
157
  return files;
127
158
  }
128
159
  }
@@ -19676,7 +19707,7 @@ const _combi_1 = __webpack_require__(/*! ./_combi */ "./node_modules/@abaplint/c
19676
19707
  const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js");
19677
19708
  class Loop {
19678
19709
  getMatcher() {
19679
- return (0, _combi_1.beginEnd)((0, _combi_1.sta)(Statements.Loop), (0, _combi_1.star)((0, _combi_1.sub)(_1.Body)), (0, _combi_1.sta)(Statements.EndLoop));
19710
+ return (0, _combi_1.beginEnd)((0, _combi_1.sta)(Statements.Loop), (0, _combi_1.alt)((0, _combi_1.sub)(_1.Chain), (0, _combi_1.star)((0, _combi_1.sub)(_1.Body))), (0, _combi_1.sta)(Statements.EndLoop));
19680
19711
  }
19681
19712
  }
19682
19713
  exports.Loop = Loop;
@@ -54157,7 +54188,7 @@ class Registry {
54157
54188
  }
54158
54189
  static abaplintVersion() {
54159
54190
  // magic, see build script "version.sh"
54160
- return "2.113.118";
54191
+ return "2.113.119";
54161
54192
  }
54162
54193
  getDDICReferences() {
54163
54194
  return this.ddicReferences;
@@ -83613,6 +83644,88 @@ function onceStrict (fn) {
83613
83644
  }
83614
83645
 
83615
83646
 
83647
+ /***/ }),
83648
+
83649
+ /***/ "./node_modules/p-limit/index.js":
83650
+ /*!***************************************!*\
83651
+ !*** ./node_modules/p-limit/index.js ***!
83652
+ \***************************************/
83653
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
83654
+
83655
+ "use strict";
83656
+
83657
+ const Queue = __webpack_require__(/*! yocto-queue */ "./node_modules/yocto-queue/index.js");
83658
+
83659
+ const pLimit = concurrency => {
83660
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
83661
+ throw new TypeError('Expected `concurrency` to be a number from 1 and up');
83662
+ }
83663
+
83664
+ const queue = new Queue();
83665
+ let activeCount = 0;
83666
+
83667
+ const next = () => {
83668
+ activeCount--;
83669
+
83670
+ if (queue.size > 0) {
83671
+ queue.dequeue()();
83672
+ }
83673
+ };
83674
+
83675
+ const run = async (fn, resolve, ...args) => {
83676
+ activeCount++;
83677
+
83678
+ const result = (async () => fn(...args))();
83679
+
83680
+ resolve(result);
83681
+
83682
+ try {
83683
+ await result;
83684
+ } catch {}
83685
+
83686
+ next();
83687
+ };
83688
+
83689
+ const enqueue = (fn, resolve, ...args) => {
83690
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
83691
+
83692
+ (async () => {
83693
+ // This function needs to wait until the next microtask before comparing
83694
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
83695
+ // when the run function is dequeued and called. The comparison in the if-statement
83696
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
83697
+ await Promise.resolve();
83698
+
83699
+ if (activeCount < concurrency && queue.size > 0) {
83700
+ queue.dequeue()();
83701
+ }
83702
+ })();
83703
+ };
83704
+
83705
+ const generator = (fn, ...args) => new Promise(resolve => {
83706
+ enqueue(fn, resolve, ...args);
83707
+ });
83708
+
83709
+ Object.defineProperties(generator, {
83710
+ activeCount: {
83711
+ get: () => activeCount
83712
+ },
83713
+ pendingCount: {
83714
+ get: () => queue.size
83715
+ },
83716
+ clearQueue: {
83717
+ value: () => {
83718
+ queue.clear();
83719
+ }
83720
+ }
83721
+ });
83722
+
83723
+ return generator;
83724
+ };
83725
+
83726
+ module.exports = pLimit;
83727
+
83728
+
83616
83729
  /***/ }),
83617
83730
 
83618
83731
  /***/ "./node_modules/path-is-absolute/index.js":
@@ -88681,6 +88794,84 @@ module.exports = function(xml, userOptions) {
88681
88794
  };
88682
88795
 
88683
88796
 
88797
+ /***/ }),
88798
+
88799
+ /***/ "./node_modules/yocto-queue/index.js":
88800
+ /*!*******************************************!*\
88801
+ !*** ./node_modules/yocto-queue/index.js ***!
88802
+ \*******************************************/
88803
+ /***/ ((module) => {
88804
+
88805
+ class Node {
88806
+ /// value;
88807
+ /// next;
88808
+
88809
+ constructor(value) {
88810
+ this.value = value;
88811
+
88812
+ // TODO: Remove this when targeting Node.js 12.
88813
+ this.next = undefined;
88814
+ }
88815
+ }
88816
+
88817
+ class Queue {
88818
+ // TODO: Use private class fields when targeting Node.js 12.
88819
+ // #_head;
88820
+ // #_tail;
88821
+ // #_size;
88822
+
88823
+ constructor() {
88824
+ this.clear();
88825
+ }
88826
+
88827
+ enqueue(value) {
88828
+ const node = new Node(value);
88829
+
88830
+ if (this._head) {
88831
+ this._tail.next = node;
88832
+ this._tail = node;
88833
+ } else {
88834
+ this._head = node;
88835
+ this._tail = node;
88836
+ }
88837
+
88838
+ this._size++;
88839
+ }
88840
+
88841
+ dequeue() {
88842
+ const current = this._head;
88843
+ if (!current) {
88844
+ return;
88845
+ }
88846
+
88847
+ this._head = this._head.next;
88848
+ this._size--;
88849
+ return current.value;
88850
+ }
88851
+
88852
+ clear() {
88853
+ this._head = undefined;
88854
+ this._tail = undefined;
88855
+ this._size = 0;
88856
+ }
88857
+
88858
+ get size() {
88859
+ return this._size;
88860
+ }
88861
+
88862
+ * [Symbol.iterator]() {
88863
+ let current = this._head;
88864
+
88865
+ while (current) {
88866
+ yield current.value;
88867
+ current = current.next;
88868
+ }
88869
+ }
88870
+ }
88871
+
88872
+ module.exports = Queue;
88873
+
88874
+
88684
88875
  /***/ }),
88685
88876
 
88686
88877
  /***/ "assert":
@@ -88749,6 +88940,28 @@ module.exports = require("node:crypto");
88749
88940
 
88750
88941
  /***/ }),
88751
88942
 
88943
+ /***/ "node:fs":
88944
+ /*!**************************!*\
88945
+ !*** external "node:fs" ***!
88946
+ \**************************/
88947
+ /***/ ((module) => {
88948
+
88949
+ "use strict";
88950
+ module.exports = require("node:fs");
88951
+
88952
+ /***/ }),
88953
+
88954
+ /***/ "node:fs/promises":
88955
+ /*!***********************************!*\
88956
+ !*** external "node:fs/promises" ***!
88957
+ \***********************************/
88958
+ /***/ ((module) => {
88959
+
88960
+ "use strict";
88961
+ module.exports = require("node:fs/promises");
88962
+
88963
+ /***/ }),
88964
+
88752
88965
  /***/ "node:os":
88753
88966
  /*!**************************!*\
88754
88967
  !*** external "node:os" ***!
@@ -88760,6 +88973,17 @@ module.exports = require("node:os");
88760
88973
 
88761
88974
  /***/ }),
88762
88975
 
88976
+ /***/ "node:path":
88977
+ /*!****************************!*\
88978
+ !*** external "node:path" ***!
88979
+ \****************************/
88980
+ /***/ ((module) => {
88981
+
88982
+ "use strict";
88983
+ module.exports = require("node:path");
88984
+
88985
+ /***/ }),
88986
+
88763
88987
  /***/ "node:process":
88764
88988
  /*!*******************************!*\
88765
88989
  !*** external "node:process" ***!
@@ -88782,6 +89006,17 @@ module.exports = require("node:tty");
88782
89006
 
88783
89007
  /***/ }),
88784
89008
 
89009
+ /***/ "node:zlib":
89010
+ /*!****************************!*\
89011
+ !*** external "node:zlib" ***!
89012
+ \****************************/
89013
+ /***/ ((module) => {
89014
+
89015
+ "use strict";
89016
+ module.exports = require("node:zlib");
89017
+
89018
+ /***/ }),
89019
+
88785
89020
  /***/ "os":
88786
89021
  /*!*********************!*\
88787
89022
  !*** external "os" ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.113.118",
3
+ "version": "2.113.119",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.113.118",
41
+ "@abaplint/core": "^2.113.119",
42
42
  "@types/chai": "^4.3.20",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",
@@ -46,18 +46,18 @@
46
46
  "@types/node": "^22.15.19",
47
47
  "@types/progress": "^2.0.7",
48
48
  "chai": "^4.5.0",
49
+ "p-limit": "^3.1.0",
49
50
  "chalk": "^5.4.1",
50
51
  "eslint": "^9.27.0",
51
52
  "glob": "^7.2.3",
52
53
  "json5": "^2.2.3",
53
54
  "memfs": "^4.17.2",
54
55
  "minimist": "^1.2.8",
55
- "mocha": "^11.3.0",
56
+ "mocha": "^11.4.0",
56
57
  "progress": "^2.0.3",
57
58
  "typescript": "^5.8.3",
58
59
  "webpack": "^5.99.8",
59
60
  "webpack-cli": "^6.0.1",
60
61
  "xml-js": "^1.6.11"
61
- },
62
- "dependencies": {}
62
+ }
63
63
  }