|
| 1 | +const _ = require('lodash'); |
1 | 2 | const Command = require('../../Command');
|
2 | 3 | const syncRoot = require('../root/synchronize.cmd');
|
3 | 4 | const { sdk } = require('../../../../logic');
|
| 5 | +const cliConfigManager = require('../../../../logic/cli-config/Manager'); |
| 6 | +const Spinner = require('ora'); |
| 7 | + |
| 8 | +const REQUEST_TIMEOUT = 2 * 60 * 1000; |
4 | 9 |
|
5 | 10 | const command = new Command({
|
6 | 11 | command: 'teams [client-name]',
|
@@ -31,11 +36,22 @@ const command = new Command({
|
31 | 36 | .example('codefresh synchronize teams [client-name] -t [client-type] -tk [accessToken]', 'Synchronize team with group');
|
32 | 37 | },
|
33 | 38 | handler: async (argv) => {
|
34 |
| - console.log(JSON.stringify(await sdk.teams.synchronizeClientWithGroup({ |
35 |
| - name: argv['client-name'], |
36 |
| - type: argv['client-type'], |
37 |
| - access_token: argv['access-token'], |
38 |
| - }), null, 2)); |
| 39 | + const config = cliConfigManager.config(); |
| 40 | + if (!_.isInteger(argv.requestTimeout) || config.request.timeout < REQUEST_TIMEOUT) { |
| 41 | + _.set(sdk, 'config.http.config.timeout', REQUEST_TIMEOUT); |
| 42 | + } |
| 43 | + const spinner = Spinner().start('Synchronizing...'); |
| 44 | + let result; |
| 45 | + try { |
| 46 | + result = await sdk.teams.synchronizeClientWithGroup({ |
| 47 | + name: argv['client-name'], |
| 48 | + type: argv['client-type'], |
| 49 | + access_token: argv['access-token'], |
| 50 | + }); |
| 51 | + } finally { |
| 52 | + spinner.clear(); |
| 53 | + } |
| 54 | + console.log(JSON.stringify(result, null, 2)); |
39 | 55 | },
|
40 | 56 | });
|
41 | 57 |
|
|
0 commit comments