Skip to content

Commit a430d5f

Browse files
authored
update (#7)
1 parent 7fead5d commit a430d5f

File tree

8 files changed

+96
-90
lines changed

8 files changed

+96
-90
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
- run: |
2222
npm install
23-
npm run build
23+
npm test
2424
- uses: actions/configure-pages@v5
2525
- uses: actions/upload-pages-artifact@v3
2626
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
- uses: actions/setup-node@v4
1616
- run: |
1717
npm install
18-
npm run build
18+
npm test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
dist
22
node_modules
3+
abap2xlsx
4+
abap2xlsx-demos
5+
open-abap-core
6+
src/abap.ts

abap.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as fs from "node:fs";
2+
import * as path from "node:path";
3+
4+
console.log("Building abap.js");
5+
6+
let output = "export const abapfiles = {\n";
7+
8+
function escape(input) {
9+
if (input.charCodeAt(0) === 0xFEFF) {
10+
input = input.substr(1);
11+
}
12+
return input.replaceAll("`", "\\`").replaceAll("${", "\\${").trimEnd();
13+
}
14+
15+
/////////////////////////////////////////
16+
17+
for (const dirent of fs.readdirSync("open-abap-core/src", {recursive: true, withFileTypes: true})) {
18+
if (dirent.isDirectory() || dirent.name.endsWith(".testclasses.abap")) {
19+
continue;
20+
}
21+
const contents = fs.readFileSync(path.join(dirent.parentPath, dirent.name)).toString();
22+
output += `"${dirent.name}": \`${escape(contents)}\`,\n`;
23+
}
24+
25+
/////////////////////////////////////////
26+
27+
{
28+
const contents = fs.readFileSync("abap2xlsx-demos/src/zcl_excel_demo1.clas.abap", "utf-8").toString("utf-8");
29+
output += `"zcl_excel_demo1.clas.abap": \`${escape(contents)}\`,\n`;
30+
}
31+
32+
{
33+
const contents = fs.readFileSync("abap2xlsx-demos/src/zif_excel_demo_output.intf.abap").toString();
34+
output += `"zif_excel_demo_output.intf.abap": \`${escape(contents)}\`,\n`;
35+
}
36+
37+
/////////////////////////////////////////
38+
39+
const filter = JSON.parse(fs.readFileSync("abap2xlsx/abap_transpile.json")).input_filter;
40+
for (const dirent of fs.readdirSync("abap2xlsx/src", {recursive: true, withFileTypes: true})) {
41+
if (dirent.isDirectory() || dirent.name.endsWith(".testclasses.abap")) {
42+
continue;
43+
}
44+
if (filter.some(f => path.join(dirent.parentPath, dirent.name).replaceAll("\\", "/").match(f)) === false) {
45+
continue;
46+
}
47+
const contents = fs.readFileSync(path.join(dirent.parentPath, dirent.name)).toString();
48+
output += `"${dirent.name}": \`${escape(contents)}\`,\n`;
49+
}
50+
51+
/////////////////////////////////////////
52+
53+
fs.writeFileSync("src/abap.ts", output + "\n};");

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
"version": "1.0.0",
55
"description": "",
66
"scripts": {
7+
"clone1": "rm -rf abap2xlsx && git clone --depth 1 https://github.com/abap2xlsx/abap2xlsx && rm -rf abap2xlsx/.git",
8+
"clone2": "rm -rf abap2xlsx-demos && git clone --depth 1 https://github.com/abap2xlsx/demos abap2xlsx-demos && rm -rf abap2xlsx-demos/.git",
9+
"clone3": "rm -rf open-abap-core && git clone --depth 1 https://github.com/open-abap/open-abap-core && rm -rf open-abap-core/.git",
10+
"clone": "npm run clone1 && npm run clone2 && npm run clone3",
711
"dev": "webpack serve --mode development --env development",
8-
"build": "webpack"
12+
"webpack": "webpack",
13+
"test": "npm run clone && node abap.mjs && npm run webpack"
914
},
1015
"author": "",
1116
"license": "MIT",
@@ -16,15 +21,15 @@
1621
"buffer": "^6.0.3",
1722
"copy-webpack-plugin": "^12.0.2",
1823
"crypto-browserify": "^3.12.0",
19-
"css-loader": "^6.11.0",
24+
"css-loader": "^7.1.2",
2025
"file-loader": "^6.2.0",
2126
"html-webpack-plugin": "^5.6.0",
22-
"monaco-editor": "^0.46.0",
27+
"monaco-editor": "^0.51.0",
2328
"path-browserify": "^1.0.1",
2429
"split-grid": "^1.0.11",
2530
"stream-browserify": "^3.0.0",
2631
"string_decoder": "^1.3.0",
27-
"style-loader": "^3.3.4",
32+
"style-loader": "^4.0.0",
2833
"ts-loader": "^9.5.1",
2934
"typescript": "^5.5.4",
3035
"webpack": "^5.94.0",

src/abap.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@ import {ABAP, MemoryConsole} from "@abaplint/runtime";
2121
import * as abaplint from "@abaplint/core";
2222
import * as abapMonaco from "@abaplint/monaco";
2323
import Split from "split-grid";
24-
import { zcl_excel_demo1 } from "./abap";
24+
import { abapfiles } from "./abap";
2525

26+
const top = "zcl_excel_demo1.clas.abap";
2627
const reg = new abaplint.Registry(new abaplint.Config(JSON.stringify(config)));
28+
for (const filename in abapfiles) {
29+
if (filename === top) {
30+
continue;
31+
}
32+
reg.addFile(new abaplint.MemoryFile(filename, abapfiles[filename]));
33+
}
2734
abapMonaco.registerABAP(reg);
2835

29-
const filename = "file:///zcl_demo.clas.abap";
36+
const filename = "file:///" + top;
3037
const model1 = monaco.editor.createModel(
31-
zcl_excel_demo1,
38+
abapfiles[top],
3239
"abap",
3340
monaco.Uri.parse(filename),
3441
);
35-
reg.addFile(new abaplint.MemoryFile(filename, ""));
42+
reg.addFile(new abaplint.MemoryFile(filename, abapfiles[top]));
3643

3744
Split({
3845
columnGutters: [
@@ -88,7 +95,7 @@ async function abapChanged() {
8895
reg.parse();
8996
abapMonaco.updateMarkers(reg, model1);
9097

91-
const res = await new Transpiler().runRaw([{filename, contents}]);
98+
// const res = await new Transpiler().runRaw([{filename, contents}]);
9299
} catch (error) {
93100
console.dir(error);
94101
}

0 commit comments

Comments
 (0)