(abap: ABAP, files: IFile[])
| 42 | return "global.abap = abap;\n" + pre + res.objects[0].chunk.getCode(); |
| 43 | } |
| 44 | |
| 45 | export async function runFilesPostgres(abap: ABAP, files: IFile[]) { |
| 46 | const memory = files.map(f => new abaplint.MemoryFile(f.filename, f.contents)); |
| 47 | const reg: abaplint.IRegistry = new abaplint.Registry().addFiles(memory); |
| 48 | const res = await new Transpiler().run(reg); |
| 49 | abap.console.clear(); |
| 50 | if (res.databaseSetup.schemas.pg.length > 0) { |
| 51 | const dbName = "transpiler-" + crypto.randomBytes(10).toString("hex"); |
| 52 | abap.context.databaseConnections["DEFAULT"] = new PostgresDatabaseClient({ |
| 53 | user: "postgres", |
| 54 | host: "localhost", |
| 55 | database: "postgres", |
| 56 | password: "postgres", |
| 57 | port: 5432, |
| 58 | }); |
| 59 | await abap.context.databaseConnections["DEFAULT"].connect(); |
| 60 | await abap.context.databaseConnections["DEFAULT"].execute(`CREATE DATABASE "${dbName}";`); |
| 61 | await abap.context.databaseConnections["DEFAULT"].disconnect(); |
| 62 | |
| 63 | abap.context.databaseConnections["DEFAULT"] = new PostgresDatabaseClient({ |
| 64 | user: "postgres", |
| 65 | host: "localhost", |
| 66 | database: dbName, |
| 67 | password: "postgres", |
| 68 | port: 5432, |
| 69 | }); |
| 70 | await abap.context.databaseConnections["DEFAULT"].connect(); |
| 71 | await abap.context.databaseConnections["DEFAULT"].execute(res.databaseSetup.schemas.pg); |
| 72 | await abap.context.databaseConnections["DEFAULT"].execute(res.databaseSetup.insert); |
| 73 | } |
| 74 | let pre = ""; |
| 75 | for (const o of res.objects) { |
| 76 | if (o.object.type === "TABL") { |
| 77 | pre = o.chunk.getCode() + "\n"; |
| 78 | } |
| 79 | } |
| 80 | return "global.abap = abap;\n" + pre + res.objects[0].chunk.getCode(); |
| 81 | } |
| 82 | |
| 83 | export async function runFilesHana(abap: ABAP, files: IFile[]) { |
no test coverage detected