@@ -4,6 +4,8 @@ const installRoot = require('../root/install.cmd');
4
4
const { sdk } = require ( '../../../../logic' ) ;
5
5
const installRuntimeCmd = require ( '../runtimeEnvironments/install.cmd' ) ;
6
6
const { getKubeContext } = require ( '../../helpers/kubernetes' ) ;
7
+ const ProgressEvents = require ( '../../helpers/progressEvents' ) ;
8
+ const cliProgress = require ( 'cli-progress' ) ;
7
9
8
10
const installAgentCmd = new Command ( {
9
11
root : false ,
@@ -107,6 +109,20 @@ const installAgentCmd = new Command({
107
109
name = data . name ;
108
110
}
109
111
const apiHost = sdk . config . context . url ;
112
+ const events = new ProgressEvents ( ) ;
113
+ const format = 'downloading [{bar}] {percentage}% | {value}/{total}' ;
114
+ const progressBar = new cliProgress . SingleBar ( { stopOnComplete : true , format } , cliProgress . Presets . shades_classic ) ;
115
+ let totalSize ;
116
+ events . onStart ( ( size ) => {
117
+ progressBar . start ( size , 0 ) ;
118
+ totalSize = size ;
119
+ } ) ;
120
+ events . onProgress ( ( progress ) => {
121
+ progressBar . update ( progress ) ;
122
+ if ( progress >= totalSize ) {
123
+ console . log ( '\n' ) ;
124
+ }
125
+ } ) ;
110
126
const agentInstallStatusCode = await sdk . agents . install ( {
111
127
apiHost,
112
128
kubeContextName,
@@ -123,6 +139,7 @@ const installAgentCmd = new Command({
123
139
verbose,
124
140
agentId : name ,
125
141
terminateProcess : ! installRuntime ,
142
+ events,
126
143
} ) ;
127
144
if ( agentInstallStatusCode !== 0 ) {
128
145
throw new Error ( `\nAgent installation failed with code ${ agentInstallStatusCode } ` ) ;
0 commit comments