@abaplint/transpiler-cli 2.10.58 → 2.10.59
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/build/bundle.js +213 -8
- package/package.json +3 -2
package/build/bundle.js
CHANGED
|
@@ -71,6 +71,9 @@ exports.FileOperations = void 0;
|
|
|
71
71
|
const fs = __webpack_require__(/*! fs */ "fs");
|
|
72
72
|
const path = __webpack_require__(/*! path */ "path");
|
|
73
73
|
const glob = __webpack_require__(/*! glob */ "./node_modules/glob/glob.js");
|
|
74
|
+
const pLimit = __webpack_require__(/*! p-limit */ "./node_modules/p-limit/index.js");
|
|
75
|
+
const os = __webpack_require__(/*! node:os */ "node:os");
|
|
76
|
+
const fsPromises = __webpack_require__(/*! node:fs/promises */ "node:fs/promises");
|
|
74
77
|
class FileOperations {
|
|
75
78
|
static deleteFolderRecursive(p) {
|
|
76
79
|
if (fs.existsSync(p) === false) {
|
|
@@ -78,26 +81,46 @@ class FileOperations {
|
|
|
78
81
|
}
|
|
79
82
|
fs.rmSync(p, { recursive: true });
|
|
80
83
|
}
|
|
81
|
-
static
|
|
82
|
-
|
|
84
|
+
static setupPLimit() {
|
|
85
|
+
let concurrency = os.cpus().length;
|
|
86
|
+
if (concurrency > 8) {
|
|
87
|
+
concurrency = 8;
|
|
88
|
+
}
|
|
89
|
+
else if (concurrency < 1) {
|
|
90
|
+
concurrency = 1;
|
|
91
|
+
}
|
|
92
|
+
return pLimit(concurrency);
|
|
93
|
+
}
|
|
94
|
+
static async readAllFiles(filesToRead, outputFolder) {
|
|
95
|
+
const limit = this.setupPLimit();
|
|
96
|
+
const promises = filesToRead.map((filename) => {
|
|
97
|
+
return limit(async () => {
|
|
98
|
+
return {
|
|
99
|
+
filename: path.basename(filename),
|
|
100
|
+
relative: path.relative(outputFolder, path.dirname(filename)),
|
|
101
|
+
contents: await fsPromises.readFile(filename, "utf8"),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return Promise.all(promises);
|
|
106
|
+
}
|
|
107
|
+
static async loadFiles(config) {
|
|
83
108
|
const filter = (config.input_filter ?? []).map(pattern => new RegExp(pattern, "i"));
|
|
84
109
|
let skipped = 0;
|
|
85
110
|
let added = 0;
|
|
86
111
|
const folders = Array.isArray(config.input_folder) ? config.input_folder : [config.input_folder];
|
|
112
|
+
const filesToRead = [];
|
|
87
113
|
for (const folder of folders) {
|
|
88
114
|
for (const filename of glob.sync(folder + "/**", { nosort: true, nodir: true })) {
|
|
89
115
|
if (filter.length > 0 && filter.some(a => a.test(filename)) === false) {
|
|
90
116
|
skipped++;
|
|
91
117
|
continue;
|
|
92
118
|
}
|
|
93
|
-
|
|
94
|
-
filename: path.basename(filename),
|
|
95
|
-
relative: path.relative(config.output_folder, path.dirname(filename)),
|
|
96
|
-
contents: fs.readFileSync(filename, "utf8"),
|
|
97
|
-
});
|
|
119
|
+
filesToRead.push(filename);
|
|
98
120
|
added++;
|
|
99
121
|
}
|
|
100
122
|
}
|
|
123
|
+
const files = await this.readAllFiles(filesToRead, config.output_folder);
|
|
101
124
|
console.log(added + " files added from source");
|
|
102
125
|
console.log(skipped + " files skipped in source");
|
|
103
126
|
return files;
|
|
@@ -94670,6 +94693,88 @@ function onceStrict (fn) {
|
|
|
94670
94693
|
}
|
|
94671
94694
|
|
|
94672
94695
|
|
|
94696
|
+
/***/ }),
|
|
94697
|
+
|
|
94698
|
+
/***/ "./node_modules/p-limit/index.js":
|
|
94699
|
+
/*!***************************************!*\
|
|
94700
|
+
!*** ./node_modules/p-limit/index.js ***!
|
|
94701
|
+
\***************************************/
|
|
94702
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
94703
|
+
|
|
94704
|
+
"use strict";
|
|
94705
|
+
|
|
94706
|
+
const Queue = __webpack_require__(/*! yocto-queue */ "./node_modules/yocto-queue/index.js");
|
|
94707
|
+
|
|
94708
|
+
const pLimit = concurrency => {
|
|
94709
|
+
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
94710
|
+
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
94711
|
+
}
|
|
94712
|
+
|
|
94713
|
+
const queue = new Queue();
|
|
94714
|
+
let activeCount = 0;
|
|
94715
|
+
|
|
94716
|
+
const next = () => {
|
|
94717
|
+
activeCount--;
|
|
94718
|
+
|
|
94719
|
+
if (queue.size > 0) {
|
|
94720
|
+
queue.dequeue()();
|
|
94721
|
+
}
|
|
94722
|
+
};
|
|
94723
|
+
|
|
94724
|
+
const run = async (fn, resolve, ...args) => {
|
|
94725
|
+
activeCount++;
|
|
94726
|
+
|
|
94727
|
+
const result = (async () => fn(...args))();
|
|
94728
|
+
|
|
94729
|
+
resolve(result);
|
|
94730
|
+
|
|
94731
|
+
try {
|
|
94732
|
+
await result;
|
|
94733
|
+
} catch {}
|
|
94734
|
+
|
|
94735
|
+
next();
|
|
94736
|
+
};
|
|
94737
|
+
|
|
94738
|
+
const enqueue = (fn, resolve, ...args) => {
|
|
94739
|
+
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
94740
|
+
|
|
94741
|
+
(async () => {
|
|
94742
|
+
// This function needs to wait until the next microtask before comparing
|
|
94743
|
+
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
94744
|
+
// when the run function is dequeued and called. The comparison in the if-statement
|
|
94745
|
+
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
94746
|
+
await Promise.resolve();
|
|
94747
|
+
|
|
94748
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
94749
|
+
queue.dequeue()();
|
|
94750
|
+
}
|
|
94751
|
+
})();
|
|
94752
|
+
};
|
|
94753
|
+
|
|
94754
|
+
const generator = (fn, ...args) => new Promise(resolve => {
|
|
94755
|
+
enqueue(fn, resolve, ...args);
|
|
94756
|
+
});
|
|
94757
|
+
|
|
94758
|
+
Object.defineProperties(generator, {
|
|
94759
|
+
activeCount: {
|
|
94760
|
+
get: () => activeCount
|
|
94761
|
+
},
|
|
94762
|
+
pendingCount: {
|
|
94763
|
+
get: () => queue.size
|
|
94764
|
+
},
|
|
94765
|
+
clearQueue: {
|
|
94766
|
+
value: () => {
|
|
94767
|
+
queue.clear();
|
|
94768
|
+
}
|
|
94769
|
+
}
|
|
94770
|
+
});
|
|
94771
|
+
|
|
94772
|
+
return generator;
|
|
94773
|
+
};
|
|
94774
|
+
|
|
94775
|
+
module.exports = pLimit;
|
|
94776
|
+
|
|
94777
|
+
|
|
94673
94778
|
/***/ }),
|
|
94674
94779
|
|
|
94675
94780
|
/***/ "./node_modules/path-is-absolute/index.js":
|
|
@@ -100604,6 +100709,84 @@ function wrappy (fn, cb) {
|
|
|
100604
100709
|
}
|
|
100605
100710
|
|
|
100606
100711
|
|
|
100712
|
+
/***/ }),
|
|
100713
|
+
|
|
100714
|
+
/***/ "./node_modules/yocto-queue/index.js":
|
|
100715
|
+
/*!*******************************************!*\
|
|
100716
|
+
!*** ./node_modules/yocto-queue/index.js ***!
|
|
100717
|
+
\*******************************************/
|
|
100718
|
+
/***/ ((module) => {
|
|
100719
|
+
|
|
100720
|
+
class Node {
|
|
100721
|
+
/// value;
|
|
100722
|
+
/// next;
|
|
100723
|
+
|
|
100724
|
+
constructor(value) {
|
|
100725
|
+
this.value = value;
|
|
100726
|
+
|
|
100727
|
+
// TODO: Remove this when targeting Node.js 12.
|
|
100728
|
+
this.next = undefined;
|
|
100729
|
+
}
|
|
100730
|
+
}
|
|
100731
|
+
|
|
100732
|
+
class Queue {
|
|
100733
|
+
// TODO: Use private class fields when targeting Node.js 12.
|
|
100734
|
+
// #_head;
|
|
100735
|
+
// #_tail;
|
|
100736
|
+
// #_size;
|
|
100737
|
+
|
|
100738
|
+
constructor() {
|
|
100739
|
+
this.clear();
|
|
100740
|
+
}
|
|
100741
|
+
|
|
100742
|
+
enqueue(value) {
|
|
100743
|
+
const node = new Node(value);
|
|
100744
|
+
|
|
100745
|
+
if (this._head) {
|
|
100746
|
+
this._tail.next = node;
|
|
100747
|
+
this._tail = node;
|
|
100748
|
+
} else {
|
|
100749
|
+
this._head = node;
|
|
100750
|
+
this._tail = node;
|
|
100751
|
+
}
|
|
100752
|
+
|
|
100753
|
+
this._size++;
|
|
100754
|
+
}
|
|
100755
|
+
|
|
100756
|
+
dequeue() {
|
|
100757
|
+
const current = this._head;
|
|
100758
|
+
if (!current) {
|
|
100759
|
+
return;
|
|
100760
|
+
}
|
|
100761
|
+
|
|
100762
|
+
this._head = this._head.next;
|
|
100763
|
+
this._size--;
|
|
100764
|
+
return current.value;
|
|
100765
|
+
}
|
|
100766
|
+
|
|
100767
|
+
clear() {
|
|
100768
|
+
this._head = undefined;
|
|
100769
|
+
this._tail = undefined;
|
|
100770
|
+
this._size = 0;
|
|
100771
|
+
}
|
|
100772
|
+
|
|
100773
|
+
get size() {
|
|
100774
|
+
return this._size;
|
|
100775
|
+
}
|
|
100776
|
+
|
|
100777
|
+
* [Symbol.iterator]() {
|
|
100778
|
+
let current = this._head;
|
|
100779
|
+
|
|
100780
|
+
while (current) {
|
|
100781
|
+
yield current.value;
|
|
100782
|
+
current = current.next;
|
|
100783
|
+
}
|
|
100784
|
+
}
|
|
100785
|
+
}
|
|
100786
|
+
|
|
100787
|
+
module.exports = Queue;
|
|
100788
|
+
|
|
100789
|
+
|
|
100607
100790
|
/***/ }),
|
|
100608
100791
|
|
|
100609
100792
|
/***/ "assert":
|
|
@@ -100661,6 +100844,28 @@ module.exports = require("fs");
|
|
|
100661
100844
|
|
|
100662
100845
|
/***/ }),
|
|
100663
100846
|
|
|
100847
|
+
/***/ "node:fs/promises":
|
|
100848
|
+
/*!***********************************!*\
|
|
100849
|
+
!*** external "node:fs/promises" ***!
|
|
100850
|
+
\***********************************/
|
|
100851
|
+
/***/ ((module) => {
|
|
100852
|
+
|
|
100853
|
+
"use strict";
|
|
100854
|
+
module.exports = require("node:fs/promises");
|
|
100855
|
+
|
|
100856
|
+
/***/ }),
|
|
100857
|
+
|
|
100858
|
+
/***/ "node:os":
|
|
100859
|
+
/*!**************************!*\
|
|
100860
|
+
!*** external "node:os" ***!
|
|
100861
|
+
\**************************/
|
|
100862
|
+
/***/ ((module) => {
|
|
100863
|
+
|
|
100864
|
+
"use strict";
|
|
100865
|
+
module.exports = require("node:os");
|
|
100866
|
+
|
|
100867
|
+
/***/ }),
|
|
100868
|
+
|
|
100664
100869
|
/***/ "os":
|
|
100665
100870
|
/*!*********************!*\
|
|
100666
100871
|
!*** external "os" ***!
|
|
@@ -100861,7 +101066,7 @@ async function run() {
|
|
|
100861
101066
|
console.log("Transpiler CLI");
|
|
100862
101067
|
const config = config_1.TranspilerConfig.find(process.argv[2]);
|
|
100863
101068
|
const libFiles = loadLib(config);
|
|
100864
|
-
const files = file_operations_1.FileOperations.loadFiles(config);
|
|
101069
|
+
const files = await file_operations_1.FileOperations.loadFiles(config);
|
|
100865
101070
|
console.log("\nBuilding");
|
|
100866
101071
|
const t = new Transpiler.Transpiler(config.options);
|
|
100867
101072
|
const reg = new abaplint.Registry();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.59",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@abaplint/core": "^2.113.125",
|
|
31
|
-
"@abaplint/transpiler": "^2.10.
|
|
31
|
+
"@abaplint/transpiler": "^2.10.59",
|
|
32
32
|
"@types/glob": "^8.1.0",
|
|
33
33
|
"@types/node": "^22.15.29",
|
|
34
34
|
"@types/progress": "^2.0.7",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"progress": "^2.0.3",
|
|
37
37
|
"ts-json-schema-generator": "^2.4.0",
|
|
38
38
|
"typescript": "^5.8.3",
|
|
39
|
+
"p-limit": "^3.1.0",
|
|
39
40
|
"webpack-cli": "^6.0.1",
|
|
40
41
|
"webpack": "^5.99.9"
|
|
41
42
|
}
|