Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions runners/console/consoleInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum ConsolePlatform {
WINDOWS,
LINUX
}
46 changes: 38 additions & 8 deletions runners/console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,16 +35,29 @@ 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");


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;
}

runInstallCobiGen(step: Step, command: Command): RunResult {
return null;
let result = new RunResult();
result.returnCode = 0;

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;
}

runCobiGenJava(step: Step, command: Command): RunResult {
Expand All @@ -55,7 +80,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) {
Expand All @@ -65,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());
Expand Down