@abaplint/transpiler-cli 2.3.59 → 2.3.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/bundle.js +2 -2
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -15097,7 +15097,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
15097
15097
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
15098
15098
 
15099
15099
  "use strict";
15100
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ReplaceTranspiler = 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 chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ReplaceTranspiler {\r\n transpile(node, traversal) {\r\n const sources = node.findDirectExpressions(abaplint.Expressions.Source);\r\n const target = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Target)).getCode();\r\n const concat = node.concatTokens().toUpperCase();\r\n const all = concat.startsWith(\"REPLACE ALL\");\r\n const extra = [];\r\n const w = node.findExpressionAfterToken(\"WITH\");\r\n if (w) {\r\n extra.push(\"with: \" + new expressions_1.SourceTranspiler().transpile(w, traversal).getCode());\r\n }\r\n const o = node.findExpressionAfterToken(\"OF\");\r\n if (o && o.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"of: \" + new expressions_1.SourceTranspiler().transpile(o, traversal).getCode());\r\n }\r\n const length = node.findExpressionAfterToken(\"LENGTH\");\r\n if (length && length.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"sectionLength: \" + new expressions_1.SourceTranspiler().transpile(length, traversal).getCode());\r\n }\r\n const offset = node.findExpressionAfterToken(\"OFFSET\");\r\n if (offset && offset.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"sectionOffset: \" + new expressions_1.SourceTranspiler().transpile(offset, traversal).getCode());\r\n }\r\n const r = node.findDirectExpression(abaplint.Expressions.FindType);\r\n const type = r === null || r === void 0 ? void 0 : r.concatTokens().toUpperCase();\r\n if (type === \"REGEX\") {\r\n extra.push(\"regex: \" + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());\r\n }\r\n if (o === undefined && o === undefined) {\r\n extra.push(\"of: \" + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());\r\n }\r\n if (concat.includes(\" IGNORING CASE\")) {\r\n extra.push(\"ignoringCase: true\");\r\n }\r\n return new chunk_1.Chunk()\r\n .append(\"abap.statements.replace({target:\", node, traversal)\r\n .appendString(target + \", all:\" + all + \", \" + extra.join(\",\"))\r\n .append(\"});\", node.getLastToken(), traversal);\r\n }\r\n}\r\nexports.ReplaceTranspiler = ReplaceTranspiler;\r\n//# sourceMappingURL=replace.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/replace.js?");
15100
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ReplaceTranspiler = 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 chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass ReplaceTranspiler {\r\n transpile(node, traversal) {\r\n const sources = node.findDirectExpressions(abaplint.Expressions.Source);\r\n const target = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Target)).getCode();\r\n const concat = node.concatTokens().toUpperCase();\r\n const all = concat.startsWith(\"REPLACE ALL\");\r\n const extra = [];\r\n const w = node.findExpressionAfterToken(\"WITH\");\r\n if (w) {\r\n extra.push(\"with: \" + new expressions_1.SourceTranspiler().transpile(w, traversal).getCode());\r\n }\r\n const o = node.findExpressionAfterToken(\"OF\");\r\n if (o && o.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"of: \" + new expressions_1.SourceTranspiler().transpile(o, traversal).getCode());\r\n }\r\n const length = node.findExpressionAfterToken(\"LENGTH\");\r\n if (length && length.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"sectionLength: \" + new expressions_1.SourceTranspiler().transpile(length, traversal).getCode());\r\n }\r\n const offset = node.findExpressionAfterToken(\"OFFSET\");\r\n if (offset && offset.get() instanceof abaplint.Expressions.Source) {\r\n extra.push(\"sectionOffset: \" + new expressions_1.SourceTranspiler().transpile(offset, traversal).getCode());\r\n }\r\n const r = node.findDirectExpression(abaplint.Expressions.FindType);\r\n const type = r === null || r === void 0 ? void 0 : r.concatTokens().toUpperCase();\r\n if (type === \"REGEX\") {\r\n extra.push(\"regex: \" + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());\r\n }\r\n if (o === undefined && o === undefined && type !== \"REGEX\") {\r\n extra.push(\"of: \" + new expressions_1.SourceTranspiler().transpile(sources[0], traversal).getCode());\r\n }\r\n if (concat.includes(\" IGNORING CASE\")) {\r\n extra.push(\"ignoringCase: true\");\r\n }\r\n return new chunk_1.Chunk()\r\n .append(\"abap.statements.replace({target: \", node, traversal)\r\n .appendString(target + \", all: \" + all + \", \" + extra.join(\", \"))\r\n .append(\"});\", node.getLastToken(), traversal);\r\n }\r\n}\r\nexports.ReplaceTranspiler = ReplaceTranspiler;\r\n//# sourceMappingURL=replace.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/statements/replace.js?");
15101
15101
 
