generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update to latest npm packages * upd * update * update * update * update to latest * update * wip * update * refactor * generate all * NROB fixed * run diff * update * update * rename * update to latest
- Loading branch information
Showing
7 changed files
with
94 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import * as child_process from 'node:child_process'; | ||
import {initializeABAP} from "../output/init.mjs"; | ||
await initializeABAP(); | ||
|
||
async function run() { | ||
const result = await abap.Classes["CL_RUN"].run(); | ||
if (fs.existsSync("generated") === false) { | ||
fs.mkdirSync("generated"); | ||
} | ||
for (const row of result.array()) { | ||
fs.writeFileSync("generated" + path.sep + row.get().filename.get(), row.get().contents.get()); | ||
|
||
const types = []; | ||
for (const f of fs.readdirSync("abap-file-formats/file-formats/")) { | ||
if (f.length === 4) { | ||
types.push(f.toUpperCase()); | ||
} | ||
} | ||
|
||
for (const type of types) { | ||
console.log(type); | ||
if (type === "ENHO") { | ||
console.log("\tskip, https://github.com/SAP/abap-file-formats/issues/409"); | ||
continue; | ||
} | ||
|
||
const result = await abap.Classes["CL_RUN"].run({object_type: new abap.types.String().set(type)}); | ||
const filename = "generated" + path.sep + type.toLowerCase() + "-v1.json"; | ||
fs.writeFileSync(filename, result.get()); | ||
|
||
const command = `diff --strip-trailing-cr generated/${type.toLowerCase()}-v1.json abap-file-formats/file-formats/${type.toLowerCase()}/${type.toLowerCase()}-v1.json`; | ||
console.log(command); | ||
const output = child_process.execSync(`${command} || true`); | ||
console.log(output.toString()); | ||
} | ||
|
||
// only run for INTF, | ||
/* | ||
const result = await abap.Classes["CL_RUN"].run({object_type: new abap.types.String().set("INTF")}); | ||
fs.writeFileSync("generated" + path.sep + "intf-v1.json", result.get()); | ||
*/ | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
CLASS cl_run DEFINITION PUBLIC FINAL CREATE PUBLIC. | ||
PUBLIC SECTION. | ||
TYPES: BEGIN OF ty_row, | ||
filename TYPE string, | ||
contents TYPE string, | ||
END OF ty_row. | ||
TYPES ty_tab TYPE STANDARD TABLE OF ty_row WITH DEFAULT KEY. | ||
CLASS-METHODS run | ||
RETURNING | ||
VALUE(tab) TYPE ty_tab. | ||
PRIVATE SECTION. | ||
CLASS-METHODS run_intf | ||
IMPORTING | ||
object_type TYPE string | ||
RETURNING | ||
VALUE(result) TYPE string. | ||
ENDCLASS. | ||
|
||
CLASS cl_run IMPLEMENTATION. | ||
METHOD run_intf. | ||
|
||
METHOD run. | ||
DATA writer TYPE REF TO zcl_aff_writer_json_schema. | ||
DATA generator TYPE REF TO zcl_aff_generator. | ||
DATA intf TYPE zif_aff_intf_v1=>ty_main. | ||
DATA string_tab TYPE string_table. | ||
DATA type_name TYPE string. | ||
DATA schema_id TYPE string. | ||
DATA ref TYPE REF TO data. | ||
|
||
schema_id = |https://github.com/SAP/abap-file-formats/blob/main/file-formats/{ to_lower( object_type ) }/{ to_lower( object_type ) }-v1.json|. | ||
type_name = to_upper( |ZIF_AFF_{ object_type }_V1=>TY_MAIN| ). | ||
|
||
CREATE DATA ref TYPE (type_name). | ||
|
||
CREATE OBJECT writer | ||
EXPORTING | ||
schema_id = 'https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf-v1.json'. | ||
schema_id = schema_id. | ||
|
||
CREATE OBJECT generator | ||
EXPORTING | ||
writer = writer. | ||
string_tab = generator->generate_type( intf ). | ||
|
||
string_tab = generator->generate_type( ref->* ). | ||
CONCATENATE LINES OF string_tab INTO result SEPARATED BY |\n|. | ||
ENDMETHOD. | ||
|
||
METHOD run. | ||
DATA str TYPE string. | ||
DATA row LIKE LINE OF tab. | ||
|
||
str = run_intf( ). | ||
|
||
row-filename = 'intf.json'. | ||
row-contents = str. | ||
APPEND row TO tab. | ||
ENDMETHOD. | ||
ENDCLASS. |