@abaplint/transpiler-cli 2.1.59 → 2.1.62
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 +12 -12
- package/abap_transpile +2 -2
- package/build/bundle.js +10 -10
- package/package.json +38 -38
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @abaplint/transpiler-cli
|
|
2
|
-
|
|
3
|
-
Transpiler CLI
|
|
4
|
-
|
|
5
|
-
Input = `src` directory
|
|
6
|
-
|
|
7
|
-
Output = `output` directory
|
|
8
|
-
|
|
9
|
-
## Examples
|
|
10
|
-
|
|
11
|
-
Call `abap_transpile` on the command line, see example in
|
|
12
|
-
|
|
1
|
+
# @abaplint/transpiler-cli
|
|
2
|
+
|
|
3
|
+
Transpiler CLI
|
|
4
|
+
|
|
5
|
+
Input = `src` directory
|
|
6
|
+
|
|
7
|
+
Output = `output` directory
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
Call `abap_transpile` on the command line, see example in
|
|
12
|
+
|
|
13
13
|
https://github.com/larshp/abap-advent-2020/blob/main/package.json#L8
|
package/abap_transpile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require("./build/bundle");
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
require("./build/bundle");
|
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() !== \"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\";\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() !== \"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?");
|
|
42
42
|
|
|
43
43
|
/***/ }),
|
|
44
44
|
|
|
@@ -13722,7 +13722,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13722
13722
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13723
13723
|
|
|
13724
13724
|
"use strict";
|
|
13725
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleDataElement = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\nclass HandleDataElement {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n let fixedValues = undefined;\r\n if (obj.getDomainName()) {\r\n const doma = reg.getObject(\"DOMA\", obj.getDomainName());\r\n if (doma) {\r\n fixedValues = doma.getFixedValues();\r\n }\r\n }\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\n \"objectType\": \"DTEL\",\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\n \"domain\": ${JSON.stringify(obj.getDomainName())},\n \"fixedValues\": ${JSON.stringify(fixedValues)},\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleDataElement = HandleDataElement;\r\n//# sourceMappingURL=handle_data_element.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_data_element.js?");
|
|
13725
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleDataElement = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\nclass HandleDataElement {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n let fixedValues = undefined;\r\n if (obj.getDomainName()) {\r\n const doma = reg.getObject(\"DOMA\", obj.getDomainName());\r\n if (doma) {\r\n fixedValues = doma.getFixedValues();\r\n }\r\n }\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\r\n \"objectType\": \"DTEL\",\r\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\r\n \"domain\": ${JSON.stringify(obj.getDomainName())},\r\n \"fixedValues\": ${JSON.stringify(fixedValues)},\r\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleDataElement = HandleDataElement;\r\n//# sourceMappingURL=handle_data_element.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_data_element.js?");
|
|
13726
13726
|
|
|
13727
13727
|
/***/ }),
|
|
13728
13728
|
|
|
@@ -13733,7 +13733,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13733
13733
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13734
13734
|
|
|
13735
13735
|
"use strict";
|
|
13736
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleTable = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\n// tables or structures\r\nclass HandleTable {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\n \"objectType\": \"TABL\",\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\n \"keyFields\": ${JSON.stringify(obj.listKeys())},\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleTable = HandleTable;\r\n//# sourceMappingURL=handle_table.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_table.js?");
|
|
13736
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleTable = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\n// tables or structures\r\nclass HandleTable {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\r\n \"objectType\": \"TABL\",\r\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\r\n \"keyFields\": ${JSON.stringify(obj.listKeys())},\r\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleTable = HandleTable;\r\n//# sourceMappingURL=handle_table.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_table.js?");
|
|
13737
13737
|
|
|
13738
13738
|
/***/ }),
|
|
13739
13739
|
|
|
@@ -13744,7 +13744,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13744
13744
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13745
13745
|
|
|
13746
13746
|
"use strict";
|
|
13747
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleTableType = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\nclass HandleTableType {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\n \"objectType\": \"TTYP\",\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleTableType = HandleTableType;\r\n//# sourceMappingURL=handle_table_type.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_table_type.js?");
|
|
13747
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.HandleTableType = void 0;\r\nconst chunk_1 = __webpack_require__(/*! ./chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst transpile_types_1 = __webpack_require__(/*! ./transpile_types */ \"./node_modules/@abaplint/transpiler/build/src/transpile_types.js\");\r\nclass HandleTableType {\r\n runObject(obj, reg) {\r\n var _a;\r\n const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(\".xml\", \".mjs\").toLowerCase();\r\n if (filename === undefined) {\r\n return [];\r\n }\r\n const type = obj.parseType(reg);\r\n const chunk = new chunk_1.Chunk().appendString(`abap.DDIC[\"${obj.getName().toUpperCase()}\"] = {\r\n \"objectType\": \"TTYP\",\r\n \"type\": ${new transpile_types_1.TranspileTypes().toType(type)},\r\n};`);\r\n const output = {\r\n object: {\r\n name: obj.getName(),\r\n type: obj.getType(),\r\n },\r\n filename: filename,\r\n chunk: chunk,\r\n requires: [],\r\n exports: [],\r\n };\r\n return [output];\r\n }\r\n}\r\nexports.HandleTableType = HandleTableType;\r\n//# sourceMappingURL=handle_table_type.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/handle_table_type.js?");
|
|
13748
13748
|
|
|
13749
13749
|
/***/ }),
|
|
13750
13750
|
|
|
@@ -13865,7 +13865,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13865
13865
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13866
13866
|
|
|
13867
13867
|
"use strict";
|
|
13868
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.CallTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nclass CallTranspiler {\r\n transpile(node, traversal) {\r\n var _a, _b, _c, _d;\r\n if (node.concatTokens().toLowerCase().includes(\"super->constructor\")) {\r\n // todo, https://github.com/abaplint/transpiler/issues/133\r\n return new chunk_1.Chunk(\"\");\r\n }\r\n const chain = node.findDirectExpression(abaplint.Expressions.MethodCallChain);\r\n if (chain) {\r\n let pre = \"\";\r\n let post = \"\";\r\n const receiving = (_b = (_a = chain.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.ParameterT)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.Target);\r\n if (receiving) {\r\n pre = traversal.traverse(receiving).getCode() + \".set(\";\r\n post = \")\";\r\n }\r\n const exceptions = node.findFirstExpression(abaplint.Expressions.ParameterListExceptions);\r\n if (exceptions) {\r\n pre = \"try {\\n\" + pre;\r\n }\r\n post += \";\";\r\n if (exceptions) {\r\n post += `\\nabap.builtin.sy.get().subrc.set(0);\n} catch (e) {\nif (e.classic) {\n switch (e.classic.toUpperCase()) {\\n`;\r\n for (const e of exceptions.findAllExpressions(abaplint.Expressions.ParameterException)) {\r\n const name = e.getFirstToken().getStr().toUpperCase();\r\n const value = (_c = e.findFirstExpression(abaplint.Expressions.SimpleName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();\r\n if (value === undefined) {\r\n continue;\r\n }\r\n if (name === \"OTHERS\") {\r\n post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\\n`;\r\n }\r\n else {\r\n post += `case \"${name}\": abap.builtin.sy.get().subrc.set(${value}); break;\\n`;\r\n }\r\n }\r\n post += ` }\n} else {\n throw e;\n}\n}`;\r\n }\r\n return new chunk_1.Chunk()\r\n .appendString(pre)\r\n .appendChunk(traversal.traverse(chain))\r\n .append(post, node.getLastToken(), traversal);\r\n }\r\n const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);\r\n if (methodSource) {\r\n let body = \"\";\r\n const methodCallBody = node.findDirectExpression(abaplint.Expressions.MethodCallBody);\r\n if (methodCallBody) {\r\n body = traversal.traverse(methodCallBody).getCode();\r\n }\r\n let pre = \"\";\r\n let post = \"\";\r\n const receiving = (_d = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _d === void 0 ? void 0 : _d.findExpressionAfterToken(\"RECEIVING\");\r\n if (receiving) {\r\n const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));\r\n pre = target.getCode() + \".set(\";\r\n post = \")\";\r\n }\r\n const ms = new expressions_1.MethodSourceTranspiler(pre).transpile(methodSource, traversal);\r\n return new chunk_1.Chunk().appendChunk(ms).appendString(\"(\" + body + \")\" + post + \";\");\r\n }\r\n throw new Error(\"CallTranspiler, todo\");\r\n }\r\n}\r\nexports.CallTranspiler = CallTranspiler;\r\n//# sourceMappingURL=call.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/call.js?");
|
|
13868
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.CallTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nclass CallTranspiler {\r\n transpile(node, traversal) {\r\n var _a, _b, _c, _d;\r\n if (node.concatTokens().toLowerCase().includes(\"super->constructor\")) {\r\n // todo, https://github.com/abaplint/transpiler/issues/133\r\n return new chunk_1.Chunk(\"\");\r\n }\r\n const chain = node.findDirectExpression(abaplint.Expressions.MethodCallChain);\r\n if (chain) {\r\n let pre = \"\";\r\n let post = \"\";\r\n const receiving = (_b = (_a = chain.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(abaplint.Expressions.ParameterT)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.Target);\r\n if (receiving) {\r\n pre = traversal.traverse(receiving).getCode() + \".set(\";\r\n post = \")\";\r\n }\r\n const exceptions = node.findFirstExpression(abaplint.Expressions.ParameterListExceptions);\r\n if (exceptions) {\r\n pre = \"try {\\n\" + pre;\r\n }\r\n post += \";\";\r\n if (exceptions) {\r\n post += `\\nabap.builtin.sy.get().subrc.set(0);\r\n} catch (e) {\r\nif (e.classic) {\r\n switch (e.classic.toUpperCase()) {\\n`;\r\n for (const e of exceptions.findAllExpressions(abaplint.Expressions.ParameterException)) {\r\n const name = e.getFirstToken().getStr().toUpperCase();\r\n const value = (_c = e.findFirstExpression(abaplint.Expressions.SimpleName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();\r\n if (value === undefined) {\r\n continue;\r\n }\r\n if (name === \"OTHERS\") {\r\n post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\\n`;\r\n }\r\n else {\r\n post += `case \"${name}\": abap.builtin.sy.get().subrc.set(${value}); break;\\n`;\r\n }\r\n }\r\n post += ` }\r\n} else {\r\n throw e;\r\n}\r\n}`;\r\n }\r\n return new chunk_1.Chunk()\r\n .appendString(pre)\r\n .appendChunk(traversal.traverse(chain))\r\n .append(post, node.getLastToken(), traversal);\r\n }\r\n const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);\r\n if (methodSource) {\r\n let body = \"\";\r\n const methodCallBody = node.findDirectExpression(abaplint.Expressions.MethodCallBody);\r\n if (methodCallBody) {\r\n body = traversal.traverse(methodCallBody).getCode();\r\n }\r\n let pre = \"\";\r\n let post = \"\";\r\n const receiving = (_d = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _d === void 0 ? void 0 : _d.findExpressionAfterToken(\"RECEIVING\");\r\n if (receiving) {\r\n const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));\r\n pre = target.getCode() + \".set(\";\r\n post = \")\";\r\n }\r\n const ms = new expressions_1.MethodSourceTranspiler(pre).transpile(methodSource, traversal);\r\n return new chunk_1.Chunk().appendChunk(ms).appendString(\"(\" + body + \")\" + post + \";\");\r\n }\r\n throw new Error(\"CallTranspiler, todo\");\r\n }\r\n}\r\nexports.CallTranspiler = CallTranspiler;\r\n//# sourceMappingURL=call.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/call.js?");
|
|
13869
13869
|
|
|
13870
13870
|
/***/ }),
|
|
13871
13871
|
|
|
@@ -13931,7 +13931,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13931
13931
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13932
13932
|
|
|
13933
13933
|
"use strict";
|
|
13934
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ClassImplementationTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst traversal_1 = __webpack_require__(/*! ../traversal */ \"./node_modules/@abaplint/transpiler/build/src/traversal.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ClassImplementationTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const token = node.findFirstExpression(abaplint.Expressions.ClassName).getFirstToken();\r\n const def = traversal.getClassDefinition(token);\r\n let ret = \"class \" + traversal_1.Traversal.escapeClassName(token.getStr().toLowerCase());\r\n if (token.getStr().toLowerCase() === \"cx_root\") {\r\n // special case for exceptions\r\n ret += \" extends Error\";\r\n }\r\n else if (def === null || def === void 0 ? void 0 : def.getSuperClass()) {\r\n ret += \" extends \" + ((_a = def === null || def === void 0 ? void 0 : def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toLowerCase());\r\n }\r\n return new chunk_1.Chunk().append(ret + ` {\nstatic INTERNAL_TYPE = 'CLAS';\nstatic IMPLEMENTED_INTERFACES = [${def === null || def === void 0 ? void 0 : def.getImplementing().map(e => `\"` + e.name.toUpperCase() + `\"`).join(\",\")}];`, node, traversal);\r\n }\r\n}\r\nexports.ClassImplementationTranspiler = ClassImplementationTranspiler;\r\n//# sourceMappingURL=class_implementation.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/class_implementation.js?");
|
|
13934
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ClassImplementationTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst traversal_1 = __webpack_require__(/*! ../traversal */ \"./node_modules/@abaplint/transpiler/build/src/traversal.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ClassImplementationTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const token = node.findFirstExpression(abaplint.Expressions.ClassName).getFirstToken();\r\n const def = traversal.getClassDefinition(token);\r\n let ret = \"class \" + traversal_1.Traversal.escapeClassName(token.getStr().toLowerCase());\r\n if (token.getStr().toLowerCase() === \"cx_root\") {\r\n // special case for exceptions\r\n ret += \" extends Error\";\r\n }\r\n else if (def === null || def === void 0 ? void 0 : def.getSuperClass()) {\r\n ret += \" extends \" + ((_a = def === null || def === void 0 ? void 0 : def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toLowerCase());\r\n }\r\n return new chunk_1.Chunk().append(ret + ` {\r\nstatic INTERNAL_TYPE = 'CLAS';\r\nstatic IMPLEMENTED_INTERFACES = [${def === null || def === void 0 ? void 0 : def.getImplementing().map(e => `\"` + e.name.toUpperCase() + `\"`).join(\",\")}];`, node, traversal);\r\n }\r\n}\r\nexports.ClassImplementationTranspiler = ClassImplementationTranspiler;\r\n//# sourceMappingURL=class_implementation.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/class_implementation.js?");
|
|
13935
13935
|
|
|
13936
13936
|
/***/ }),
|
|
13937
13937
|
|
|
@@ -14140,7 +14140,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
14140
14140
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
14141
14141
|
|
|
14142
14142
|
"use strict";
|
|
14143
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DoTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nconst unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ \"./node_modules/@abaplint/transpiler/build/src/unique_identifier.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass DoTranspiler {\r\n transpile(node, traversal) {\r\n const found = node.findFirstExpression(abaplint.Expressions.Source);\r\n if (found) {\r\n const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();\r\n const idSource = unique_identifier_1.UniqueIdentifier.get();\r\n const id = unique_identifier_1.UniqueIdentifier.get();\r\n return new chunk_1.Chunk(`const ${idSource} = ${source};\nfor (let ${id} = 0; ${id} < ${idSource}; ${id}++) {\nabap.builtin.sy.get().index.set(${id} + 1);`);\r\n }\r\n else {\r\n const unique = unique_identifier_1.UniqueIdentifier.get();\r\n return new chunk_1.Chunk(`let ${unique} = 1;\nwhile (true) {\nabap.builtin.sy.get().index.set(${unique}++);`);\r\n }\r\n }\r\n}\r\nexports.DoTranspiler = DoTranspiler;\r\n//# sourceMappingURL=do.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/do.js?");
|
|
14143
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DoTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nconst unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ \"./node_modules/@abaplint/transpiler/build/src/unique_identifier.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass DoTranspiler {\r\n transpile(node, traversal) {\r\n const found = node.findFirstExpression(abaplint.Expressions.Source);\r\n if (found) {\r\n const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();\r\n const idSource = unique_identifier_1.UniqueIdentifier.get();\r\n const id = unique_identifier_1.UniqueIdentifier.get();\r\n return new chunk_1.Chunk(`const ${idSource} = ${source};\r\nfor (let ${id} = 0; ${id} < ${idSource}; ${id}++) {\r\nabap.builtin.sy.get().index.set(${id} + 1);`);\r\n }\r\n else {\r\n const unique = unique_identifier_1.UniqueIdentifier.get();\r\n return new chunk_1.Chunk(`let ${unique} = 1;\r\nwhile (true) {\r\nabap.builtin.sy.get().index.set(${unique}++);`);\r\n }\r\n }\r\n}\r\nexports.DoTranspiler = DoTranspiler;\r\n//# sourceMappingURL=do.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/do.js?");
|
|
14144
14144
|
|
|
14145
14145
|
/***/ }),
|
|
14146
14146
|
|
|
@@ -14789,7 +14789,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
14789
14789
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
14790
14790
|
|
|
14791
14791
|
"use strict";
|
|
14792
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SelectTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nconst unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ \"./node_modules/@abaplint/transpiler/build/src/unique_identifier.js\");\r\nclass SelectTranspiler {\r\n transpile(node, traversal, targetOverride) {\r\n var _a, _b, _c, _d;\r\n let target = \"undefined\";\r\n if (targetOverride) {\r\n target = targetOverride;\r\n }\r\n else if (node.findFirstExpression(abaplint.Expressions.Target)) {\r\n target = traversal.traverse(node.findFirstExpression(abaplint.Expressions.Target)).getCode();\r\n }\r\n let select = \"SELECT \";\r\n const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList)\r\n || node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop);\r\n if ((fieldList === null || fieldList === void 0 ? void 0 : fieldList.getChildren().length) === 1) {\r\n select += fieldList.concatTokens();\r\n }\r\n else {\r\n // add commas between field names, this is required for SQLite, and easy to remove in other clients?\r\n select += fieldList === null || fieldList === void 0 ? void 0 : fieldList.findAllExpressions(abaplint.Expressions.SQLField).map(e => e.concatTokens()).join(\", \");\r\n }\r\n select += \" \";\r\n select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + \" \";\r\n let where;\r\n for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {\r\n if (this.isWhereExpression(node, sqlCond)) {\r\n where = sqlCond;\r\n }\r\n }\r\n if (where) {\r\n select += \"WHERE \" + this.concatCond(where, traversal) + \" \";\r\n }\r\n const upTo = node.findFirstExpression(abaplint.Expressions.SQLUpTo);\r\n if (upTo) {\r\n select += upTo.concatTokens() + \" \";\r\n }\r\n const orderBy = node.findFirstExpression(abaplint.Expressions.SQLOrderBy);\r\n if (orderBy) {\r\n select += orderBy.concatTokens() + \" \";\r\n }\r\n for (const d of node.findAllExpressionsRecursive(abaplint.Expressions.Dynamic)) {\r\n const chain = d.findFirstExpression(abaplint.Expressions.FieldChain);\r\n if (chain) {\r\n const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();\r\n const search = d.concatTokens();\r\n select = select.replace(search, `\" + ${code} + \"`);\r\n }\r\n }\r\n if (node.concatTokens().toUpperCase().startsWith(\"SELECT SINGLE \")) {\r\n select += \"UP TO 1 ROWS\";\r\n }\r\n let runtimeOptions = \"\";\r\n if (node.concatTokens().toUpperCase().includes(\" APPENDING TABLE \")) {\r\n runtimeOptions = `, {appending: true}`;\r\n }\r\n let extra = \"\";\r\n const keys = this.findKeys(node, traversal);\r\n if (keys.length > 0) {\r\n extra = `, primaryKey: ${JSON.stringify(keys)}`;\r\n }\r\n if (node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) {\r\n const unique = unique_identifier_1.UniqueIdentifier.get();\r\n const faeName = (_d = (_c = (_b = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _c === void 0 ? void 0 : _c.concatTokens()) === null || _d === void 0 ? void 0 : _d.toLowerCase();\r\n select = select.replace(new RegExp(\" \" + faeName, \"g\"), \" \" + unique);\r\n select = select.replace(unique + \".get().table_line.get()\", unique + \".get()\"); // there can be only one?\r\n const code = `if (${faeName}.array().length === 0) {\n throw \"FAE, todo, empty table\";\n} else {\n abap.statements.clear(${target});\n for await (const ${unique} of abap.statements.loop(${faeName})) {\n await abap.statements.select(${target}, {select: \"${select.trim()}\"${extra}}, {appending: true});\n }\n abap.builtin.sy.get().dbcnt.set(${target}.array().length);\n}`;\r\n return new chunk_1.Chunk().append(code, node, traversal);\r\n }\r\n else {\r\n return new chunk_1.Chunk().append(`await abap.statements.select(${target}, {select: \"${select.trim()}\"${extra}}${runtimeOptions});`, node, traversal);\r\n }\r\n }\r\n findKeys(node, traversal) {\r\n let keys = [];\r\n const from = node.findAllExpressions(abaplint.Expressions.SQLFromSource).map(e => e.concatTokens());\r\n if (from.length === 1) {\r\n const tabl = traversal.findTable(from[0]);\r\n if (tabl) {\r\n keys = tabl.listKeys().map(k => k.toLowerCase());\r\n }\r\n }\r\n return keys;\r\n }\r\n concatCond(cond, traversal) {\r\n var _a;\r\n let ret = \"\";\r\n for (const c of cond.getChildren()) {\r\n if (c instanceof abaplint.Nodes.ExpressionNode\r\n && c.get() instanceof abaplint.Expressions.SQLCompare) {\r\n if (ret !== \"\") {\r\n ret += \" \";\r\n }\r\n if (c.findDirectExpression(abaplint.Expressions.Dynamic)) {\r\n const chain = (_a = c.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(abaplint.Expressions.FieldChain);\r\n if (chain) {\r\n const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();\r\n ret += `\" + ${code} + \"`;\r\n }\r\n else {\r\n throw new Error(\"SQL Condition, transpiler todo, dyn cond, \" + c.concatTokens());\r\n }\r\n }\r\n else if (c.findDirectExpression(abaplint.Expressions.SQLIn)) {\r\n ret += this.sqlIn(c, traversal);\r\n }\r\n else {\r\n ret += this.basicCondition(c, traversal);\r\n }\r\n }\r\n else if (c instanceof abaplint.Nodes.ExpressionNode) {\r\n ret += \" \" + this.concatCond(c, traversal);\r\n }\r\n else {\r\n ret += \" \" + c.concatTokens();\r\n }\r\n }\r\n return ret.trim();\r\n }\r\n sqlIn(c, _traversal) {\r\n const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);\r\n const slqin = c.findDirectExpression(abaplint.Expressions.SQLIn);\r\n const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);\r\n if (fieldName === undefined || slqin === undefined || source === undefined) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens());\r\n }\r\n const ret = `\" + abap.expandIN(\"${fieldName.concatTokens()}\", ${source.concatTokens()}) + \"`;\r\n return ret;\r\n }\r\n basicCondition(c, traversal) {\r\n let ret = \"\";\r\n if (c.getChildren().length !== 3) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens() + \", \" + c.getChildren().length);\r\n }\r\n const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);\r\n const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);\r\n const source = c.findDirectExpression(abaplint.Expressions.SQLSource);\r\n if (fieldName === undefined || operator === undefined || source === undefined) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens());\r\n }\r\n ret += fieldName.concatTokens() + \" \" + operator.concatTokens() + \" \";\r\n const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);\r\n if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {\r\n ret += \"'\\\" + \" + new expressions_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + \" + \\\"'\";\r\n }\r\n else {\r\n ret += source.concatTokens();\r\n }\r\n return ret;\r\n }\r\n isWhereExpression(node, expression) {\r\n // check if previous token before sqlCond is \"WHERE\". It could also be \"ON\" in case of join condition\r\n let prevToken;\r\n const sqlCondToken = expression.getFirstToken();\r\n for (const token of node.getTokens()) {\r\n if (token.getStart() === sqlCondToken.getStart()) {\r\n break;\r\n }\r\n prevToken = token;\r\n }\r\n if (prevToken && prevToken.getStr() === \"WHERE\") {\r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n}\r\nexports.SelectTranspiler = SelectTranspiler;\r\n//# sourceMappingURL=select.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/select.js?");
|
|
14792
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SelectTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../expressions */ \"./node_modules/@abaplint/transpiler/build/src/expressions/index.js\");\r\nconst unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ \"./node_modules/@abaplint/transpiler/build/src/unique_identifier.js\");\r\nclass SelectTranspiler {\r\n transpile(node, traversal, targetOverride) {\r\n var _a, _b, _c, _d;\r\n let target = \"undefined\";\r\n if (targetOverride) {\r\n target = targetOverride;\r\n }\r\n else if (node.findFirstExpression(abaplint.Expressions.Target)) {\r\n target = traversal.traverse(node.findFirstExpression(abaplint.Expressions.Target)).getCode();\r\n }\r\n let select = \"SELECT \";\r\n const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList)\r\n || node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop);\r\n if ((fieldList === null || fieldList === void 0 ? void 0 : fieldList.getChildren().length) === 1) {\r\n select += fieldList.concatTokens();\r\n }\r\n else {\r\n // add commas between field names, this is required for SQLite, and easy to remove in other clients?\r\n select += fieldList === null || fieldList === void 0 ? void 0 : fieldList.findAllExpressions(abaplint.Expressions.SQLField).map(e => e.concatTokens()).join(\", \");\r\n }\r\n select += \" \";\r\n select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + \" \";\r\n let where;\r\n for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {\r\n if (this.isWhereExpression(node, sqlCond)) {\r\n where = sqlCond;\r\n }\r\n }\r\n if (where) {\r\n select += \"WHERE \" + this.concatCond(where, traversal) + \" \";\r\n }\r\n const upTo = node.findFirstExpression(abaplint.Expressions.SQLUpTo);\r\n if (upTo) {\r\n select += upTo.concatTokens() + \" \";\r\n }\r\n const orderBy = node.findFirstExpression(abaplint.Expressions.SQLOrderBy);\r\n if (orderBy) {\r\n select += orderBy.concatTokens() + \" \";\r\n }\r\n for (const d of node.findAllExpressionsRecursive(abaplint.Expressions.Dynamic)) {\r\n const chain = d.findFirstExpression(abaplint.Expressions.FieldChain);\r\n if (chain) {\r\n const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();\r\n const search = d.concatTokens();\r\n select = select.replace(search, `\" + ${code} + \"`);\r\n }\r\n }\r\n if (node.concatTokens().toUpperCase().startsWith(\"SELECT SINGLE \")) {\r\n select += \"UP TO 1 ROWS\";\r\n }\r\n let runtimeOptions = \"\";\r\n if (node.concatTokens().toUpperCase().includes(\" APPENDING TABLE \")) {\r\n runtimeOptions = `, {appending: true}`;\r\n }\r\n let extra = \"\";\r\n const keys = this.findKeys(node, traversal);\r\n if (keys.length > 0) {\r\n extra = `, primaryKey: ${JSON.stringify(keys)}`;\r\n }\r\n if (node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) {\r\n const unique = unique_identifier_1.UniqueIdentifier.get();\r\n const faeName = (_d = (_c = (_b = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _c === void 0 ? void 0 : _c.concatTokens()) === null || _d === void 0 ? void 0 : _d.toLowerCase();\r\n select = select.replace(new RegExp(\" \" + faeName, \"g\"), \" \" + unique);\r\n select = select.replace(unique + \".get().table_line.get()\", unique + \".get()\"); // there can be only one?\r\n const code = `if (${faeName}.array().length === 0) {\r\n throw \"FAE, todo, empty table\";\r\n} else {\r\n abap.statements.clear(${target});\r\n for await (const ${unique} of abap.statements.loop(${faeName})) {\r\n await abap.statements.select(${target}, {select: \"${select.trim()}\"${extra}}, {appending: true});\r\n }\r\n abap.builtin.sy.get().dbcnt.set(${target}.array().length);\r\n}`;\r\n return new chunk_1.Chunk().append(code, node, traversal);\r\n }\r\n else {\r\n return new chunk_1.Chunk().append(`await abap.statements.select(${target}, {select: \"${select.trim()}\"${extra}}${runtimeOptions});`, node, traversal);\r\n }\r\n }\r\n findKeys(node, traversal) {\r\n let keys = [];\r\n const from = node.findAllExpressions(abaplint.Expressions.SQLFromSource).map(e => e.concatTokens());\r\n if (from.length === 1) {\r\n const tabl = traversal.findTable(from[0]);\r\n if (tabl) {\r\n keys = tabl.listKeys().map(k => k.toLowerCase());\r\n }\r\n }\r\n return keys;\r\n }\r\n concatCond(cond, traversal) {\r\n var _a;\r\n let ret = \"\";\r\n for (const c of cond.getChildren()) {\r\n if (c instanceof abaplint.Nodes.ExpressionNode\r\n && c.get() instanceof abaplint.Expressions.SQLCompare) {\r\n if (ret !== \"\") {\r\n ret += \" \";\r\n }\r\n if (c.findDirectExpression(abaplint.Expressions.Dynamic)) {\r\n const chain = (_a = c.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(abaplint.Expressions.FieldChain);\r\n if (chain) {\r\n const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();\r\n ret += `\" + ${code} + \"`;\r\n }\r\n else {\r\n throw new Error(\"SQL Condition, transpiler todo, dyn cond, \" + c.concatTokens());\r\n }\r\n }\r\n else if (c.findDirectExpression(abaplint.Expressions.SQLIn)) {\r\n ret += this.sqlIn(c, traversal);\r\n }\r\n else {\r\n ret += this.basicCondition(c, traversal);\r\n }\r\n }\r\n else if (c instanceof abaplint.Nodes.ExpressionNode) {\r\n ret += \" \" + this.concatCond(c, traversal);\r\n }\r\n else {\r\n ret += \" \" + c.concatTokens();\r\n }\r\n }\r\n return ret.trim();\r\n }\r\n sqlIn(c, _traversal) {\r\n const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);\r\n const slqin = c.findDirectExpression(abaplint.Expressions.SQLIn);\r\n const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);\r\n if (fieldName === undefined || slqin === undefined || source === undefined) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens());\r\n }\r\n const ret = `\" + abap.expandIN(\"${fieldName.concatTokens()}\", ${source.concatTokens()}) + \"`;\r\n return ret;\r\n }\r\n basicCondition(c, traversal) {\r\n let ret = \"\";\r\n if (c.getChildren().length !== 3) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens() + \", \" + c.getChildren().length);\r\n }\r\n const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);\r\n const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);\r\n const source = c.findDirectExpression(abaplint.Expressions.SQLSource);\r\n if (fieldName === undefined || operator === undefined || source === undefined) {\r\n throw new Error(\"SQL Condition, transpiler todo, \" + c.concatTokens());\r\n }\r\n ret += fieldName.concatTokens() + \" \" + operator.concatTokens() + \" \";\r\n const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);\r\n if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {\r\n ret += \"'\\\" + \" + new expressions_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + \" + \\\"'\";\r\n }\r\n else {\r\n ret += source.concatTokens();\r\n }\r\n return ret;\r\n }\r\n isWhereExpression(node, expression) {\r\n // check if previous token before sqlCond is \"WHERE\". It could also be \"ON\" in case of join condition\r\n let prevToken;\r\n const sqlCondToken = expression.getFirstToken();\r\n for (const token of node.getTokens()) {\r\n if (token.getStart() === sqlCondToken.getStart()) {\r\n break;\r\n }\r\n prevToken = token;\r\n }\r\n if (prevToken && prevToken.getStr() === \"WHERE\") {\r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n}\r\nexports.SelectTranspiler = SelectTranspiler;\r\n//# sourceMappingURL=select.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/select.js?");
|
|
14793
14793
|
|
|
14794
14794
|
/***/ }),
|
|
14795
14795
|
|
|
@@ -15053,7 +15053,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
15053
15053
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
15054
15054
|
|
|
15055
15055
|
"use strict";
|
|
15056
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ClassDefinitionTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ClassDefinitionTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const className = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n let found = false;\r\n if (className !== undefined) {\r\n for (const a of traversal.getCurrentObject().getABAPFiles()) {\r\n if (a.getInfo().getClassImplementationByName(className) !== undefined) {\r\n found = true;\r\n }\r\n }\r\n }\r\n if (found) {\r\n return new chunk_1.Chunk(\"\");\r\n }\r\n else {\r\n // its an abstract class with only abstract methods\r\n return new chunk_1.Chunk(`\nclass ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {\n static INTERNAL_TYPE = 'CLAS';\n async constructor_() {\n this.me = new abap.types.ABAPObject();\n this.me.set(this);\n return this;\n }\n}`);\r\n }\r\n }\r\n}\r\nexports.ClassDefinitionTranspiler = ClassDefinitionTranspiler;\r\n//# sourceMappingURL=class_definition.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/structures/class_definition.js?");
|
|
15056
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ClassDefinitionTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ClassDefinitionTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const className = (_a = node.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n let found = false;\r\n if (className !== undefined) {\r\n for (const a of traversal.getCurrentObject().getABAPFiles()) {\r\n if (a.getInfo().getClassImplementationByName(className) !== undefined) {\r\n found = true;\r\n }\r\n }\r\n }\r\n if (found) {\r\n return new chunk_1.Chunk(\"\");\r\n }\r\n else {\r\n // its an abstract class with only abstract methods\r\n return new chunk_1.Chunk(`\r\nclass ${className === null || className === void 0 ? void 0 : className.toLowerCase()} {\r\n static INTERNAL_TYPE = 'CLAS';\r\n async constructor_() {\r\n this.me = new abap.types.ABAPObject();\r\n this.me.set(this);\r\n return this;\r\n }\r\n}`);\r\n }\r\n }\r\n}\r\nexports.ClassDefinitionTranspiler = ClassDefinitionTranspiler;\r\n//# sourceMappingURL=class_definition.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/structures/class_definition.js?");
|
|
15057
15057
|
|
|
15058
15058
|
/***/ }),
|
|
15059
15059
|
|
|
@@ -15207,7 +15207,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
15207
15207
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
15208
15208
|
|
|
15209
15209
|
"use strict";
|
|
15210
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UnitTest = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass UnitTest {\r\n // todo, move this method somewhere else, its much more than just unit test relevant\r\n initializationScript(reg, dbSetup, extraSetup, useImport) {\r\n let ret = \"\";\r\n if (useImport === true) {\r\n ret = `/* eslint-disable import/newline-after-import */\nimport \"./_top.mjs\";\\n`;\r\n }\r\n else {\r\n ret = `/* eslint-disable import/newline-after-import */\nimport runtime from \"@abaplint/runtime\";\nglobalThis.abap = new runtime.ABAP();\\n`;\r\n }\r\n ret += `${this.buildImports(reg, useImport)}\n\nexport async function initializeABAP() {\\n`;\r\n ret += ` const sqlite = [];\\n`;\r\n for (const i of dbSetup.schemas.sqlite) {\r\n ret += `sqlite.push(\\`${i}\\`);\\n`;\r\n }\r\n ret += ` const hdb = \\`${dbSetup.schemas.hdb}\\`;\\n`;\r\n ret += ` const pg = \\`${dbSetup.schemas.pg}\\`;\\n`;\r\n ret += ` const schemas = {sqlite, hdb, pg};\\n`;\r\n ret += ` const insert = [];\\n`;\r\n for (const i of dbSetup.insert) {\r\n ret += `insert.push(\\`${i}\\`);\\n`;\r\n }\r\n if (extraSetup === undefined) {\r\n ret += `// no setup logic specified in config\\n`;\r\n }\r\n else {\r\n ret += ` const {setup} = await import(\"${extraSetup}\");\\n` +\r\n ` await setup(globalThis.abap, schemas, insert);\\n`;\r\n }\r\n ret += `}`;\r\n return ret;\r\n }\r\n escapeNamespace(filename) {\r\n // ES modules are resolved and cached as URLs. This means that special characters must be percent-encoded, such as # with %23 and ? with %3F.\r\n return filename.replace(/\\//g, \"%23\");\r\n }\r\n unitTestScriptOpen(reg, _skip, _only) {\r\n let ret = `/* eslint-disable curly */\nimport fs from \"fs\";\nimport path from \"path\";\nimport {fileURLToPath} from \"url\";\nimport {initializeABAP} from \"./init.mjs\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nasync function run() {\n await initializeABAP();\n let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]});\n let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});\n let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]}), json: new abap.types.String()});\n`;\r\n for (const obj of reg.getObjects()) {\r\n if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {\r\n continue;\r\n }\r\n const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(\".testclasses.\"); });\r\n if (hasTestFile === true) {\r\n ret += ` await import(\"./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs\");\\n`;\r\n }\r\n for (const file of obj.getABAPFiles()) {\r\n for (const def of file.getInfo().listClassDefinitions()) {\r\n if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {\r\n // todo, fix, there might be global test methods\r\n continue;\r\n }\r\n for (const m of def.methods) {\r\n if (m.isForTesting === false) {\r\n continue;\r\n }\r\n ret += ` ls_input.get().class_name.set(\"${obj.getName()}\");\n ls_input.get().testclass_name.set(\"${def.name.toUpperCase()}\");\n ls_input.get().method_name.set(\"${m.name.toUpperCase()}\");\n abap.statements.append({source: ls_input, target: lt_input});\\n`;\r\n }\r\n }\r\n }\r\n }\r\n ret += `\n\n ls_result.set(await abap.Classes[\"KERNEL_UNIT_RUNNER\"].run({it_input: lt_input}));\n fs.writeFileSync(__dirname + path.sep + \"output.json\", ls_result.get().json.get());\n}\n\nrun().then(() => {\n process.exit(0);\n}).catch((err) => {\n console.log(err);\n process.exit(1);\n});`;\r\n return ret;\r\n }\r\n unitTestScript(reg, skip, _only) {\r\n let ret = `/* eslint-disable curly */\nimport fs from \"fs\";\nimport path from \"path\";\nimport {fileURLToPath} from \"url\";\nimport {initializeABAP} from \"./init.mjs\";\nimport runtime from \"@abaplint/runtime\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nasync function run() {\n await initializeABAP();\n const unit = new runtime.UnitTestResult();\n let clas;\n let locl;\n let meth;\n try {\\n`;\r\n for (const obj of reg.getObjects()) {\r\n if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {\r\n continue;\r\n }\r\n ret += `// --------------------------------------------\\n`;\r\n ret += ` clas = unit.addObject(\"${obj.getName()}\");\\n`;\r\n for (const file of obj.getABAPFiles()) {\r\n for (const def of file.getInfo().listClassDefinitions()) {\r\n if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {\r\n // todo, fix, there might be global test methods\r\n continue;\r\n }\r\n ret += ` {\n const {${def.name}} = await import(\"./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs\");\n locl = clas.addTestClass(\"${def.name}\");\n if (${def.name}.class_setup) await ${def.name}.class_setup();\\n`;\r\n for (const m of def.methods) {\r\n if (m.isForTesting === false) {\r\n continue;\r\n }\r\n const skipThis = (skip || []).some(a => a.object === obj.getName() && a.class === def.name && a.method === m.name);\r\n if (skipThis) {\r\n ret += ` console.log('${obj.getName()}: running ${def.name}->${m.name}, skipped');\\n`;\r\n ret += ` meth = locl.addMethod(\"${m.name}\");\\n`;\r\n ret += ` meth.skip();\\n`;\r\n continue;\r\n }\r\n ret += ` {\\n const test = await (new ${def.name}()).constructor_();\\n`;\r\n ret += ` if (test.setup) await test.setup();\\n`;\r\n ret += ` console.log(\"${obj.getName()}: running ${def.name}->${m.name}\");\\n`;\r\n ret += ` meth = locl.addMethod(\"${m.name}\");\\n`;\r\n ret += ` await test.${m.name}();\\n`;\r\n ret += ` meth.pass();\\n`;\r\n ret += ` if (test.teardown) await test.teardown();\\n`;\r\n ret += ` }\\n`;\r\n }\r\n ret += ` if (${def.name}.class_teardown) await ${def.name}.class_teardown();\\n`;\r\n ret += ` }\\n`;\r\n }\r\n }\r\n }\r\n ret += `// -------------------END-------------------\n console.log(abap.console.get());\n fs.writeFileSync(__dirname + path.sep + \"_output.xml\", unit.xUnitXML());\n } catch (e) {\n if (meth) {\n meth.fail();\n }\n console.log(abap.console.get());\n fs.writeFileSync(__dirname + path.sep + \"_output.xml\", unit.xUnitXML());\n throw e;\n }\n}\n\nrun().then(() => {\n process.exit(0);\n}).catch((err) => {\n console.log(err);\n process.exit(1);\n});`;\r\n return ret;\r\n }\r\n buildImports(reg, useImport) {\r\n // note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap\r\n // todo, some sorting might be required? eg. a class constructor using constant from interface?\r\n // temporary sorting: by filename\r\n const list = [];\r\n const imp = (filename) => {\r\n if (useImport === true) {\r\n return `import \"./${filename}.mjs\";`;\r\n }\r\n else {\r\n return `await import(\"./${filename}.mjs\");`;\r\n }\r\n };\r\n for (const obj of reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n || obj instanceof abaplint.Objects.DataElement\r\n || obj instanceof abaplint.Objects.TableType) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n for (const obj of reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.FunctionGroup) {\r\n for (const m of obj.getModules()) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.fugr.${m.getName().toLowerCase()}`));\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n return list.sort().join(\"\\n\");\r\n }\r\n}\r\nexports.UnitTest = UnitTest;\r\n//# sourceMappingURL=unit_test.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/unit_test.js?");
|
|
15210
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UnitTest = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass UnitTest {\r\n // todo, move this method somewhere else, its much more than just unit test relevant\r\n initializationScript(reg, dbSetup, extraSetup, useImport) {\r\n let ret = \"\";\r\n if (useImport === true) {\r\n ret = `/* eslint-disable import/newline-after-import */\r\nimport \"./_top.mjs\";\\n`;\r\n }\r\n else {\r\n ret = `/* eslint-disable import/newline-after-import */\r\nimport runtime from \"@abaplint/runtime\";\r\nglobalThis.abap = new runtime.ABAP();\\n`;\r\n }\r\n ret += `${this.buildImports(reg, useImport)}\r\n\r\nexport async function initializeABAP() {\\n`;\r\n ret += ` const sqlite = [];\\n`;\r\n for (const i of dbSetup.schemas.sqlite) {\r\n ret += `sqlite.push(\\`${i}\\`);\\n`;\r\n }\r\n ret += ` const hdb = \\`${dbSetup.schemas.hdb}\\`;\\n`;\r\n ret += ` const pg = \\`${dbSetup.schemas.pg}\\`;\\n`;\r\n ret += ` const schemas = {sqlite, hdb, pg};\\n`;\r\n ret += ` const insert = [];\\n`;\r\n for (const i of dbSetup.insert) {\r\n ret += `insert.push(\\`${i}\\`);\\n`;\r\n }\r\n if (extraSetup === undefined) {\r\n ret += `// no setup logic specified in config\\n`;\r\n }\r\n else {\r\n ret += ` const {setup} = await import(\"${extraSetup}\");\\n` +\r\n ` await setup(globalThis.abap, schemas, insert);\\n`;\r\n }\r\n ret += `}`;\r\n return ret;\r\n }\r\n escapeNamespace(filename) {\r\n // ES modules are resolved and cached as URLs. This means that special characters must be percent-encoded, such as # with %23 and ? with %3F.\r\n return filename.replace(/\\//g, \"%23\");\r\n }\r\n unitTestScriptOpen(reg, _skip, _only) {\r\n let ret = `/* eslint-disable curly */\r\nimport fs from \"fs\";\r\nimport path from \"path\";\r\nimport {fileURLToPath} from \"url\";\r\nimport {initializeABAP} from \"./init.mjs\";\r\n\r\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\r\n\r\nasync function run() {\r\n await initializeABAP();\r\n let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]});\r\n let ls_input = new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30})});\r\n let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character({length: 30}), testclass_name: new abap.types.Character({length: 30}), method_name: new abap.types.Character({length: 30}), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String()}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]}), json: new abap.types.String()});\r\n`;\r\n for (const obj of reg.getObjects()) {\r\n if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {\r\n continue;\r\n }\r\n const hasTestFile = obj.getFiles().some(f => { return f.getFilename().includes(\".testclasses.\"); });\r\n if (hasTestFile === true) {\r\n ret += ` await import(\"./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs\");\\n`;\r\n }\r\n for (const file of obj.getABAPFiles()) {\r\n for (const def of file.getInfo().listClassDefinitions()) {\r\n if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {\r\n // todo, fix, there might be global test methods\r\n continue;\r\n }\r\n for (const m of def.methods) {\r\n if (m.isForTesting === false) {\r\n continue;\r\n }\r\n ret += ` ls_input.get().class_name.set(\"${obj.getName()}\");\r\n ls_input.get().testclass_name.set(\"${def.name.toUpperCase()}\");\r\n ls_input.get().method_name.set(\"${m.name.toUpperCase()}\");\r\n abap.statements.append({source: ls_input, target: lt_input});\\n`;\r\n }\r\n }\r\n }\r\n }\r\n ret += `\r\n\r\n ls_result.set(await abap.Classes[\"KERNEL_UNIT_RUNNER\"].run({it_input: lt_input}));\r\n fs.writeFileSync(__dirname + path.sep + \"output.json\", ls_result.get().json.get());\r\n}\r\n\r\nrun().then(() => {\r\n process.exit(0);\r\n}).catch((err) => {\r\n console.log(err);\r\n process.exit(1);\r\n});`;\r\n return ret;\r\n }\r\n unitTestScript(reg, skip, _only) {\r\n let ret = `/* eslint-disable curly */\r\nimport fs from \"fs\";\r\nimport path from \"path\";\r\nimport {fileURLToPath} from \"url\";\r\nimport {initializeABAP} from \"./init.mjs\";\r\nimport runtime from \"@abaplint/runtime\";\r\n\r\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\r\n\r\nasync function run() {\r\n await initializeABAP();\r\n const unit = new runtime.UnitTestResult();\r\n let clas;\r\n let locl;\r\n let meth;\r\n try {\\n`;\r\n for (const obj of reg.getObjects()) {\r\n if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {\r\n continue;\r\n }\r\n ret += `// --------------------------------------------\\n`;\r\n ret += ` clas = unit.addObject(\"${obj.getName()}\");\\n`;\r\n for (const file of obj.getABAPFiles()) {\r\n for (const def of file.getInfo().listClassDefinitions()) {\r\n if (def.isForTesting === false || def.isGlobal === true || def.methods.length === 0) {\r\n // todo, fix, there might be global test methods\r\n continue;\r\n }\r\n ret += ` {\r\n const {${def.name}} = await import(\"./${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}.testclasses.mjs\");\r\n locl = clas.addTestClass(\"${def.name}\");\r\n if (${def.name}.class_setup) await ${def.name}.class_setup();\\n`;\r\n for (const m of def.methods) {\r\n if (m.isForTesting === false) {\r\n continue;\r\n }\r\n const skipThis = (skip || []).some(a => a.object === obj.getName() && a.class === def.name && a.method === m.name);\r\n if (skipThis) {\r\n ret += ` console.log('${obj.getName()}: running ${def.name}->${m.name}, skipped');\\n`;\r\n ret += ` meth = locl.addMethod(\"${m.name}\");\\n`;\r\n ret += ` meth.skip();\\n`;\r\n continue;\r\n }\r\n ret += ` {\\n const test = await (new ${def.name}()).constructor_();\\n`;\r\n ret += ` if (test.setup) await test.setup();\\n`;\r\n ret += ` console.log(\"${obj.getName()}: running ${def.name}->${m.name}\");\\n`;\r\n ret += ` meth = locl.addMethod(\"${m.name}\");\\n`;\r\n ret += ` await test.${m.name}();\\n`;\r\n ret += ` meth.pass();\\n`;\r\n ret += ` if (test.teardown) await test.teardown();\\n`;\r\n ret += ` }\\n`;\r\n }\r\n ret += ` if (${def.name}.class_teardown) await ${def.name}.class_teardown();\\n`;\r\n ret += ` }\\n`;\r\n }\r\n }\r\n }\r\n ret += `// -------------------END-------------------\r\n console.log(abap.console.get());\r\n fs.writeFileSync(__dirname + path.sep + \"_output.xml\", unit.xUnitXML());\r\n } catch (e) {\r\n if (meth) {\r\n meth.fail();\r\n }\r\n console.log(abap.console.get());\r\n fs.writeFileSync(__dirname + path.sep + \"_output.xml\", unit.xUnitXML());\r\n throw e;\r\n }\r\n}\r\n\r\nrun().then(() => {\r\n process.exit(0);\r\n}).catch((err) => {\r\n console.log(err);\r\n process.exit(1);\r\n});`;\r\n return ret;\r\n }\r\n buildImports(reg, useImport) {\r\n // note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap\r\n // todo, some sorting might be required? eg. a class constructor using constant from interface?\r\n // temporary sorting: by filename\r\n const list = [];\r\n const imp = (filename) => {\r\n if (useImport === true) {\r\n return `import \"./${filename}.mjs\";`;\r\n }\r\n else {\r\n return `await import(\"./${filename}.mjs\");`;\r\n }\r\n };\r\n for (const obj of reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n || obj instanceof abaplint.Objects.DataElement\r\n || obj instanceof abaplint.Objects.TableType) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n for (const obj of reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.FunctionGroup) {\r\n for (const m of obj.getModules()) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.fugr.${m.getName().toLowerCase()}`));\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n return list.sort().join(\"\\n\");\r\n }\r\n}\r\nexports.UnitTest = UnitTest;\r\n//# sourceMappingURL=unit_test.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/unit_test.js?");
|
|
15211
15211
|
|
|
15212
15212
|
/***/ }),
|
|
15213
15213
|
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Transpiler - Command Line Interface",
|
|
5
|
-
"bin": {
|
|
6
|
-
"abap_transpile": "./abap_transpile"
|
|
7
|
-
},
|
|
8
|
-
"types": "./build/types.d.ts",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"ABAP",
|
|
11
|
-
"abaplint"
|
|
12
|
-
],
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "tsc && npm run webpack",
|
|
19
|
-
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
20
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
21
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
22
|
-
"compile": "npm test",
|
|
23
|
-
"webpack": "webpack --progress"
|
|
24
|
-
},
|
|
25
|
-
"author": "abaplint",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@abaplint/transpiler": "^2.1.
|
|
29
|
-
"@types/glob": "^7.2.0",
|
|
30
|
-
"glob": "=7.2.0",
|
|
31
|
-
"@types/progress": "^2.0.5",
|
|
32
|
-
"@abaplint/core": "^2.93.12",
|
|
33
|
-
"progress": "^2.0.3",
|
|
34
|
-
"webpack": "^5.74.0",
|
|
35
|
-
"webpack-cli": "^4.10.0",
|
|
36
|
-
"typescript": "^4.8.3"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/transpiler-cli",
|
|
3
|
+
"version": "2.1.62",
|
|
4
|
+
"description": "Transpiler - Command Line Interface",
|
|
5
|
+
"bin": {
|
|
6
|
+
"abap_transpile": "./abap_transpile"
|
|
7
|
+
},
|
|
8
|
+
"types": "./build/types.d.ts",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"ABAP",
|
|
11
|
+
"abaplint"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "tsc && npm run webpack",
|
|
19
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
20
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
21
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
22
|
+
"compile": "npm test",
|
|
23
|
+
"webpack": "webpack --progress"
|
|
24
|
+
},
|
|
25
|
+
"author": "abaplint",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@abaplint/transpiler": "^2.1.62",
|
|
29
|
+
"@types/glob": "^7.2.0",
|
|
30
|
+
"glob": "=7.2.0",
|
|
31
|
+
"@types/progress": "^2.0.5",
|
|
32
|
+
"@abaplint/core": "^2.93.12",
|
|
33
|
+
"progress": "^2.0.3",
|
|
34
|
+
"webpack": "^5.74.0",
|
|
35
|
+
"webpack-cli": "^4.10.0",
|
|
36
|
+
"typescript": "^4.8.3"
|
|
37
|
+
}
|
|
38
|
+
}
|