Skip to content

Commit 973ece8

Browse files
committed
devonfw-tutorials#183 wikiRunner/createDevon4ngProject
1 parent 48340c3 commit 973ece8

File tree

2 files changed

+121
-2
lines changed

2 files changed

+121
-2
lines changed

runners/wikiConsole/index.ts

+106-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,119 @@ export class WikiConsole extends WikiRunner {
88

99
init(playbook: Playbook): void {
1010
super.init(playbook);
11+
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory()));
1112
}
1213

1314
async destroy(playbook: Playbook): Promise<void> {
15+
if(playbook.conclusion) {
16+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "conclusion.asciidoc"), { conclusion: playbook.conclusion});
17+
}
1418
super.destroy(playbook);
1519
}
1620

1721
runInstallDevonfwIde(runCommand: RunCommand): RunResult {
1822
let tools = runCommand.command.parameters[0].join(" ");
19-
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools })
23+
let version = "";
24+
if(runCommand.command.parameters.length == 2) {
25+
version = runCommand.command.parameters[1];
26+
}
27+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "installDevonfwIde.asciidoc"), { tools: tools, version:version })
28+
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"));
2029
return null;
2130
}
22-
}
31+
32+
33+
runChangeFile(runCommand: RunCommand): RunResult{
34+
let workspacePath = this.getVariable(this.workspaceDirectory).replace(/\\/g, "/");
35+
let filePath = path.join(workspacePath,runCommand.command.parameters[0]);
36+
let fileName = path.basename(runCommand.command.parameters[0]);
37+
let contentPath, contentString;
38+
if(runCommand.command.parameters[1].fileConsole || runCommand.command.parameters[1].contentConsole){
39+
contentPath = runCommand.command.parameters[1].fileConsole;
40+
contentString = runCommand.command.parameters[1].contentConsole;
41+
}else{
42+
contentPath = runCommand.command.parameters[1].file;
43+
contentString = runCommand.command.parameters[1].content;
44+
}
45+
contentPath = contentPath
46+
? path.join(this.getPlaybookPath(), contentPath)
47+
: undefined;
48+
let contentFile = contentPath
49+
? path.basename(contentPath)
50+
: undefined;
51+
let placeholder = runCommand.command.parameters[1].placeholder;
52+
let lineNumber = runCommand.command.parameters[1].lineNumber;
53+
54+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "changeFile.asciidoc"), {filePath : filePath,
55+
contentPath: contentPath, contentString: contentString, placeholder: placeholder, lineNumber: lineNumber, fileName: fileName, contentFile: contentFile});
56+
return null;
57+
}
58+
59+
60+
runRunServerJava(runCommand: RunCommand): RunResult {
61+
let server_path = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
62+
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 })
63+
return null;
64+
}
65+
66+
runNpmInstall(runCommand: RunCommand): RunResult {
67+
let projectPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
68+
let npmCommand = {
69+
"name": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].name) ? runCommand.command.parameters[1].name : undefined,
70+
"global": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].global) ? runCommand.command.parameters[1].global : false,
71+
"args": (runCommand.command.parameters.length > 1 && runCommand.command.parameters[1].args) ? runCommand.command.parameters[1].args.join(" ") : undefined
72+
};
73+
74+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "npmInstall.asciidoc"), { projectPath: projectPath, npmCommand: npmCommand });
75+
return null;
76+
}
77+
78+
runCloneRepository(runCommand: RunCommand): RunResult {
79+
let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
80+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "cloneRepository.asciidoc"), { directoryPath: directoryPath, url: runCommand.command.parameters[1] });
81+
return null;
82+
}
83+
84+
runDownloadFile(runCommand: RunCommand): RunResult{
85+
let url = runCommand.command.parameters[0];
86+
let fileName = runCommand.command.parameters[1];
87+
let dir = runCommand.command.parameters[2];
88+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "downloadFile.asciidoc"), {url: url, dir: dir, fileName: fileName});
89+
90+
return null;
91+
}
92+
93+
runBuildNg(runCommand: RunCommand): RunResult {
94+
let angularPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
95+
let outputPath = runCommand.command.parameters.length < 1 ? runCommand.command.parameters[1] : "";
96+
this.renderWiki(path.join(this.getRunnerDirectory(), "template", "buildNg.asciidoc"), {angularPath: angularPath, outputPath: outputPath});
97+
98+
return null;
99+
}
100+
101+
runDockerCompose(runCommand: RunCommand): RunResult {
102+
let dir = runCommand.command.parameters[0];
103+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "dockerCompose.asciidoc"), { dir: dir, port: runCommand.command.parameters[1].port, app_path: runCommand.command.parameters[1].path })
104+
return null;
105+
}
106+
107+
runCreateFolder(runCommand: RunCommand): RunResult {
108+
let folderPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
109+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createFolder.asciidoc"), { folderPath: folderPath });
110+
return null;
111+
}
112+
113+
runBuildJava(runCommand: RunCommand): RunResult {
114+
let directoryPath = path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]);
115+
let skipTest = (runCommand.command.parameters.length == 2 && runCommand.command.parameters[1] == true) ? false : true;
116+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "buildJava.asciidoc"), { directoryPath: directoryPath, skipTest: skipTest });
117+
return null;
118+
}
119+
120+
runCreateDevon4ngProject(runCommand: RunCommand): RunResult {
121+
let cdCommand = runCommand.command.parameters[1];
122+
let ngParams = runCommand.command.parameters.length > 2 && (runCommand.command.parameters[2] instanceof Array) ? runCommand.command.parameters[2].join(" ") : "";
123+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4ngProject.asciidoc"), {cdCommand: cdCommand, projectName: runCommand.command.parameters[0], ngParams: ngParams})
124+
return null;
125+
}
126+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
== Create devon4ng project
2+
3+
<% if (cdCommand) { %>
4+
5+
=== Prerequisites
6+
7+
As the project should be created at `<%= cdCommand; %>`, make sure that this directory exists before proceeding with the next step.
8+
9+
<% } %>
10+
11+
=== Creating the Angular project
12+
13+
Use the `ng` command provided by the `devonfw-ide` to create the project <%= projectName; %>:
14+
15+
`devon ng create <%= projectName; %><% if(ngParams){ %><%= ngParams; %><% } %>`

0 commit comments

Comments
 (0)