@@ -21,7 +21,10 @@ export class AmplifyEventLogger {
2121 /**
2222 * a logger instance to be used for CDK events
2323 */
24- constructor ( private readonly printer : Printer = globalPrinter ) { }
24+ constructor (
25+ private readonly printer : Printer = globalPrinter ,
26+ private readonly amplifyIOEventsBridgeSingletonFactory : AmplifyIOEventsBridgeSingletonFactory ,
27+ ) { }
2528
2629 getEventLoggers = ( ) => {
2730 if ( minimumLogLevel === LogLevel . DEBUG ) {
@@ -105,6 +108,9 @@ export class AmplifyEventLogger {
105108 case 'SYNTH_FINISHED' :
106109 this . printer . stopSpinner ( ) ;
107110 break ;
111+ case 'DEPLOY_STARTED' :
112+ this . printer . stopSpinner ( ) ;
113+ break ;
108114 case 'AMPLIFY_CFN_PROGRESS_UPDATE' :
109115 if ( ! this . printer . isSpinnerRunning ( ) ) {
110116 this . printer . startSpinner ( 'Deployment in progress...' ) ;
@@ -130,17 +136,6 @@ export class AmplifyEventLogger {
130136 this . printer . startSpinner ( 'Building and publishing assets...' ) ;
131137 }
132138 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 ( ) ;
144139 }
145140
146141 // Hot swap deployment
@@ -205,12 +200,24 @@ export class AmplifyEventLogger {
205200 fancyCfnDeploymentProgress = async < T > (
206201 msg : AmplifyIoHostEventMessage < T > ,
207202 ) : Promise < void > => {
208- // Start deployment progress display
209203 // 5100 -> Deployment starts 7100 -> Destroy starts
210204 if (
211205 ( msg . code === 'CDK_TOOLKIT_I5100' || msg . code === 'CDK_TOOLKIT_I7100' ) &&
212206 ! this . cfnDeploymentProgressLogger
213207 ) {
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
214221 this . cfnDeploymentProgressLogger = this . getNewCfnDeploymentProgressLogger (
215222 this . printer ,
216223 ) ;
@@ -264,6 +271,16 @@ export class AmplifyEventLogger {
264271 nonTtyCfnDeploymentProgress = async < T > (
265272 msg : AmplifyIoHostEventMessage < T > ,
266273 ) : 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+ }
267284 if ( msg . code === 'CDK_TOOLKIT_I5502' ) {
268285 // CDKs formatted cfn deployment progress
269286 this . printer . print ( msg . message ) ;
@@ -280,7 +297,7 @@ export class AmplifyEventLogger {
280297 rewritableBlock : new RewritableBlock (
281298 getBlockWidth ,
282299 getBlockHeight ,
283- new AmplifyIOEventsBridgeSingletonFactory ( printer ) . getInstance ( ) ,
300+ this . amplifyIOEventsBridgeSingletonFactory . getInstance ( ) ,
284301 ) ,
285302 } ) ;
286303 } ;
0 commit comments