From 4c794fc87b522add3ca12f5e032d1015c3878f2b Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:14:03 +0100 Subject: [PATCH 01/55] "tutorial repo" --- playbooks/cobigen-cli/index.asciidoc | 20 ---------- playbooks/tutorials | 1 + runners/katacoda/index.ts | 37 ++++++++++++++++--- runners/katacoda/templates/cd.md | 4 ++ runners/katacoda/templates/createProject.md | 15 ++++++++ runners/katacoda/templates/installCobiGen.md | 1 + .../katacoda/templates/installDevonfwIde.md | 2 + 7 files changed, 55 insertions(+), 25 deletions(-) delete mode 100644 playbooks/cobigen-cli/index.asciidoc create mode 160000 playbooks/tutorials create mode 100644 runners/katacoda/templates/cd.md create mode 100644 runners/katacoda/templates/createProject.md diff --git a/playbooks/cobigen-cli/index.asciidoc b/playbooks/cobigen-cli/index.asciidoc deleted file mode 100644 index b30e8e16..00000000 --- a/playbooks/cobigen-cli/index.asciidoc +++ /dev/null @@ -1,20 +0,0 @@ -= CobiGen Cli -==== -CobiGen is a generic incremental code generator. It allows you build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class. - -CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands. In this scenario, you will learn how to install and use the cobigen cli inside a java project. - -More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html -==== - -To use the cobigen cli you first have to install the devonfw ide. You will find more information about devonfw on https://devonfw.com/website/pages/welcome/welcome.html. -[step] --- -installDevonfwIde([java,mvn]) --- - -Now, you have to download cobigen -[step] --- -installCobiGen() --- diff --git a/playbooks/tutorials b/playbooks/tutorials new file mode 160000 index 00000000..91ef1def --- /dev/null +++ b/playbooks/tutorials @@ -0,0 +1 @@ +Subproject commit 91ef1def56c10079e0c2db6058d9d29f72e34bf1 diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index e4f71979..6bdb333d 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -20,7 +20,8 @@ export class Katacoda extends Runner { private setupScripts: KatacodaSetupScript[] = []; private assetManager: KatacodaAssetManager; private setupDir: string; - + private currentDir: string = "/"; + init(playbook: Playbook): void { // create directory for katacoda tutorials if not exist this.createFolder(path.join(this.getOutputDirectory(), "katacoda/"), false) @@ -67,11 +68,13 @@ export class Katacoda extends Runner { runInstallDevonfwIde(step: Step, command: Command): RunResult { let params = command.parameters.replace(/\[/, "").replace("\]", "").replace(/,/, " ").replace(/vscode/,"").replace(/eclipse/, "").trim(); - + + let cdCommand = this.changeCurrentDir("/"); + // create script to download devonfw ide settings this.renderTemplate(path.join("scripts", "cloneDevonfwIdeSettings.sh"), path.join(this.setupDir, "cloneDevonfwIdeSettings.sh"), { tools: params, cloneDir: "/root/devonfw-settings/"}); - // add the script to the setup scripts for executing it at the beginning of the tutorial + this.setupScripts.push({ "name": "Clone devonfw IDE settings", "script": "cloneDevonfwIdeSettings.sh" @@ -81,7 +84,8 @@ export class Katacoda extends Runner { "title": "Install devonfw IDE", "text": "step" + this.stepsCount + ".md", }); - this.renderTemplate("installDevonfwIde.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter }); + this.renderTemplate("installDevonfwIde.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand}); + this.currentDir = this.currentDir + "devonfw"; return null; } @@ -90,10 +94,24 @@ export class Katacoda extends Runner { "title": "Install CobiGen", "text": "step" + this.stepsCount + ".md" }); - this.renderTemplate("installCobiGen.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter }); + this.renderTemplate("installCobiGen.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter}); + return null; } + runCreateProject(step: Step, command:Command): RunResult { + + let cdCommand = this.changeCurrentDir("/devonfw"); + this.steps.push({ + "title": "Create a new project", + "text": "step" + this.stepsCount + ".md" + }); + this.currentDir = this.currentDir + '/workspaces/main/cobigenexample'; + this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand }); + return null; + + } + private renderTemplate(name: string, targetPath: string, variables) { let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", name), 'utf8'); let result = ejs.render(template, variables); @@ -110,4 +128,13 @@ export class Katacoda extends Runner { this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false); } + + private changeCurrentDir(dir:string):string{ + if(this.currentDir == dir){ + return ""; + } + this.currentDir = dir; + let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); + return ejs.render(template, {dir: dir}); + } } \ No newline at end of file diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md new file mode 100644 index 00000000..882c54aa --- /dev/null +++ b/runners/katacoda/templates/cd.md @@ -0,0 +1,4 @@ + +You are currently not in the right folder. + +`cd <%= dir; %>`{{execute}} \ No newline at end of file diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md new file mode 100644 index 00000000..56787915 --- /dev/null +++ b/runners/katacoda/templates/createProject.md @@ -0,0 +1,15 @@ +<%= text; %> + +## Setting up your java project + +<%= cdCommand; %> + +Navigate to the 'workspaces/main/' folder in your devonfw installation directory. +`cd workspaces/main/`{{execute}} + +Now you can use devon to setup a java project for you by executing the following command. +`devon java create com.example.application.cobigenexample`{{execute}} + +Switch into the newly create project directory. +`cd cobigenexample/`{{execute}} +<%= textAfter; %> \ No newline at end of file diff --git a/runners/katacoda/templates/installCobiGen.md b/runners/katacoda/templates/installCobiGen.md index 041c1389..cb21dfa6 100644 --- a/runners/katacoda/templates/installCobiGen.md +++ b/runners/katacoda/templates/installCobiGen.md @@ -4,4 +4,5 @@ `devon cobigen`{{execute}} + <%= textAfter; %> \ No newline at end of file diff --git a/runners/katacoda/templates/installDevonfwIde.md b/runners/katacoda/templates/installDevonfwIde.md index f6e55f97..2170d4f3 100644 --- a/runners/katacoda/templates/installDevonfwIde.md +++ b/runners/katacoda/templates/installDevonfwIde.md @@ -2,6 +2,8 @@ ## devonfw setup +<%= cdCommand; %> + Create the directory where the devonfw ide will be installed. `mkdir devonfw`{{execute}} From 26eb021395b9b491bf37c7df4c82c9ad6dfb9e95 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:20:28 +0100 Subject: [PATCH 02/55] tutorial repo --- playbooks/tutorials | 1 - 1 file changed, 1 deletion(-) delete mode 160000 playbooks/tutorials diff --git a/playbooks/tutorials b/playbooks/tutorials deleted file mode 160000 index 91ef1def..00000000 --- a/playbooks/tutorials +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 91ef1def56c10079e0c2db6058d9d29f72e34bf1 From c154ca350c779c2c4afebec038fa5bc88c9d8c7c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:28:34 +0100 Subject: [PATCH 03/55] Update Playbook --- .gitmodules | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fd1b0c50 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "playbooks/playbooks/tutorials"] + path = playbooks/playbooks/tutorials + url = https://github.com/denise-khuu/tutorials.git From 85164613728f559233c442a592e4a05c38ade444 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:30:55 +0100 Subject: [PATCH 04/55] Playbook repo --- .gitmodules | 3 +++ playbooks/tutorials | 1 + 2 files changed, 4 insertions(+) create mode 160000 playbooks/tutorials diff --git a/.gitmodules b/.gitmodules index fd1b0c50..696bf0f6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "playbooks/playbooks/tutorials"] path = playbooks/playbooks/tutorials url = https://github.com/denise-khuu/tutorials.git +[submodule "playbooks/tutorials"] + path = playbooks/tutorials + url = https://github.com/denise-khuu/tutorials.git diff --git a/playbooks/tutorials b/playbooks/tutorials new file mode 160000 index 00000000..853d943b --- /dev/null +++ b/playbooks/tutorials @@ -0,0 +1 @@ +Subproject commit 853d943beaf813c07a70bd02b3de3f64deeec71b From a907100cfb5f1b564e1207b390b5e9e2827c766f Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 09:42:16 +0100 Subject: [PATCH 05/55] Feature add Project and Playbook repo --- engine/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/run.ts b/engine/run.ts index 436f5bf6..01cd9e03 100644 --- a/engine/run.ts +++ b/engine/run.ts @@ -43,7 +43,7 @@ class Run { parsePlaybooks() { let parser = new Parser(); - let playbooksDir = (this.args.get("playbooksDir")) || __dirname + "/../playbooks/"; + let playbooksDir = (this.args.get("playbooksDir")) || __dirname + "/../playbooks/tutorials/"; let playbookDirs = fs.readdirSync(playbooksDir); for (let index in playbookDirs) { let indexFile = playbooksDir + playbookDirs[index] + "/index.asciidoc"; From 2d992e9b894fea90b9e604452423124d0a04299c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 10:36:09 +0100 Subject: [PATCH 06/55] createProject --- engine/run.ts | 2 +- playbooks/.github/workflows/main.yml | 35 +++++ playbooks/.github/workflows/pr.yml | 18 +++ playbooks/LICENSE | 201 +++++++++++++++++++++++++++ playbooks/README.md | 1 + playbooks/cobigen-cli/index.asciidoc | 20 +++ playbooks/tutorials | 1 - runners/katacoda/index.ts | 3 + runners/katacoda/templates/cd.md | 2 +- 9 files changed, 280 insertions(+), 3 deletions(-) create mode 100644 playbooks/.github/workflows/main.yml create mode 100644 playbooks/.github/workflows/pr.yml create mode 100644 playbooks/LICENSE create mode 100644 playbooks/README.md create mode 100644 playbooks/cobigen-cli/index.asciidoc delete mode 160000 playbooks/tutorials diff --git a/engine/run.ts b/engine/run.ts index 01cd9e03..436f5bf6 100644 --- a/engine/run.ts +++ b/engine/run.ts @@ -43,7 +43,7 @@ class Run { parsePlaybooks() { let parser = new Parser(); - let playbooksDir = (this.args.get("playbooksDir")) || __dirname + "/../playbooks/tutorials/"; + let playbooksDir = (this.args.get("playbooksDir")) || __dirname + "/../playbooks/"; let playbookDirs = fs.readdirSync(playbooksDir); for (let index in playbookDirs) { let indexFile = playbooksDir + playbookDirs[index] + "/index.asciidoc"; diff --git a/playbooks/.github/workflows/main.yml b/playbooks/.github/workflows/main.yml new file mode 100644 index 00000000..360c36a5 --- /dev/null +++ b/playbooks/.github/workflows/main.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout tutorial-compiler + uses: actions/checkout@v2 + with: + repository: devonfw-forge/tutorial-compiler + + - name: Checkout playbooks + uses: actions/checkout@v2 + with: + repository: devonfw-forge/tutorials + path: playbooks + + - uses: actions/setup-node@v2-beta + + - name: install TS + run: npm install typescript + + - name: npm install + run: npm install + + - name: run buildRun.sh + run: sh buildRun.sh \ No newline at end of file diff --git a/playbooks/.github/workflows/pr.yml b/playbooks/.github/workflows/pr.yml new file mode 100644 index 00000000..db434569 --- /dev/null +++ b/playbooks/.github/workflows/pr.yml @@ -0,0 +1,18 @@ +name: PR + +on: + pull_request_target: + branches: [ main ] + + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: mshick/add-pr-comment@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + message: | + You can view the generated tutorials of this PR on https://www.katacoda.com/devonfw-dev in a few minutes. diff --git a/playbooks/LICENSE b/playbooks/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/playbooks/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/playbooks/README.md b/playbooks/README.md new file mode 100644 index 00000000..6a0584ab --- /dev/null +++ b/playbooks/README.md @@ -0,0 +1 @@ +# tutorials \ No newline at end of file diff --git a/playbooks/cobigen-cli/index.asciidoc b/playbooks/cobigen-cli/index.asciidoc new file mode 100644 index 00000000..b1178151 --- /dev/null +++ b/playbooks/cobigen-cli/index.asciidoc @@ -0,0 +1,20 @@ += CobiGen Cli +==== +CobiGen is a generic incremental code generator. It allows you build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class. + +CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands. In this scenario, you will learn how to install and use the cobigen cli inside a java project. + +More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html +==== + +To use the cobigen cli you first have to install the devonfw ide. You will find more information about devonfw on https://devonfw.com/website/pages/welcome/welcome.html. +[step] +-- +installDevonfwIde([java,mvn]) +-- + +Now, you have to download cobigen +[step] +-- +installCobiGen() +-- diff --git a/playbooks/tutorials b/playbooks/tutorials deleted file mode 160000 index 853d943b..00000000 --- a/playbooks/tutorials +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 853d943beaf813c07a70bd02b3de3f64deeec71b diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 6bdb333d..3fe39d72 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -130,6 +130,9 @@ export class Katacoda extends Runner { } private changeCurrentDir(dir:string):string{ + + let changeToDir: string; + if(this.currentDir == dir){ return ""; } diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index 882c54aa..fdc389c8 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,4 +1,4 @@ -You are currently not in the right folder. +We have to start at the right folder `cd <%= dir; %>`{{execute}} \ No newline at end of file From 664b7a7a39db3f748604b58c661a2c1ad028130b Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 10:51:34 +0100 Subject: [PATCH 07/55] createProject() and cd-Template --- runners/katacoda/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 3fe39d72..748615db 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -69,12 +69,13 @@ export class Katacoda extends Runner { runInstallDevonfwIde(step: Step, command: Command): RunResult { let params = command.parameters.replace(/\[/, "").replace("\]", "").replace(/,/, " ").replace(/vscode/,"").replace(/eclipse/, "").trim(); + // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir("/"); // create script to download devonfw ide settings this.renderTemplate(path.join("scripts", "cloneDevonfwIdeSettings.sh"), path.join(this.setupDir, "cloneDevonfwIdeSettings.sh"), { tools: params, cloneDir: "/root/devonfw-settings/"}); - // add the script to the setup scripts for executing it at the beginning of the tutorial + // add the script to the setup scripts for executing it at the beginning of the tutorial this.setupScripts.push({ "name": "Clone devonfw IDE settings", "script": "cloneDevonfwIdeSettings.sh" @@ -101,7 +102,9 @@ export class Katacoda extends Runner { runCreateProject(step: Step, command:Command): RunResult { + // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir("/devonfw"); + this.steps.push({ "title": "Create a new project", "text": "step" + this.stepsCount + ".md" @@ -131,12 +134,11 @@ export class Katacoda extends Runner { private changeCurrentDir(dir:string):string{ - let changeToDir: string; - if(this.currentDir == dir){ return ""; } this.currentDir = dir; + let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); return ejs.render(template, {dir: dir}); } From 081df1e26f0e96d67c10b0f3b78baaeeb7380b34 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:01:59 +0100 Subject: [PATCH 08/55] createProject() and cd-Template --- playbooks/cobigen-cli/index.asciidoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/playbooks/cobigen-cli/index.asciidoc b/playbooks/cobigen-cli/index.asciidoc index b1178151..60781290 100644 --- a/playbooks/cobigen-cli/index.asciidoc +++ b/playbooks/cobigen-cli/index.asciidoc @@ -18,3 +18,8 @@ Now, you have to download cobigen -- installCobiGen() -- +You are ready to create your first project +[step] +-- +installCobiGen() +-- From 67274b25117356cf2ed987f010e4e6b7a17d6d49 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:16:00 +0100 Subject: [PATCH 09/55] createProject() and cd-Template --- playbooks/cobigen-cli/index.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/cobigen-cli/index.asciidoc b/playbooks/cobigen-cli/index.asciidoc index 60781290..6a64dde7 100644 --- a/playbooks/cobigen-cli/index.asciidoc +++ b/playbooks/cobigen-cli/index.asciidoc @@ -21,5 +21,5 @@ installCobiGen() You are ready to create your first project [step] -- -installCobiGen() +createProject() -- From d7b309092f68aeda5a134972cde41267f2e3fbfa Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:38:04 +0100 Subject: [PATCH 10/55] Playbook --- playbooks/.github/workflows/main.yml | 35 ----- playbooks/.github/workflows/pr.yml | 18 --- playbooks/LICENSE | 201 --------------------------- playbooks/README.md | 1 - playbooks/cobigen-cli/index.asciidoc | 25 ---- 5 files changed, 280 deletions(-) delete mode 100644 playbooks/.github/workflows/main.yml delete mode 100644 playbooks/.github/workflows/pr.yml delete mode 100644 playbooks/LICENSE delete mode 100644 playbooks/README.md delete mode 100644 playbooks/cobigen-cli/index.asciidoc diff --git a/playbooks/.github/workflows/main.yml b/playbooks/.github/workflows/main.yml deleted file mode 100644 index 360c36a5..00000000 --- a/playbooks/.github/workflows/main.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - - workflow_dispatch: -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout tutorial-compiler - uses: actions/checkout@v2 - with: - repository: devonfw-forge/tutorial-compiler - - - name: Checkout playbooks - uses: actions/checkout@v2 - with: - repository: devonfw-forge/tutorials - path: playbooks - - - uses: actions/setup-node@v2-beta - - - name: install TS - run: npm install typescript - - - name: npm install - run: npm install - - - name: run buildRun.sh - run: sh buildRun.sh \ No newline at end of file diff --git a/playbooks/.github/workflows/pr.yml b/playbooks/.github/workflows/pr.yml deleted file mode 100644 index db434569..00000000 --- a/playbooks/.github/workflows/pr.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: PR - -on: - pull_request_target: - branches: [ main ] - - workflow_dispatch: -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: mshick/add-pr-comment@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - repo-token-user-login: 'github-actions[bot]' - message: | - You can view the generated tutorials of this PR on https://www.katacoda.com/devonfw-dev in a few minutes. diff --git a/playbooks/LICENSE b/playbooks/LICENSE deleted file mode 100644 index 261eeb9e..00000000 --- a/playbooks/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/playbooks/README.md b/playbooks/README.md deleted file mode 100644 index 6a0584ab..00000000 --- a/playbooks/README.md +++ /dev/null @@ -1 +0,0 @@ -# tutorials \ No newline at end of file diff --git a/playbooks/cobigen-cli/index.asciidoc b/playbooks/cobigen-cli/index.asciidoc deleted file mode 100644 index 6a64dde7..00000000 --- a/playbooks/cobigen-cli/index.asciidoc +++ /dev/null @@ -1,25 +0,0 @@ -= CobiGen Cli -==== -CobiGen is a generic incremental code generator. It allows you build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class. - -CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands. In this scenario, you will learn how to install and use the cobigen cli inside a java project. - -More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html -==== - -To use the cobigen cli you first have to install the devonfw ide. You will find more information about devonfw on https://devonfw.com/website/pages/welcome/welcome.html. -[step] --- -installDevonfwIde([java,mvn]) --- - -Now, you have to download cobigen -[step] --- -installCobiGen() --- -You are ready to create your first project -[step] --- -createProject() --- From 90b2c3f29d81fd269fecc9ad1b7d2d3468972f7c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:43:33 +0100 Subject: [PATCH 11/55] playbook --- .gitmodules | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 696bf0f6..00000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "playbooks/playbooks/tutorials"] - path = playbooks/playbooks/tutorials - url = https://github.com/denise-khuu/tutorials.git -[submodule "playbooks/tutorials"] - path = playbooks/tutorials - url = https://github.com/denise-khuu/tutorials.git From c2d6a08264fefeb04f903cfab29729b2ccd21b23 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 13:35:42 +0100 Subject: [PATCH 12/55] createProject added Comments --- .gitmodules | 3 +++ playbooks | 1 + runners/katacoda/index.ts | 10 ++++++++-- runners/katacoda/templates/createProject.md | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 playbooks diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..5e7eccc1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "playbooks"] + path = playbooks + url = https://github.com/denise-khuu/tutorials.git diff --git a/playbooks b/playbooks new file mode 160000 index 00000000..853d943b --- /dev/null +++ b/playbooks @@ -0,0 +1 @@ +Subproject commit 853d943beaf813c07a70bd02b3de3f64deeec71b diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 748615db..696ef8c9 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -86,7 +86,10 @@ export class Katacoda extends Runner { "text": "step" + this.stepsCount + ".md", }); this.renderTemplate("installDevonfwIde.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand}); + + //update current directory this.currentDir = this.currentDir + "devonfw"; + return null; } @@ -96,7 +99,6 @@ export class Katacoda extends Runner { "text": "step" + this.stepsCount + ".md" }); this.renderTemplate("installCobiGen.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter}); - return null; } @@ -109,7 +111,10 @@ export class Katacoda extends Runner { "title": "Create a new project", "text": "step" + this.stepsCount + ".md" }); + + //update current directory this.currentDir = this.currentDir + '/workspaces/main/cobigenexample'; + this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand }); return null; @@ -133,12 +138,13 @@ export class Katacoda extends Runner { } private changeCurrentDir(dir:string):string{ - + if(this.currentDir == dir){ return ""; } this.currentDir = dir; + //create template let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); return ejs.render(template, {dir: dir}); } diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md index 56787915..1dc342c6 100644 --- a/runners/katacoda/templates/createProject.md +++ b/runners/katacoda/templates/createProject.md @@ -12,4 +12,5 @@ Now you can use devon to setup a java project for you by executing the following Switch into the newly create project directory. `cd cobigenexample/`{{execute}} + <%= textAfter; %> \ No newline at end of file From 709f4b153f8f6fafc9fffe71f78584c7cc16c892 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 13:43:59 +0100 Subject: [PATCH 13/55] createProject and currentDir added --- runners/katacoda/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 696ef8c9..f1d669dc 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -144,7 +144,7 @@ export class Katacoda extends Runner { } this.currentDir = dir; - //create template + //create template to change directory let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); return ejs.render(template, {dir: dir}); } From dcd83e1e181c25e1d57fc0b58b8c26e35c26dbda Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 23 Nov 2020 14:10:13 +0100 Subject: [PATCH 14/55] createProject and currentDir --- playbooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks b/playbooks index 853d943b..a5d86b00 160000 --- a/playbooks +++ b/playbooks @@ -1 +1 @@ -Subproject commit 853d943beaf813c07a70bd02b3de3f64deeec71b +Subproject commit a5d86b00505eeef0009e720391a2be046f7852ff From 2921d99c7d7e150e5fa2c2ce6e51c2cbe412e688 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 14:29:10 +0100 Subject: [PATCH 15/55] index.asciidoc createProject added --- playbooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks b/playbooks index a5d86b00..01aa249b 160000 --- a/playbooks +++ b/playbooks @@ -1 +1 @@ -Subproject commit a5d86b00505eeef0009e720391a2be046f7852ff +Subproject commit 01aa249bf0c62026e8b9d9e75b728c9e3dce8970 From df3ed0b8dca024caa6891e03f61367775c247feb Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 15:56:05 +0100 Subject: [PATCH 16/55] merging problems solved --- runners/katacoda/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index e6723567..299b61b2 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -144,6 +144,7 @@ export class Katacoda extends Runner { this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand }); return null; + } private renderTemplate(name: string, targetPath: string, variables) { let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", name), 'utf8'); From eb6317d12fb9aa4f1e48f8962b41cb3eaab270c4 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:04:26 +0100 Subject: [PATCH 17/55] merging problems solved --- playbooks | 1 - runners/katacoda/index.ts | 13 ++----------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 160000 playbooks diff --git a/playbooks b/playbooks deleted file mode 160000 index 01aa249b..00000000 --- a/playbooks +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 01aa249bf0c62026e8b9d9e75b728c9e3dce8970 diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 299b61b2..b6174894 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -67,22 +67,13 @@ export class Katacoda extends Runner { } runInstallDevonfwIde(step: Step, command: Command): RunResult { -<<<<<<< HEAD - let params = command.parameters.replace(/\[/, "").replace("\]", "").replace(/,/, " ").replace(/vscode/,"").replace(/eclipse/, "").trim(); - - // generate template to change directory, if the current directory is not equal to the required start directory - let cdCommand = this.changeCurrentDir("/"); - - // create script to download devonfw ide settings - this.renderTemplate(path.join("scripts", "cloneDevonfwIdeSettings.sh"), path.join(this.setupDir, "cloneDevonfwIdeSettings.sh"), { tools: params, cloneDir: "/root/devonfw-settings/"}); - -======= + let cdCommand = this.changeCurrentDir("/"); + let tools = command.parameters[0].join(" ").replace(/vscode/,"").replace(/eclipse/, "").trim(); // create script to download devonfw ide settings this.renderTemplate(path.join("scripts", "cloneDevonfwIdeSettings.sh"), path.join(this.setupDir, "cloneDevonfwIdeSettings.sh"), { tools: tools, cloneDir: "/root/devonfw-settings/"}); ->>>>>>> 08f6c837bfbfd87f8ef9a13a7bab47d763ae0fbe // add the script to the setup scripts for executing it at the beginning of the tutorial this.setupScripts.push({ "name": "Clone devonfw IDE settings", From 322b704ee2c1dcc95d327c9481f5131cafc33a73 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:27:11 +0100 Subject: [PATCH 18/55] merging problems solved --- runners/console/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runners/console/index.ts b/runners/console/index.ts index a63478fa..ee52fcc4 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -39,6 +39,10 @@ export class Console extends Runner { return null; } + runCreateProject(){ + return null; + } + async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) { let installedTools = command.parameters[0]; @@ -62,6 +66,10 @@ export class Console extends Runner { console.log("assertCobiGenJava"); } + async assertCreateProject(step: Step, command: Command, result: RunResult) { + console.log("assertCobiGenJava"); + } + private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; From eaba1a1b10ee438656bf08c47704a690acbe6656 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:28:58 +0100 Subject: [PATCH 19/55] git modules deleted and added functions console/index.ts --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5e7eccc1..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "playbooks"] - path = playbooks - url = https://github.com/denise-khuu/tutorials.git From 6cd75902acfcf28524e88046f871f375229d47d9 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:36:18 +0100 Subject: [PATCH 20/55] git modules deleted and added functions console/index.ts --- 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 ee52fcc4..4de7b42c 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -42,7 +42,7 @@ export class Console extends Runner { runCreateProject(){ return null; } - + async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) { let installedTools = command.parameters[0]; @@ -67,7 +67,7 @@ export class Console extends Runner { } async assertCreateProject(step: Step, command: Command, result: RunResult) { - console.log("assertCobiGenJava"); + console.log("assertCreateProject"); } private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { From 8c981c18f3c8c8313ffe3de73b1e84a28d71044b Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:51:28 +0100 Subject: [PATCH 21/55] git modules deleted and added functions console/index.ts --- runners/katacoda/index.ts | 10 +++++----- runners/katacoda/templates/cd.md | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index b6174894..7019dcf4 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -20,7 +20,7 @@ export class Katacoda extends Runner { private setupScripts: KatacodaSetupScript[] = []; private assetManager: KatacodaAssetManager; private setupDir: string; - private currentDir: string = "/"; + private currentDir: string = "root"; init(playbook: Playbook): void { // create directory for katacoda tutorials if not exist @@ -67,7 +67,7 @@ export class Katacoda extends Runner { } runInstallDevonfwIde(step: Step, command: Command): RunResult { - let cdCommand = this.changeCurrentDir("/"); + let cdCommand = this.changeCurrentDir("root"); let tools = command.parameters[0].join(" ").replace(/vscode/,"").replace(/eclipse/, "").trim(); @@ -87,7 +87,7 @@ export class Katacoda extends Runner { this.renderTemplate("installDevonfwIde.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand}); //update current directory - this.currentDir = this.currentDir + "devonfw"; + this.currentDir = path.join(this.currentDir, "devonfw"); return null; } @@ -123,7 +123,7 @@ export class Katacoda extends Runner { runCreateProject(step: Step, command:Command): RunResult { // generate template to change directory, if the current directory is not equal to the required start directory - let cdCommand = this.changeCurrentDir("/devonfw"); + let cdCommand = this.changeCurrentDir(path.join("root", "devonfw")); this.steps.push({ "title": "Create a new project", @@ -131,7 +131,7 @@ export class Katacoda extends Runner { }); //update current directory - this.currentDir = this.currentDir + '/workspaces/main/cobigenexample'; + this.currentDir = path.join(this.currentDir, "workspace", "main","cobigenexample"); this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand }); return null; diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index fdc389c8..b620694b 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,4 +1,5 @@ -We have to start at the right folder +We have to start at the folder '<%= dir; %>'. +The following command will lead you to the right folder. `cd <%= dir; %>`{{execute}} \ No newline at end of file From 4ae350e9a8c51550f8551e0dc079c296c50cd167 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 17:08:08 +0100 Subject: [PATCH 22/55] currentDir changed with path.join --- runners/katacoda/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 7019dcf4..bc29c7e6 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -20,7 +20,7 @@ export class Katacoda extends Runner { private setupScripts: KatacodaSetupScript[] = []; private assetManager: KatacodaAssetManager; private setupDir: string; - private currentDir: string = "root"; + private currentDir: string = "/root"; init(playbook: Playbook): void { // create directory for katacoda tutorials if not exist From 1e6534c7f865eb90e3fa887ae9bcf1b0b6b13efc Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 17:11:25 +0100 Subject: [PATCH 23/55] currentDir changed with path.join --- runners/katacoda/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index bc29c7e6..34d438d7 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -67,7 +67,7 @@ export class Katacoda extends Runner { } runInstallDevonfwIde(step: Step, command: Command): RunResult { - let cdCommand = this.changeCurrentDir("root"); + let cdCommand = this.changeCurrentDir("/root"); let tools = command.parameters[0].join(" ").replace(/vscode/,"").replace(/eclipse/, "").trim(); From e69f8a617f151a2aab99b1234f16aef12f9d52fb Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Tue, 24 Nov 2020 17:19:42 +0100 Subject: [PATCH 24/55] currentDir changed with path.join --- runners/katacoda/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 34d438d7..bee72959 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -123,7 +123,7 @@ export class Katacoda extends Runner { runCreateProject(step: Step, command:Command): RunResult { // generate template to change directory, if the current directory is not equal to the required start directory - let cdCommand = this.changeCurrentDir(path.join("root", "devonfw")); + let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); this.steps.push({ "title": "Create a new project", From f3c07eb8fdf351fc6fe160c6ed6155d918e8a10e Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 08:51:00 +0100 Subject: [PATCH 25/55] added name and language variables --- runners/katacoda/index.ts | 7 ++++++- runners/katacoda/templates/createProject.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index bee72959..cb6d75e2 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -122,6 +122,11 @@ export class Katacoda extends Runner { runCreateProject(step: Step, command:Command): RunResult { + let params = command.parameters; + let language = params[0]; + let name = params[1]; + + // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); @@ -133,7 +138,7 @@ export class Katacoda extends Runner { //update current directory this.currentDir = path.join(this.currentDir, "workspace", "main","cobigenexample"); - this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand }); + this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, name : name, language: language }); return null; } diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md index 1dc342c6..433bc43c 100644 --- a/runners/katacoda/templates/createProject.md +++ b/runners/katacoda/templates/createProject.md @@ -8,7 +8,7 @@ Navigate to the 'workspaces/main/' folder in your devonfw installation directory `cd workspaces/main/`{{execute}} Now you can use devon to setup a java project for you by executing the following command. -`devon java create com.example.application.cobigenexample`{{execute}} +`devon <%= language; %> create com.example.application.<%= name; %>`{{execute}} Switch into the newly create project directory. `cd cobigenexample/`{{execute}} From ceb5f799d081010e44a289e0694073dadba623f1 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 08:53:41 +0100 Subject: [PATCH 26/55] added name and language variables --- runners/katacoda/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index cb6d75e2..cd5fcd58 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -126,7 +126,6 @@ export class Katacoda extends Runner { let language = params[0]; let name = params[1]; - // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); From dde0695761ba2b5778008dbd74927890a1fb1abc Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:20:50 +0100 Subject: [PATCH 27/55] project name and language are added --- runners/katacoda/index.ts | 2 +- runners/katacoda/templates/createProject.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index cd5fcd58..2188d390 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -137,7 +137,7 @@ export class Katacoda extends Runner { //update current directory this.currentDir = path.join(this.currentDir, "workspace", "main","cobigenexample"); - this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, name : name, language: language }); + this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, language: language, name : name}); return null; } diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md index 433bc43c..ebbef46b 100644 --- a/runners/katacoda/templates/createProject.md +++ b/runners/katacoda/templates/createProject.md @@ -7,7 +7,7 @@ Navigate to the 'workspaces/main/' folder in your devonfw installation directory. `cd workspaces/main/`{{execute}} -Now you can use devon to setup a java project for you by executing the following command. +Now you can use devon to setup a <%= language; %> project for you by executing the following command. `devon <%= language; %> create com.example.application.<%= name; %>`{{execute}} Switch into the newly create project directory. From 0c7cae6ae8ba214075226d7c489e2d33417abd8a Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:28:47 +0100 Subject: [PATCH 28/55] cd.md changed the instructions --- runners/katacoda/templates/cd.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index b620694b..a27d8f6e 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,5 +1,4 @@ -We have to start at the folder '<%= dir; %>'. -The following command will lead you to the right folder. +Please change the folder to <% dir: %> `cd <%= dir; %>`{{execute}} \ No newline at end of file From 3fcff7319c0c9f573be9f74fc6ac6e3f0a230b79 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:29:21 +0100 Subject: [PATCH 29/55] cd.md changed the instructions --- runners/katacoda/templates/cd.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index a27d8f6e..25646c9a 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,4 +1,4 @@ -Please change the folder to <% dir: %> +Please change the folder to <%= dir; %> `cd <%= dir; %>`{{execute}} \ No newline at end of file From e61b2d9df0222d4bfd76faa34c23361fb0418776 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:10:04 +0100 Subject: [PATCH 30/55] added parameters to runcreateProject --- runners/console/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 4de7b42c..b863b866 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -39,7 +39,7 @@ export class Console extends Runner { return null; } - runCreateProject(){ + runCreateProject(step: Step, command: Command): RunResult{ return null; } From 9175012cc01d62b511efa182d273ea85d6f44690 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:47:27 +0100 Subject: [PATCH 31/55] added name tag to createProject --- runners/katacoda/index.ts | 2 +- runners/katacoda/templates/createProject.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 2188d390..320487e1 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -135,7 +135,7 @@ export class Katacoda extends Runner { }); //update current directory - this.currentDir = path.join(this.currentDir, "workspace", "main","cobigenexample"); + this.currentDir = path.join(this.currentDir, "workspace", "main", name); this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, language: language, name : name}); return null; diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md index ebbef46b..2ec53f39 100644 --- a/runners/katacoda/templates/createProject.md +++ b/runners/katacoda/templates/createProject.md @@ -11,6 +11,6 @@ Now you can use devon to setup a <%= language; %> project for you by executing `devon <%= language; %> create com.example.application.<%= name; %>`{{execute}} Switch into the newly create project directory. -`cd cobigenexample/`{{execute}} +`cd <%= name; %>`{{execute}} <%= textAfter; %> \ No newline at end of file From 92536d52f4c70f1c5ef86d242076002fe7039aa5 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 30 Nov 2020 08:09:30 +0100 Subject: [PATCH 32/55] update --- runners/katacoda/index.ts | 46 +++++++++++++++++++++++++++++--- runners/katacoda/templates/cd.md | 4 +-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 2188d390..867f1b73 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -127,7 +127,7 @@ export class Katacoda extends Runner { let name = params[1]; // generate template to change directory, if the current directory is not equal to the required start directory - let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); + let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw", "dsfsdf", "sadsad")); this.steps.push({ "title": "Create a new project", @@ -159,14 +159,54 @@ export class Katacoda extends Runner { } private changeCurrentDir(dir:string):string{ - + let dirPath = ""; + let startIndex = 1, whileIndex, isEqualIndex; + + //returns an empty string, if both variables have the same path if(this.currentDir == dir){ return ""; } + + //saves the remaining path, if currentdir is the prefix of dir + if(dir.substring(0,this.currentDir.length) == this.currentDir){ + dirPath = dir.replace(this.currentDir.concat('/'), ''); + } + + else{ + //split am / + //iteratieren bis nicht mehr gleich + //wen nder gleiche Teil nur null elemente lang ist dann absoluter pfad + //sonst ich zähle beim akturellen pfad die verbleibenden elemente + //kenne die Anzahl der ../ + //dann verbleibende dir pfad anhängen + //substring of array //chunk + dirPath = '../'; + + //iterates through the currentDir path, while searching for slashes + while(this.currentDir.indexOf('/', startIndex) > -1){ + + whileIndex = this.currentDir.indexOf('/', startIndex); + + //saves the position of the slash, where dir and currentDir have the same parent directories + if(dir.substring(0, whileIndex) == this.currentDir.substring(0, whileIndex)){ + isEqualIndex = whileIndex; + } + + //creates the path to move several folders upwards + else{ + dirPath = path.join(dirPath, ".."); + } + + startIndex += whileIndex; + } + //creates the full path to get to dir + dirPath = path.join(dirPath, dir.replace(dir.substring(0,isEqualIndex), '')); + + } this.currentDir = dir; //create template to change directory let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); - return ejs.render(template, {dir: dir}); + return ejs.render(template, {dirPath: dirPath}); } } \ No newline at end of file diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index 25646c9a..cf11a7f0 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,4 +1,4 @@ -Please change the folder to <%= dir; %> +Please change the folder to <%= dirPath; %> -`cd <%= dir; %>`{{execute}} \ No newline at end of file +`cd <%= dirPath; %>`{{execute}} \ No newline at end of file From a5ef5a35285d28d199999218ac907f87c2d82c83 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 2 Dec 2020 08:44:29 +0100 Subject: [PATCH 33/55] changeCurrentDir is splitted to a function generating a template and a function generating the cd param. Tests added --- buildRun.ps1 | 1 + buildRun.sh | 1 + localBuildRun.ps1 | 2 ++ localBuildRun.sh | 1 + localBuildTest.ps1 | 7 ++++ localBuildTest.sh | 6 ++++ package-lock.json | 6 ++++ package.json | 6 ++-- runners/katacoda/dirUtils.ts | 52 +++++++++++++++++++++++++++ runners/katacoda/index.ts | 51 ++++---------------------- spec/runners/katacoda/dirUtilsSpec.ts | 24 +++++++++++++ spec/support/jasmine.json | 11 ++++++ 12 files changed, 122 insertions(+), 46 deletions(-) create mode 100644 localBuildTest.ps1 create mode 100644 localBuildTest.sh create mode 100644 runners/katacoda/dirUtils.ts create mode 100644 spec/runners/katacoda/dirUtilsSpec.ts create mode 100644 spec/support/jasmine.json diff --git a/buildRun.ps1 b/buildRun.ps1 index c20dc7e3..4d94d544 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -3,4 +3,5 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PS Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build +npm test node $PSScriptRoot\build\engine\run.js \ No newline at end of file diff --git a/buildRun.sh b/buildRun.sh index e9b27230..7d6302c4 100644 --- a/buildRun.sh +++ b/buildRun.sh @@ -3,4 +3,5 @@ cp engine/parser.def build/engine/parser.def cp -r playbooks build cp -r environments build cp -r runners build +npm test node build/engine/run.js \ No newline at end of file diff --git a/localBuildRun.ps1 b/localBuildRun.ps1 index 0bfa1744..1394ca6d 100644 --- a/localBuildRun.ps1 +++ b/localBuildRun.ps1 @@ -3,4 +3,6 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PS Copy-Item -Force -Recurse -Path $PSScriptRoot\..\tutorials -Destination $PSScriptRoot\build\playbooks Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build +npm test +if(-not $?) { throw 'tests failed' } node $PSScriptRoot\build\engine\run.js \ No newline at end of file diff --git a/localBuildRun.sh b/localBuildRun.sh index d6f8f295..069c2e04 100644 --- a/localBuildRun.sh +++ b/localBuildRun.sh @@ -3,4 +3,5 @@ cp engine/parser.def build/engine/parser.def cp -r ../tutorials build/playbooks cp -r environments build cp -r runners build +npm test node build/engine/run.js \ No newline at end of file diff --git a/localBuildTest.ps1 b/localBuildTest.ps1 new file mode 100644 index 00000000..ca1fef83 --- /dev/null +++ b/localBuildTest.ps1 @@ -0,0 +1,7 @@ +tsc +Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PSScriptRoot\build\engine\parser.def +Copy-Item -Force -Recurse -Path $PSScriptRoot\..\tutorials -Destination $PSScriptRoot\build\playbooks +Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build +Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build +npm test +if(-not $?) { throw 'tests failed' } \ No newline at end of file diff --git a/localBuildTest.sh b/localBuildTest.sh new file mode 100644 index 00000000..cd7e8dad --- /dev/null +++ b/localBuildTest.sh @@ -0,0 +1,6 @@ +tsc +cp engine/parser.def build/engine/parser.def +cp -r ../tutorials build/playbooks +cp -r environments build +cp -r runners build +npm test diff --git a/package-lock.json b/package-lock.json index 1330cb1a..75a99417 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,12 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/jasmine": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz", + "integrity": "sha512-AzfesNFLvOs6Q1mHzIsVJXSeUnqVh4ZHG8ngygKJfbkcSLwzrBVm/LKa+mR8KrOfnWtUL47112gde1MC0IXqpQ==", + "dev": true + }, "@types/node": { "version": "14.14.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.2.tgz", diff --git a/package.json b/package.json index d2dfd695..32396bb0 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,11 @@ "ts-pegjs": "^0.2.7", "yargs": "^16.1.0" }, - "devDependencies": {}, + "devDependencies": { + "@types/jasmine": "^3.6.2" + }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "npx jasmine" }, "author": "", "license": "ISC" diff --git a/runners/katacoda/dirUtils.ts b/runners/katacoda/dirUtils.ts new file mode 100644 index 00000000..867625ab --- /dev/null +++ b/runners/katacoda/dirUtils.ts @@ -0,0 +1,52 @@ +import { captureRejectionSymbol } from "events"; +import * as path from 'path'; + +export class DirUtils{ + + getCdParam(currentDir:string, dir:string):string{ + + //cd-Parameter + let dirPath = ""; + + let currentPaths = currentDir.split('/'); + let dirPaths = dir.split('/'); + + let index; + let isEqual = true; + + //returns an empty string, if both variables have the same path + if(currentDir == dir){ + return ""; + } + + //saves the remaining path, if currentdir is the prefix of dir + if(dir.substring(0,currentDir.length) == currentDir){ + return dir.replace(currentDir.concat('/'), ''); + } + + else{ + //returns the absolut directory, if the first parent folder is different + if(currentPaths[1] != dirPaths[1]){ + return dir; + } + + //iterates throught currentPath array to compare parent directories + currentPaths.forEach((currentPath, i) => { + if(currentPath == dirPaths[i] && isEqual == true){ + index = i; + }else{ + isEqual = false; + dirPath = dirPath.concat('../'); + } + }) + + //slice newPaths to get the relative path + dirPaths = dirPaths.slice(index + 1, dirPaths.length); + + return dirPath.concat(dirPaths.join('/')); + + } + + } + +} \ No newline at end of file diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 867f1b73..988d9cfc 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -9,6 +9,7 @@ import { KatacodaAssetManager } from "./katacodaAssetManager"; import * as path from 'path'; import * as ejs from 'ejs'; import * as fs from 'fs'; +import { DirUtils } from "./dirUtils"; export class Katacoda extends Runner { @@ -159,54 +160,16 @@ export class Katacoda extends Runner { } private changeCurrentDir(dir:string):string{ - let dirPath = ""; - let startIndex = 1, whileIndex, isEqualIndex; - - //returns an empty string, if both variables have the same path - if(this.currentDir == dir){ - return ""; - } - - //saves the remaining path, if currentdir is the prefix of dir - if(dir.substring(0,this.currentDir.length) == this.currentDir){ - dirPath = dir.replace(this.currentDir.concat('/'), ''); - } - - else{ - //split am / - //iteratieren bis nicht mehr gleich - //wen nder gleiche Teil nur null elemente lang ist dann absoluter pfad - //sonst ich zähle beim akturellen pfad die verbleibenden elemente - //kenne die Anzahl der ../ - //dann verbleibende dir pfad anhängen - //substring of array //chunk - dirPath = '../'; - - //iterates through the currentDir path, while searching for slashes - while(this.currentDir.indexOf('/', startIndex) > -1){ - - whileIndex = this.currentDir.indexOf('/', startIndex); - - //saves the position of the slash, where dir and currentDir have the same parent directories - if(dir.substring(0, whileIndex) == this.currentDir.substring(0, whileIndex)){ - isEqualIndex = whileIndex; - } - - //creates the path to move several folders upwards - else{ - dirPath = path.join(dirPath, ".."); - } - - startIndex += whileIndex; - } - //creates the full path to get to dir - dirPath = path.join(dirPath, dir.replace(dir.substring(0,isEqualIndex), '')); - - } + let dirUtils = new DirUtils(); + let dirPath = dirUtils.getCdParam(this.currentDir, dir); this.currentDir = dir; //create template to change directory let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); return ejs.render(template, {dirPath: dirPath}); } + + private findRelPath(oldDir:string, newDir:string){ + + } } \ No newline at end of file diff --git a/spec/runners/katacoda/dirUtilsSpec.ts b/spec/runners/katacoda/dirUtilsSpec.ts new file mode 100644 index 00000000..70f45f26 --- /dev/null +++ b/spec/runners/katacoda/dirUtilsSpec.ts @@ -0,0 +1,24 @@ +import 'jasmine'; +import { DirUtils } from '../../../runners/katacoda/dirUtils'; + +describe("DirUtils", () => { + let target = new DirUtils(); + describe("changeCurrentDir", () => { + it("is already in the right folder", () => { + expect(target.getCdParam('/root', '/root')).toBe(''); + }); + it("changes directly to the child folder, because currentDir is the prefix of dir", () => { + expect(target.getCdParam('/root/devonfw', '/root/devonfw/setup')).toBe('setup'); + }); + it("returns an absolute path, because both dirs don't have matching parent folders", () => { + expect(target.getCdParam('/setup', '/root/devonfw/setup')).toBe('/root/devonfw/setup'); + }); + it("changes to parent folder before changing to child folder", () => { + expect(target.getCdParam('/root/devonfw', '/root/setup/folder0/folder1')).toBe('../setup/folder0/folder1'); + }); + it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { + expect(target.getCdParam('/root/devonfw/folder/setup', '/root/devonfw/setup/setup')).toBe('../../setup/setup'); + }); + + }); +}); diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json new file mode 100644 index 00000000..85388f09 --- /dev/null +++ b/spec/support/jasmine.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "build/spec", + "spec_files": [ + "**/*[sS]pec.js" + ], + "helpers": [ + "helpers/**/*.js" + ], + "stopSpecOnExpectationFailure": false, + "random": true +} From b6aba5abc5d84ab547c7b7906d950d6bfc3a6f67 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 2 Dec 2020 10:57:27 +0100 Subject: [PATCH 34/55] deleted relPath --- runners/katacoda/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index a90b5a3d..22562435 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -169,7 +169,5 @@ export class Katacoda extends Runner { return ejs.render(template, {dirPath: dirPath}); } - private findRelPath(oldDir:string, newDir:string){ - } } \ No newline at end of file From cab266a6268a2d5ddbe8a76faaeaa52f48891ff3 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 2 Dec 2020 11:01:47 +0100 Subject: [PATCH 35/55] changed newPath to dirPaths --- runners/katacoda/dirUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/dirUtils.ts b/runners/katacoda/dirUtils.ts index 867625ab..bc886a4b 100644 --- a/runners/katacoda/dirUtils.ts +++ b/runners/katacoda/dirUtils.ts @@ -40,7 +40,7 @@ export class DirUtils{ } }) - //slice newPaths to get the relative path + //slice dirPaths to get the relative path dirPaths = dirPaths.slice(index + 1, dirPaths.length); return dirPath.concat(dirPaths.join('/')); From 8f97bdccbba35a4a85eaec652830d5ea1cd1b87c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 2 Dec 2020 14:04:28 +0100 Subject: [PATCH 36/55] dirUtils replace concat with path.join --- runners/katacoda/dirUtils.ts | 11 +++++------ spec/runners/katacoda/dirUtilsSpec.ts | 11 ++++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/runners/katacoda/dirUtils.ts b/runners/katacoda/dirUtils.ts index bc886a4b..23bdaf3a 100644 --- a/runners/katacoda/dirUtils.ts +++ b/runners/katacoda/dirUtils.ts @@ -5,11 +5,10 @@ export class DirUtils{ getCdParam(currentDir:string, dir:string):string{ - //cd-Parameter let dirPath = ""; - let currentPaths = currentDir.split('/'); - let dirPaths = dir.split('/'); + let currentPaths = currentDir.split(path.sep); + let dirPaths = dir.split(path.sep); let index; let isEqual = true; @@ -21,7 +20,7 @@ export class DirUtils{ //saves the remaining path, if currentdir is the prefix of dir if(dir.substring(0,currentDir.length) == currentDir){ - return dir.replace(currentDir.concat('/'), ''); + return path.join(dir.replace(currentDir + path.sep, '')); } else{ @@ -36,14 +35,14 @@ export class DirUtils{ index = i; }else{ isEqual = false; - dirPath = dirPath.concat('../'); + dirPath = path.join(dirPath,'..'); } }) //slice dirPaths to get the relative path dirPaths = dirPaths.slice(index + 1, dirPaths.length); - return dirPath.concat(dirPaths.join('/')); + return path.join(dirPath, dirPaths.join(path.sep)); } diff --git a/spec/runners/katacoda/dirUtilsSpec.ts b/spec/runners/katacoda/dirUtilsSpec.ts index 70f45f26..d19a2713 100644 --- a/spec/runners/katacoda/dirUtilsSpec.ts +++ b/spec/runners/katacoda/dirUtilsSpec.ts @@ -1,23 +1,24 @@ import 'jasmine'; +import * as path from 'path'; import { DirUtils } from '../../../runners/katacoda/dirUtils'; describe("DirUtils", () => { let target = new DirUtils(); describe("changeCurrentDir", () => { it("is already in the right folder", () => { - expect(target.getCdParam('/root', '/root')).toBe(''); + expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); }); it("changes directly to the child folder, because currentDir is the prefix of dir", () => { - expect(target.getCdParam('/root/devonfw', '/root/devonfw/setup')).toBe('setup'); + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); }); it("returns an absolute path, because both dirs don't have matching parent folders", () => { - expect(target.getCdParam('/setup', '/root/devonfw/setup')).toBe('/root/devonfw/setup'); + expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); }); it("changes to parent folder before changing to child folder", () => { - expect(target.getCdParam('/root/devonfw', '/root/setup/folder0/folder1')).toBe('../setup/folder0/folder1'); + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); }); it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { - expect(target.getCdParam('/root/devonfw/folder/setup', '/root/devonfw/setup/setup')).toBe('../../setup/setup'); + expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); }); }); From 95a0b2632e640ac62452f0056d9f1b1962b3c78d Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 2 Dec 2020 14:06:31 +0100 Subject: [PATCH 37/55] replace dummy path --- runners/katacoda/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 22562435..cba1e325 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -128,7 +128,7 @@ export class Katacoda extends Runner { let name = params[1]; // generate template to change directory, if the current directory is not equal to the required start directory - let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw", "dsfsdf", "sadsad")); + let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); this.steps.push({ "title": "Create a new project", From f9ea402057525cdc91f52eec82c26ac416a570bc Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 09:17:31 +0100 Subject: [PATCH 38/55] Template will only be generated, if targetDir and currentDir have different strings --- localBuildTest.ps1 | 6 +----- localBuildTest.sh | 4 ---- runners/katacoda/dirUtils.ts | 36 ++++++++++++++++---------------- runners/katacoda/index.ts | 19 +++++++++-------- runners/katacoda/templates/cd.md | 4 ++-- 5 files changed, 31 insertions(+), 38 deletions(-) diff --git a/localBuildTest.ps1 b/localBuildTest.ps1 index ca1fef83..fc4e6687 100644 --- a/localBuildTest.ps1 +++ b/localBuildTest.ps1 @@ -1,7 +1,3 @@ tsc -Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PSScriptRoot\build\engine\parser.def -Copy-Item -Force -Recurse -Path $PSScriptRoot\..\tutorials -Destination $PSScriptRoot\build\playbooks -Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build -Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build npm test -if(-not $?) { throw 'tests failed' } \ No newline at end of file +if(-not $?){ throw 'tests failed' } \ No newline at end of file diff --git a/localBuildTest.sh b/localBuildTest.sh index cd7e8dad..de504293 100644 --- a/localBuildTest.sh +++ b/localBuildTest.sh @@ -1,6 +1,2 @@ tsc -cp engine/parser.def build/engine/parser.def -cp -r ../tutorials build/playbooks -cp -r environments build -cp -r runners build npm test diff --git a/runners/katacoda/dirUtils.ts b/runners/katacoda/dirUtils.ts index 23bdaf3a..a8a45a19 100644 --- a/runners/katacoda/dirUtils.ts +++ b/runners/katacoda/dirUtils.ts @@ -1,37 +1,37 @@ -import { captureRejectionSymbol } from "events"; import * as path from 'path'; export class DirUtils{ - getCdParam(currentDir:string, dir:string):string{ - + getCdParam(currentDir:string, targetDir:string):string{ + + //returns an empty string, if both variables have the same path + if(currentDir == targetDir){ + return ""; + } + let dirPath = ""; let currentPaths = currentDir.split(path.sep); - let dirPaths = dir.split(path.sep); + let targetPaths = targetDir.split(path.sep); let index; let isEqual = true; - - //returns an empty string, if both variables have the same path - if(currentDir == dir){ - return ""; - } - //saves the remaining path, if currentdir is the prefix of dir - if(dir.substring(0,currentDir.length) == currentDir){ - return path.join(dir.replace(currentDir + path.sep, '')); + //saves the remaining path, if currentdir is the prefix of targetDir + if(targetDir.substring(0,currentDir.length) == currentDir){ + return path.join(targetDir.replace(currentDir + path.sep, '')); } + else{ //returns the absolut directory, if the first parent folder is different - if(currentPaths[1] != dirPaths[1]){ - return dir; + if(currentPaths[1] != targetPaths[1]){ + return targetDir; } //iterates throught currentPath array to compare parent directories currentPaths.forEach((currentPath, i) => { - if(currentPath == dirPaths[i] && isEqual == true){ + if(currentPath == targetPaths[i] && isEqual == true){ index = i; }else{ isEqual = false; @@ -39,10 +39,10 @@ export class DirUtils{ } }) - //slice dirPaths to get the relative path - dirPaths = dirPaths.slice(index + 1, dirPaths.length); + //slice targetPaths to get the relative path + targetPaths = targetPaths.slice(index + 1, targetPaths.length); - return path.join(dirPath, dirPaths.join(path.sep)); + return path.join(dirPath, targetPaths.join(path.sep)); } diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index cba1e325..d3cf6655 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -123,9 +123,6 @@ export class Katacoda extends Runner { runCreateProject(step: Step, command:Command): RunResult { - let params = command.parameters; - let language = params[0]; - let name = params[1]; // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); @@ -136,9 +133,9 @@ export class Katacoda extends Runner { }); //update current directory - this.currentDir = path.join(this.currentDir, "workspace", "main", name); + this.currentDir = path.join(this.currentDir, "workspace", "main", command.parameters[1]); - this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, language: language, name : name}); + this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, language: command.parameters[0], name : command.parameters[1]}); return null; } @@ -159,14 +156,18 @@ export class Katacoda extends Runner { this.assetManager.registerFile(setupFile, "setup/setup.txt", "/root/setup", false); } - private changeCurrentDir(dir:string):string{ + private changeCurrentDir(targetDir:string):string{ + if(this.currentDir == targetDir){ + return ""; + } let dirUtils = new DirUtils(); - let dirPath = dirUtils.getCdParam(this.currentDir, dir); - this.currentDir = dir; + let dir = dirUtils.getCdParam(this.currentDir, targetDir); + + this.currentDir = targetDir; //create template to change directory let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", 'cd.md'), 'utf8'); - return ejs.render(template, {dirPath: dirPath}); + return ejs.render(template, {dir: dir}); } diff --git a/runners/katacoda/templates/cd.md b/runners/katacoda/templates/cd.md index cf11a7f0..25646c9a 100644 --- a/runners/katacoda/templates/cd.md +++ b/runners/katacoda/templates/cd.md @@ -1,4 +1,4 @@ -Please change the folder to <%= dirPath; %> +Please change the folder to <%= dir; %> -`cd <%= dirPath; %>`{{execute}} \ No newline at end of file +`cd <%= dir; %>`{{execute}} \ No newline at end of file From e94c16ab0eb9579331e78c02ddcfb8af99b901f4 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 10:44:57 +0100 Subject: [PATCH 39/55] function changed to createDevon4jProject --- localBuildRun.sh | 3 +++ localBuildTest.sh | 3 +++ runners/console/index.ts | 4 ++-- runners/katacoda/index.ts | 7 +++---- .../katacoda/templates/createDevon4jProject.md | 13 +++++++++++++ runners/katacoda/templates/createProject.md | 16 ---------------- runners/katacoda/templates/installCobiGen.md | 1 - 7 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 runners/katacoda/templates/createDevon4jProject.md delete mode 100644 runners/katacoda/templates/createProject.md diff --git a/localBuildRun.sh b/localBuildRun.sh index 069c2e04..f8085047 100644 --- a/localBuildRun.sh +++ b/localBuildRun.sh @@ -4,4 +4,7 @@ cp -r ../tutorials build/playbooks cp -r environments build cp -r runners build npm test +if [ $? -eq 1 ]; then + echo 'tests failed' +fi node build/engine/run.js \ No newline at end of file diff --git a/localBuildTest.sh b/localBuildTest.sh index de504293..552aa422 100644 --- a/localBuildTest.sh +++ b/localBuildTest.sh @@ -1,2 +1,5 @@ tsc npm test +if [ $? -eq 1 ]; then + echo 'tests failed' +fi \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index 9a7740db..2dc9b82c 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -64,7 +64,7 @@ export class Console extends Runner { return null; } - runCreateProject(step: Step, command: Command): RunResult{ + runCreateDevon4jProject(step: Step, command: Command): RunResult{ return null; } @@ -96,7 +96,7 @@ export class Console extends Runner { console.log("assertCobiGenJava"); } - async assertCreateProject(step: Step, command: Command, result: RunResult) { + async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) { console.log("assertCreateProject"); } diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index d3cf6655..410aca00 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -121,9 +121,8 @@ export class Katacoda extends Runner { } - runCreateProject(step: Step, command:Command): RunResult { + runCreateDevon4jProject(step: Step, command:Command): RunResult { - // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); @@ -133,9 +132,9 @@ export class Katacoda extends Runner { }); //update current directory - this.currentDir = path.join(this.currentDir, "workspace", "main", command.parameters[1]); + this.currentDir = path.join(this.currentDir, "workspace", "main"); - this.renderTemplate("createProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, language: command.parameters[0], name : command.parameters[1]}); + this.renderTemplate("createDevon4jProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, name : command.parameters[0] }); return null; } diff --git a/runners/katacoda/templates/createDevon4jProject.md b/runners/katacoda/templates/createDevon4jProject.md new file mode 100644 index 00000000..eb0a1297 --- /dev/null +++ b/runners/katacoda/templates/createDevon4jProject.md @@ -0,0 +1,13 @@ +<%= text; %> + +## Setting up your java project + +<%= cdCommand; %> + +Navigate to the 'workspaces/main/' folder in your devonfw installation directory. +`cd workspaces/main/`{{execute}} + +Now you can use devonfw to setup a java project for you by executing the following devon command. +`devon java create com.example.application.<%= name; %>`{{execute}} + +<%= textAfter; %> \ No newline at end of file diff --git a/runners/katacoda/templates/createProject.md b/runners/katacoda/templates/createProject.md deleted file mode 100644 index 2ec53f39..00000000 --- a/runners/katacoda/templates/createProject.md +++ /dev/null @@ -1,16 +0,0 @@ -<%= text; %> - -## Setting up your java project - -<%= cdCommand; %> - -Navigate to the 'workspaces/main/' folder in your devonfw installation directory. -`cd workspaces/main/`{{execute}} - -Now you can use devon to setup a <%= language; %> project for you by executing the following command. -`devon <%= language; %> create com.example.application.<%= name; %>`{{execute}} - -Switch into the newly create project directory. -`cd <%= name; %>`{{execute}} - -<%= textAfter; %> \ No newline at end of file diff --git a/runners/katacoda/templates/installCobiGen.md b/runners/katacoda/templates/installCobiGen.md index cb21dfa6..041c1389 100644 --- a/runners/katacoda/templates/installCobiGen.md +++ b/runners/katacoda/templates/installCobiGen.md @@ -4,5 +4,4 @@ `devon cobigen`{{execute}} - <%= textAfter; %> \ No newline at end of file From 23b9ef9e3149f4a5f6e92cc913be89805f05c1ed Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 10:48:18 +0100 Subject: [PATCH 40/55] function changed to createDevon4jProject --- runners/console/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 2dc9b82c..b7dd8983 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -97,7 +97,7 @@ export class Console extends Runner { } async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) { - console.log("assertCreateProject"); + console.log("assertCreateDevon4jProject"); } private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { From 4e07be299a54efd030346f3be8863ebc52f52496 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:04:59 +0100 Subject: [PATCH 41/55] WIP: feature/buildJava --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 32396bb0..93b9cf7a 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,7 @@ "pegjs": "^0.10.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0" - }, - "devDependencies": { + "yargs": "^16.1.0", "@types/jasmine": "^3.6.2" }, "scripts": { From b96aa9556e425fb0ca10fbb5cfffb2d2506d51fc Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:12:16 +0100 Subject: [PATCH 42/55] npm dependency of jasmine changed --- buildRun.sh | 1 - package.json | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/buildRun.sh b/buildRun.sh index 7d6302c4..e9b27230 100644 --- a/buildRun.sh +++ b/buildRun.sh @@ -3,5 +3,4 @@ cp engine/parser.def build/engine/parser.def cp -r playbooks build cp -r environments build cp -r runners build -npm test node build/engine/run.js \ No newline at end of file diff --git a/package.json b/package.json index 93b9cf7a..beb78d21 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", "yargs": "^16.1.0", + }, + "devDependencies": { "@types/jasmine": "^3.6.2" }, "scripts": { From 2d505c9a7ecb979f1dc4a4f3ff3ab62c9d70a77c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:14:12 +0100 Subject: [PATCH 43/55] npm test in buildRun.sh --- buildRun.ps1 | 1 - buildRun.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/buildRun.ps1 b/buildRun.ps1 index 4d94d544..c20dc7e3 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -3,5 +3,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PS Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build -npm test node $PSScriptRoot\build\engine\run.js \ No newline at end of file diff --git a/buildRun.sh b/buildRun.sh index e9b27230..7d6302c4 100644 --- a/buildRun.sh +++ b/buildRun.sh @@ -3,4 +3,5 @@ cp engine/parser.def build/engine/parser.def cp -r playbooks build cp -r environments build cp -r runners build +npm test node build/engine/run.js \ No newline at end of file From 14ab8e823abbd8732501cbf79cf46db52e43e82c Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:14:44 +0100 Subject: [PATCH 44/55] npm test in buildRun.sh --- buildRun.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/buildRun.ps1 b/buildRun.ps1 index c20dc7e3..4d94d544 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -3,4 +3,5 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\engine\parser.def -Destination $PS Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build +npm test node $PSScriptRoot\build\engine\run.js \ No newline at end of file From c07d6a60621310e2dbb1f1645f92e3d2db97561e Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:17:43 +0100 Subject: [PATCH 45/55] npm test in buildRun.sh --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index beb78d21..32396bb0 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "pegjs": "^0.10.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0", + "yargs": "^16.1.0" }, "devDependencies": { "@types/jasmine": "^3.6.2" From 993a283482df3b573977cdb0dfb4ead8837d9bab Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:31:25 +0100 Subject: [PATCH 46/55] jasmine without @types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32396bb0..b53f608c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "yargs": "^16.1.0" }, "devDependencies": { - "@types/jasmine": "^3.6.2" + "jasmine": "^3.6.2" }, "scripts": { "test": "npx jasmine" From db775ecbb84a0258d62837625f0361a1beab2a6b Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:34:57 +0100 Subject: [PATCH 47/55] jasmine without @types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b53f608c..32396bb0 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "yargs": "^16.1.0" }, "devDependencies": { - "jasmine": "^3.6.2" + "@types/jasmine": "^3.6.2" }, "scripts": { "test": "npx jasmine" From d0740ae6ae1d9a1bbe921058a9fd677117fb09c1 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:38:20 +0100 Subject: [PATCH 48/55] jasmine without @types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32396bb0..b53f608c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "yargs": "^16.1.0" }, "devDependencies": { - "@types/jasmine": "^3.6.2" + "jasmine": "^3.6.2" }, "scripts": { "test": "npx jasmine" From eac509baf0e7efbd2cb54501cb6862e5906f3db4 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 11:53:24 +0100 Subject: [PATCH 49/55] jasmine without @types and dirUtilsSpec changed --- package-lock.json | 22 ++++++++++++++++------ spec/runners/katacoda/dirUtilsSpec.ts | 26 +++++++++++++------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75a99417..de3c92f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,12 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/jasmine": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz", - "integrity": "sha512-AzfesNFLvOs6Q1mHzIsVJXSeUnqVh4ZHG8ngygKJfbkcSLwzrBVm/LKa+mR8KrOfnWtUL47112gde1MC0IXqpQ==", - "dev": true - }, "@types/node": { "version": "14.14.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.2.tgz", @@ -174,6 +168,22 @@ "minimatch": "^3.0.4" } }, + "jasmine": { + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.3.tgz", + "integrity": "sha512-Th91zHsbsALWjDUIiU5d/W5zaYQsZFMPTdeNmi8GivZPmAaUAK8MblSG3yQI4VMGC/abF2us7ex60NH1AAIMTA==", + "dev": true, + "requires": { + "glob": "^7.1.6", + "jasmine-core": "~3.6.0" + } + }, + "jasmine-core": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.6.0.tgz", + "integrity": "sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", diff --git a/spec/runners/katacoda/dirUtilsSpec.ts b/spec/runners/katacoda/dirUtilsSpec.ts index d19a2713..2c81c291 100644 --- a/spec/runners/katacoda/dirUtilsSpec.ts +++ b/spec/runners/katacoda/dirUtilsSpec.ts @@ -1,24 +1,24 @@ -import 'jasmine'; +import * as jasmine from 'jasmine'; import * as path from 'path'; import { DirUtils } from '../../../runners/katacoda/dirUtils'; -describe("DirUtils", () => { +jasmine.describe("DirUtils", () => { let target = new DirUtils(); - describe("changeCurrentDir", () => { - it("is already in the right folder", () => { - expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); + jasmine.describe("changeCurrentDir", () => { + jasmine.it("is already in the right folder", () => { + jasmine.expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); }); - it("changes directly to the child folder, because currentDir is the prefix of dir", () => { - expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); + jasmine.it("changes directly to the child folder, because currentDir is the prefix of dir", () => { + jasmine.expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); }); - it("returns an absolute path, because both dirs don't have matching parent folders", () => { - expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); + jasmine.it("returns an absolute path, because both dirs don't have matching parent folders", () => { + jasmine.expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); }); - it("changes to parent folder before changing to child folder", () => { - expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); + jasmine.it("changes to parent folder before changing to child folder", () => { + jasmine.expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); }); - it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { - expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); + jasmine.it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { + jasmine.expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); }); }); From 37a8c85838c64a4be5cc2040e463ecf7bbd6df9f Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Thu, 3 Dec 2020 12:03:27 +0100 Subject: [PATCH 50/55] jasmine in dependencies not devd --- package.json | 3 ++- runners/katacoda/index.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b53f608c..22bef894 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "pegjs": "^0.10.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0" + "yargs": "^16.1.0", + "jasmine": "^3.6.2" }, "devDependencies": { "jasmine": "^3.6.2" diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 410aca00..c7f39d62 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -6,10 +6,10 @@ import { Command } from "../../engine/command"; import { KatacodaTools } from "./katacodaTools"; import { KatacodaStep, KatacodaSetupScript } from "./katacodaInterfaces"; import { KatacodaAssetManager } from "./katacodaAssetManager"; +import { DirUtils } from "./dirUtils"; import * as path from 'path'; import * as ejs from 'ejs'; import * as fs from 'fs'; -import { DirUtils } from "./dirUtils"; export class Katacoda extends Runner { From 10a8d44bd2befde733bbb4d0a9b37687c895f3a5 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 7 Dec 2020 08:49:59 +0100 Subject: [PATCH 51/55] @types/jasmine is added to package.json and path param --- package-lock.json | 6 +++++ package.json | 4 +-- runners/console/index.ts | 7 ----- runners/katacoda/index.ts | 5 ++-- .../templates/createDevon4jProject.md | 4 +-- spec/runners/katacoda/dirUtilsSpec.ts | 26 +++++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index de3c92f7..831540cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,12 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/jasmine": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz", + "integrity": "sha512-AzfesNFLvOs6Q1mHzIsVJXSeUnqVh4ZHG8ngygKJfbkcSLwzrBVm/LKa+mR8KrOfnWtUL47112gde1MC0IXqpQ==", + "dev": true + }, "@types/node": { "version": "14.14.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.2.tgz", diff --git a/package.json b/package.json index 22bef894..94e27d8f 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "pegjs": "^0.10.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0", - "jasmine": "^3.6.2" + "yargs": "^16.1.0" }, "devDependencies": { + "@types/jasmine": "^3.6.2", "jasmine": "^3.6.2" }, "scripts": { diff --git a/runners/console/index.ts b/runners/console/index.ts index f6ef6d1b..56312f16 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -79,10 +79,6 @@ export class Console extends Runner { return null; } - runCreateDevon4jProject(step: Step, command: Command): RunResult{ - return null; - } - async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) { let installedTools = command.parameters[0]; @@ -124,9 +120,6 @@ export class Console extends Runner { .fileExits(path.join(workspaceDir, command.parameters[0], "core", "src", "main", "java", "com", "example", "application", command.parameters[0], "SpringBootApp.java")); } - async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) { - console.log("assertCreateDevon4jProject"); - } private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index c7f39d62..04b50824 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -125,6 +125,7 @@ export class Katacoda extends Runner { // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); + let cdTarget = this.changeCurrentDir(path.join(command.parameters[1])); this.steps.push({ "title": "Create a new project", @@ -134,8 +135,8 @@ export class Katacoda extends Runner { //update current directory this.currentDir = path.join(this.currentDir, "workspace", "main"); - this.renderTemplate("createDevon4jProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, name : command.parameters[0] }); - return null; + this.renderTemplate("createDevon4jProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, cdTarget: cdTarget, name : command.parameters[0]}); + return null; } private renderTemplate(name: string, targetPath: string, variables) { diff --git a/runners/katacoda/templates/createDevon4jProject.md b/runners/katacoda/templates/createDevon4jProject.md index eb0a1297..8f66d731 100644 --- a/runners/katacoda/templates/createDevon4jProject.md +++ b/runners/katacoda/templates/createDevon4jProject.md @@ -4,8 +4,8 @@ <%= cdCommand; %> -Navigate to the 'workspaces/main/' folder in your devonfw installation directory. -`cd workspaces/main/`{{execute}} +Navigate to the right folder in your devonfw installation directory. +<%= cdTarget; %> Now you can use devonfw to setup a java project for you by executing the following devon command. `devon java create com.example.application.<%= name; %>`{{execute}} diff --git a/spec/runners/katacoda/dirUtilsSpec.ts b/spec/runners/katacoda/dirUtilsSpec.ts index 2c81c291..f3b05c7c 100644 --- a/spec/runners/katacoda/dirUtilsSpec.ts +++ b/spec/runners/katacoda/dirUtilsSpec.ts @@ -1,24 +1,24 @@ -import * as jasmine from 'jasmine'; +import 'jasmine'; import * as path from 'path'; import { DirUtils } from '../../../runners/katacoda/dirUtils'; -jasmine.describe("DirUtils", () => { +describe("DirUtils", () => { let target = new DirUtils(); - jasmine.describe("changeCurrentDir", () => { - jasmine.it("is already in the right folder", () => { - jasmine.expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); + describe("changeCurrentDir", () => { + it("is already in the right folder", () => { + expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); }); - jasmine.it("changes directly to the child folder, because currentDir is the prefix of dir", () => { - jasmine.expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); + it("changes directly to the child folder, because currentDir is the prefix of dir", () => { + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); }); - jasmine.it("returns an absolute path, because both dirs don't have matching parent folders", () => { - jasmine.expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); + it("returns an absolute path, because both dirs don't have matching parent folders", () => { + expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); }); - jasmine.it("changes to parent folder before changing to child folder", () => { - jasmine.expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); + it("changes to parent folder before changing to child folder", () => { + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); }); - jasmine.it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { - jasmine.expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); + it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { + expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); }); }); From 698af05d3bcf4367d84e6aea5e2c3a05e6fa2ad6 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 7 Dec 2020 09:49:34 +0100 Subject: [PATCH 52/55] documentation --- documentation/Functions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 9ef2396e..3341979f 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -36,7 +36,8 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createDevon4jProject #### parameter 1. The project name +2. the absolute path to the parent folder #### example -createDevon4jProject("cobigenexample") +createDevon4jProject("cobigenexample", "/root/devonfw/workspace/main") *** From db6742ec7d6fa4e9510350fa528eb093f68a5039 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Mon, 7 Dec 2020 11:30:12 +0100 Subject: [PATCH 53/55] Exit code and slash instead of backslash --- localBuildRun.sh | 1 + localBuildTest.sh | 1 + runners/katacoda/dirUtils.ts | 6 +++--- spec/runners/katacoda/dirUtilsSpec.ts | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/localBuildRun.sh b/localBuildRun.sh index f8085047..25076b0e 100644 --- a/localBuildRun.sh +++ b/localBuildRun.sh @@ -6,5 +6,6 @@ cp -r runners build npm test if [ $? -eq 1 ]; then echo 'tests failed' + exit 1 fi node build/engine/run.js \ No newline at end of file diff --git a/localBuildTest.sh b/localBuildTest.sh index 552aa422..2c089a93 100644 --- a/localBuildTest.sh +++ b/localBuildTest.sh @@ -2,4 +2,5 @@ tsc npm test if [ $? -eq 1 ]; then echo 'tests failed' + exit 1 fi \ No newline at end of file diff --git a/runners/katacoda/dirUtils.ts b/runners/katacoda/dirUtils.ts index a8a45a19..2c5780a2 100644 --- a/runners/katacoda/dirUtils.ts +++ b/runners/katacoda/dirUtils.ts @@ -19,14 +19,14 @@ export class DirUtils{ //saves the remaining path, if currentdir is the prefix of targetDir if(targetDir.substring(0,currentDir.length) == currentDir){ - return path.join(targetDir.replace(currentDir + path.sep, '')); + return path.join(targetDir.replace(currentDir + path.sep, '')).replace("\\", "/"); } else{ //returns the absolut directory, if the first parent folder is different if(currentPaths[1] != targetPaths[1]){ - return targetDir; + return targetDir.replace("\\", "/"); } //iterates throught currentPath array to compare parent directories @@ -42,7 +42,7 @@ export class DirUtils{ //slice targetPaths to get the relative path targetPaths = targetPaths.slice(index + 1, targetPaths.length); - return path.join(dirPath, targetPaths.join(path.sep)); + return path.join(dirPath, targetPaths.join(path.sep)).replace("\\", "/"); } diff --git a/spec/runners/katacoda/dirUtilsSpec.ts b/spec/runners/katacoda/dirUtilsSpec.ts index f3b05c7c..9e7186b4 100644 --- a/spec/runners/katacoda/dirUtilsSpec.ts +++ b/spec/runners/katacoda/dirUtilsSpec.ts @@ -9,16 +9,16 @@ describe("DirUtils", () => { expect(target.getCdParam(path.join('/root'), path.join('/root'))).toBe(''); }); it("changes directly to the child folder, because currentDir is the prefix of dir", () => { - expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup')); + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/devonfw/setup'))).toBe(path.join('setup').replace("\\", "/")); }); it("returns an absolute path, because both dirs don't have matching parent folders", () => { - expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup')); + expect(target.getCdParam(path.join('/setup'), path.join('/root/devonfw/setup'))).toBe(path.join('/root/devonfw/setup').replace("\\", "/")); }); it("changes to parent folder before changing to child folder", () => { - expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1')); + expect(target.getCdParam(path.join('/root/devonfw'), path.join('/root/setup/folder0/folder1'))).toBe(path.join('../setup/folder0/folder1').replace("\\", "/")); }); it("changes to parent folder before changing to child folder and one child folder has the same position and name", () => { - expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup')); + expect(target.getCdParam(path.join('/root/devonfw/folder/setup'), path.join('/root/devonfw/setup/setup'))).toBe(path.join('../../setup/setup').replace("\\", "/")); }); }); From 92e585c334cb7dff6fc1aefedb696642117f77cc Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 9 Dec 2020 11:02:01 +0100 Subject: [PATCH 54/55] changed back to createproject with one param and cd commands in template --- runners/katacoda/index.ts | 3 +-- runners/katacoda/templates/createDevon4jProject.md | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 04b50824..c72ec05f 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -125,7 +125,6 @@ export class Katacoda extends Runner { // generate template to change directory, if the current directory is not equal to the required start directory let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw")); - let cdTarget = this.changeCurrentDir(path.join(command.parameters[1])); this.steps.push({ "title": "Create a new project", @@ -135,7 +134,7 @@ export class Katacoda extends Runner { //update current directory this.currentDir = path.join(this.currentDir, "workspace", "main"); - this.renderTemplate("createDevon4jProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, cdTarget: cdTarget, name : command.parameters[0]}); + this.renderTemplate("createDevon4jProject.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, name : command.parameters[0]}); return null; } diff --git a/runners/katacoda/templates/createDevon4jProject.md b/runners/katacoda/templates/createDevon4jProject.md index 8f66d731..e61774bc 100644 --- a/runners/katacoda/templates/createDevon4jProject.md +++ b/runners/katacoda/templates/createDevon4jProject.md @@ -4,8 +4,8 @@ <%= cdCommand; %> -Navigate to the right folder in your devonfw installation directory. -<%= cdTarget; %> +Navigate to the 'workspaces/main/' folder in your devonfw installation directory. +`cd workspaces/main`{{execute}} Now you can use devonfw to setup a java project for you by executing the following devon command. `devon java create com.example.application.<%= name; %>`{{execute}} From ae466ecd12d822b675ea58c1186fc9583d0c81b4 Mon Sep 17 00:00:00 2001 From: denise-khuu <74537227+denise-khuu@users.noreply.github.com> Date: Wed, 9 Dec 2020 11:03:21 +0100 Subject: [PATCH 55/55] Function.md changed back --- documentation/Functions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 3341979f..9ef2396e 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -36,8 +36,7 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createDevon4jProject #### parameter 1. The project name -2. the absolute path to the parent folder #### example -createDevon4jProject("cobigenexample", "/root/devonfw/workspace/main") +createDevon4jProject("cobigenexample") ***