Skip to content

Commit 58830b5

Browse files
Merge pull request devonfw-tutorials#148 from GuentherJulian/feature/wikiRunner
Feature/wiki runner
2 parents 4859c99 + 66e3d88 commit 58830b5

File tree

10 files changed

+136
-1
lines changed

10 files changed

+136
-1
lines changed

engine/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Runner } from "./runner";
44
import { RunCommand } from "./run_command";
55
import { RunResult } from "./run_result";
66

7-
87
export class Engine {
98

109
private runners: Map<string, Runner> = new Map<string, Runner>();
@@ -106,6 +105,7 @@ export class Engine {
106105
runner.playbookName = this.playbook.name;
107106
runner.playbookPath = this.playbook.path;
108107
runner.playbookTitle = this.playbook.title;
108+
runner.environmentName = this.environmentName;
109109
this.runners.set(name, runner);
110110
}
111111

engine/runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export abstract class Runner {
1010
public playbookName: string;
1111
public playbookPath: string;
1212
public playbookTitle: string;
13+
public environmentName: string;
1314
protected readonly useDevonCommand: string = "useDevonCommand";
1415
protected readonly workspaceDirectory: string = "workspaceDirectory";
1516

engine/wikiRunner.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Runner } from "./runner";
2+
import { Playbook } from "./playbook";
3+
import * as fs from "fs";
4+
import * as path from "path";
5+
import * as ejs from "ejs";
6+
7+
export abstract class WikiRunner extends Runner {
8+
9+
public outputPathTutorial: string;
10+
11+
init(playbook: Playbook): void {
12+
let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false)
13+
this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true);
14+
}
15+
16+
destroy(playbook: Playbook): void {
17+
18+
}
19+
20+
public renderWiki(templateFile: string, variables: any) {
21+
let template = fs.readFileSync(templateFile, 'utf8');
22+
let result = ejs.render(template, variables);
23+
let tempFile = path.join(this.outputPathTutorial, "wiki.asciidoc");
24+
fs.writeFileSync(tempFile, result, { flag: "a" });
25+
}
26+
27+
}

environments/wiki_eclipse.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"failOnIncomplete": false,
3+
"runners": [
4+
"wikiEclipse",
5+
"wikiEditor",
6+
"wikiConsole"
7+
]
8+
}

environments/wiki_vscode.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"failOnIncomplete": false,
3+
"runners": [
4+
"wikiVsCode",
5+
"wikiEditor",
6+
"wikiConsole"
7+
]
8+
}

runners/wikiConsole/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Playbook } from "../../engine/playbook";
2+
import { RunCommand } from "../../engine/run_command";
3+
import { RunResult } from "../../engine/run_result";
4+
import { WikiRunner } from "../../engine/wikiRunner";
5+
import * as path from "path";
6+
7+
export class WikiConsole extends WikiRunner {
8+
9+
init(playbook: Playbook): void {
10+
super.init(playbook);
11+
}
12+
13+
destroy(playbook: Playbook): void {
14+
super.destroy(playbook);
15+
}
16+
17+
runInstallDevonfwIde(runCommand: RunCommand): RunResult {
18+
let tools = runCommand.command.parameters[0].join(" ");
19+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools })
20+
return null;
21+
}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
defonfw setup
2+
=============
3+
4+
5+
Prerequisites
6+
~~~~~~~~~~~~~~
7+
* You need to have a tool to extract `.tar.gz` files. On Windows lower Windows 10 use can use https://www.7-zip.org/7-zip[7-Zip]. The most other platforms support this feature by default.
8+
* You need to have https://git-scm.com/[Git] and https://curl.se/[Curl] installed. On Windows you have to install https://git-scm.com/download/win[Git for Windows]. On Linux systems you might need to install the following tools in case they are not present (`sudo apt-get install git curl` or `sudo yum install git-core curl`)
9+
10+
Create a new directory in the location where you want to install the devonfw IDE. If you are using the terminal, navigate to this location and run `mkdir devonfw` and `cd devonfw` to create the directory and navigate into it.
11+
12+
Download
13+
~~~~~~~~~
14+
Now you have to download the latest release of the devonfw IDE. You can download it from https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.tools.ide&a=devonfw-ide-scripts&v=LATEST&p=tar.gz[here].
15+
16+
In the Terminal execute `Invoke-WebRequest -OutFile devonfw-ide-scripts.tar.gz 'https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.tools.ide&a=devonfw-ide-scripts&v=LATEST&p=tar.gz'` if you are using Windows.
17+
18+
On Linux use `wget -c 'https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.tools.ide&a=devonfw-ide-scripts&v=LATEST&p=tar.gz' -O devonfw-ide-scripts.tar.gz -`.
19+
20+
After that you need to extract the downloaded file. To do this, run `tar -xvzf devonfw-ide-scripts.tar.gz`. Or you can simply use a tool (e.g. 7-Zip) for this.
21+
22+
Setup
23+
~~~~~~
24+
First, you need to prepare a settings repository to specify the tools to be installed within the devonfw IDE. Normally this is done by your project. If you just want to test the devonfw IDE, you can use the default URL, which is https://github.com/devonfw/ide-settings.
25+
26+
For now clone the repository on https://github.com/devonfw/ide-settings or your own fork of it.
27+
For this tutorial you have to write `DEVON_IDE_TOOLS=(<%= tools; %>)` into the devon.properties file of the cloned settings repository. These settings will now be passed into the installation process of the devonfw IDE.
28+
Start the setup process by executing `.\setup 'path/to/settings'` (Windows) or `bash setup path/to/settings.git` (Linux).
29+
30+
You can also just execute `.\setup` (Windows) or `bash setup` (Linux) and press Enter when the setup assistent asks for the URL to the settings repository. This will also download the default settings and install the default tools within the defonfw IDE.

runners/wikiEclipse/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Playbook } from "../../engine/playbook";
2+
import { WikiRunner } from "../../engine/wikiRunner";
3+
4+
export class WikiEclipse extends WikiRunner {
5+
6+
init(playbook: Playbook): void {
7+
super.init(playbook);
8+
}
9+
10+
destroy(playbook: Playbook): void {
11+
super.destroy(playbook);
12+
}
13+
}

runners/wikiEditor/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Playbook } from "../../engine/playbook";
2+
import { WikiRunner } from "../../engine/wikiRunner";
3+
4+
export class WikiEditor extends WikiRunner {
5+
6+
init(playbook: Playbook): void {
7+
super.init(playbook);
8+
}
9+
10+
destroy(playbook: Playbook): void {
11+
super.destroy(playbook);
12+
}
13+
}

runners/wikiVsCode/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Playbook } from "../../engine/playbook";
2+
import { WikiRunner } from "../../engine/wikiRunner";
3+
4+
export class WikiVsCode extends WikiRunner {
5+
6+
init(playbook: Playbook): void {
7+
super.init(playbook);
8+
}
9+
10+
destroy(playbook: Playbook): void {
11+
super.destroy(playbook);
12+
}
13+
}

0 commit comments

Comments
 (0)