@abaplint/transpiler-cli 2.3.21 → 2.3.22
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 +1 -1
- package/package.json +2 -2
package/build/bundle.js
CHANGED
|
@@ -38,7 +38,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
38
38
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
39
39
|
|
|
40
40
|
"use strict";
|
|
41
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst glob = __webpack_require__(/*! glob */ \"./node_modules/glob/glob.js\");\r\nconst childProcess = __webpack_require__(/*! child_process */ \"child_process\");\r\nconst os = __webpack_require__(/*! os */ \"os\");\r\nconst ProgressBar = __webpack_require__(/*! progress */ \"./node_modules/progress/index.js\");\r\nconst Transpiler = __webpack_require__(/*! @abaplint/transpiler */ \"./node_modules/@abaplint/transpiler/build/src/index.js\");\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst config_1 = __webpack_require__(/*! ./config */ \"./build/config.js\");\r\nconst file_operations_1 = __webpack_require__(/*! ./file_operations */ \"./build/file_operations.js\");\r\nclass Progress {\r\n set(total, _text) {\r\n this.bar = new ProgressBar(\":percent - :elapseds - :text\", { total, renderThrottle: 100 });\r\n }\r\n async tick(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n}\r\nfunction loadLib(config) {\r\n const files = [];\r\n if (config.lib && config.lib !== \"\" && config.libs === undefined) {\r\n config.libs = [{ url: config.lib }];\r\n }\r\n for (const l of config.libs || []) {\r\n let dir = \"\";\r\n let cleanupFolder = false;\r\n if (l.folder !== undefined && l.folder !== \"\" && fs.existsSync(process.cwd() + l.folder)) {\r\n console.log(\"From folder: \" + l.folder);\r\n dir = process.cwd() + l.folder;\r\n }\r\n else {\r\n console.log(\"Clone: \" + l.url);\r\n dir = fs.mkdtempSync(path.join(os.tmpdir(), \"abap_transpile-\"));\r\n childProcess.execSync(\"git clone --quiet --depth 1 \" + l.url + \" .\", { cwd: dir, stdio: \"inherit\" });\r\n cleanupFolder = true;\r\n }\r\n let count = 0;\r\n let pattern = \"/src/**\";\r\n if (l.files !== undefined && l.files !== \"\") {\r\n pattern = l.files;\r\n }\r\n for (let filename of glob.sync(dir + pattern, { nosort: true, nodir: true })) {\r\n if (filename.endsWith(\".clas.testclasses.abap\")) {\r\n continue;\r\n }\r\n const contents = fs.readFileSync(filename, \"utf8\");\r\n filename = path.basename(filename);\r\n files.push({ filename, contents });\r\n count++;\r\n }\r\n console.log(count + \" files added from lib\");\r\n if (cleanupFolder === true) {\r\n file_operations_1.FileOperations.deleteFolderRecursive(dir);\r\n }\r\n }\r\n return files;\r\n}\r\nfunction writeObjects(objects, writeSourceMaps, outputFolder, files) {\r\n for (const o of objects) {\r\n let contents = o.chunk.getCode();\r\n if (writeSourceMaps === true\r\n && o.object.type.toUpperCase() !== \"TABL\"\r\n && o.object.type.toUpperCase() !== \"DTEL\"\r\n && o.object.type.toUpperCase() !== \"ENQU\"\r\n && o.object.type.toUpperCase() !== \"TTYP\") {\r\n const name = o.filename + \".map\";\r\n contents = contents + `\\n//# sourceMappingURL=` + name;\r\n let map = o.chunk.getMap(o.filename);\r\n for (const f of files) { // hack the paths to the original files\r\n if (f.relative === undefined) {\r\n continue;\r\n }\r\n if (map.includes(`\"${f.filename}\"`)) {\r\n let withPath = `\"${f.relative}${path.sep}${f.filename}\"`;\r\n withPath = withPath.replace(/\\\\/g, \"\\\\\\\\\");\r\n map = map.replace(`\"${f.filename}\"`, withPath);\r\n }\r\n }\r\n fs.writeFileSync(outputFolder + path.sep + name, map);\r\n }\r\n fs.writeFileSync(outputFolder + path.sep + o.filename, contents);\r\n }\r\n}\r\nasync function run() {\r\n console.log(\"Transpiler CLI\");\r\n const config = config_1.TranspilerConfig.find(process.argv[2]);\r\n const libFiles = loadLib(config);\r\n const files = file_operations_1.FileOperations.loadFiles(config);\r\n console.log(\"\\nBuilding\");\r\n const t = new Transpiler.Transpiler(config.options);\r\n const reg = new abaplint.Registry();\r\n for (const f of files) {\r\n reg.addFile(new abaplint.MemoryFile(f.filename, f.contents));\r\n }\r\n for (const l of libFiles) {\r\n reg.addDependency(new abaplint.MemoryFile(l.filename, l.contents));\r\n }\r\n reg.parse();\r\n const output = await t.run(reg, new Progress());\r\n console.log(\"\\nOutput\");\r\n const outputFolder = config.output_folder;\r\n if (!fs.existsSync(outputFolder)) {\r\n fs.mkdirSync(outputFolder);\r\n }\r\n writeObjects(output.objects, config.write_source_map, outputFolder, files);\r\n console.log(output.objects.length + \" objects written to disk\");\r\n if (config.write_unit_tests === true) {\r\n // breaking change? rename this output file,\r\n fs.writeFileSync(outputFolder + path.sep + \"index.mjs\", output.unitTestScript);\r\n fs.writeFileSync(outputFolder + path.sep + \"_unit_open.mjs\", output.unitTestScriptOpen);\r\n }\r\n // breaking change? rename this output file,\r\n fs.writeFileSync(outputFolder + path.sep + \"init.mjs\", output.initializationScript);\r\n // new static referenced imports,\r\n fs.writeFileSync(outputFolder + path.sep + \"_init.mjs\", output.initializationScript2);\r\n fs.writeFileSync(outputFolder + path.sep + \"_top.mjs\", `import runtime from \"@abaplint/runtime\";\r\nglobalThis.abap = new runtime.ABAP();`);\r\n}\r\nrun().then(() => {\r\n process.exit();\r\n}).catch((err) => {\r\n console.log(err);\r\n process.exit(1);\r\n});\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./build/index.js?");
|
|
41
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst path = __webpack_require__(/*! path */ \"path\");\r\nconst glob = __webpack_require__(/*! glob */ \"./node_modules/glob/glob.js\");\r\nconst childProcess = __webpack_require__(/*! child_process */ \"child_process\");\r\nconst os = __webpack_require__(/*! os */ \"os\");\r\nconst ProgressBar = __webpack_require__(/*! progress */ \"./node_modules/progress/index.js\");\r\nconst Transpiler = __webpack_require__(/*! @abaplint/transpiler */ \"./node_modules/@abaplint/transpiler/build/src/index.js\");\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst config_1 = __webpack_require__(/*! ./config */ \"./build/config.js\");\r\nconst file_operations_1 = __webpack_require__(/*! ./file_operations */ \"./build/file_operations.js\");\r\nclass Progress {\r\n set(total, _text) {\r\n this.bar = new ProgressBar(\":percent - :elapseds - :text\", { total, renderThrottle: 100 });\r\n }\r\n async tick(text) {\r\n this.bar.tick({ text });\r\n this.bar.render();\r\n }\r\n}\r\nfunction loadLib(config) {\r\n const files = [];\r\n if (config.lib && config.lib !== \"\" && config.libs === undefined) {\r\n config.libs = [{ url: config.lib }];\r\n }\r\n for (const l of config.libs || []) {\r\n let dir = \"\";\r\n let cleanupFolder = false;\r\n if (l.folder !== undefined && l.folder !== \"\" && fs.existsSync(process.cwd() + l.folder)) {\r\n console.log(\"From folder: \" + l.folder);\r\n dir = process.cwd() + l.folder;\r\n }\r\n else {\r\n console.log(\"Clone: \" + l.url);\r\n dir = fs.mkdtempSync(path.join(os.tmpdir(), \"abap_transpile-\"));\r\n childProcess.execSync(\"git clone --quiet --depth 1 \" + l.url + \" .\", { cwd: dir, stdio: \"inherit\" });\r\n cleanupFolder = true;\r\n }\r\n let count = 0;\r\n let pattern = \"/src/**\";\r\n if (l.files !== undefined && l.files !== \"\") {\r\n pattern = l.files;\r\n }\r\n for (let filename of glob.sync(dir + pattern, { nosort: true, nodir: true })) {\r\n if (filename.endsWith(\".clas.testclasses.abap\")) {\r\n continue;\r\n }\r\n const contents = fs.readFileSync(filename, \"utf8\");\r\n filename = path.basename(filename);\r\n files.push({ filename, contents });\r\n count++;\r\n }\r\n console.log(count + \" files added from lib\");\r\n if (cleanupFolder === true) {\r\n file_operations_1.FileOperations.deleteFolderRecursive(dir);\r\n }\r\n }\r\n return files;\r\n}\r\nfunction writeObjects(objects, writeSourceMaps, outputFolder, files) {\r\n for (const o of objects) {\r\n let contents = o.chunk.getCode();\r\n if (writeSourceMaps === true\r\n && o.object.type.toUpperCase() !== \"TABL\"\r\n && o.object.type.toUpperCase() !== \"DTEL\"\r\n && o.object.type.toUpperCase() !== \"ENQU\"\r\n && o.object.type.toUpperCase() !== \"TTYP\") {\r\n const name = o.filename + \".map\";\r\n // SourceMappingUrl needs to be percent-encoded, ref https://github.com/microsoft/TypeScript/issues/40951\r\n contents = contents + `\\n//# sourceMappingURL=` + name.replace(/#/g, \"%23\");\r\n let map = o.chunk.getMap(o.filename);\r\n for (const f of files) { // hack the paths to the original files\r\n if (f.relative === undefined) {\r\n continue;\r\n }\r\n if (map.includes(`\"${f.filename}\"`)) {\r\n let withPath = `\"${f.relative}${path.sep}${f.filename}\"`;\r\n withPath = withPath.replace(/\\\\/g, \"\\\\\\\\\");\r\n map = map.replace(`\"${f.filename}\"`, withPath);\r\n }\r\n }\r\n fs.writeFileSync(outputFolder + path.sep + name, map);\r\n }\r\n if (o.object.type.toUpperCase() === \"PROG\") {\r\n // hmm, will this work for INCLUDEs ?\r\n contents = `await import(\"./_init.mjs\");\\n` + contents;\r\n }\r\n fs.writeFileSync(outputFolder + path.sep + o.filename, contents);\r\n }\r\n}\r\nasync function run() {\r\n console.log(\"Transpiler CLI\");\r\n const config = config_1.TranspilerConfig.find(process.argv[2]);\r\n const libFiles = loadLib(config);\r\n const files = file_operations_1.FileOperations.loadFiles(config);\r\n console.log(\"\\nBuilding\");\r\n const t = new Transpiler.Transpiler(config.options);\r\n const reg = new abaplint.Registry();\r\n for (const f of files) {\r\n reg.addFile(new abaplint.MemoryFile(f.filename, f.contents));\r\n }\r\n for (const l of libFiles) {\r\n reg.addDependency(new abaplint.MemoryFile(l.filename, l.contents));\r\n }\r\n reg.parse();\r\n const output = await t.run(reg, new Progress());\r\n console.log(\"\\nOutput\");\r\n const outputFolder = config.output_folder;\r\n if (!fs.existsSync(outputFolder)) {\r\n fs.mkdirSync(outputFolder);\r\n }\r\n writeObjects(output.objects, config.write_source_map, outputFolder, files);\r\n console.log(output.objects.length + \" objects written to disk\");\r\n if (config.write_unit_tests === true) {\r\n // breaking change? rename this output file,\r\n fs.writeFileSync(outputFolder + path.sep + \"index.mjs\", output.unitTestScript);\r\n fs.writeFileSync(outputFolder + path.sep + \"_unit_open.mjs\", output.unitTestScriptOpen);\r\n }\r\n // breaking change? rename this output file,\r\n fs.writeFileSync(outputFolder + path.sep + \"init.mjs\", output.initializationScript);\r\n // new static referenced imports,\r\n fs.writeFileSync(outputFolder + path.sep + \"_init.mjs\", output.initializationScript2);\r\n fs.writeFileSync(outputFolder + path.sep + \"_top.mjs\", `import runtime from \"@abaplint/runtime\";\r\nglobalThis.abap = new runtime.ABAP();`);\r\n}\r\nrun().then(() => {\r\n process.exit();\r\n}).catch((err) => {\r\n console.log(err);\r\n process.exit(1);\r\n});\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./build/index.js?");
|
|
42
42
|
|
|
43
43
|
/***/ }),
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.22",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"abap_transpile": "./abap_transpile"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "abaplint",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@abaplint/transpiler": "^2.3.
|
|
28
|
+
"@abaplint/transpiler": "^2.3.22",
|
|
29
29
|
"@types/glob": "^7.2.0",
|
|
30
30
|
"glob": "=7.2.0",
|
|
31
31
|
"@types/progress": "^2.0.5",
|