diff --git a/documentation/Functions.md b/documentation/Functions.md index 0b0a65c1..9ef2396e 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -1,3 +1,42 @@ -You can use the following function: +## Functions +The following functions are already implemented: * installDevonIde -* installCobiGen \ No newline at end of file +* installCobiGen +* createProject +* cobiGenJava + +*** + +### installDevonIde +#### parameter +1. The tools you want to install within the devonfw ide: string array +#### example +installDevonfwIde(["java","mvn"]) + +*** + +### installCobiGen +#### parameter +* No parameters +#### example +installCobiGen() + +*** + +### cobiGenJava +#### parameter +1. The path to the java file you want to generate code for: string +2. The numbers that represent the templates that CobiGen uses to generate code: int array +#### example +cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) + + +*** + +### createDevon4jProject +#### parameter +1. The project name +#### example +createDevon4jProject("cobigenexample") + +*** diff --git a/runners/console/index.ts b/runners/console/index.ts index 540222b0..bb1219db 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -60,6 +60,21 @@ export class Console extends Runner { return result; } + runCreateDevon4jProject(step: Step, command: Command): RunResult { + let result = new RunResult(); + result.returnCode = 0; + + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main") + let projectName = command.parameters[0]; + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("devon java create com.example.application." + projectName, workspaceDir, result); + } else { + this.executeCommandSync("~/.devon/devon java create com.example.application." + projectName, workspaceDir, result); + } + + return result; + } + runCobiGenJava(step: Step, command: Command): RunResult { return null; } @@ -89,7 +104,20 @@ export class Console extends Runner { } async assertCobiGenJava(step: Step, command: Command, result: RunResult) { - console.log("assertCobiGenJava"); + console.log("there is no assertion yet for the cobiGenJava command"); + } + + async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) { + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); + + new Assertions() + .noErrorCode(result) + .noException(result) + .directoryExits(path.join(workspaceDir, command.parameters[0])) + .directoryExits(path.join(workspaceDir, command.parameters[0], "api", "src", "main", "java")) + .directoryExits(path.join(workspaceDir, command.parameters[0], "core", "src", "main", "java")) + .directoryExits(path.join(workspaceDir, command.parameters[0], "server", "src", "main", "java")) + .fileExits(path.join(workspaceDir, command.parameters[0], "core", "src", "main", "java", "com", "example", "application", command.parameters[0], "SpringBootApp.java")); } private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {