diff --git a/engine/runner.ts b/engine/runner.ts index 2e49f325..9c7d98c6 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -11,8 +11,8 @@ export abstract class Runner { public playbookPath: string; public playbookTitle: string; public environmentName: string; - protected readonly useDevonCommand: string = "useDevonCommand"; - protected readonly workspaceDirectory: string = "workspaceDirectory"; + protected readonly USE_DEVON_COMMAND: string = "useDevonCommand"; + protected readonly WORKSPACE_DIRECTORY: string = "workspaceDirectory"; private setVariableCallback: (name: string, value: any) => any; registerSetVariableCallback(callback: (name: string, value: any) => any) { @@ -83,7 +83,7 @@ export abstract class Runner { } init(playbook: Playbook): void { - this.setVariable(this.useDevonCommand, false); + this.setVariable(this.USE_DEVON_COMMAND, false); } run(runCommand: RunCommand): RunResult { diff --git a/engine/wikiRunner.ts b/engine/wikiRunner.ts index cc132c1b..e7cd1b21 100644 --- a/engine/wikiRunner.ts +++ b/engine/wikiRunner.ts @@ -7,11 +7,13 @@ import * as ejs from "ejs"; export abstract class WikiRunner extends Runner { public outputPathTutorial: string; + protected readonly INSTALLED_TOOLS: string = "installedTools"; init(playbook: Playbook): void { let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false) this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true); - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory())); + this.setVariable(this.INSTALLED_TOOLS, ""); } async destroy(playbook: Playbook): Promise { diff --git a/runners/console/index.ts b/runners/console/index.ts index 67a625f9..21015e5b 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -34,7 +34,7 @@ export class Console extends Runner { ConsoleUtils.createBackupDevonDirectory(); this.createFolder(path.normalize(this.getWorkingDirectory()), true); - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory())); this.env = process.env; } @@ -89,8 +89,8 @@ export class Console extends Runner { ConsoleUtils.executeCommandSync("bash setup --batch " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, this.env); } - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main")); - this.setVariable(this.useDevonCommand, true); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main")); + this.setVariable(this.USE_DEVON_COMMAND, true); return result; } @@ -108,7 +108,7 @@ export class Console extends Runner { ? runCommand.command.parameters[0].workspace : this.playbookName.replace("/", "").replace(" ","-")); - let workspacesDir = this.getVariable(this.useDevonCommand) + let workspacesDir = this.getVariable(this.USE_DEVON_COMMAND) ? path.join(this.getWorkingDirectory(), "devonfw", "workspaces") : path.join(this.getWorkingDirectory(), 'workspaces'); @@ -144,8 +144,8 @@ export class Console extends Runner { ConsoleUtils.executeCommandSync("git clone https://github.com/devonfw-tutorials/" + workspacesName + ".git .", workspacesDir, result, this.env); } - if(!this.getVariable(this.useDevonCommand)){ - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory(), 'workspaces')); + if(!this.getVariable(this.USE_DEVON_COMMAND)){ + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory(), 'workspaces')); } return result; @@ -156,7 +156,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - if(!this.getVariable(this.useDevonCommand)){ + if(!this.getVariable(this.USE_DEVON_COMMAND)){ console.warn("Devonfw IDE is not installed"); } @@ -168,7 +168,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - if(!this.getVariable(this.useDevonCommand)){ + if(!this.getVariable(this.USE_DEVON_COMMAND)){ console.warn("Devonfw IDE is not installed"); } @@ -182,7 +182,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(!fs.existsSync(filepath.substr(0, filepath.lastIndexOf(path.sep)))) { fs.mkdirSync(filepath.substr(0, filepath.lastIndexOf(path.sep)), { recursive: true }); } @@ -201,12 +201,12 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let buildCommand = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? "mvn clean install" : "mvn clean install -Dmaven.test.skip=true"; - this.getVariable(this.useDevonCommand) + this.getVariable(this.USE_DEVON_COMMAND) ? ConsoleUtils.executeDevonCommandSync(buildCommand, projectDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandSync(buildCommand, projectDir, result, this.env); @@ -217,7 +217,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - if(!this.getVariable(this.useDevonCommand)){ + if(!this.getVariable(this.USE_DEVON_COMMAND)){ console.warn("Devonfw IDE is not installed"); } @@ -230,7 +230,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let content = fs.readFileSync(filepath, { encoding: "utf-8" }); if(runCommand.command.parameters[1].placeholder) { @@ -278,7 +278,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(runCommand.command.parameters.length == 2 && runCommand.command.parameters[1].port){ let process = ConsoleUtils.executeCommandAsync("docker-compose up", filepath, result, this.env); process.on('close', (code) => { @@ -301,9 +301,9 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let serverDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let serverDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(runCommand.command.parameters.length == 2 && runCommand.command.parameters[1].port){ - let process = (this.getVariable(this.useDevonCommand)) + let process = (this.getVariable(this.USE_DEVON_COMMAND)) ? ConsoleUtils.executeDevonCommandAsync("mvn spring-boot:run", serverDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandAsync("mvn spring-boot:run", serverDir, result, this.env); @@ -322,7 +322,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let directorypath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let directorypath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(runCommand.command.parameters[0] != "") { this.createFolder(directorypath, true); } @@ -335,14 +335,14 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let projectPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let npmCommand = "npm install"; if(runCommand.command.parameters.length > 1){ if (runCommand.command.parameters[1].global) npmCommand += " -g"; if (runCommand.command.parameters[1].args) npmCommand += " " + runCommand.command.parameters[1].args.join(" "); if (runCommand.command.parameters[1].name) npmCommand += " " + runCommand.command.parameters[1].name; } - this.getVariable(this.useDevonCommand) + this.getVariable(this.USE_DEVON_COMMAND) ? ConsoleUtils.executeDevonCommandSync(npmCommand, projectPath, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandSync(npmCommand, projectPath, result, this.env); @@ -353,7 +353,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let downloadlDir = this.getVariable(this.workspaceDirectory); + let downloadlDir = this.getVariable(this.WORKSPACE_DIRECTORY); if (runCommand.command.parameters.length == 3) { downloadlDir = path.join(downloadlDir, runCommand.command.parameters[2]); this.createFolder(downloadlDir, false); @@ -370,9 +370,9 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(runCommand.command.parameters.length == 2 && runCommand.command.parameters[1].port){ - let process = this.getVariable(this.useDevonCommand) + let process = this.getVariable(this.USE_DEVON_COMMAND) ? ConsoleUtils.executeDevonCommandAsync("ng serve", projectDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandAsync("ng serve", projectDir, result, this.env); if(process.pid) { @@ -389,12 +389,12 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let command1 = "ng build"; if(runCommand.command.parameters.length == 2) { command1 = command1 + " --output-path " + runCommand.command.parameters[1]; } - this.getVariable(this.useDevonCommand) + this.getVariable(this.USE_DEVON_COMMAND) ? ConsoleUtils.executeDevonCommandSync(command1, projectDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandSync(command1, projectDir, result, this.env); @@ -405,7 +405,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let folderPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let folderPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); if(folderPath && !fs.existsSync(folderPath)) { this.createFolder(folderPath, true); } @@ -422,7 +422,7 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - if(!this.getVariable(this.useDevonCommand)){ + if(!this.getVariable(this.USE_DEVON_COMMAND)){ console.warn("Devonfw IDE is not installed"); } ConsoleUtils.executeDevonCommandSync("cobigen adapt-templates",path.join(this.getWorkingDirectory(), "devonfw"), path.join(this.getWorkingDirectory(), "devonfw"), result, this.env); @@ -433,9 +433,9 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[1]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[1]); let params = runCommand.command.parameters.length > 2 && (runCommand.command.parameters[2] instanceof Array) ? (" " + runCommand.command.parameters[2].join(" ")) : ""; - this.getVariable(this.useDevonCommand) + this.getVariable(this.USE_DEVON_COMMAND) ? ConsoleUtils.executeDevonCommandSync("ng create " + runCommand.command.parameters[0] + params, projectDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env) : ConsoleUtils.executeCommandSync("ng new " + runCommand.command.parameters[0] + params, projectDir, result, this.env); @@ -449,9 +449,8 @@ export class Console extends Runner { let workspacesDir = path.join(this.getWorkingDirectory(), runCommand.command.parameters[0]); if(!fs.existsSync(workspacesDir)) fs.mkdirSync(workspacesDir); - this.setVariable(this.workspaceDirectory, workspacesDir); - - return result; + this.setVariable(this.WORKSPACE_DIRECTORY, workspacesDir); + return result; } runExecuteCommand(runCommand: RunCommand): RunResult { @@ -470,8 +469,8 @@ export class Console extends Runner { : runCommand.command.parameters[commandIndex]; let dirPath = (runCommand.command.parameters.length > 1 && runCommand.command.parameters[2].dir) - ? path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[2].dir) - : this.getVariable(this.workspaceDirectory) + ? path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2].dir) + : this.getVariable(this.WORKSPACE_DIRECTORY) if(runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].asynchronous){ if(runCommand.command.parameters[3].port){ @@ -522,7 +521,7 @@ export class Console extends Runner { ? "powershell.exe " + path.join(this.playbookPath, runCommand.command.parameters[1]) : "bash " + path.join(this.playbookPath, runCommand.command.parameters[0]); - ConsoleUtils.executeCommandSync(scriptCommand, this.getVariable(this.workspaceDirectory), result, this.env); + ConsoleUtils.executeCommandSync(scriptCommand, this.getVariable(this.WORKSPACE_DIRECTORY), result, this.env); return result; } @@ -560,9 +559,9 @@ export class Console extends Runner { } async assertRestoreWorkspace(runCommand: RunCommand, result: RunResult) { - let workspacesDir = this.getVariable(this.useDevonCommand) + let workspacesDir = this.getVariable(this.USE_DEVON_COMMAND) ? path.join(this.getWorkingDirectory(), "devonfw", "workspaces") - : this.getVariable(this.workspaceDirectory); + : this.getVariable(this.WORKSPACE_DIRECTORY); try{ new Assertions() @@ -595,9 +594,9 @@ export class Console extends Runner { new Assertions() .noErrorCode(result) .noException(result) - .directoryExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], "api", "target")) - .directoryExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], "core", "target")) - .directoryExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], "server", "target")); + .directoryExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], "api", "target")) + .directoryExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], "core", "target")) + .directoryExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], "server", "target")); } catch(error) { await this.cleanUp(); throw error; @@ -642,7 +641,7 @@ export class Console extends Runner { new Assertions() .noErrorCode(result) .noException(result) - .fileExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + .fileExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); } catch(error) { await this.cleanUp(); throw error; @@ -658,7 +657,7 @@ export class Console extends Runner { content = fs.readFileSync(path.join(this.playbookPath, runCommand.command.parameters[1].file), { encoding: "utf-8" }); } - let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); new Assertions() .noErrorCode(result) .noException(result) @@ -716,13 +715,13 @@ export class Console extends Runner { try { let repository = runCommand.command.parameters[1]; let repoName = repository.slice(repository.lastIndexOf("/"), -4); - let directorypath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], repoName); + let directorypath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], repoName); new Assertions() .noErrorCode(result) .noException(result) - .directoryExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], repoName)) - .directoryNotEmpty(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0], repoName)) + .directoryExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], repoName)) + .directoryNotEmpty(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0], repoName)) .repositoryIsClean(directorypath); } catch(error) { await this.cleanUp(); @@ -732,7 +731,7 @@ export class Console extends Runner { async assertNpmInstall(runCommand: RunCommand, result: RunResult) { try { - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); new Assertions() .noErrorCode(result) .noException(result) @@ -750,7 +749,7 @@ export class Console extends Runner { async assertDownloadFile(runCommand: RunCommand, result: RunResult){ try { - let directory = this.getVariable(this.workspaceDirectory); + let directory = this.getVariable(this.WORKSPACE_DIRECTORY); if(runCommand.command.parameters.length == 3) { directory = path.join(directory, runCommand.command.parameters[2]); } @@ -789,7 +788,7 @@ export class Console extends Runner { async assertBuildNg(runCommand: RunCommand, result: RunResult) { try { - let projectPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); var outputpath; if(runCommand.command.parameters.length == 2) { outputpath = runCommand.command.parameters[1].trim(); @@ -814,7 +813,7 @@ export class Console extends Runner { async assertCreateFolder(runCommand: RunCommand, result: RunResult){ try { - let folderPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let folderPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); new Assertions() .noErrorCode(result) .noException(result) @@ -842,7 +841,7 @@ export class Console extends Runner { async assertCreateDevon4ngProject(runCommand: RunCommand, result: RunResult) { try { - let projectDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[1], runCommand.command.parameters[0]); + let projectDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[1], runCommand.command.parameters[0]); new Assertions() .noErrorCode(result) .noException(result) @@ -885,7 +884,7 @@ export class Console extends Runner { new Assertions() .noErrorCode(result) .noException(result) - .fileExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + .fileExits(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); } catch(error) { await this.cleanUp(); diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 44f0e10e..2a831a2f 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -46,7 +46,7 @@ export class Katacoda extends Runner { this.createFolder(this.setupDir, false); //set working direktory - this.setVariable(this.workspaceDirectory, path.join("/root")); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join("/root")); this.assetManager = new KatacodaAssetManager(path.join(this.outputPathTutorial, "assets")); @@ -100,8 +100,8 @@ export class Katacoda extends Runner { //update current and working directory this.currentDir = path.join(this.currentDir, "devonfw"); - this.setVariable(this.workspaceDirectory, path.join("/root", "devonfw", "workspaces", "main")); - this.setVariable(this.useDevonCommand, true); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join("/root", "devonfw", "workspaces", "main")); + this.setVariable(this.USE_DEVON_COMMAND, true); fs.appendFileSync(path.join(this.getRunnerDirectory(),"templates","scripts", "intro_foreground.sh"), "\nexport NG_CLI_ANALYTICS=CI"); fs.appendFileSync(path.join(this.getRunnerDirectory(),"templates","scripts", "intro_background.sh"), "\necho \'export NG_CLI_ANALYTICS=CI\' >> /root/.profile\n"); @@ -126,8 +126,8 @@ export class Katacoda extends Runner { "script": "restoreDevonfwIde.sh" }); //update working directory - this.setVariable(this.workspaceDirectory, path.join("/root", "devonfw", "workspaces", "main")); - this.setVariable(this.useDevonCommand, true); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join("/root", "devonfw", "workspaces", "main")); + this.setVariable(this.USE_DEVON_COMMAND, true); fs.appendFileSync(path.join(this.getRunnerDirectory(),"templates","scripts", "intro_foreground.sh"), "\n. ~/.bashrc\nexport NG_CLI_ANALYTICS=CI"); fs.appendFileSync(path.join(this.getRunnerDirectory(),"templates","scripts", "intro_background.sh"), "\necho \'export NG_CLI_ANALYTICS=CI\' >> /root/.profile\n"); @@ -141,20 +141,20 @@ export class Katacoda extends Runner { ? runCommand.command.parameters[0].workspace : this.playbookName.replace("/", "").replace(" ","-")); - let workspacesDir = this.getVariable(this.useDevonCommand) + let workspacesDir = this.getVariable(this.USE_DEVON_COMMAND) ? path.join('/root', "devonfw", "workspaces").replace(/\\/g, "/") : path.join('/root', "workspaces").replace(/\\/g, "/"); let user = this.getVariable('user') ? this.getVariable('user') : 'devonfw-tutorials'; - this.renderTemplate(path.join("scripts", "restoreWorkspace.sh"), path.join(this.setupDir, "restoreWorkspace.sh"), {user: user, branch: this.getVariable("branch"), workspace: workspacesName, workspaceDir: workspacesDir, useDevonCommand: !!this.getVariable(this.useDevonCommand)}); + this.renderTemplate(path.join("scripts", "restoreWorkspace.sh"), path.join(this.setupDir, "restoreWorkspace.sh"), {user: user, branch: this.getVariable("branch"), workspace: workspacesName, workspaceDir: workspacesDir, USE_DEVON_COMMAND: !!this.getVariable(this.USE_DEVON_COMMAND)}); this.setupScripts.push({ "name": "Restore Workspace", "script": "restoreWorkspace.sh" }); - if(!this.getVariable(this.useDevonCommand)) - this.setVariable(this.workspaceDirectory, path.join('/root', "workspaces")); + if(!this.getVariable(this.USE_DEVON_COMMAND)) + this.setVariable(this.WORKSPACE_DIRECTORY, path.join('/root', "workspaces")); this.pushStep(runCommand); return null; @@ -197,8 +197,8 @@ export class Katacoda extends Runner { } runCreateFile(runCommand: RunCommand): RunResult{ - let workspaceDir = path.join(this.getVariable(this.workspaceDirectory).concat(path.sep).replace(path.sep + "root" + path.sep, "")); - let filePath = path.join(this.getVariable(this.workspaceDirectory), path.dirname(runCommand.command.parameters[0])).replace(/\\/g, "/"); + let workspaceDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY).concat(path.sep).replace(path.sep + "root" + path.sep, "")); + let filePath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), path.dirname(runCommand.command.parameters[0])).replace(/\\/g, "/"); let fileDir = path.join(workspaceDir, runCommand.command.parameters[0]).replace(/\\/g, "/"); let fileName = path.basename(path.join(runCommand.command.parameters[0])); let content = ""; @@ -212,8 +212,9 @@ export class Katacoda extends Runner { } runChangeFile(runCommand: RunCommand): RunResult{ + let workspaceDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY).concat(path.sep).replace(path.sep + "root" + path.sep, "")); let fileName = path.basename(path.join(runCommand.command.parameters[0])); - let fileDir = path.relative('/root', path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])).replace(/\\/g, "/"); + let fileDir = path.relative('/root', path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])).replace(/\\/g, "/"); let placeholder = runCommand.command.parameters[1].placeholder ? runCommand.command.parameters[1].placeholder : ""; let dataTarget = runCommand.command.parameters[1].placeholder ? "insert" : "replace"; let content = ""; @@ -248,30 +249,30 @@ export class Katacoda extends Runner { runBuildJava(runCommand: RunCommand): RunResult{ - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); let skipTest = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? false : true; this.pushStep(runCommand, "Build the Java project", "step" + runCommand.stepIndex + ".md"); - this.renderTemplate("buildJava.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, skipTest: skipTest, useDevonCommand: this.getVariable(this.useDevonCommand)}); + this.renderTemplate("buildJava.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, skipTest: skipTest, USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND)}); return null; } runBuildNg(runCommand: RunCommand): RunResult { - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); this.pushStep(runCommand, "Build the Angular project", "step" + runCommand.stepIndex + ".md"); - this.renderTemplate("buildNg.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, outputDir: runCommand.command.parameters[1], useDevonCommand: this.getVariable(this.useDevonCommand) }); + this.renderTemplate("buildNg.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, outputDir: runCommand.command.parameters[1], USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND) }); return null; } runCloneRepository(runCommand: RunCommand): RunResult { - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory))); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY))); let directoryPath = ""; if(runCommand.command.parameters[0].trim()) { directoryPath = path.join(runCommand.command.parameters[0]).replace(/\\/g, "/"); @@ -285,17 +286,17 @@ export class Katacoda extends Runner { } runRunServerJava(runCommand: RunCommand): RunResult{ - let serverDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let serverDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let terminal = this.getTerminal('runServerJava'); let cdCommand = this.changeCurrentDir(serverDir, terminal.terminalId, terminal.isRunning); this.pushStep(runCommand, "Start the Java server", "step" + runCommand.stepIndex + ".md"); - this.renderTemplate("runServerJava.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, terminalId: terminal.terminalId, interrupt: terminal.isRunning, useDevonCommand: this.getVariable(this.useDevonCommand)}); + this.renderTemplate("runServerJava.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, terminalId: terminal.terminalId, interrupt: terminal.isRunning, USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND)}); return null; } runNpmInstall(runCommand: RunCommand): RunResult { - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); let packageTitle = (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : "the dependencies"; let npmCommand = { "name": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : undefined, @@ -305,12 +306,12 @@ export class Katacoda extends Runner { this.pushStep(runCommand, "Install " + packageTitle, "step" + runCommand.stepIndex + ".md") - this.renderTemplate("npmInstall.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, useDevonCommand: this.getVariable(this.useDevonCommand), npmCommand: npmCommand}); + this.renderTemplate("npmInstall.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND), npmCommand: npmCommand}); return null; } runRunClientNg(runCommand: RunCommand): RunResult { - let serverDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let serverDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let terminal = this.getTerminal('runClientNg'); let cdCommand = this.changeCurrentDir(serverDir, terminal.terminalId, terminal.isRunning); @@ -318,12 +319,12 @@ export class Katacoda extends Runner { fs.appendFileSync(path.join(this.getRunnerDirectory(),"templates","scripts", "intro_background.sh"), "\necho \'export NODE_OPTIONS=\"--max-old-space-size=16384\"\' >> /root/.profile\n"); - this.renderTemplate("runClientNg.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, terminalId: terminal.terminalId, interrupt: terminal.isRunning, port: runCommand.command.parameters[1].port, useDevonCommand: this.getVariable(this.useDevonCommand)}); + this.renderTemplate("runClientNg.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, terminalId: terminal.terminalId, interrupt: terminal.isRunning, port: runCommand.command.parameters[1].port, USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND)}); return null; } runCreateFolder(runCommand: RunCommand): RunResult { - let folderPath = new DirUtils().getCdParam(this.currentDir, path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])); + let folderPath = new DirUtils().getCdParam(this.currentDir, path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])); this.pushStep(runCommand, "Create a new folder", "step" + runCommand.stepIndex + ".md"); @@ -334,7 +335,7 @@ export class Katacoda extends Runner { runDownloadFile(runCommand: RunCommand): RunResult { this.pushStep(runCommand, "Download a file", "step" + runCommand.stepIndex + ".md"); - let downloadDir = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/") + let downloadDir = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/") if (runCommand.command.parameters.length == 3) { downloadDir = downloadDir.concat("/", runCommand.command.parameters[2]) } @@ -365,7 +366,7 @@ export class Katacoda extends Runner { this.renderTemplate("nextKatacodaStep.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, content: content }); if(runCommand.command.parameters[2]) { - this.currentDir = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[2]); + this.currentDir = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2]); } return null; @@ -381,7 +382,7 @@ export class Katacoda extends Runner { runDockerCompose(runCommand: RunCommand) : RunResult { let terminal = this.getTerminal('runDockerCompose'); - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]), terminal.terminalId, terminal.isRunning); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]), terminal.terminalId, terminal.isRunning); this.pushStep(runCommand, "Execute Docker Compose", "step" + runCommand.stepIndex + ".md"); @@ -391,12 +392,12 @@ export class Katacoda extends Runner { } runCreateDevon4ngProject(runCommand: RunCommand): RunResult { - let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[1])); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[1])); let params = runCommand.command.parameters.length > 2 && (runCommand.command.parameters[2] instanceof Array) ? runCommand.command.parameters[2].join(" ") : ""; this.pushStep(runCommand, "Create Angular project", "step" + runCommand.stepIndex + ".md"); - this.renderTemplate("createDevon4ngProject.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, projectName: runCommand.command.parameters[0], params: params, useDevonCommand: this.getVariable(this.useDevonCommand) }); + this.renderTemplate("createDevon4ngProject.md", this.outputPathTutorial + "step" + runCommand.stepIndex + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, projectName: runCommand.command.parameters[0], params: params, USE_DEVON_COMMAND: this.getVariable(this.USE_DEVON_COMMAND) }); return null; } @@ -409,7 +410,7 @@ export class Katacoda extends Runner { let changeDir = false; if(runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].dir){ filepath = runCommand.command.parameters[2].asynchronous - ? path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[2].dir).replace(/\\/g, "/") + ? path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2].dir).replace(/\\/g, "/") : runCommand.command.parameters[2].dir; changeDir = true; this.currentDir = filepath; @@ -431,7 +432,7 @@ export class Katacoda extends Runner { runChangeWorkspace(runCommand: RunCommand): RunResult { let workspacesDir = path.join('/root', runCommand.command.parameters[0]); - this.setVariable(this.workspaceDirectory, workspacesDir); + this.setVariable(this.WORKSPACE_DIRECTORY, workspacesDir); this.pushStep(runCommand); return null; } @@ -453,7 +454,7 @@ export class Katacoda extends Runner { runOpenFile(runCommand: RunCommand): RunResult { let fileName = path.basename(runCommand.command.parameters[0]); - let filePath = path.relative('/root', path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0])).replace(/\\/g, "/"); + let filePath = path.relative('/root', path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0])).replace(/\\/g, "/"); this.pushStep(runCommand, "Open " + fileName, "step" + runCommand.stepIndex + ".md"); diff --git a/runners/vscode/index.ts b/runners/vscode/index.ts index 8306c129..d1866973 100644 --- a/runners/vscode/index.ts +++ b/runners/vscode/index.ts @@ -68,7 +68,7 @@ export class VsCode extends Runner { let result = new RunResult(); result.returnCode = 0; - let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let directoryPath = path.dirname(filepath).replace(/\\/g, "\\\\").replace(/\//g, "//"); let directoryName = filepath.split(path.sep)[filepath.split(path.sep).length - 2]; let testfile = path.join(this.getWorkingDirectory(), "vscode_tests", "runCobiGenJava.js"); diff --git a/runners/wikiConsole/index.ts b/runners/wikiConsole/index.ts index 07b0ff0d..e645ed07 100644 --- a/runners/wikiConsole/index.ts +++ b/runners/wikiConsole/index.ts @@ -8,8 +8,8 @@ export class WikiConsole extends WikiRunner { init(playbook: Playbook): void { super.init(playbook); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory())); this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "intro.asciidoc"), {name: playbook.name, title: playbook.title, subtitle: playbook.subtitle, description: playbook.description}); - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); } async destroy(playbook: Playbook): Promise { @@ -26,7 +26,8 @@ export class WikiConsole extends WikiRunner { version = runCommand.command.parameters[1]; } this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools, version:version }) - this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main")); + this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main")); + this.setVariable(this.INSTALLED_TOOLS, tools); return null; } @@ -35,7 +36,7 @@ export class WikiConsole extends WikiRunner { } runChangeFile(runCommand: RunCommand): RunResult{ - let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/"); + let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/"); let filePath = path.join(workspacePath,runCommand.command.parameters[0]); let fileName = path.basename(runCommand.command.parameters[0]); let contentPath, contentString; @@ -62,13 +63,13 @@ export class WikiConsole extends WikiRunner { runRunServerJava(runCommand: RunCommand): RunResult { - let server_path = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let server_path = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "runServerJava.asciidoc"), { server_path: server_path, port: runCommand.command.parameters[1].port, app_path: runCommand.command.parameters[1].path }) return null; } runNpmInstall(runCommand: RunCommand): RunResult { - let projectPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let projectPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let npmCommand = { "name": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : undefined, "global": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].global) ? runCommand.command.parameters[1].global : false, @@ -80,7 +81,7 @@ export class WikiConsole extends WikiRunner { } runCloneRepository(runCommand: RunCommand): RunResult { - let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let directoryPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "cloneRepository.asciidoc"), { directoryPath: directoryPath, url: runCommand.command.parameters[1] }); return null; } @@ -95,7 +96,7 @@ export class WikiConsole extends WikiRunner { } runBuildNg(runCommand: RunCommand): RunResult { - let angularPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let angularPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let outputPath = runCommand.command.parameters.length < 1 ? runCommand.command.parameters[1] : ""; this.renderWiki(path.join(this.getRunnerDirectory(), "template", "buildNg.asciidoc"), {angularPath: angularPath, outputPath: outputPath}); @@ -110,18 +111,24 @@ export class WikiConsole extends WikiRunner { } runCreateFolder(runCommand: RunCommand): RunResult { - let folderPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let folderPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createFolder.asciidoc"), { folderPath: folderPath }); return null; } runBuildJava(runCommand: RunCommand): RunResult { - let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]); + let directoryPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]); let skipTest = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? false : true; this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "buildJava.asciidoc"), { directoryPath: directoryPath, skipTest: skipTest }); return null; } + runInstallCobiGen(runCommand: RunCommand): RunResult{ + let devonPath = path.relative(this.getWorkingDirectory(), this.getVariable(this.WORKSPACE_DIRECTORY)).replace(/\\/g, "/");; + this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installCobiGen.asciidoc"), {devonPath: devonPath}); + return null; + } + runCreateDevon4jProject(runCommand: RunCommand): RunResult { this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0] }); return null; diff --git a/runners/wikiConsole/templates/installCobiGen.asciidoc b/runners/wikiConsole/templates/installCobiGen.asciidoc new file mode 100644 index 00000000..360a148e --- /dev/null +++ b/runners/wikiConsole/templates/installCobiGen.asciidoc @@ -0,0 +1,14 @@ +== Install GobiGen +Installing devonfw code generator (i.e. CobiGen). + +=== Prerequisites +* An installed devonfw distribution is needed. To execute the CobiGen CLI, you have to install the devonfw IDE first. Follow the https://devonfw.com/website/pages/docs/devonfw-ide-introduction.asciidoc.html[devonfw-ide] documentation to install the same. + +=== Install CobiGen with a command prompt + +First, you need to open a command prompt in your current workspace. For Windows, you can use PowerShell and on Linux and macOS, you can use the Terminal. +Navigate to the devonfw installation directory with this command `cd <%= devonPath;%>`. +Execute the command `devon cobigen` and CobiGen will be installed. +To update the environment, you have to execute `devon` and you have successfully installed CobiGen. + +Some further information about the usage of CobiGen can be found https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html[here]. diff --git a/runners/wikiConsole/templates/installDevonfwIde.asciidoc b/runners/wikiConsole/templates/installDevonfwIde.asciidoc index 90e38c17..2cce5448 100644 --- a/runners/wikiConsole/templates/installDevonfwIde.asciidoc +++ b/runners/wikiConsole/templates/installDevonfwIde.asciidoc @@ -47,4 +47,5 @@ You can also just execute `.\setup` (Windows) or `bash setup` (Linux) and press <% if(tools.indexOf("mvn") > 0){ %> The installer will also ask you if you want to enter secrets for your maven repository. You can simply skip this by pressing 'Enter'. -<% } %> \ No newline at end of file +<% } %> + diff --git a/runners/wikiEclipse/index.ts b/runners/wikiEclipse/index.ts index ee0390e6..71b73d4c 100644 --- a/runners/wikiEclipse/index.ts +++ b/runners/wikiEclipse/index.ts @@ -15,7 +15,7 @@ export class WikiEclipse extends WikiRunner { } runChangeFile(runCommand: RunCommand): RunResult{ - let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/"); + let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/"); let fileName = path.basename(runCommand.command.parameters[0]); let filePath = path.join(workspacePath,runCommand.command.parameters[0].replace(fileName, "")); let contentPath, contentFile, contentString; @@ -40,6 +40,19 @@ export class WikiEclipse extends WikiRunner { contentFile: contentFile, fileName: fileName}); return null; } + + + runInstallCobiGen(runCommand: RunCommand): RunResult{ + this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installCobiGen.asciidoc"), {}); + return null; + } + + supports(name: string, parameters: any[]): boolean { + return this.getVariable(this.INSTALLED_TOOLS).includes("eclipse") + ? super.supports(name, parameters) + : false; + } + runCreateDevon4jProject(runCommand: RunCommand): RunResult { this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0]}); diff --git a/runners/wikiEclipse/templates/installCobigen.asciidoc b/runners/wikiEclipse/templates/installCobigen.asciidoc new file mode 100644 index 00000000..82ec3c4b --- /dev/null +++ b/runners/wikiEclipse/templates/installCobigen.asciidoc @@ -0,0 +1,12 @@ +== Install GobiGen +Installing devonfw code generator (i.e. CobiGen). + +=== Prerequisites +* An installed devonfw Eclipse installation is needed. CobiGen Eclipse plugin will be installed with your devonfw distribution. In order to execute it, you have to install the devonfw IDE first. Follow the https://devonfw.com/website/pages/docs/devonfw-ide-introduction.asciidoc.html[devonfw-ide] documentation to install the same. + +=== Install CobiGen for Eclipse IDE + +CobiGen is already installed for your Eclipse IDE if you have installed it with the devonfw setup. +You can open the *Help* menu and select *About Eclipse IDE*. To check if CobiGen is installed select *Installation Details* and CobiGen should be in the list of *Installed Software* and *Plug-ins*. You can use CobiGen by right-click on a file and selecting CobiGen in the opened menu. Now you can choose some CobiGen functions you want to execute for the selected file. + +Some further information about the usage of CobiGen can be found https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html[here]. \ No newline at end of file diff --git a/runners/wikiEditor/index.ts b/runners/wikiEditor/index.ts index 73a3fb11..01d2b8f3 100644 --- a/runners/wikiEditor/index.ts +++ b/runners/wikiEditor/index.ts @@ -15,7 +15,7 @@ export class WikiEditor extends WikiRunner { } runChangeFile(runCommand: RunCommand): RunResult{ - let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/"); + let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/"); let fileName = path.basename(runCommand.command.parameters[0]); let filePath = path.join(workspacePath,runCommand.command.parameters[0].replace(fileName, "")); let contentPath, contentFile, contentString; diff --git a/runners/wikiVsCode/index.ts b/runners/wikiVsCode/index.ts index 6544093d..a647a331 100644 --- a/runners/wikiVsCode/index.ts +++ b/runners/wikiVsCode/index.ts @@ -6,6 +6,7 @@ import * as path from "path"; export class WikiVsCode extends WikiRunner { + init(playbook: Playbook): void { super.init(playbook); } @@ -15,7 +16,7 @@ export class WikiVsCode extends WikiRunner { } runChangeFile(runCommand: RunCommand): RunResult{ - let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/"); + let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/"); let fileName = path.basename(runCommand.command.parameters[0]); let filePath = path.join(workspacePath,runCommand.command.parameters[0].replace(fileName, "")); let contentPath, contentFile, contentString; @@ -40,4 +41,17 @@ export class WikiVsCode extends WikiRunner { contentFile: contentFile, fileName: fileName}); return null; } + + runInstallCobiGen(runCommand: RunCommand): RunResult{ + let dir = path.relative(this.getVariable(this.WORKSPACE_DIRECTORY), this.getWorkingDirectory()).replace(/\\/g, "/");; + this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installCobiGen.asciidoc"), {dir: dir}); + return null; + } + + supports(name: string, parameters: any[]): boolean { + return this.getVariable(this.INSTALLED_TOOLS).includes("vscode") + ? super.supports(name, parameters) + : false; + } + } \ No newline at end of file diff --git a/runners/wikiVsCode/templates/installCobiGen.asciidoc b/runners/wikiVsCode/templates/installCobiGen.asciidoc new file mode 100644 index 00000000..43eb77cb --- /dev/null +++ b/runners/wikiVsCode/templates/installCobiGen.asciidoc @@ -0,0 +1,20 @@ +== Install GobiGen +Installing devonfw code generator (i.e. CobiGen). + +=== Prerequisites +* An installed VS Code Editor is needed. VS Code is installed inside your devonfw distribution. If VS Code or devonfw is missing, you have to install it first. Follow the https://devonfw.com/website/pages/docs/devonfw-ide-introduction.asciidoc.html[devonfw ] documentation to install the missing ones. + +=== Install CobiGen for VS Code Editor +First, download the VS Code extension file. You can download it from https://github.com/devonfw-forge/cobigen-vscode-plugin/releases/download/0.0.1/cobigen-plugin-0.0.1.vsix[here] or execute the following command in PowerShell or Terminal. + + +.Operating system +. Windows + +`Invoke-WebRequest https://github.com/devonfw-forge/cobigen-vscode-plugin/releases/download/0.0.1/cobigen-plugin-0.0.1.vsix -O <%= dir;%>cobigen-plugin-0.0.1.vsix` +. Linux and macOS + +`wget https://github.com/devonfw-forge/cobigen-vscode-plugin/releases/download/0.0.1/cobigen-plugin-0.0.1.vsix -O cobigen-plugin-0.0.1.vsix -P $(pwd)/<%= dir;%>` + +Install CobiGen by opening VS Code Editor and the *Extensions* menu with ctrl+shift+X and select *...* in the top right corner of the extensions window. Select *Install from VSIX* and select the previously downloaded cobigen-plugin-0.0.1.vsix file, it is located in the directory you startet executing this wiki. +Now CobiGen is installed, use CobiGen by right-clicking on a file and selecting CobiGen in the opened menu. CobiGen generate will be executed with the selected file. + +Some further information about the usage of CobiGen can be found https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html[here].