Skip to content

Commit 3be3073

Browse files
authored
Merge pull request #244 from EduardKrieger/feature/wikiRunnerInstallCobiGen
Feature/wikiRunnerInstallCobiGen
2 parents ed550d6 + 2a1c771 commit 3be3073

13 files changed

Lines changed: 183 additions & 100 deletions

File tree

engine/runner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export abstract class Runner {
1111
public playbookPath: string;
1212
public playbookTitle: string;
1313
public environmentName: string;
14-
protected readonly useDevonCommand: string = "useDevonCommand";
15-
protected readonly workspaceDirectory: string = "workspaceDirectory";
14+
protected readonly USE_DEVON_COMMAND: string = "useDevonCommand";
15+
protected readonly WORKSPACE_DIRECTORY: string = "workspaceDirectory";
1616

1717
private setVariableCallback: (name: string, value: any) => any;
1818
registerSetVariableCallback(callback: (name: string, value: any) => any) {
@@ -83,7 +83,7 @@ export abstract class Runner {
8383
}
8484

8585
init(playbook: Playbook): void {
86-
this.setVariable(this.useDevonCommand, false);
86+
this.setVariable(this.USE_DEVON_COMMAND, false);
8787
}
8888

8989
run(runCommand: RunCommand): RunResult {

engine/wikiRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import * as ejs from "ejs";
77
export abstract class WikiRunner extends Runner {
88

99
public outputPathTutorial: string;
10+
protected readonly INSTALLED_TOOLS: string = "installedTools";
1011

1112
init(playbook: Playbook): void {
1213
let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false)
1314
this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true);
14-
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory()));
15+
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory()));
16+
this.setVariable(this.INSTALLED_TOOLS, "");
1517
}
1618

1719
async destroy(playbook: Playbook): Promise<void> {

runners/console/index.ts

Lines changed: 49 additions & 50 deletions
Large diffs are not rendered by default.

runners/katacoda/index.ts

Lines changed: 33 additions & 32 deletions
Large diffs are not rendered by default.

runners/vscode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class VsCode extends Runner {
6868
let result = new RunResult();
6969
result.returnCode = 0;
7070

71-
let filepath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
71+
let filepath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
7272
let directoryPath = path.dirname(filepath).replace(/\\/g, "\\\\").replace(/\//g, "//");
7373
let directoryName = filepath.split(path.sep)[filepath.split(path.sep).length - 2];
7474
let testfile = path.join(this.getWorkingDirectory(), "vscode_tests", "runCobiGenJava.js");

runners/wikiConsole/index.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export class WikiConsole extends WikiRunner {
99

1010
init(playbook: Playbook): void {
1111
super.init(playbook);
12+
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory()));
1213
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "intro.asciidoc"), {name: playbook.name, title: playbook.title, subtitle: playbook.subtitle, description: playbook.description});
13-
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory()));
1414
}
1515

1616
async destroy(playbook: Playbook): Promise<void> {
@@ -27,7 +27,8 @@ export class WikiConsole extends WikiRunner {
2727
version = runCommand.command.parameters[1];
2828
}
2929
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools, version:version })
30-
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"));
30+
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"));
31+
this.setVariable(this.INSTALLED_TOOLS, tools);
3132
return null;
3233
}
3334

@@ -36,7 +37,7 @@ export class WikiConsole extends WikiRunner {
3637
}
3738

3839
runChangeFile(runCommand: RunCommand): RunResult{
39-
let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/");
40+
let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/");
4041
let filePath = path.join(workspacePath,runCommand.command.parameters[0]);
4142
let fileName = path.basename(runCommand.command.parameters[0]);
4243
let contentPath, contentString;
@@ -63,13 +64,13 @@ export class WikiConsole extends WikiRunner {
6364

6465

6566
runRunServerJava(runCommand: RunCommand): RunResult {
66-
let server_path = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
67+
let server_path = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
6768
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 })
6869
return null;
6970
}
7071

7172
runNpmInstall(runCommand: RunCommand): RunResult {
72-
let projectPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
73+
let projectPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
7374
let npmCommand = {
7475
"name": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : undefined,
7576
"global": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].global) ? runCommand.command.parameters[1].global : false,
@@ -81,7 +82,7 @@ export class WikiConsole extends WikiRunner {
8182
}
8283

