@@ -4,6 +4,7 @@ const syncRoot = require('../root/synchronize.cmd');
44const { sdk } = require ( '../../../../logic' ) ;
55const cliConfigManager = require ( '../../../../logic/cli-config/Manager' ) ;
66const Spinner = require ( 'ora' ) ;
7+ const CFError = require ( 'cf-errors' ) ;
78
89const REQUEST_TIMEOUT = 2 * 60 * 1000 ;
910
@@ -40,19 +41,26 @@ const command = new Command({
4041 type : 'boolean' ,
4142 default : false ,
4243 } )
43- . example ( 'codefresh synchronize teams [client-name] -t [client-type] -tk [accessToken]' , 'Synchronize team with group' ) ;
44+ . example ( 'codefresh synchronize teams [client-name] -t [client-type] -- tk [accessToken]' , 'Synchronize team with group' ) ;
4445 } ,
4546 handler : async ( argv ) => {
47+ const clientType = _ . isArray ( argv [ 'client-type' ] ) ? _ . head ( argv [ 'client-type' ] ) : argv [ 'client-type' ] ;
48+
4649 const config = cliConfigManager . config ( ) ;
4750 if ( ! _ . isInteger ( argv . requestTimeout ) || config . request . timeout < REQUEST_TIMEOUT ) {
4851 _ . set ( sdk , 'config.http.config.timeout' , REQUEST_TIMEOUT ) ;
4952 }
53+
54+ if ( clientType === 'github' && ! argv [ 'access-token' ] ) {
55+ throw new CFError ( 'access-token should be provided in case if client-type is "github"' ) ;
56+ }
57+
5058 const spinner = Spinner ( ) . start ( 'Synchronizing...' ) ;
5159 let result ;
5260 try {
5361 result = await sdk . teams . synchronizeClientWithGroup ( {
5462 name : argv [ 'client-name' ] ,
55- type : argv [ 'client-type' ] ,
63+ type : clientType ,
5664 access_token : argv [ 'access-token' ] ,
5765 disableNotifications : argv [ 'disable-notifications' ]
5866 } ) ;
0 commit comments