Skip to content

Commit a31e110

Browse files
authored
Merge pull request #38 from GuentherJulian/feature/consoleCreateProject
Feature/consoleCreateProject
2 parents e9e4981 + 0f7de41 commit a31e110

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

documentation/Functions.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1-
You can use the following function:
1+
## Functions
2+
The following functions are already implemented:
23
* installDevonIde
3-
* installCobiGen
4+
* installCobiGen
5+
* createProject
6+
* cobiGenJava
7+
8+
***
9+
10+
### installDevonIde
11+
#### parameter
12+
1. The tools you want to install within the devonfw ide: string array
13+
#### example
14+
installDevonfwIde(["java","mvn"])
15+
16+
***
17+
18+
### installCobiGen
19+
#### parameter
20+
* No parameters
21+
#### example
22+
installCobiGen()
23+
24+
***
25+
26+
### cobiGenJava
27+
#### parameter
28+
1. The path to the java file you want to generate code for: string
29+
2. The numbers that represent the templates that CobiGen uses to generate code: int array
30+
#### example
31+
cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8])
32+
33+
34+
***
35+
36+
### createDevon4jProject
37+
#### parameter
38+
1. The project name
39+
#### example
40+
createDevon4jProject("cobigenexample")
41+
42+
***

runners/console/index.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ export class Console extends Runner {
6060
return result;
6161
}
6262

63+
runCreateDevon4jProject(step: Step, command: Command): RunResult {
64+
let result = new RunResult();
65+
result.returnCode = 0;
66+
67+
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main")
68+
let projectName = command.parameters[0];
69+
if(this.platform == ConsolePlatform.WINDOWS) {
70+
this.executeCommandSync("devon java create com.example.application." + projectName, workspaceDir, result);
71+
} else {
72+
this.executeCommandSync("~/.devon/devon java create com.example.application." + projectName, workspaceDir, result);
73+
}
74+
75+
return result;
76+
}
77+
6378
runCobiGenJava(step: Step, command: Command): RunResult {
6479
return null;
6580
}
@@ -89,7 +104,20 @@ export class Console extends Runner {
89104
}
90105

91106
async assertCobiGenJava(step: Step, command: Command, result: RunResult) {
92-
console.log("assertCobiGenJava");
107+
console.log("there is no assertion yet for the cobiGenJava command");
108+
}
109+
110+
async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) {
111+
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
112+
113+
new Assertions()
114+
.noErrorCode(result)
115+
.noException(result)
116+
.directoryExits(path.join(workspaceDir, command.parameters[0]))
117+
.directoryExits(path.join(workspaceDir, command.parameters[0], "api", "src", "main", "java"))
118+
.directoryExits(path.join(workspaceDir, command.parameters[0], "core", "src", "main", "java"))
119+
.directoryExits(path.join(workspaceDir, command.parameters[0], "server", "src", "main", "java"))
120+
.fileExits(path.join(workspaceDir, command.parameters[0], "core", "src", "main", "java", "com", "example", "application", command.parameters[0], "SpringBootApp.java"));
93121
}
94122

95123
private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {

0 commit comments

Comments
 (0)