8384
runCloneRepository(runCommand: RunCommand): RunResult {
84-
let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
85+
let directoryPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
8586
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "cloneRepository.asciidoc"), { directoryPath: directoryPath, url: runCommand.command.parameters[1] });
8687
return null;
8788
}
@@ -96,7 +97,7 @@ export class WikiConsole extends WikiRunner {
9697
}
9798

9899
runBuildNg(runCommand: RunCommand): RunResult {
99-
let angularPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
100+
let angularPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
100101
let outputPath = runCommand.command.parameters.length < 1 ? runCommand.command.parameters[1] : "";
101102
this.renderWiki(path.join(this.getRunnerDirectory(), "template", "buildNg.asciidoc"), {angularPath: angularPath, outputPath: outputPath});
102103

@@ -111,18 +112,24 @@ export class WikiConsole extends WikiRunner {
111112
}
112113

113114
runCreateFolder(runCommand: RunCommand): RunResult {
114-
let folderPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
115+
let folderPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
115116
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createFolder.asciidoc"), { folderPath: folderPath });
116117
return null;
117118
}
118119

119120
runBuildJava(runCommand: RunCommand): RunResult {
120-
let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
121+
let directoryPath = path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[0]);
121122
let skipTest = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? false : true;
122123
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "buildJava.asciidoc"), { directoryPath: directoryPath, skipTest: skipTest });
123124
return null;
124125
}
125126

127+
runInstallCobiGen(runCommand: RunCommand): RunResult{
128+
let devonPath = path.relative(this.getWorkingDirectory(), this.getVariable(this.WORKSPACE_DIRECTORY)).replace(/\\/g, "/");;
129+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installCobiGen.asciidoc"), {devonPath: devonPath});
130+
return null;
131+
}
132+
126133
runCreateDevon4jProject(runCommand: RunCommand): RunResult {
127134
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0] });
128135
return null;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
== Install GobiGen
2+
Installing devonfw code generator (i.e. CobiGen).
3+
4+
=== Prerequisites
5+
* 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.
6+
7+
=== Install CobiGen with a command prompt
8+
9+
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.
10+
Navigate to the devonfw installation directory with this command `cd <%= devonPath;%>`.
11+
Execute the command `devon cobigen` and CobiGen will be installed.
12+
To update the environment, you have to execute `devon` and you have successfully installed CobiGen.
13+
14+
Some further information about the usage of CobiGen can be found https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html[here].

runners/wikiConsole/templates/installDevonfwIde.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ You can also just execute `.\setup` (Windows) or `bash setup` (Linux) and press
4747

4848
<% if(tools.indexOf("mvn") > 0){ %>
4949
The installer will also ask you if you want to enter secrets for your maven repository. You can simply skip this by pressing 'Enter'.
50-
<% } %>
50+
<% } %>
51+

runners/wikiEclipse/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class WikiEclipse extends WikiRunner {
1515
}
1616

1717
runChangeFile(runCommand: RunCommand): RunResult{
18-
let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/");
18+
let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/");
1919
let fileName = path.basename(runCommand.command.parameters[0]);
2020
let filePath = path.join(workspacePath,runCommand.command.parameters[0].replace(fileName, ""));
2121
let contentPath, contentFile, contentString;
@@ -40,6 +40,19 @@ export class WikiEclipse extends WikiRunner {
4040
contentFile: contentFile, fileName: fileName});
4141
return null;
4242
}
43+
44+
45+
runInstallCobiGen(runCommand: RunCommand): RunResult{
46+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installCobiGen.asciidoc"), {});
47+
return null;
48+
}
49+
50+
supports(name: string, parameters: any[]): boolean {
51+
return this.getVariable(this.INSTALLED_TOOLS).includes("eclipse")
52+
? super.supports(name, parameters)
53+
: false;
54+
}
55+
4356

4457
runCreateDevon4jProject(runCommand: RunCommand): RunResult {
4558
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0]});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
== Install GobiGen
2+
Installing devonfw code generator (i.e. CobiGen).
3+
4+
=== Prerequisites
5+
* 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.
6+
7+
=== Install CobiGen for Eclipse IDE
8+
9+
CobiGen is already installed for your Eclipse IDE if you have installed it with the devonfw setup.
10+
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.
11+
12+
Some further information about the usage of CobiGen can be found https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html[here].

0 commit comments

Comments
 (0)