@@ -30,17 +30,25 @@ function addVendorHelper() {
30
30
} )
31
31
. then ( ( functions ) => uniqBy ( functions , ( func ) => func . module ) )
32
32
. map ( ( f ) => {
33
- this . serverless . cli . log (
34
- `Adding Python requirements helper to ${ f . module } ...`
35
- ) ;
33
+ if ( this . log ) {
34
+ this . log . info ( `Adding Python requirements helper to ${ f . module } ` ) ;
35
+ } else {
36
+ this . serverless . cli . log (
37
+ `Adding Python requirements helper to ${ f . module } ...`
38
+ ) ;
39
+ }
36
40
37
41
return fse . copyAsync (
38
42
path . resolve ( __dirname , '../unzip_requirements.py' ) ,
39
43
path . join ( this . servicePath , f . module , 'unzip_requirements.py' )
40
44
) ;
41
45
} ) ;
42
46
} else {
43
- this . serverless . cli . log ( 'Adding Python requirements helper...' ) ;
47
+ if ( this . log ) {
48
+ this . log . info ( 'Adding Python requirements helper' ) ;
49
+ } else {
50
+ this . serverless . cli . log ( 'Adding Python requirements helper...' ) ;
51
+ }
44
52
45
53
if ( ! get ( this . serverless . service , 'package.patterns' ) ) {
46
54
set ( this . serverless . service , [ 'package' , 'patterns' ] , [ ] ) ;
@@ -72,15 +80,25 @@ function removeVendorHelper() {
72
80
} )
73
81
. then ( ( funcs ) => uniqBy ( funcs , ( f ) => f . module ) )
74
82
. map ( ( f ) => {
75
- this . serverless . cli . log (
76
- `Removing Python requirements helper from ${ f . module } ...`
77
- ) ;
83
+ if ( this . log ) {
84
+ this . log . info (
85
+ `Removing Python requirements helper from ${ f . module } `
86
+ ) ;
87
+ } else {
88
+ this . serverless . cli . log (
89
+ `Removing Python requirements helper from ${ f . module } ...`
90
+ ) ;
91
+ }
78
92
return fse . removeAsync (
79
93
path . join ( this . servicePath , f . module , 'unzip_requirements.py' )
80
94
) ;
81
95
} ) ;
82
96
} else {
83
- this . serverless . cli . log ( 'Removing Python requirements helper...' ) ;
97
+ if ( this . log ) {
98
+ this . log . info ( 'Removing Python requirements helper' ) ;
99
+ } else {
100
+ this . serverless . cli . log ( 'Removing Python requirements helper...' ) ;
101
+ }
84
102
return fse . removeAsync (
85
103
path . join ( this . servicePath , 'unzip_requirements.py' )
86
104
) ;
@@ -104,21 +122,46 @@ function packRequirements() {
104
122
} )
105
123
. then ( ( funcs ) => uniqBy ( funcs , ( f ) => f . module ) )
106
124
. map ( ( f ) => {
107
- this . serverless . cli . log (
108
- `Zipping required Python packages for ${ f . module } ...`
109
- ) ;
125
+ let packProgress ;
126
+ if ( this . progress ) {
127
+ packProgress = this . progress . get (
128
+ `python-pack-requirements-${ f . module } `
129
+ ) ;
130
+ packProgress . update (
131
+ `Zipping required Python packages for ${ f . module } ` ,
132
+ { isMainEvent : true }
133
+ ) ;
134
+ } else {
135
+ this . serverless . cli . log (
136
+ `Zipping required Python packages for ${ f . module } ...`
137
+ ) ;
138
+ }
110
139
f . package . patterns . push ( `${ f . module } /.requirements.zip` ) ;
111
- return addTree (
112
- new JSZip ( ) ,
113
- `.serverless/${ f . module } /requirements`
114
- ) . then ( ( zip ) => writeZip ( zip , `${ f . module } /.requirements.zip` ) ) ;
140
+ return addTree ( new JSZip ( ) , `.serverless/${ f . module } /requirements` )
141
+ . then ( ( zip ) => writeZip ( zip , `${ f . module } /.requirements.zip` ) )
142
+ . then ( ( ) => packProgress && packProgress . remove ( ) )
143
+ . catch ( ( e ) => {
144
+ packProgress && packProgress . remove ( ) ;
145
+ throw e ;
146
+ } ) ;
115
147
} ) ;
116
148
} else {
117
- this . serverless . cli . log ( 'Zipping required Python packages...' ) ;
149
+ let packProgress ;
150
+ if ( this . progress ) {
151
+ packProgress = this . progress . get ( `python-pack-requirements` ) ;
152
+ } else {
153
+ this . serverless . cli . log ( 'Zipping required Python packages...' ) ;
154
+ }
118
155
this . serverless . service . package . patterns . push ( '.requirements.zip' ) ;
119
- return addTree ( new JSZip ( ) , '.serverless/requirements' ) . then ( ( zip ) =>
120
- writeZip ( zip , path . join ( this . servicePath , '.requirements.zip' ) )
121
- ) ;
156
+ return addTree ( new JSZip ( ) , '.serverless/requirements' )
157
+ . then ( ( zip ) =>
158
+ writeZip ( zip , path . join ( this . servicePath , '.requirements.zip' ) )
159
+ )
160
+ . then ( ( ) => packProgress && packProgress . remove ( ) )
161
+ . catch ( ( e ) => {
162
+ packProgress && packProgress . remove ( ) ;
163
+ throw e ;
164
+ } ) ;
122
165
}
123
166
}
124
167
}
0 commit comments