Skip to content

Commit 132e661

Browse files
Merge branch 'main' into executeFile
2 parents 8f07fd6 + b567257 commit 132e661

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+541
-155
lines changed

.github/workflows/linuxPullRequest.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: run checkout.sh
2121
run: bash checkout.sh
2222

23-
- name: run buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }} ${{ github.event.inputs.logLevel }}
23+
- name: run buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }}
2424
uses: GabrielBB/[email protected]
2525
with:
26-
run: sh buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }} ${{ github.event.inputs.logLevel }}
26+
run: sh buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }}

.github/workflows/windowsPullRequest.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ jobs:
2020
- name: run checkout.ps1
2121
run: .\checkout.ps1
2222

23-
- name: run buildRun.ps1 --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }} ${{ github.event.inputs.logLevel }}
24-
run: .\buildRun.ps1 --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }} ${{ github.event.inputs.logLevel }}
23+
- name: run buildRun.ps1 --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }}
24+
run: .\buildRun.ps1 --user ${{ github.actor }} --branch ${{ github.event.pull_request.head.ref }}
25+

documentation/Development.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
In this section we will describe how you can implement your own tutorials.
44
Learn more about the file system and where you can add your commands in
5-
https://github.com/devonfw-forge/tutorials/wiki/Structure
5+
https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Structure
66

77
### How to create a playbook
88
The playbooks for the tutorial-compiler are contained in the tutorials repository. There you will find a description of how to create your own playbook.
9-
https://github.com/devonfw-forge/tutorials/wiki/Development
9+
https://github.com/devonfw-tutorials/tutorials/wiki/Development
1010

1111
### How to create your own command
1212
To create a new command you can use in your playbooks, you have to implement a new function for this command in all runner class you want to support this command. If you want to use the command only in katacoda tutorials for example, you have to implement the function only in the katacoda runner class.

documentation/Functions.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ will run "git clone https://github.com/[GitHub-name]/[playbook-name]" and checko
103103
`'/root/workspaces'`
104104

105105

