Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
753d346
Added runCloneRepository
MarcelDiessner Dec 22, 2020
a813fec
runCloneRepository and Assertion implemented
MarcelDiessner Dec 22, 2020
60f8ca9
assertCloneRepository Errors fixed
MarcelDiessner Dec 22, 2020
0975a6e
katacoda runner for cloneRepository implemented
MarcelDiessner Dec 22, 2020
da2ac37
katacoda runner for cloneRepository implemented
MarcelDiessner Dec 22, 2020
26a2653
Merge branch 'feature/cloneRepository' of https://github.com/TheMarcy…
MarcelDiessner Dec 22, 2020
20f4291
resolved issues of reviews
MarcelDiessner Dec 22, 2020
dcfbcb8
Added documentation
MarcelDiessner Dec 23, 2020
b0fcd2f
Fixed documentation
MarcelDiessner Dec 23, 2020
1515d48
Merge branch 'main' into feature/cloneRepository
MarcelDiessner Dec 23, 2020
dccc983
Added Case for Empty String
MarcelDiessner Dec 23, 2020
18d0840
Merge branch 'feature/cloneRepository' of https://github.com/TheMarcy…
MarcelDiessner Dec 23, 2020
4bf5940
Added second example in documentation
MarcelDiessner Dec 23, 2020
8e09849
Fixed if statement for correct result
MarcelDiessner Dec 23, 2020
b6c22a3
check for empty string now in template and assertCloneRepository chec…
MarcelDiessner Dec 30, 2020
c67c6c0
Removed Statementcast to Boolean
MarcelDiessner Dec 30, 2020
44a1a43
Added assertion repositoryIsClean to check for git status result
MarcelDiessner Jan 6, 2021
ebf9579
removed wrong import
MarcelDiessner Jan 6, 2021
af82294
changed string to directoryPath in cloneRepository.md
MarcelDiessner Jan 6, 2021
5847120
Change to correct current dir
MarcelDiessner Jan 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions runners/console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ export class Console extends Runner {
return result;
}

runCloneRepository(step: Step, command: Command): RunResult {
let result = new RunResult();
result.returnCode = 0;

let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
let directorypath = path.join(workspaceDir, command.parameters[0]);

this.createFolder(directorypath, false);
this.executeCommandSync("git clone " + command.parameters[1], directorypath, result);

return result;
}

async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) {
let installedTools = command.parameters[0];

Expand Down Expand Up @@ -222,6 +235,15 @@ export class Console extends Runner {
.fileContains(filepath, content);
}

async assertCloneRepository(step: Step, command: Command, result: RunResult) {
let repository = command.parameters[1]
let repoName = repository.slice(repository.lastIndexOf("/"), -4);
new Assertions()
.noErrorCode(result)
.noException(result)
.directoryExits(path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main", command.parameters[0], repoName));
}

private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {
if(result.returnCode != 0) return;

Expand Down
15 changes: 15 additions & 0 deletions runners/katacoda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ export class Katacoda extends Runner {

}

runCloneRepository(step: Step, command: Command): RunResult {

let cdCommand = this.changeCurrentDir(path.join("/root", "devonfw", "workspaces", "main"));
let workspaceDir = path.join("devonfw", "workspaces", "main");
let directoryPath = path.join(workspaceDir, command.parameters[0]).replace(/\\/g, "/");

this.steps.push({
"title": "Clones Repository " + command.parameters[1],
"text": "step" + this.stepsCount + ".md"
});

this.renderTemplate("cloneRepository.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, directoryPath: directoryPath, repository: command.parameters[1]});
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);
Expand Down
15 changes: 15 additions & 0 deletions runners/katacoda/templates/cloneRepository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%= text; %>

<%= cdCommand; %>

If the parent directories aren't already in the project, 'mkdir -p' will create them for you.

`mkdir -p <%= directoryPath; %>`{{execute}}

`cd <%= directoryPath; %>`{{execute}}

Now clone the repository to your local directory.

`git clone <%= repository; %>`{{execute}}

<%= textAfter; %>