@@ -3,13 +3,14 @@ import { RunCommand } from "../../engine/run_command";
33import { RunResult } from "../../engine/run_result" ;
44import { WikiRunner } from "../../engine/wikiRunner" ;
55import * as path from "path" ;
6+ import * as fs from 'fs' ;
67
78export class WikiConsole extends WikiRunner {
89
910 init ( playbook : Playbook ) : void {
1011 super . init ( playbook ) ;
12+ this . setVariable ( this . WORKSPACE_DIRECTORY , path . join ( this . getWorkingDirectory ( ) ) ) ;
1113 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "intro.asciidoc" ) , { name : playbook . name , title : playbook . title , subtitle : playbook . subtitle , description : playbook . description } ) ;
12- this . setVariable ( this . workspaceDirectory , path . join ( this . getWorkingDirectory ( ) ) ) ;
1314 }
1415
1516 async destroy ( playbook : Playbook ) : Promise < void > {
@@ -26,7 +27,8 @@ export class WikiConsole extends WikiRunner {
2627 version = runCommand . command . parameters [ 1 ] ;
2728 }
2829 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "installDevonfwIde.asciidoc" ) , { tools : tools , version :version } )
29- this . setVariable ( this . workspaceDirectory , path . join ( this . getWorkingDirectory ( ) , "devonfw" , "workspaces" , "main" ) ) ;
30+ this . setVariable ( this . WORKSPACE_DIRECTORY , path . join ( this . getWorkingDirectory ( ) , "devonfw" , "workspaces" , "main" ) ) ;
31+ this . setVariable ( this . INSTALLED_TOOLS , tools ) ;
3032 return null ;
3133 }
3234
@@ -35,7 +37,7 @@ export class WikiConsole extends WikiRunner {
3537 }
3638
3739 runChangeFile ( runCommand : RunCommand ) : RunResult {
38- let workspacePath = this . getVariable ( this . workspaceDirectory ) . replace ( / \\ / g, "/" ) ;
40+ let workspacePath = this . getVariable ( this . WORKSPACE_DIRECTORY ) . replace ( / \\ / g, "/" ) ;
3941 let filePath = path . join ( workspacePath , runCommand . command . parameters [ 0 ] ) ;
4042 let fileName = path . basename ( runCommand . command . parameters [ 0 ] ) ;
4143 let contentPath , contentString ;
@@ -62,13 +64,13 @@ export class WikiConsole extends WikiRunner {
6264
6365
6466 runRunServerJava ( runCommand : RunCommand ) : RunResult {
65- let server_path = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
67+ let server_path = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
6668 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "runServerJava.asciidoc" ) , { server_path : server_path , port : runCommand . command . parameters [ 1 ] . port , app_path : runCommand . command . parameters [ 1 ] . path } )
6769 return null ;
6870 }
6971
7072 runNpmInstall ( runCommand : RunCommand ) : RunResult {
71- let projectPath = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
73+ let projectPath = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
7274 let npmCommand = {
7375 "name" : ( runCommand . command . parameters . length > 1 && runCommand . command . parameters [ 1 ] . name ) ? runCommand . command . parameters [ 1 ] . name : undefined ,
7476 "global" : ( runCommand . command . parameters . length > 1 && runCommand . command . parameters [ 1 ] . global ) ? runCommand . command . parameters [ 1 ] . global : false ,
@@ -80,7 +82,7 @@ export class WikiConsole extends WikiRunner {
8082 }
8183
8284 runCloneRepository ( runCommand : RunCommand ) : RunResult {
83- let directoryPath = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
85+ let directoryPath = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
8486 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "cloneRepository.asciidoc" ) , { directoryPath : directoryPath , url : runCommand . command . parameters [ 1 ] } ) ;
8587 return null ;
8688 }
@@ -95,7 +97,7 @@ export class WikiConsole extends WikiRunner {
9597 }
9698
9799 runBuildNg ( runCommand : RunCommand ) : RunResult {
98- let angularPath = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
100+ let angularPath = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
99101 let outputPath = runCommand . command . parameters . length < 1 ? runCommand . command . parameters [ 1 ] : "" ;
100102 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "template" , "buildNg.asciidoc" ) , { angularPath : angularPath , outputPath : outputPath } ) ;
101103
@@ -110,18 +112,24 @@ export class WikiConsole extends WikiRunner {
110112 }
111113
112114 runCreateFolder ( runCommand : RunCommand ) : RunResult {
113- let folderPath = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
115+ let folderPath = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
114116 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "createFolder.asciidoc" ) , { folderPath : folderPath } ) ;
115117 return null ;
116118 }
117119
118120 runBuildJava ( runCommand : RunCommand ) : RunResult {
119- let directoryPath = path . join ( this . getVariable ( this . workspaceDirectory ) , runCommand . command . parameters [ 0 ] ) ;
121+ let directoryPath = path . join ( this . getVariable ( this . WORKSPACE_DIRECTORY ) , runCommand . command . parameters [ 0 ] ) ;
120122 let skipTest = ( runCommand . command . parameters . length == 2 && runCommand . command . parameters [ 1 ] == true ) ? false : true ;
121123 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "buildJava.asciidoc" ) , { directoryPath : directoryPath , skipTest : skipTest } ) ;
122124 return null ;
123125 }
124126
127+ runInstallCobiGen ( runCommand : RunCommand ) : RunResult {
128+ let devonPath = path . relative ( this . getWorkingDirectory ( ) , this . getVariable ( this . WORKSPACE_DIRECTORY ) ) . replace ( / \\ / g, "/" ) ; ;
129+ this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "installCobiGen.asciidoc" ) , { devonPath : devonPath } ) ;
130+ return null ;
131+ }
132+
125133 runCreateDevon4jProject ( runCommand : RunCommand ) : RunResult {
126134 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "createDevon4jProject.asciidoc" ) , { name : runCommand . command . parameters [ 0 ] } ) ;
127135 return null ;
@@ -130,6 +138,28 @@ export class WikiConsole extends WikiRunner {
130138 runAdaptTemplatesCobiGen ( runComannd : RunCommand ) : RunResult {
131139 let devonPath = path . relative ( this . getWorkingDirectory ( ) , this . getVariable ( this . WORKSPACE_DIRECTORY ) ) . replace ( / \\ / g, "/" ) ;
132140 this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "adaptTemplates.asciidoc" ) , { devonPath : devonPath } ) ;
141+ return null ;
142+ }
143+
144+ runNextKatacodaStep ( runCommand : RunCommand ) : RunResult {
145+ let tempFile = path . join ( this . getTempDirectory ( ) , runCommand . command . name + ".md" ) ;
146+ fs . writeFileSync ( tempFile , "" ) ;
147+ for ( let i = 0 ; i < runCommand . command . parameters [ 1 ] . length ; i ++ ) {
148+ let param = runCommand . command . parameters [ 1 ] [ i ] ;
149+ if ( param . content ) {
150+ fs . appendFileSync ( tempFile , param . content ) ;
151+ } else if ( param . file ) {
152+ fs . appendFileSync ( tempFile , fs . readFileSync ( path . join ( this . playbookPath , param . file ) , "utf-8" ) ) ;
153+ } else if ( param . image ) {
154+ let image = path . join ( this . playbookPath , param . image ) ;
155+ fs . appendFileSync ( tempFile , " + ")" ) ;
156+ }
157+ fs . appendFileSync ( tempFile , "\n\n" ) ;
158+ }
159+
160+ let content = fs . readFileSync ( tempFile , "utf-8" ) ;
161+ this . renderWiki ( path . join ( this . getRunnerDirectory ( ) , "templates" , "nextKatacodaStep.asciidoc" ) , { title : runCommand . command . parameters [ 0 ] , content : content , path : runCommand . command . parameters [ 2 ] } ) ;
162+
133163 return null ;
134164 }
135165}
0 commit comments