106-
Learn more about the workspace directory and working directory on [Structure](https://github.com/devonfw-forge/tutorial-compiler/wiki/Structure)
106+
Learn more about the workspace directory and working directory on [Structure](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Structure)
107107

108108
109109
### changeWorkspace
@@ -113,7 +113,7 @@ Learn more about the workspace directory and working directory on [Structure](ht
113113
changeWorkspace("devonfw/workspaces/project")
114114
will set the workspace directory to "[working directory]/devonfw/workspaces/project"
115115

116-
Learn more about the workspace directory and working directory on [Structure](https://github.com/devonfw-forge/tutorial-compiler/wiki/Structure)
116+
Learn more about the workspace directory and working directory on [Structure](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Structure)
117117

118118
### executeCommand
119119
#### parameter
@@ -177,9 +177,10 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8])
177177

178178
### createDevon4jProject
179179
#### parameter
180-
1. The project name
180+
1. The base package name
181181
#### example
182-
createDevon4jProject("cobigenexample")
182+
createDevon4jProject("com.mycustomer.myapplication")
183+
183184

184185
***
185186

@@ -205,7 +206,7 @@ createFile("cobigenexample/core/src/main/java/com/example/application/cobigenexa
205206
#### parameter
206207
1. Path of the file to be changed (relative path to the workspace directory)
207208
2.
208-
* Path of the file to get the content from or a string, that should be inserted.
209+
* Path of the file to get the content from or a string, that should be inserted.(relative path to the playbook directory)
209210
* (Optional) Name of a placeholder
210211
* (Optional) Line number where u want to insert your code. (Possible lines are: 1...n+1 for N = number of existing lines. File cant be empty)
211212
#### example
@@ -255,11 +256,11 @@ createFolder("directoryPath/subDirectory")
255256
1. Path into which the repository is to be cloned, relative to workspace.
256257
2. Git repository URL
257258
#### example
258-
cloneRepository("", "https://github.com/devonfw-forge/tutorial-compiler.git")
259+
cloneRepository("", "https://github.com/devonfw-tutorials/tutorial-compiler.git")
259260
Repository will be cloned directly into the workspace directory.
260261

261-
cloneRepository("devonfw-forge", "https://github.com/devonfw-forge/tutorial-compiler.git")
262-
Repository will be cloned into a newly created subdirectory devonfw-forge.
262+
cloneRepository(devonfw-tutorials", "https://github.com/devonfw-tutorials/tutorial-compiler.git")
263+
Repository will be cloned into a newly created subdirectory devonfw-tutorials.
263264

264265
***
265266

@@ -396,4 +397,13 @@ This command also works if the devonfw IDE is not installed, but then you have t
396397
2. Path of the script (Windows). Relative to the playbook directory
397398

398399
#### example
399-
addSetupScript("assets/createProjectScript.sh", "assets/createProjectScript.ps1")
400+
addSetupScript("assets/createProjectScript.sh", "assets/createProjectScript.ps1")
401+
402+
***
403+
404+
### openFile
405+
#### parameter
406+
1. Path of the file to be opened (relative path to the workspace directory)
407+
408+
#### example
409+
openFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java")

documentation/Home.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
**Welcome to the tutorial-compiler wiki!**
22

33
To download and setup the tutorial-compiler use the description in the setup section.<br/>
4-
[Setup](https://github.com/devonfw-forge/tutorial-compiler/wiki/Setup)
4+
[Setup](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Setup)
55

66
If you want to implement your own tutorials the Development section may help you.<br/>
7-
[Development](https://github.com/devonfw-forge/tutorial-compiler/wiki/Development)
7+
[Development](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Development)
88

99
You find a list of functions which are already implemented in the Functions section.<br/>
10-
[Functions](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions)
10+
[Functions](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions)
1111

1212
Learn more about the project structure.<br/>
13-
[Structure](https://github.com/devonfw-forge/tutorial-compiler/wiki/Structure)
13+
[Structure](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Structure)
1414

1515

documentation/Structure.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/--index.asciidoc
1414

1515
Write your own tutorials in "./tutorials/[playbook-name]/index.asciidoc".
16-
You will find all the details in the tutorials [Developement](https://github.com/devonfw-forge/tutorials/wiki/Development) page.
16+
You will find all the details in the tutorials [Developement](https://github.com/devonfw-tutorials/tutorials/wiki/Development) page.
1717

1818

1919
# File system of the "tutorial-compiler" - repository
@@ -35,15 +35,15 @@ You will find all the details in the tutorials [Developement](https://github.com
3535
* wikiEclipse
3636
* wikiEditor
3737

38-
Create your own commands as shown in tutorial-compilers's [Developement](https://github.com/devonfw-forge/tutorials/wiki/Development) page inside the "./index.ts"-files.
38+
Create your own commands as shown in tutorial-compilers's [Developement](https://github.com/devonfw-tutorials/tutorials/wiki/Development) page inside the "./index.ts"-files.
3939

4040
### Assertions
4141

4242
|--tutorial-compiler
4343
|--assertions
4444

4545
Add assertions by adding a new class into the "./tutorial-compiler/assertions"-folder
46-
Learn more about it in [Development](https://github.com/devonfw-forge/tutorials/wiki/Development)
46+
Learn more about it in [Development](https://github.com/devonfw-tutorials/tutorials/wiki/Development)
4747

4848

4949
## Katacoda tutorials
@@ -78,8 +78,8 @@ Without the devonfw IDE the workspace directory equals the working directory.
7878

7979
|--[working-directory]
8080

81-
In [Functions](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions) you will find the phrase "relative to workspace", which means relative to the working directory.
82-
You can set a new workspace with the function [changeWorkspace](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions).
81+
In [Functions](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions) you will find the phrase "relative to workspace", which means relative to the working directory.
82+
You can set a new workspace with the function [changeWorkspace](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions).
8383

8484
### Workspace with devonfw IDE
8585

@@ -89,16 +89,16 @@ You can set a new workspace with the function [changeWorkspace](https://github.c
8989
|--main
9090

9191
The functions
92-
* [restoreDevonfwIde](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions)
93-
* [installDevonfwIde](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions)
92+
* [restoreDevonfwIde](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions)
93+
* [installDevonfwIde](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions)
9494

9595
will change the workspace to the "[working-directory]/devonfw/workspaces/main".
9696
The phrase "relative to workspace" means in this case relative to "./main"
97-
You can set a new workspace with the function [changeWorkspace](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions).
97+
You can set a new workspace with the function [changeWorkspace](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions).
9898

9999
### Workspace with restoreWorkspace
100100

101-
The function [restoreWorkspace](https://github.com/devonfw-forge/tutorial-compiler/wiki/Functions) will change the workspace.
101+
The function [restoreWorkspace](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions) will change the workspace.
102102

103103
#### WIthout devonfw IDE
104104

engine/parser.def

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ blockmarker "===="
4646
= "===="
4747

4848
stepstitle
49-
= "==" _ string __
49+
= "==" _ steptitle __
50+
51+
steptitle
52+
= [^\r\n] + { return { "steptitle": text()};}
5053

5154
steptextlines
5255
= steptextline* { return { "steptextlines": text()}; }

engine/parser.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export class Parser {
5252

5353
getTitle(parseResult, index) {
5454
try {
55-
return (parseResult[3][index][3][2]|| parseResult[3][index][2][3][2]);
55+
// parseResult[3][index][4][2] step without block
56+
// parseResult[3][index][2][4][2] step inside a block
57+
return (parseResult[3][index][4][2].steptitle || parseResult[3][index][2][4][2].steptitle);
5658
} catch(error) {
5759
return null;
5860
}

engine/run.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Parser } from "./parser";
22
import { Playbook } from "./playbook";
33
import { Environment } from "./environment";
44
import { Engine } from "./engine";
5-
import { isObject } from "util";
65
const fs = require('fs');
76
const yargs = require('yargs/yargs');
87

@@ -21,6 +20,7 @@ class Run {
2120
this.parsePlaybooks();
2221
this.parseEnvironments();
2322
let entries = this.filterEnv(Array.from(this.environments.entries()));
23+
2424
for (let entry of entries) {
2525
let key = entry[0];
2626
let value = entry[1];
@@ -46,7 +46,7 @@ class Run {
4646
}
4747

4848
if (this.errors.length != 0) {
49-
console.log("Errors", this.errors);
49+
console.log("Errors", JSON.stringify(this.errors, null, "\t"));
5050
}
5151
return this.errors.length == 0;
5252
}

engine/wikiRunner.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export abstract class WikiRunner extends Runner {
1111
init(playbook: Playbook): void {
1212
let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false)
1313
this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true);
14+
this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory()));
1415
}
1516

1617
async destroy(playbook: Playbook): Promise<void> {

localBuildRun.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ if(-not $?) { throw 'tests failed' }
88
node $PSScriptRoot\build\engine\run.js $args
99
if(Test-Path $PSScriptRoot\build\playbooks){
1010
Remove-Item .\build\playbooks -Recurse -Force
11-
}
11+
}

runners/console/consoleUtils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ConsoleUtils {
2626
static executeCommandAsync(command: string, directory: string, result: RunResult, env: any): child_process.ChildProcess {
2727
if(result.returnCode != 0) return;
2828
let process = child_process.spawn(command, [], { shell: true, cwd: directory, env: env });
29+
2930
let output = "";
3031
process.stdout.on('data', function(data) {
3132
output += data.toString();

runners/console/index.ts

+32-8
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class Console extends Runner {
168168

169169
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
170170
let projectName = runCommand.command.parameters[0];
171-
ConsoleUtils.executeDevonCommandSync("java create com.example.application." + projectName, workspaceDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env);
171+
ConsoleUtils.executeDevonCommandSync("java create " + projectName, workspaceDir, path.join(this.getWorkingDirectory(), "devonfw"), result, this.env);
172172
return result;
173173
}
174174

@@ -408,7 +408,7 @@ export class Console extends Runner {
408408
}
409409

410410
runNextKatacodaStep(runCommand: RunCommand): RunResult {
411-
//Only needed for katacoda runner
411+
//Only needed for katacoda and wiki runner
412412
return null;
413413
}
414414

@@ -520,6 +520,13 @@ export class Console extends Runner {
520520

521521
return result;
522522
}
523+
524+
runOpenFile(runCommand: RunCommand): RunResult {
525+
let result = new RunResult();
526+
result.returnCode = 0;
527+
//Only needed for katacoda, wiki runner and the assertions
528+
return result;
529+
}
523530

524531

525532
async assertInstallDevonfwIde(runCommand: RunCommand, result: RunResult) {
@@ -606,15 +613,18 @@ export class Console extends Runner {
606613
async assertCreateDevon4jProject(runCommand: RunCommand, result: RunResult) {
607614
try {
608615
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
609-
616+
let lastDot = runCommand.command.parameters[0].lastIndexOf('.') + 1;
617+
let projectFolder = runCommand.command.parameters[0].substr(lastDot);
618+
let package2Folder = path.join(runCommand.command.parameters[0].replace(/\./g, path.sep));
619+
610620
new Assertions()
611621
.noErrorCode(result)
612622
.noException(result)
613-
.directoryExits(path.join(workspaceDir, runCommand.command.parameters[0]))
614-
.directoryExits(path.join(workspaceDir, runCommand.command.parameters[0], "api", "src", "main", "java"))
615-
.directoryExits(path.join(workspaceDir, runCommand.command.parameters[0], "core", "src", "main", "java"))
616-
.directoryExits(path.join(workspaceDir, runCommand.command.parameters[0], "server", "src", "main", "java"))
617-
.fileExits(path.join(workspaceDir, runCommand.command.parameters[0], "core", "src", "main", "java", "com", "example", "application", runCommand.command.parameters[0], "SpringBootApp.java"));
623+
.directoryExits(path.join(workspaceDir, projectFolder))
624+
.directoryExits(path.join(workspaceDir, projectFolder, "api", "src", "main", "java"))
625+
.directoryExits(path.join(workspaceDir, projectFolder, "core", "src", "main", "java"))
626+
.directoryExits(path.join(workspaceDir, projectFolder, "server", "src", "main", "java"))
627+
.fileExits(path.join(workspaceDir, projectFolder, "core", "src", "main", "java", package2Folder, "SpringBootApp.java"));
618628
} catch(error) {
619629
await this.cleanUp();
620630
throw error;
@@ -864,6 +874,20 @@ export class Console extends Runner {
864874
}
865875
}
866876

877+
async assertOpenFile(runCommand: RunCommand, result: RunResult){
878+
try{
879+
new Assertions()
880+
.noErrorCode(result)
881+
.noException(result)
882+
.fileExits(path.join(this.getVariable(this.workspaceDirectory), runCommand.command.parameters[0]));
883+
}
884+
catch(error) {
885+
await this.cleanUp();
886+
throw error;
887+
}
888+
}
889+
890+
867891
private lookup(obj, lookupkey) {
868892
for(var key in obj) {
869893

0 commit comments

Comments
 (0)