import { logger } from '../util' ; import { OrgJsonType } from '../model/type/org.type' ; import { AbstractService } from './Service.abstract' ; import FabricTools from '../instance/fabricTools' ; import ConfigtxYaml from '../model/yaml/network/configtx' ; export default class Org extends AbstractService { description public importConfig ( data ) { data . forEach ( org => { logger . debug ( `Import org config: ${ org . name }` ) ; this . bdkFile . createOrgDefinitionJson ( org . name , org . json ) ; } ) ; } description param path public exportConfig ( path ) { const orgJson = this . bdkFile . getOrgConfigJson ( this . config . orgName ) ; const exportPeerOrgJson = { name : this . config . orgName , json : orgJson , } ; this . bdkFile . createExportOrgDefinitionJson ( exportPeerOrgJson , path ) ; } description param orgName returns public async createOrgDefinitionJson ( orgName , configtxYaml ) { logger . debug ( `Generate ${ orgName } config json file: configtxgen ${ this . config . infraConfig . bdkPath }/${ this . config . networkName }/org-json/${ orgName }.json` ) ; this . bdkFile . createConfigtx ( configtxYaml ) ; const orgJson = ( await ( new FabricTools ( this . config , this . infra ) ) . printOrgDefinitionJson ( orgName ) ) . stdout . match ( /{.*}/s ) ?. [ 0 ] || '' ; this . bdkFile . createOrgDefinitionJson ( orgName , orgJson ) ; } }