Skip to content

Commit b810efb

Browse files
Merge pull request #267 from EduardKrieger/feature/wikiRunnerAddSetupScript
Feature/wikiRunnerAddSetupScript
2 parents d33c86f + d19f7ab commit b810efb

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

runners/wikiConsole/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ 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';
6+
import * as fs from "fs";
7+
78

89
export class WikiConsole extends WikiRunner {
910

@@ -135,6 +136,16 @@ export class WikiConsole extends WikiRunner {
135136
return null;
136137
}
137138

139+
runAddSetupScript(runCommand: RunCommand): RunResult{
140+
let scriptNameLinux = path.basename(runCommand.command.parameters[0]);
141+
let scriptNameWindows = path.basename(runCommand.command.parameters[1]);
142+
let windowsContent = fs.readFileSync(path.join(this.playbookPath, runCommand.command.parameters[1]), { encoding: "utf-8" });
143+
let linuxContent = fs.readFileSync(path.join(this.playbookPath, runCommand.command.parameters[0]), { encoding: "utf-8" });
144+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "addSetupScript.asciidoc"), {scriptNameWindows: scriptNameWindows, windowsContent: windowsContent,
145+
scriptNameLinux: scriptNameLinux, linuxContent: linuxContent});
146+
return null;
147+
}
148+
138149
runAdaptTemplatesCobiGen(runComannd: RunCommand): RunResult{
139150
let devonPath = path.relative(this.getWorkingDirectory(), this.getVariable(this.WORKSPACE_DIRECTORY)).replace(/\\/g, "/");
140151
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "adaptTemplates.asciidoc"), {devonPath: devonPath});
@@ -159,7 +170,7 @@ export class WikiConsole extends WikiRunner {
159170

160171
let content = fs.readFileSync(tempFile, "utf-8");
161172
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "nextKatacodaStep.asciidoc"), { title: runCommand.command.parameters[0], content: content, path: runCommand.command.parameters[2]});
162-
173+
163174
return null;
164175
}
165176
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
== Run a Setupscript
2+
Run a Script to setup the enviroment for the Tutorial.
3+
4+
5+
=== Prerequisites
6+
* Any Editor that can edit files.
7+
8+
=== Create the Setupscript
9+
Open a editor and create a new file by going to the file context menu in the top left corner of the editor and select *New* or *New File* or mostly also the keyboard shortcut ctrl+n will also work.
10+
11+
.Operating system
12+
. Windows +
13+
The editor opens a new editor window for an untitled file where you should insert the following text.
14+
+
15+
[source, powershell]
16+
----
17+
<%- windowsContent; %>
18+
----
19+
Save the file by selecting *Save* or *Save as* in the file context menu or by using the keyboard shortcut ctrl+s.
20+
A file explorer window opens where you should set the filename to *<%= scriptNameWindows; %>* and save it to your current directory.
21+
22+
. Linux and macOS +
23+
The editor opens a new editor window for an untitled file where you can insert the following text.
24+
+
25+
[source, bash]
26+
----
27+
<%- linuxContent; %>
28+
----
29+
Save the file by selecting *Save* or *Save as* in the file context menu or by using the keyboard shortcut ctrl+s.
30+
A file explorer window opens where you should set the filename to *<%= scriptNameLinux; %>* and save it to your current directory.
31+
32+
=== Run the Setupscript
33+
34+
.Operating system
35+
. Windows +
36+
Open the PowerShell in your current workspace and execute the command `./<%= scriptNameWindows; %>` to run the script.
37+
. Linux and macOS +
38+
Open the Terminal in your current workspace and execute the command `bash <%= scriptNameWindows; %>` to run the script.
39+

runners/wikiConsole/templates/intro.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
The definition of each step of this tutorial can be found at https://github.com/devonfw-tutorials/tutorials/tree/main/<%= name; %>. <% } %>
77

88
Feel free to report any errors to us or fix them yourself. Errors can be reported by creating an issue in the https://github.com/devonfw-tutorials/tutorials/issues[tutorials repository]. To fix the error fork the repository and create a pull request. Errors in the wiki can be reported and fixed in the https://github.com/devonfw-tutorials/tutorial-compiler[Tutorial-compiler repository].
9-
You can find a description of what to look for when creating a pull request at the devonfw contribution guide: https://devonfw.com/website/pages/community/community.html#community.asciidoc_contributing-to-devonfw. If you want to create a tutorial you can start with the https://katacoda.com/devonfw/scenarios/create-your-own-tutorial[katacoda tutorial] and read the description for creating your own tutorials: https://github.com/devonfw-tutorials/tutorials/wiki/Development.
9+
You can find a description of what to look for when creating a pull request at the devonfw contribution guide: https://devonfw.com/website/pages/community/community.html#community.asciidoc_contributing-to-devonfw. If you want to create a tutorial you can start with the https://katacoda.com/devonfw/scenarios/create-your-own-tutorial[katacoda tutorial] and read the description for creating your own tutorials: https://github.com/devonfw-tutorials/tutorials/wiki/Development.
10+

0 commit comments

Comments
 (0)