@@ -123,13 +123,18 @@ function deployment(settings, verbose) {
123123 const pathObj = path . parse ( settings . tarPath ) ;
124124 const form = new FormData ( ) ;
125125 const startDate = new Date ( ) ;
126+ const tarStream = fs . createReadStream ( settings . tarPath ) ;
127+ const stat = fs . statSync ( settings . tarPath ) ;
128+ const fileSize = ( stat . size / ( 1024 * 1024 ) ) . toFixed ( 2 ) ;
129+ const spin = ' ⢹⢺⢼⣸⣇⡧⡗⡏' . split ( '' ) ;
130+ let n = 1 ;
126131
127132 if ( verbose ) {
128- console . log ( chalk . gray ( `${ settings . name || '--------' } uploading` ) )
133+ console . log ( chalk . gray ( `${ settings . name || '--------' } uploading [ ${ fileSize } MB] ` ) )
129134 } else {
130135 process . stdout . cursorTo ( 0 ) ;
131136 process . stdout . clearLine ( ) ;
132- process . stdout . write ( chalk . gray ( ` Uploading` ) )
137+ process . stdout . write ( chalk . gray ( `${ chalk . white ( spin [ n ++ ] ) } Uploading [ ${ fileSize } MB] ` ) )
133138 } ;
134139
135140 if ( settings . name ) form . append ( 'serviceName' , settings . name ) ;
@@ -139,31 +144,24 @@ function deployment(settings, verbose) {
139144 if ( settings . instances ) form . append ( 'serviceInstances' , settings . instances ) ;
140145 if ( settings . aliveEndpoint ) form . append ( 'serviceAliveEndpoint' , settings . aliveEndpoint ) ;
141146 if ( settings . variables ) form . append ( 'serviceVariables' , settings . variables ) ;
142- const tarStream = fs . createReadStream ( settings . tarPath ) ;
143- const stat = fs . statSync ( settings . tarPath ) ;
144147 let uploadedSize = 0 ;
145148 tarStream . on ( 'data' , buffer => {
146149 uploadedSize += buffer . length ;
147150 if ( verbose ) {
148- console . log ( chalk . gray ( `${ settings . name || '--------' } ${ ( uploadedSize / stat . size * 100 ) . toFixed ( 2 ) } % uploaded` ) ) ;
151+ console . log ( chalk . gray ( `${ settings . name || '--------' } ${ ( uploadedSize / stat . size * 100 ) . toFixed ( 2 ) } % uploaded [ ${ ( uploadedSize / ( 1024 * 1024 ) ) . toFixed ( 2 ) } MB] ` ) ) ;
149152 } else {
153+ if ( n === 8 ) n = 1 ;
150154 process . stdout . cursorTo ( 0 ) ;
151155 process . stdout . clearLine ( ) ;
152- process . stdout . write ( chalk . gray ( ` ${ ( uploadedSize / stat . size * 100 ) . toFixed ( 2 ) } % uploaded` ) ) ;
156+ process . stdout . write ( chalk . gray ( `${ chalk . white ( spin [ n ++ ] ) } ${ ( uploadedSize / stat . size * 100 ) . toFixed ( 2 ) } % uploaded [ ${ ( uploadedSize / ( 1024 * 1024 ) ) . toFixed ( 2 ) } MB] ` ) ) ;
153157 }
154158 } ) ;
155159 form . append ( pathObj . name , tarStream ) ;
156160
157161 return new Promise ( ( resolve , reject ) => {
158- const spin = ' ⢹⢺⢼⣸⣇⡧⡗⡏' . split ( '' ) ;
159162 const startDate = new Date ( ) ;
160- let n = 1 ;
161163 const es = new EventSource ( `${ settings . url } /deploys/live` , { headers : { connection : 'keep-alive' , 'cache-control' : 'no-cache' , authorization : `Bearer ${ settings . token } ` } } ) ;
162164
163- es . onerror = ( ) => {
164- process . stderr . write ( '\x1B[?25h' ) ; //show terminal cursor
165- reject ( new Error ( 'Deployment error occurred' ) ) ;
166- } ;
167165 es . onmessage = e => {
168166 let progressState = { } ;
169167 try {
0 commit comments