@@ -4,6 +4,7 @@ const syncRoot = require('../root/synchronize.cmd');
4
4
const { sdk } = require ( '../../../../logic' ) ;
5
5
const cliConfigManager = require ( '../../../../logic/cli-config/Manager' ) ;
6
6
const Spinner = require ( 'ora' ) ;
7
+ const CFError = require ( 'cf-errors' ) ;
7
8
8
9
const REQUEST_TIMEOUT = 2 * 60 * 1000 ;
9
10
@@ -40,19 +41,26 @@ const command = new Command({
40
41
type : 'boolean' ,
41
42
default : false ,
42
43
} )
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' ) ;
44
45
} ,
45
46
handler : async ( argv ) => {
47
+ const clientType = _ . isArray ( argv [ 'client-type' ] ) ? _ . head ( argv [ 'client-type' ] ) : argv [ 'client-type' ] ;
48
+
46
49
const config = cliConfigManager . config ( ) ;
47
50
if ( ! _ . isInteger ( argv . requestTimeout ) || config . request . timeout < REQUEST_TIMEOUT ) {
48
51
_ . set ( sdk , 'config.http.config.timeout' , REQUEST_TIMEOUT ) ;
49
52
}
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
+
50
58
const spinner = Spinner ( ) . start ( 'Synchronizing...' ) ;
51
59
let result ;
52
60
try {
53
61
result = await sdk . teams . synchronizeClientWithGroup ( {
54
62
name : argv [ 'client-name' ] ,
55
- type : argv [ 'client-type' ] ,
63
+ type : clientType ,
56
64
access_token : argv [ 'access-token' ] ,
57
65
disableNotifications : argv [ 'disable-notifications' ]
58
66
} ) ;
0 commit comments