Skip to content

Commit 1b9c984

Browse files
Merge branch 'main' into feature/synchronizeDocumentation
2 parents 27546a9 + d258978 commit 1b9c984

16 files changed

Lines changed: 253 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: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { RunCommand } from "../../engine/run_command";
33
import { RunResult } from "../../engine/run_result";
44
import { WikiRunner } from "../../engine/wikiRunner";
55
import * as path from "path";
6+
import * as fs from 'fs';
67

78
export class WikiConsole extends WikiRunner {
89

910
init(playbook: Playbook): void {
1011
super.init(playbook);
12+
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory()));
1113
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "intro.asciidoc"), {name: playbook.name, title: playbook.title, subtitle: playbook.subtitle, description: playbook.description});
12-
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory()));
1314
}
1415

1516
async destroy(playbook: Playbook): Promise<void> {
@@ -26,7 +27,8 @@ export class WikiConsole extends WikiRunner {
2627
version = runCommand.command.parameters[1];
2728
}
2829
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools, version:version })
29-
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);
3032
return null;
3133
}
3234

@@ -35,7 +37,7 @@ export class WikiConsole extends WikiRunner {
3537
}
3638

3739
runChangeFile(runCommand: RunCommand): RunResult{
38-
let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/");
40+
let workspacePath = this.getVariable(this.WORKSPACE_DIRECTORY).replace(/\\/g, "/");
3941
let filePath = path.join(workspacePath,runCommand.command.parameters[0]);
4042
let fileName = path.basename(runCommand.command.parameters[0]);
4143
let contentPath, contentString;
@@ -62,13 +64,13 @@ export class WikiConsole extends WikiRunner {
6264

6365

6466
runRunServerJava(runCommand: RunCommand): RunResult {
65-
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]);
6668
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 })
6769
return null;
6870
}
6971

7072
runNpmInstall(runCommand: RunCommand): RunResult {
71-
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]);
7274
let npmCommand = {
7375
"name": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : undefined,
7476
"global": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].global) ? runCommand.command.parameters[1].global : false,
@@ -80,7 +82,7 @@ export class WikiConsole extends WikiRunner {
8082
}
8183

8284
runCloneRepository(runCommand: RunCommand): RunResult {
83-
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]);
8486
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "cloneRepository.asciidoc"), { directoryPath: directoryPath, url: runCommand.command.parameters[1] });
8587
return null;
8688
}
@@ -95,7 +97,7 @@ export class WikiConsole extends WikiRunner {
9597
}
9698

9799
runBuildNg(runCommand: RunCommand): RunResult {
98-
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]);
99101
let outputPath = runCommand.command.parameters.length < 1 ? runCommand.command.parameters[1] : "";
100102
this.renderWiki(path.join(this.getRunnerDirectory(), "template", "buildNg.asciidoc"), {angularPath: angularPath, outputPath: outputPath});
101103

@@ -110,21 +112,55 @@ export class WikiConsole extends WikiRunner {
110112
}
111113

112114
runCreateFolder(runCommand: RunCommand): RunResult {
113-
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]);
114116
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createFolder.asciidoc"), { folderPath: folderPath });
115117
return null;
116118
}
117119

118120
runBuildJava(runCommand: RunCommand): RunResult {
119-
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]);
120122
let skipTest = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? false : true;
121123
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "buildJava.asciidoc"), { directoryPath: directoryPath, skipTest: skipTest });
122124
return null;
123125
}
124126

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+
125133
runCreateDevon4jProject(runCommand: RunCommand): RunResult {
126134
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0] });
127135
return null;
128136
}
137+
138+
runAdaptTemplatesCobiGen(runComannd: RunCommand): RunResult{
139+
let devonPath = path.relative(this.getWorkingDirectory(), this.getVariable(this.WORKSPACE_DIRECTORY)).replace(/\\/g, "/");
140+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "adaptTemplates.asciidoc"), {devonPath: devonPath});
141+
return null;
142+
}
143+
144+
runNextKatacodaStep(runCommand: RunCommand): RunResult {
145+
let tempFile = path.join(this.getTempDirectory(), runCommand.command.name + ".md");
146+
fs.writeFileSync(tempFile, "");
147+
for(let i = 0; i < runCommand.command.parameters[1].length; i++) {
148+
let param = runCommand.command.parameters[1][i];
149+
if(param.content) {
150+
fs.appendFileSync(tempFile, param.content);
151+
} else if(param.file) {
152+
fs.appendFileSync(tempFile, fs.readFileSync(path.join(this.playbookPath, param.file), "utf-8"));
153+
} else if (param.image) {
154+
let image = path.join(this.playbookPath, param.image);
155+
fs.appendFileSync(tempFile, "![" + path.basename(image) + "](./assets/" + path.basename(image) + ")");
156+
}
157+
fs.appendFileSync(tempFile, "\n\n");
158+
}
159+
160+
let content = fs.readFileSync(tempFile, "utf-8");
161+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "nextKatacodaStep.asciidoc"), { title: runCommand.command.parameters[0], content: content, path: runCommand.command.parameters[2]});
162+
163+
return null;
164+
}
129165
}
130166

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
== Generate CobiGen Templates
2+
How to use CobiGen, to generate templates for the following code generation.
3+
More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html.
4+
5+
=== Prerequisites
6+
7+
* 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.
8+
9+
=== Generate CobiGen Templates with CobiGen CLI
10+
11+
First open a command prompt in your current workspace. You should be inside your devonfw directory, if not change your directory to *<%= devonPath;%>*.
12+
Run the CobiGen command `devon cobigen adapt-templates`
13+
to generate a new templates folder next to the CobiGen CLI and save its location in a configuration file.
14+
15+
You can also spezify the location of the templates folder with the parameter `--custom-location` or `-cl` and pass the absolute path to your custom location.
16+
17+
18+
19+
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+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
== <%= title; %>
2+
3+
<%= content; %>
4+
5+
<% if(path) {%>
6+
After that, move to the target directory by executing `cd <%= path; %>` in the terminal.
7+
<% } %>

0 commit comments

Comments
 (0)