From c967d3da9f34499816ac0c820d3e267a52f95437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Wed, 25 Nov 2020 11:39:09 +0100 Subject: [PATCH 1/4] installCobiGen command for console runner --- runners/console/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index a63478fa..3fbbaca0 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -32,7 +32,12 @@ export class Console extends Runner { } runInstallCobiGen(step: Step, command: Command): RunResult { - return null; + let result = new RunResult(); + result.returnCode = 0; + + this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result); + + return result; } runCobiGenJava(step: Step, command: Command): RunResult { @@ -55,7 +60,12 @@ export class Console extends Runner { } async assertInstallCobiGen(step: Step, command: Command, result: RunResult) { - console.log("assertInstallCobiGen"); + let assert = new Assertions() + .noErrorCode(result) + .noException(result) + .directoryExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli")) + .fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen.jar")) + .fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen")); } async assertCobiGenJava(step: Step, command: Command, result: RunResult) { From 55cced5f280703e165b03a0630a416af180b2028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Wed, 25 Nov 2020 12:08:27 +0100 Subject: [PATCH 2/4] modified command installDevonIde --- runners/console/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 3fbbaca0..1ab42978 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -28,6 +28,8 @@ export class Console extends Runner { this.executeCommandSync(path.join(installDir, "setup") + " " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), "", result, "yes"); + this.executeCommandSync("devon", installDir, result); + return result; } @@ -36,7 +38,6 @@ export class Console extends Runner { result.returnCode = 0; this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result); - return result; } From ff840c70d19b2943dbf947a9e3d76d78340db2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Wed, 25 Nov 2020 12:14:24 +0100 Subject: [PATCH 3/4] modified command installDevonIde --- runners/console/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 1ab42978..2cba16af 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -28,7 +28,7 @@ export class Console extends Runner { this.executeCommandSync(path.join(installDir, "setup") + " " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), "", result, "yes"); - this.executeCommandSync("devon", installDir, result); + this.executeCommandSync(". ~/.bashrc", installDir, result); return result; } From 8611be073762b09c07c9d2f4931ab623d21accd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Thu, 26 Nov 2020 19:34:17 +0100 Subject: [PATCH 4/4] changed installDevonIde and installCobiGen for console runnder. Added platform support --- runners/console/consoleInterfaces.ts | 4 ++++ runners/console/index.ts | 35 +++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 runners/console/consoleInterfaces.ts diff --git a/runners/console/consoleInterfaces.ts b/runners/console/consoleInterfaces.ts new file mode 100644 index 00000000..9f2076ba --- /dev/null +++ b/runners/console/consoleInterfaces.ts @@ -0,0 +1,4 @@ +export enum ConsolePlatform { + WINDOWS, + LINUX +} \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index 2cba16af..540222b0 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -3,12 +3,24 @@ import { RunResult } from "../../engine/run_result"; import { Step } from "../../engine/step"; import { Command } from "../../engine/command"; import { Assertions } from "../../assertions"; +import { Playbook } from "../../engine/playbook"; +import { ConsolePlatform } from "./consoleInterfaces"; import * as path from 'path'; import * as child_process from "child_process"; import * as fs from "fs"; export class Console extends Runner { + private platform: ConsolePlatform; + + init(playbook: Playbook): void { + if(process.platform=="win32") { + this.platform = ConsolePlatform.WINDOWS; + } else { + this.platform = ConsolePlatform.LINUX; + } + } + runInstallDevonfwIde(step: Step, command: Command): RunResult { let result = new RunResult(); result.returnCode = 0; @@ -23,12 +35,15 @@ export class Console extends Runner { let installDir = path.join(this.getWorkingDirectory(), "devonfw"); this.createFolder(installDir, true); - this.executeCommandSync("curl -L -o devonfw.tar.gz https://bit.ly/2BCkFa9", installDir, result); - this.executeCommandSync("tar -xf devonfw.tar.gz", installDir, result); - - this.executeCommandSync(path.join(installDir, "setup") + " " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), "", result, "yes"); - - this.executeCommandSync(". ~/.bashrc", installDir, result); + + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("powershell.exe Invoke-WebRequest -OutFile devonfw.tar.gz https://bit.ly/2BCkFa9", installDir, result); + this.executeCommandSync("powershell.exe tar -xvzf devonfw.tar.gz", installDir, result); + this.executeCommandSync("powershell.exe ./setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes"); + } else { + this.executeCommandSync("wget -c https://bit.ly/2BCkFa9 -O - | tar -xz", installDir, result); + this.executeCommandSync("bash setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes"); + } return result; } @@ -37,7 +52,11 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result); + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result); + } else { + this.executeCommandSync("~/.devon/devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result); + } return result; } @@ -76,7 +95,7 @@ export class Console extends Runner { private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; - let process = child_process.spawnSync("cd " + path.join(directory) + " && " + command, { shell: true, input: input }); + let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input }); if(process.status != 0) { console.log("Error executing command: " + command + " (exit code: " + process.status + ")"); console.log(process.stderr.toString(), process.stdout.toString());