Skip to content

Commit ed50f7f

Browse files
Merge branch 'main' into enhancement/reworkNextKatacodaStep
2 parents dbd20bf + 74d5470 commit ed50f7f

32 files changed

Lines changed: 405 additions & 168 deletions

documentation/Functions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,20 +352,21 @@ If the tutorial should be tested on the console environment, you have to specify
352352
### displayContent <a name="displayContent"></a>
353353
#### parameter
354354
1. The title of the step.
355-
2. An array of json objects with files, content, or images to be rendered within the katacoda step. The use for this function is to display an image and some descriptive text. No Katacoda Syntax is allowed in the files or the content!
355+
2. An array of json objects with files, content, or images to be rendered within the Katacoda step. The use for this function is to display an image and some descriptive text. No Katacoda syntax is allowed in the files or the content!
356356
3. (Optional) Path to the current directory where the user is located (relative to the workspace directory). Only needed if the directory is changed within this step.
357357
#### example
358358
display("Step title", [{ "file": "files/description.asciidoc" }, { "content": "This is just plain content." }, { "image": "files/image.png" }])
359359

360360
#### Details
361361
Available attributes in the json objects:
362362

363-
1. file: Path to a file whose content is to be displayed in the katacoda step (e.g. .asciidoc or .txt file). The file should be following the formating of asciidoc files.
364-
2. content: Plain text to be displayed in the katacoda step. This Text should be following the formating of asciidoc files.
365-
3. image: Path to an image to be displayed in the katacoda step.
363+
1. file: Path to a file whose content is to be displayed in the Katacoda step (e.g. .asciidoc or .txt file). The file should be following the formating of asciidoc files.
364+
2. content: Plain text to be displayed in the Katacoda step. This Text should be following the formating of asciidoc files.
365+
3. image: Path to an image to be displayed in the Katacoda step.
366+
366367

367368
#### Formatting rules for content and .asciidoc or .txt files.
368-
* You can add headers to structure your text. The generated headers are shown in the examples below. The headers should fit into the overall structure of the generated wiki so level 1 header arent allowed, but the other header can be used at your judgement.
369+
* You can add headers to structure your text. The generated headers are shown in the examples below. The headers should fit into the overall structure of the generated wiki so level 1 header are not allowed, but the other header can be used at your judgement.
369370
* A list always needs an empty newline between the last row and the list.
370371
* Use asciidoc style of links
371372

engine/wikiRunner.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import { Runner } from "./runner";
22
import { Playbook } from "./playbook";
3+
import { RunCommand } from "./run_command";
34
import * as fs from "fs";
45
import * as path from "path";
56
import * as ejs from "ejs";
67

78
export abstract class WikiRunner extends Runner {
89

910
public outputPathTutorial: string;
11+
public commandCntMap = new Map();
12+
13+
protected readonly INSTALLED_TOOLS: string = "installedTools";
1014
protected fileTypeMap = new Map([ [".java", "java"],[".ts", "typescript"],
1115
[".js", "javascript"], [".html", "html"],
1216
[".scss", "css"], [".asciidoc", "asciidoc"], ]);
13-
protected readonly INSTALLED_TOOLS: string = "installedTools";
17+
1418

1519

1620
init(playbook: Playbook): void {
1721
let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false)
1822
this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true);
1923
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory()));
2024
this.setVariable(this.INSTALLED_TOOLS, "");
25+
for(let i = 0; i< playbook.steps.length; i++){
26+
this.commandCntMap.set(i, playbook.steps[i].lines.length-1);
27+
}
2128
}
2229

2330
async destroy(playbook: Playbook): Promise<void> {
@@ -31,4 +38,22 @@ export abstract class WikiRunner extends Runner {
3138
fs.writeFileSync(tempFile, result, { flag: "a" });
3239
}
3340

41+
protected checkForText(runCommand: RunCommand): string{
42+
return runCommand.lineIndex == 0
43+
? runCommand.text
44+
: undefined;
45+
}
46+
47+
protected checkForTitle(runCommand: RunCommand): string{
48+
return runCommand.lineIndex == 0
49+
? runCommand.stepTitle
50+
: undefined;
51+
}
52+
53+
protected checkForTextAfter(runCommand: RunCommand): string{
54+
return this.commandCntMap.get(runCommand.stepIndex) == runCommand.lineIndex
55+
? runCommand.textAfter
56+
: undefined;
57+
}
58+
3459
}

runners/console/index.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -941,16 +941,6 @@ export class Console extends Runner {
941941
for(let asyncProcess of this.asyncProcesses) {
942942
killProcessesRecursively(systemProcesses, asyncProcess.pid);
943943
}
944-
}
945-
for(let proc of systemProcesses){
946-
if(path.normalize(proc.path).includes(path.normalize(this.getWorkingDirectory()))){
947-
try {
948-
process.kill(proc.pid);
949-
} catch(e) {
950-
console.error("Error killing process "+proc.name+" with id: " + proc.pid , e);
951-
}
952-
}
953-
}
954944
//Check if there are still running processes on the given ports
955945
// Maybe not needed anymore can be deleted and the function documentation should be updated
956946
for(let asyncProcess of this.asyncProcesses.reverse()) {
@@ -965,9 +955,17 @@ export class Console extends Runner {
965955
}
966956
}
967957
}
968-
969-
958+
for(let proc of systemProcesses){
959+
if(path.normalize(proc.path).includes(path.normalize(this.getWorkingDirectory()))){
960+
try {
961+
process.kill(proc.pid);
962+
} catch(e) {
963+
console.error("Error killing process "+proc.name+" with id: " + proc.pid , e);
964+
}
965+
}
966+
}
970967
}
968+
}
971969

972970
private async cleanUp(): Promise<void> {
973971
await this.killAsyncProcesses();

0 commit comments

Comments
 (0)