@abaplint/transpiler-cli 1.6.66 → 1.6.67

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 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
@@ -12578,7 +12578,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
12578
12578
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12579
12579
 
12580
12580
  "use strict";
12581
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ParameterSTranspiler = void 0;\r\nconst core_1 = __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 ParameterSTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const nameToken = (_a = node.findDirectExpression(core_1.Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();\r\n const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source));\r\n return new chunk_1.Chunk().append(name + \": \", nameToken || node, traversal).appendChunk(source);\r\n }\r\n}\r\nexports.ParameterSTranspiler = ParameterSTranspiler;\r\n//# sourceMappingURL=parameter_s.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/expressions/parameter_s.js?");
12581
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ParameterSTranspiler = void 0;\r\nconst core_1 = __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 ParameterSTranspiler {\r\n transpile(node, traversal) {\r\n var _a;\r\n const nameToken = (_a = node.findDirectExpression(core_1.Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr().toLowerCase();\r\n const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source));\r\n return new chunk_1.Chunk().append(name + \": \", nameToken || node, traversal).appendChunk(source);\r\n }\r\n}\r\nexports.ParameterSTranspiler = ParameterSTranspiler;\r\n//# sourceMappingURL=parameter_s.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/expressions/parameter_s.js?");
12582
12582
 
12583
12583
  /***/ }),
12584
12584
 
@@ -13029,7 +13029,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
13029
13029
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13030
13030
 
13031
13031
  "use strict";
13032
- 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?");
13032
+ 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?");
13033
13033
 
13034
13034
  /***/ }),
13035
13035
 
@@ -13942,7 +13942,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
13942
13942
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13943
13943
 
13944
13944
  "use strict";