15102
15102
  /***/ }),
15103
15103
 
@@ -15658,7 +15658,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
15658
15658
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
15659
15659
 
15660
15660
  "use strict";
15661
- 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(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30})}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]});\r\n let ls_input = new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(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(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(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 // some sorting required: eg. a class constructor using constant from interface\r\n const list = [];\r\n const late = [];\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.LockObject\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.${this.escapeNamespace(m.getName().toLowerCase())}`));\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class) {\r\n if (obj.getName().toUpperCase() !== \"CL_ABAP_CHAR_UTILITIES\"\r\n && this.hasClassConstructor(reg, obj)) {\r\n // this will not solve all problems with class constors 100%, but probably good enough\r\n late.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n else {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n else if (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(), ...late].join(\"\\n\");\r\n }\r\n // class constructors might make early use of eg. constants from interfaces\r\n // sub classes will import() super classes and trigger a class constructor of the super\r\n hasClassConstructor(reg, clas) {\r\n var _a, _b;\r\n if (((_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getMethodDefinitions().getByName(\"CLASS_CONSTRUCTOR\")) !== undefined) {\r\n return true;\r\n }\r\n const sup = (_b = clas.getDefinition()) === null || _b === void 0 ? void 0 : _b.getSuperClass();\r\n if (sup !== undefined) {\r\n const superClass = reg.getObject(\"CLAS\", sup);\r\n if (superClass) {\r\n return this.hasClassConstructor(reg, superClass);\r\n }\r\n }\r\n return false;\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?");
15661
+ 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(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)}), {\"withHeader\":false,\"type\":\"STANDARD\",\"isUnique\":false,\"keyFields\":[]});\r\n let ls_input = new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(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(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(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 // some sorting required: eg. a class constructor using constant from interface\r\n const list = [];\r\n const late = [];\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.LockObject\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.${this.escapeNamespace(m.getName().toLowerCase())}`));\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class) {\r\n if (obj.getName().toUpperCase() !== \"CL_ABAP_CHAR_UTILITIES\"\r\n && this.hasClassConstructor(reg, obj)) {\r\n // this will not solve all problems with class constors 100%, but probably good enough\r\n late.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n else {\r\n list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));\r\n }\r\n }\r\n else if (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(), ...late].join(\"\\n\");\r\n }\r\n // class constructors might make early use of eg. constants from interfaces\r\n // sub classes will import() super classes and trigger a class constructor of the super\r\n hasClassConstructor(reg, clas) {\r\n var _a, _b;\r\n if (((_a = clas.getDefinition()) === null || _a === void 0 ? void 0 : _a.getMethodDefinitions().getByName(\"CLASS_CONSTRUCTOR\")) !== undefined) {\r\n return true;\r\n }\r\n const sup = (_b = clas.getDefinition()) === null || _b === void 0 ? void 0 : _b.getSuperClass();\r\n if (sup !== undefined) {\r\n const superClass = reg.getObject(\"CLAS\", sup);\r\n if (superClass) {\r\n return this.hasClassConstructor(reg, superClass);\r\n }\r\n }\r\n return false;\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?");
15662
15662
 
15663
15663
  /***/ }),
15664
15664
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.3.59",
3
+ "version": "2.3.61",
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.59",
28
+ "@abaplint/transpiler": "^2.3.61",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",