From 9b17e133ef74e3be72da64420218f7495a76853e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Mon, 30 Nov 2020 09:44:46 +0100 Subject: [PATCH 1/8] new branch for feature createProject for console runner --- runners/console/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runners/console/index.ts b/runners/console/index.ts index 540222b0..8a9a1c80 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -60,6 +60,13 @@ export class Console extends Runner { return result; } + runCreateProject(step: Step, command: Command): RunResult { + let result = new RunResult(); + result.returnCode = 0; + + return result; + } + runCobiGenJava(step: Step, command: Command): RunResult { return null; } @@ -92,6 +99,10 @@ export class Console extends Runner { console.log("assertCobiGenJava"); } + async assertCreateProject(step: Step, command: Command, result: RunResult) { + console.log("assertCreateProject"); + } + private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; From 3bcaacb3216ee51933d2ce67fa26decbdb451a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Mon, 30 Nov 2020 10:48:45 +0100 Subject: [PATCH 2/8] implemented command createProject in console runner --- runners/console/index.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 8a9a1c80..bd94b676 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -64,6 +64,13 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main") + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], workspaceDir, result); + } else { + this.executeCommandSync("~/.devon/devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], path.join(this.getWorkingDirectory(), "devonfw"), result); + } + return result; } @@ -100,7 +107,19 @@ export class Console extends Runner { } async assertCreateProject(step: Step, command: Command, result: RunResult) { - console.log("assertCreateProject"); + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); + + let assert = new Assertions() + .noErrorCode(result) + .noException(result) + .directoryExits(path.join(workspaceDir, command.parameters[1])); + + if(command.parameters[0] == "java") { + assert.directoryExits(path.join(workspaceDir, command.parameters[1], "api", "src", "main", "java")) + .directoryExits(path.join(workspaceDir, command.parameters[1], "core", "src", "main", "java")) + .directoryExits(path.join(workspaceDir, command.parameters[1], "server", "src", "main", "java")) + .fileExits(path.join(workspaceDir, command.parameters[1], "core", "src", "main", "java", "com", "example", "application", command.parameters[1], "SpringBootApp.java")); + } } private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { From 98c4b0a509505875a641ce915d17bb17fd605c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Mon, 30 Nov 2020 11:00:36 +0100 Subject: [PATCH 3/8] modified command createProject in console runner --- runners/console/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index bd94b676..5365b2aa 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -68,7 +68,7 @@ export class Console extends Runner { if(this.platform == ConsolePlatform.WINDOWS) { this.executeCommandSync("devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], workspaceDir, result); } else { - this.executeCommandSync("~/.devon/devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], path.join(this.getWorkingDirectory(), "devonfw"), result); + this.executeCommandSync("~/.devon/devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], workspaceDir, result); } return result; @@ -108,7 +108,7 @@ export class Console extends Runner { async assertCreateProject(step: Step, command: Command, result: RunResult) { let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); - + let assert = new Assertions() .noErrorCode(result) .noException(result) From 2cb0213bcb0c43f000d004f78bab865208047e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Mon, 30 Nov 2020 11:07:39 +0100 Subject: [PATCH 4/8] changed list of functions in documentation --- documentation/Functions.md | 45 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 0b0a65c1..c2d1c774 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -1,3 +1,44 @@ -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]) + + +*** + +### createProject +#### parameter +1. the programming language that you will use for this project +2. the project name + +#### example +createProject("java","cobigenexample") + +*** From 997bd28246b63dbf2e46b238f1abe95e8cd6c445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Tue, 1 Dec 2020 12:17:30 +0100 Subject: [PATCH 5/8] changed createProject command in console runner --- documentation/Functions.md | 4 ++-- runners/console/index.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index c2d1c774..388be734 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -35,10 +35,10 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createProject #### parameter -1. the programming language that you will use for this project +1. the template used for project generation 2. the project name #### example -createProject("java","cobigenexample") +createProject("devon4j","cobigenexample") *** diff --git a/runners/console/index.ts b/runners/console/index.ts index 5365b2aa..40f45c63 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -65,10 +65,17 @@ export class Console extends Runner { result.returnCode = 0; let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main") - if(this.platform == ConsolePlatform.WINDOWS) { - this.executeCommandSync("devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], workspaceDir, result); + let template = command.parameters[0]; + let projectName = command.parameters[1]; + if(template == "devon4j") { + 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); + } } else { - this.executeCommandSync("~/.devon/devon " + command.parameters[0] + " create com.example.application." + command.parameters[1], workspaceDir, result); + // TODO: implement generation of devon4ng, devon4node and devon4net projects + result.exceptions.push(new Error("template not supported: " + template)); } return result; @@ -114,7 +121,7 @@ export class Console extends Runner { .noException(result) .directoryExits(path.join(workspaceDir, command.parameters[1])); - if(command.parameters[0] == "java") { + if(command.parameters[0] == "devon4j") { assert.directoryExits(path.join(workspaceDir, command.parameters[1], "api", "src", "main", "java")) .directoryExits(path.join(workspaceDir, command.parameters[1], "core", "src", "main", "java")) .directoryExits(path.join(workspaceDir, command.parameters[1], "server", "src", "main", "java")) From 8b4579629db7f177cf45e5de9e98ccad65087b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Thu, 3 Dec 2020 13:21:14 +0100 Subject: [PATCH 6/8] changed method from createProject to createDevon4jProject --- documentation/Functions.md | 7 +++---- runners/console/index.ts | 33 ++++++++++++--------------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 388be734..25b8eeda 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -33,12 +33,11 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) *** -### createProject +### createDevon4jProject #### parameter -1. the template used for project generation -2. the project name +1. the project name #### example -createProject("devon4j","cobigenexample") +createDevon4jProject("cobigenexample") *** diff --git a/runners/console/index.ts b/runners/console/index.ts index 40f45c63..9864d107 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -60,22 +60,16 @@ export class Console extends Runner { return result; } - runCreateProject(step: Step, command: Command): RunResult { + runCreateDevon4jProject(step: Step, command: Command): RunResult { let result = new RunResult(); result.returnCode = 0; let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main") - let template = command.parameters[0]; - let projectName = command.parameters[1]; - if(template == "devon4j") { - 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); - } + let projectName = command.parameters[0]; + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("devon java create com.example.application." + projectName, workspaceDir, result); } else { - // TODO: implement generation of devon4ng, devon4node and devon4net projects - result.exceptions.push(new Error("template not supported: " + template)); + this.executeCommandSync("~/.devon/devon java create com.example.application." + projectName, workspaceDir, result); } return result; @@ -113,20 +107,17 @@ export class Console extends Runner { console.log("assertCobiGenJava"); } - async assertCreateProject(step: Step, command: Command, result: RunResult) { + async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) { let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); - let assert = new Assertions() + new Assertions() .noErrorCode(result) .noException(result) - .directoryExits(path.join(workspaceDir, command.parameters[1])); - - if(command.parameters[0] == "devon4j") { - assert.directoryExits(path.join(workspaceDir, command.parameters[1], "api", "src", "main", "java")) - .directoryExits(path.join(workspaceDir, command.parameters[1], "core", "src", "main", "java")) - .directoryExits(path.join(workspaceDir, command.parameters[1], "server", "src", "main", "java")) - .fileExits(path.join(workspaceDir, command.parameters[1], "core", "src", "main", "java", "com", "example", "application", command.parameters[1], "SpringBootApp.java")); - } + .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) { From b48df03cc3f3f254ea86d4c691bfa7b2c2d5ca44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Thu, 3 Dec 2020 13:39:37 +0100 Subject: [PATCH 7/8] removed empty line in wiki --- documentation/Functions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 25b8eeda..2a520c97 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -36,7 +36,6 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createDevon4jProject #### parameter 1. the project name - #### example createDevon4jProject("cobigenexample") From 0f7de41689c51113b50c4e4c858a5ccb7cf27338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20G=C3=BCnther?= Date: Fri, 4 Dec 2020 11:35:58 +0100 Subject: [PATCH 8/8] changed log message in assertCobiGen --- documentation/Functions.md | 2 +- runners/console/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 2a520c97..9ef2396e 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -35,7 +35,7 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createDevon4jProject #### parameter -1. the project name +1. The project name #### example createDevon4jProject("cobigenexample") diff --git a/runners/console/index.ts b/runners/console/index.ts index 9864d107..bb1219db 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -104,7 +104,7 @@ 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) {