@abaplint/transpiler 2.0.51 → 2.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/index.js +2 -1
- package/build/src/types.d.ts +1 -0
- package/build/src/unit_test.d.ts +1 -1
- package/build/src/unit_test.js +32 -24
- package/package.json +2 -2
package/build/src/index.js
CHANGED
|
@@ -28,7 +28,7 @@ class Transpiler {
|
|
|
28
28
|
return new Transpiler().run(reg);
|
|
29
29
|
}
|
|
30
30
|
async run(reg, progress) {
|
|
31
|
-
var _a, _b, _c, _d, _e;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
32
|
reg.parse();
|
|
33
33
|
new keywords_1.Keywords().handle(reg);
|
|
34
34
|
this.validate(reg);
|
|
@@ -38,6 +38,7 @@ class Transpiler {
|
|
|
38
38
|
unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
|
|
39
39
|
unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, (_c = this.options) === null || _c === void 0 ? void 0 : _c.skip, (_d = this.options) === null || _d === void 0 ? void 0 : _d.only),
|
|
40
40
|
initializationScript: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_e = this.options) === null || _e === void 0 ? void 0 : _e.extraSetup),
|
|
41
|
+
initializationScript2: new unit_test_1.UnitTest().initializationScript(reg, dbSetup, (_f = this.options) === null || _f === void 0 ? void 0 : _f.extraSetup, true),
|
|
41
42
|
databaseSetup: dbSetup,
|
|
42
43
|
reg: reg,
|
|
43
44
|
};
|
package/build/src/types.d.ts
CHANGED
package/build/src/unit_test.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type TestMethodList = {
|
|
|
6
6
|
method: string;
|
|
7
7
|
}[];
|
|
8
8
|
export declare class UnitTest {
|
|
9
|
-
initializationScript(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string): string;
|
|
9
|
+
initializationScript(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string, useImport?: boolean): string;
|
|
10
10
|
private escapeNamespace;
|
|
11
11
|
unitTestScriptOpen(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
|
|
12
12
|
unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
|
package/build/src/unit_test.js
CHANGED
|
@@ -5,11 +5,18 @@ exports.UnitTest = void 0;
|
|
|
5
5
|
const abaplint = require("@abaplint/core");
|
|
6
6
|
class UnitTest {
|
|
7
7
|
// todo, move this method somewhere else, its much more than just unit test relevant
|
|
8
|
-
initializationScript(reg, dbSetup, extraSetup) {
|
|
9
|
-
let ret =
|
|
8
|
+
initializationScript(reg, dbSetup, extraSetup, useImport) {
|
|
9
|
+
let ret = "";
|
|
10
|
+
if (useImport === true) {
|
|
11
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
12
|
+
import "./_top.mjs";\n`;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
ret = `/* eslint-disable import/newline-after-import */
|
|
10
16
|
import runtime from "@abaplint/runtime";
|
|
11
|
-
globalThis.abap = new runtime.ABAP()
|
|
12
|
-
|
|
17
|
+
globalThis.abap = new runtime.ABAP();\n`;
|
|
18
|
+
}
|
|
19
|
+
ret += `${this.buildImports(reg, useImport)}
|
|
13
20
|
|
|
14
21
|
export async function initializeABAP() {\n`;
|
|
15
22
|
ret += ` const sqlite = \`${dbSetup.schemas.sqlite}\`;\n`;
|
|
@@ -67,7 +74,7 @@ async function run() {
|
|
|
67
74
|
ret += ` ls_input.get().class_name.set("${obj.getName()}");
|
|
68
75
|
ls_input.get().testclass_name.set("${def.name.toUpperCase()}");
|
|
69
76
|
ls_input.get().method_name.set("${m.name.toUpperCase()}");
|
|
70
|
-
abap.statements.append({source: ls_input, target: lt_input})
|
|
77
|
+
abap.statements.append({source: ls_input, target: lt_input});\n`;
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -146,13 +153,13 @@ async function run() {
|
|
|
146
153
|
}
|
|
147
154
|
ret += `// -------------------END-------------------
|
|
148
155
|
console.log(abap.console.get());
|
|
149
|
-
fs.writeFileSync(__dirname + path.sep + "
|
|
156
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
150
157
|
} catch (e) {
|
|
151
158
|
if (meth) {
|
|
152
159
|
meth.fail();
|
|
153
160
|
}
|
|
154
161
|
console.log(abap.console.get());
|
|
155
|
-
fs.writeFileSync(__dirname + path.sep + "
|
|
162
|
+
fs.writeFileSync(__dirname + path.sep + "_output.xml", unit.xUnitXML());
|
|
156
163
|
throw e;
|
|
157
164
|
}
|
|
158
165
|
}
|
|
@@ -165,37 +172,38 @@ run().then(() => {
|
|
|
165
172
|
});`;
|
|
166
173
|
return ret;
|
|
167
174
|
}
|
|
168
|
-
buildImports(reg) {
|
|
169
|
-
// note: ES modules are hoised, so use the dynamic import()
|
|
175
|
+
buildImports(reg, useImport) {
|
|
176
|
+
// note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
|
|
170
177
|
// todo, some sorting might be required? eg. a class constructor using constant from interface?
|
|
171
178
|
// temporary sorting: by filename
|
|
172
179
|
const list = [];
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
|
|
180
|
+
const imp = (filename) => {
|
|
181
|
+
if (useImport === true) {
|
|
182
|
+
return `import "./${filename}.mjs";`;
|
|
176
183
|
}
|
|
177
|
-
else
|
|
178
|
-
|
|
184
|
+
else {
|
|
185
|
+
return `await import("./${filename}.mjs");`;
|
|
179
186
|
}
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
};
|
|
188
|
+
for (const obj of reg.getObjects()) {
|
|
189
|
+
if (obj instanceof abaplint.Objects.Table
|
|
190
|
+
|| obj instanceof abaplint.Objects.DataElement
|
|
191
|
+
|| obj instanceof abaplint.Objects.TableType) {
|
|
192
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
for (const obj of reg.getObjects()) {
|
|
185
196
|
if (obj instanceof abaplint.Objects.FunctionGroup) {
|
|
186
197
|
for (const m of obj.getModules()) {
|
|
187
|
-
list.push(
|
|
198
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.fugr.${m.getName().toLowerCase()}`));
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
|
-
else if (obj instanceof abaplint.Objects.Class
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else if (obj instanceof abaplint.Objects.Interface) {
|
|
194
|
-
list.push(`await import("./${this.escapeNamespace(obj.getName().toLowerCase())}.intf.mjs");`);
|
|
201
|
+
else if (obj instanceof abaplint.Objects.Class
|
|
202
|
+
|| obj instanceof abaplint.Objects.Interface) {
|
|
203
|
+
list.push(imp(`${this.escapeNamespace(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
list.sort();
|
|
198
|
-
return list.join("\n");
|
|
206
|
+
return list.sort().join("\n");
|
|
199
207
|
}
|
|
200
208
|
}
|
|
201
209
|
exports.UnitTest = UnitTest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.54",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "abaplint",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.91.
|
|
31
|
+
"@abaplint/core": "^2.91.6",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|