13945
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UnitTest = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass UnitTest {\r\n initializationScript(reg, dbSetup) {\r\n return `import runtime from \"@abaplint/runtime\";\nglobal.abap = new runtime.ABAP();\n${this.buildImports(reg)}\nexport async function initDB() {\n return global.abap.initDB(\\`${dbSetup}\\`);\n}`;\r\n }\r\n unitTestScript(reg, skip) {\r\n let ret = `import fs from \"fs\";\nimport path from \"path\";\nimport {dirname} from 'path';\nimport {fileURLToPath} from 'url';\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nimport {initDB} from \"./init.mjs\";\nimport runtime from \"@abaplint/runtime\";\n\nasync function run() {\n await initDB();\n const unit = new runtime.UnitTestResult();\n let clas;\n let locl;\n let meth;\ntry {\\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\r\n || def.isGlobal === true // todo, fix, there might be global test methods\r\n || def.methods.length === 0) {\r\n continue;\r\n }\r\n ret += `{\nconst {${def.name}} = await import(\"./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs\");\nlocl = clas.addTestClass(\"${def.name}\");\\n`;\r\n ret += `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-------------------\nconsole.log(abap.console.get());\nfs.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();\n}).catch((err) => {\n console.log(err);\n process.exit(1);\n});`;\r\n return ret;\r\n }\r\n buildImports(reg) {\r\n // note: ES modules are hoised, so use the dynamic import()\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 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(`await import(\"./${obj.getName().toLowerCase()}.fugr.${m.getName().toLowerCase()}.mjs\");`);\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class) {\r\n list.push(`await import(\"./${obj.getName().toLowerCase()}.clas.mjs\");`);\r\n }\r\n else if (obj instanceof abaplint.Objects.Interface) {\r\n list.push(`await import(\"./${obj.getName().toLowerCase()}.intf.mjs\");`);\r\n }\r\n }\r\n list.sort();\r\n return list.join(\"\\n\") + \"\\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?");
13945
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UnitTest = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass UnitTest {\r\n initializationScript(reg, dbSetup) {\r\n return `import runtime from \"@abaplint/runtime\";\r\nglobal.abap = new runtime.ABAP();\r\n${this.buildImports(reg)}\r\nexport async function initDB() {\r\n return global.abap.initDB(\\`${dbSetup}\\`);\r\n}`;\r\n }\r\n unitTestScript(reg, skip) {\r\n let ret = `import fs from \"fs\";\r\nimport path from \"path\";\r\nimport {dirname} from 'path';\r\nimport {fileURLToPath} from 'url';\r\nconst __dirname = dirname(fileURLToPath(import.meta.url));\r\nimport {initDB} from \"./init.mjs\";\r\nimport runtime from \"@abaplint/runtime\";\r\n\r\nasync function run() {\r\n await initDB();\r\n const unit = new runtime.UnitTestResult();\r\n let clas;\r\n let locl;\r\n let meth;\r\ntry {\\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\r\n || def.isGlobal === true // todo, fix, there might be global test methods\r\n || def.methods.length === 0) {\r\n continue;\r\n }\r\n ret += `{\r\nconst {${def.name}} = await import(\"./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs\");\r\nlocl = clas.addTestClass(\"${def.name}\");\\n`;\r\n ret += `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\nconsole.log(abap.console.get());\r\nfs.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();\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) {\r\n // note: ES modules are hoised, so use the dynamic import()\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 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(`await import(\"./${obj.getName().toLowerCase()}.fugr.${m.getName().toLowerCase()}.mjs\");`);\r\n }\r\n }\r\n else if (obj instanceof abaplint.Objects.Class) {\r\n list.push(`await import(\"./${obj.getName().toLowerCase()}.clas.mjs\");`);\r\n }\r\n else if (obj instanceof abaplint.Objects.Interface) {\r\n list.push(`await import(\"./${obj.getName().toLowerCase()}.intf.mjs\");`);\r\n }\r\n }\r\n list.sort();\r\n return list.join(\"\\n\") + \"\\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?");
13946
13946
 
13947
13947
  /***/ }),
13948
13948
 
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
- {
2
- "name": "@abaplint/transpiler-cli",
3
- "version": "1.6.66",
4
- "description": "Transpiler - Command Line Interface",
5
- "bin": {
6
- "abap_transpile": "./abap_transpile"
7
- },
8
- "keywords": [
9
- "ABAP",
10
- "abaplint"
11
- ],
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/abaplint/transpiler.git"
15
- },
16
- "scripts": {
17
- "test": "tsc && npm run webpack",
18
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
19
- "compile": "npm test",
20
- "webpack": "webpack --progress"
21
- },
22
- "author": "abaplint",
23
- "license": "MIT",
24
- "devDependencies": {
25
- "@abaplint/transpiler": "^1.6.66",
26
- "@types/glob": "^7.2.0",
27
- "glob": "^7.2.0",
28
- "@types/progress": "^2.0.5",
29
- "@abaplint/core": "=2.80.10",
30
- "progress": "^2.0.3",
31
- "webpack": "^5.64.2",
32
- "webpack-cli": "^4.9.1",
33
- "typescript": "^4.5.2"
34
- }
35
- }
1
+ {
2
+ "name": "@abaplint/transpiler-cli",
3
+ "version": "1.6.67",
4
+ "description": "Transpiler - Command Line Interface",
5
+ "bin": {
6
+ "abap_transpile": "./abap_transpile"
7
+ },
8
+ "keywords": [
9
+ "ABAP",
10
+ "abaplint"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/abaplint/transpiler.git"
15
+ },
16
+ "scripts": {
17
+ "test": "tsc && npm run webpack",
18
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
19
+ "compile": "npm test",
20
+ "webpack": "webpack --progress"
21
+ },
22
+ "author": "abaplint",
23
+ "license": "MIT",
24
+ "devDependencies": {
25
+ "@abaplint/transpiler": "^1.6.67",
26
+ "@types/glob": "^7.2.0",
27
+ "glob": "^7.2.0",
28
+ "@types/progress": "^2.0.5",
29
+ "@abaplint/core": "=2.80.10",
30
+ "progress": "^2.0.3",
31
+ "webpack": "^5.64.4",
32
+ "webpack-cli": "^4.9.1",
33
+ "typescript": "^4.5.2"
34
+ }
35
+ }