@@ -17,13 +17,20 @@ const formatServices = require('../util/formatServices');
17
17
18
18
const defaultIgnores = [ '.git' , 'node_modules' , '.exoframeignore' ] ;
19
19
20
- const streamToResponse = ( { tarStream, remoteUrl, options, verbose} ) =>
20
+ const streamToResponse = ( { tarStream, remoteUrl, options, verbose, handleUpload , handleDownload } ) =>
21
21
new Promise ( ( resolve , reject ) => {
22
22
// store error and result
23
23
let error ;
24
24
let result = { } ;
25
25
// pipe stream to remote
26
- const stream = _ ( tarStream . pipe ( got . stream . post ( remoteUrl , options ) ) )
26
+ const stream = _ (
27
+ tarStream . pipe (
28
+ got . stream
29
+ . post ( remoteUrl , options )
30
+ . on ( 'uploadProgress' , handleUpload )
31
+ . on ( 'downloadProgress' , handleDownload )
32
+ )
33
+ )
27
34
. split ( )
28
35
. filter ( l => l && l . length ) ;
29
36
// store output
@@ -188,14 +195,20 @@ exports.handler = async (args = {}) => {
188
195
189
196
// pipe stream to remote
190
197
try {
191
- const res = await streamToResponse ( { tarStream, remoteUrl, options, verbose} ) ;
198
+ const handleUpload = ( ) => {
199
+ spinner . text = `Uploading project..` ;
200
+ } ;
201
+ const handleDownload = ( ) => {
202
+ spinner . text = 'Project uploaded! Waiting for deployment..' ;
203
+ } ;
204
+ const res = await streamToResponse ( { tarStream, remoteUrl, options, verbose, handleUpload, handleDownload} ) ;
192
205
// check deployments
193
206
if ( ! res . deployments || ! res . deployments . length ) {
194
207
const err = new Error ( 'Something went wrong!' ) ;
195
208
err . response = res ;
196
209
throw err ;
197
210
}
198
- spinner && spinner . succeed ( 'Upload finished!' ) ;
211
+ spinner && spinner . succeed ( 'Deployment finished!' ) ;
199
212
200
213
// log response in verbose-verbose mode
201
214
verbose > 2 && console . log ( chalk . gray ( 'Server response:' ) , JSON . stringify ( res , null , 2 ) , '\n' ) ;
0 commit comments