@@ -21,7 +21,10 @@ export class AmplifyEventLogger {
21
21
/**
22
22
* a logger instance to be used for CDK events
23
23
*/
24
- constructor ( private readonly printer : Printer = globalPrinter ) { }
24
+ constructor (
25
+ private readonly printer : Printer = globalPrinter ,
26
+ private readonly amplifyIOEventsBridgeSingletonFactory : AmplifyIOEventsBridgeSingletonFactory ,
27
+ ) { }
25
28
26
29
getEventLoggers = ( ) => {
27
30
if ( minimumLogLevel === LogLevel . DEBUG ) {
@@ -105,6 +108,9 @@ export class AmplifyEventLogger {
105
108
case 'SYNTH_FINISHED' :
106
109
this . printer . stopSpinner ( ) ;
107
110
break ;
111
+ case 'DEPLOY_STARTED' :
112
+ this . printer . stopSpinner ( ) ;
113
+ break ;
108
114
case 'AMPLIFY_CFN_PROGRESS_UPDATE' :
109
115
if ( ! this . printer . isSpinnerRunning ( ) ) {
110
116
this . printer . startSpinner ( 'Deployment in progress...' ) ;
@@ -130,17 +136,6 @@ export class AmplifyEventLogger {
130
136
this . printer . startSpinner ( 'Building and publishing assets...' ) ;
131
137
}
132
138
return Promise . resolve ( ) ;
133
- } else if (
134
- // CDK_TOOLKIT_I5221 when assets are published or when no publishing is required
135
- msg . code === 'CDK_TOOLKIT_I5221' ||
136
- msg . message . includes ( '0 still need to be published' )
137
- ) {
138
- // We only want to display the success message once or if tty is not available
139
- if ( this . printer . isSpinnerRunning ( ) || ! this . printer . ttyEnabled ) {
140
- this . printer . stopSpinner ( ) ;
141
- this . printer . log ( `${ format . success ( '✔' ) } Built and published assets` ) ;
142
- }
143
- return Promise . resolve ( ) ;
144
139
}
145
140
146
141
// Hot swap deployment
@@ -205,12 +200,24 @@ export class AmplifyEventLogger {
205
200
fancyCfnDeploymentProgress = async < T > (
206
201
msg : AmplifyIoHostEventMessage < T > ,
207
202
) : Promise < void > => {
208
- // Start deployment progress display
209
203
// 5100 -> Deployment starts 7100 -> Destroy starts
210
204
if (
211
205
( msg . code === 'CDK_TOOLKIT_I5100' || msg . code === 'CDK_TOOLKIT_I7100' ) &&
212
206
! this . cfnDeploymentProgressLogger
213
207
) {
208
+ if ( msg . code === 'CDK_TOOLKIT_I5100' ) {
209
+ // Mark assets published. We use "deploy started" as a cue to mark that all assets have been published
210
+ await this . amplifyIOEventsBridgeSingletonFactory . getInstance ( ) . notify ( {
211
+ message : `Built and published assets` ,
212
+ code : 'DEPLOY_STARTED' ,
213
+ action : 'amplify' ,
214
+ time : new Date ( ) ,
215
+ level : 'result' ,
216
+ data : undefined ,
217
+ } ) ;
218
+ }
219
+
220
+ // Start deployment progress display
214
221
this . cfnDeploymentProgressLogger = this . getNewCfnDeploymentProgressLogger (
215
222
this . printer ,
216
223
) ;
@@ -264,6 +271,16 @@ export class AmplifyEventLogger {
264
271
nonTtyCfnDeploymentProgress = async < T > (
265
272
msg : AmplifyIoHostEventMessage < T > ,
266
273
) : Promise < void > => {
274
+ if ( msg . code === 'CDK_TOOLKIT_I5100' ) {
275
+ await this . amplifyIOEventsBridgeSingletonFactory . getInstance ( ) . notify ( {
276
+ message : `Built and published assets` ,
277
+ code : 'DEPLOY_STARTED' ,
278
+ action : 'amplify' ,
279
+ time : new Date ( ) ,
280
+ level : 'result' ,
281
+ data : undefined ,
282
+ } ) ;
283
+ }
267
284
if ( msg . code === 'CDK_TOOLKIT_I5502' ) {
268
285
// CDKs formatted cfn deployment progress
269
286
this . printer . print ( msg . message ) ;
@@ -280,7 +297,7 @@ export class AmplifyEventLogger {
280
297
rewritableBlock : new RewritableBlock (
281
298
getBlockWidth ,
282
299
getBlockHeight ,
283
- new AmplifyIOEventsBridgeSingletonFactory ( printer ) . getInstance ( ) ,
300
+ this . amplifyIOEventsBridgeSingletonFactory . getInstance ( ) ,
284
301
) ,
285
302
} ) ;
286
303
} ;
0 commit comments