Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/wikiRunnerExecuteCommand #277

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions runners/wikiConsole/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,35 @@ export class WikiConsole extends WikiRunner {

return null;
}

runExecuteCommand(runCommand: RunCommand): RunResult{
let text = this.checkForText(runCommand);
let title = this.checkForTitle(runCommand);
let textAfter = this.checkForTextAfter(runCommand);
let currentdir = path.relative(this.getWorkingDirectory(), this.getVariable(this.WORKSPACE_DIRECTORY));
let windowsCommand = runCommand.command.parameters[0];
let linuxCommand = runCommand.command.parameters[1];
let dir = (runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].dir)
? runCommand.command.parameters[2].dir
: undefined;
let async = (runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].async)
? runCommand.command.parameters[2].async
: false;
let args = (runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].args)
? runCommand.command.parameters[2].args.join(" ")
: undefined;
let port = (runCommand.command.parameters.length > 3 && runCommand.command.parameters[3].port)
? runCommand.command.parameters[3].port
: undefined;
let appPath = (runCommand.command.parameters.length > 3 && runCommand.command.parameters[3].path)
? runCommand.command.parameters[3].path
: undefined;

this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "executeCommand.asciidoc"),
{windowsCommand: windowsCommand, linuxCommand: linuxCommand, dir: dir, async: async, args: args,
port: port, appPath: appPath, currentdir: currentdir, title: title, text: text, textAfter: textAfter});

return null;
}
}

33 changes: 33 additions & 0 deletions runners/wikiConsole/templates/executeCommand.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%if(title){%>== <%- title; %>
<%if(text){%><%- text; %><%}%><%}else{%>

=== Execute a command
<%if(text){%><%- text; %><%}%>

==== Execute a command in a command prompt
First, you need to open a command prompt in your current Workspace. For Windows, you can use Powershell and on Linux, you can use the Terminal.
<% if(async){ %>The command wil start a server so that you have to open a new command prompt, that will be blocked while the server is running. <% } %>
Your current working folder should be *<startingFolder><% if(currentdir){ %>/<%= currentdir; %><%}%>*.
<% if(dir){ %>
The command will be executed in the folder *<startingFolder><% if(currentdir){ %>/<%= currentdir; %><% } %>/<%= dir; %>*. If the folders are not present, you maybe missed a wiki chapter or you have to create them and change your directory.<%}%>

.Operating system
. Windows +
Then execute the command `<%- windowsCommand; %><% if(args){ %> <%- args; %><%}%>`.
. Linux and macOS +
Then execute the command `<%- linuxCommand; %><% if(args){ %> <%- args; %><%}%>`.

<% if(port){ %>

==== Startup Assertion

You can check if the server is running correctly by checking if `localhost:<%= port; %>/<%= appPath; %>` is accessible by either using a tool like `curl`, `Postman` or simply accessing the service via your webbrowser.

Example: `curl -Is localhost:<%= port; %>/<%= appPath; %> | head -n 1`

This command should return an `200 OK` header if the service is available.

<% } %>

<%if(textAfter){%><%- textAfter; %><%}%>

2 changes: 1 addition & 1 deletion runners/wikiConsole/templates/runServerJava.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This command will start the Java server.

You can check if the server is running correctly by checking if `localhost:<%= port; %>/<%= app_path; %>` is accessible by either using a tool like `curl`, `Postman` or simply accessing the service via your webbrowser.

Example: `curl -Is localhost:<%= port; %>/<%app_path%> | head -n 1`
Example: `curl -Is localhost:<%= port; %>/<%= app_path; %> | head -n 1`

This command should return an `200 OK` header if the service is available.

Expand Down