@@ -3,59 +3,72 @@ import * as chalk from "chalk";
33import { GlobalJson , FabloConfigJson } from "../types/FabloConfigJson" ;
44
55const DEFAULT_FABLO_CONFIG : FabloConfigJson = {
6- " $schema" : "https://github.com/hyperledger-labs/fablo/releases/download/2.2.0/schema.json" ,
6+ $schema : "https://github.com/hyperledger-labs/fablo/releases/download/2.2.0/schema.json" ,
77 global : {
88 fabricVersion : "2.5.9" ,
9- tls : false
9+ tls : false ,
10+ peerDevMode : false ,
1011 } ,
1112 orgs : [
1213 {
1314 organization : {
1415 name : "Orderer" ,
15- domain : "orderer.example.com"
16+ domain : "orderer.example.com" ,
17+ mspName : "OrdererMSP" ,
18+ } ,
19+ ca : {
20+ prefix : "ca" ,
21+ db : "sqlite" ,
1622 } ,
1723 orderers : [
1824 {
1925 groupName : "group1" ,
2026 type : "solo" ,
21- instances : 1
22- }
23- ]
27+ instances : 1 ,
28+ prefix : "ord" ,
29+ } ,
30+ ] ,
2431 } ,
2532 {
2633 organization : {
2734 name : "Org1" ,
28- domain : "org1.example.com"
35+ domain : "org1.example.com" ,
36+ mspName : "Org1MSP" ,
37+ } ,
38+ ca : {
39+ prefix : "ca" ,
40+ db : "sqlite" ,
2941 } ,
42+ orderers : [ ] ,
3043 peer : {
3144 instances : 2 ,
32- db : "LevelDb"
33- }
34- }
45+ db : "LevelDb" ,
46+ prefix : "peer" ,
47+ } ,
48+ } ,
3549 ] ,
3650 channels : [
3751 {
3852 name : "my-channel1" ,
3953 orgs : [
4054 {
4155 name : "Org1" ,
42- peers : [
43- "peer0" ,
44- "peer1"
45- ]
46- }
47- ]
48- }
56+ peers : [ "peer0" , "peer1" ] ,
57+ } ,
58+ ] ,
59+ } ,
4960 ] ,
5061 chaincodes : [
5162 {
5263 name : "chaincode1" ,
5364 version : "0.0.1" ,
5465 lang : "node" ,
5566 channel : "my-channel1" ,
56- directory : "./chaincodes/chaincode-kv-node"
57- }
58- ]
67+ directory : "./chaincodes/chaincode-kv-node" ,
68+ privateData : [ ] ,
69+ } ,
70+ ] ,
71+ hooks : { } ,
5972} ;
6073
6174export default class InitGenerator extends Generator {
@@ -65,7 +78,7 @@ export default class InitGenerator extends Generator {
6578
6679 async copySampleConfig ( ) : Promise < void > {
6780 let fabloConfigJson = { ...DEFAULT_FABLO_CONFIG } ;
68-
81+
6982 const shouldInitWithNodeChaincode = this . args . length && this . args . find ( ( v ) => v === "node" ) ;
7083 if ( shouldInitWithNodeChaincode ) {
7184 console . log ( "Creating sample Node.js chaincode" ) ;
@@ -75,16 +88,16 @@ export default class InitGenerator extends Generator {
7588 } else {
7689 fabloConfigJson = { ...fabloConfigJson , chaincodes : [ ] } ;
7790 }
78-
91+
7992 const shouldAddFabloRest = this . args . length && this . args . find ( ( v ) => v === "rest" ) ;
8093 if ( shouldAddFabloRest ) {
81- const orgs = fabloConfigJson . orgs . map ( ( org : any ) => ( { ...org , tools : { fabloRest : true } } ) ) ;
94+ const orgs = fabloConfigJson . orgs . map ( ( org ) => ( { ...org , tools : { fabloRest : true } } ) ) ;
8295 fabloConfigJson = { ...fabloConfigJson , orgs } ;
8396 } else {
84- const orgs = fabloConfigJson . orgs . map ( ( org : any ) => ( { ...org , tools : { } } ) ) ;
97+ const orgs = fabloConfigJson . orgs . map ( ( org ) => ( { ...org , tools : { } } ) ) ;
8598 fabloConfigJson = { ...fabloConfigJson , orgs } ;
8699 }
87-
100+
88101 const shouldUseKubernetes = this . args . length && this . args . find ( ( v ) => v === "kubernetes" || v === "k8s" ) ;
89102 const shouldRunInDevMode = this . args . length && this . args . find ( ( v ) => v === "dev" ) ;
90103 const global : GlobalJson = {
@@ -93,14 +106,14 @@ export default class InitGenerator extends Generator {
93106 peerDevMode : ! ! shouldRunInDevMode ,
94107 } ;
95108 fabloConfigJson = { ...fabloConfigJson , global } ;
96-
109+
97110 this . fs . write ( this . destinationPath ( "fablo-config.json" ) , JSON . stringify ( fabloConfigJson , undefined , 2 ) ) ;
98-
111+
99112 this . on ( "end" , ( ) => {
100113 console . log ( "===========================================================" ) ;
101114 console . log ( chalk . bold ( "Sample config file created! :)" ) ) ;
102115 console . log ( "You can start your network with 'fablo up' command" ) ;
103116 console . log ( "===========================================================" ) ;
104117 } ) ;
105118 }
106- }
119+ }
0 commit comments