@@ -110,7 +110,7 @@ export async function tryHotswapDeployment(
110110 hotswapPropertyOverrides ,
111111 ) ;
112112
113- await hotswapSpan . end ( ) ;
113+ await hotswapSpan . end ( result ) ;
114114
115115 if ( result ?. hotswapped === true ) {
116116 return {
@@ -135,7 +135,7 @@ async function hotswapDeployment(
135135 stack : cxapi . CloudFormationStackArtifact ,
136136 hotswapMode : HotswapMode ,
137137 hotswapPropertyOverrides : HotswapPropertyOverrides ,
138- ) : Promise < HotswapResult > {
138+ ) : Promise < Omit < HotswapResult , 'duration' > > {
139139 // resolve the environment, so we can substitute things like AWS::Region in CFN expressions
140140 const resolvedEnv = await sdkProvider . resolveEnvironment ( stack . environment ) ;
141141 // create a new SDK using the CLI credentials, because the default one will not work for new-style synthesis -
@@ -162,11 +162,18 @@ async function hotswapDeployment(
162162 currentTemplate . nestedStacks , hotswapPropertyOverrides ,
163163 ) ;
164164
165- await logNonHotswappableChanges ( ioSpan , nonHotswappable , hotswapMode ) ;
165+ await logRejectedChanges ( ioSpan , nonHotswappable , hotswapMode ) ;
166166
167167 const hotswappableChanges = hotswappable . map ( o => o . change ) ;
168168 const nonHotswappableChanges = nonHotswappable . map ( n => n . change ) ;
169169
170+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5401 . msg ( 'Hotswap plan created' , {
171+ stack,
172+ mode : hotswapMode ,
173+ hotswappableChanges,
174+ nonHotswappableChanges,
175+ } ) ) ;
176+
170177 // preserve classic hotswap behavior
171178 if ( hotswapMode === 'fall-back' ) {
172179 if ( nonHotswappableChanges . length > 0 ) {
@@ -181,7 +188,7 @@ async function hotswapDeployment(
181188 }
182189
183190 // apply the short-circuitable changes
184- await applyAllHotswappableChanges ( sdk , ioSpan , hotswappable ) ;
191+ await applyAllHotswapOperations ( sdk , ioSpan , hotswappable ) ;
185192
186193 return {
187194 stack,
@@ -489,27 +496,29 @@ function isCandidateForHotswapping(
489496 } ;
490497}
491498
492- async function applyAllHotswappableChanges ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswappableChanges : HotswapOperation [ ] ) : Promise < void [ ] > {
493- if ( hotswappableChanges . length > 0 ) {
494- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( `\n ${ ICON } hotswapping resources:` ) ) ;
499+ async function applyAllHotswapOperations ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswappableChanges : HotswapOperation [ ] ) : Promise < void [ ] > {
500+ if ( hotswappableChanges . length === 0 ) {
501+ return Promise . resolve ( [ ] ) ;
495502 }
503+
504+ await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( `\n${ ICON } hotswapping resources:` ) ) ;
496505 const limit = pLimit ( 10 ) ;
497506 // eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism
498507 return Promise . all ( hotswappableChanges . map ( hotswapOperation => limit ( ( ) => {
499- return applyHotswappableChange ( sdk , ioSpan , hotswapOperation ) ;
508+ return applyHotswapOperation ( sdk , ioSpan , hotswapOperation ) ;
500509 } ) ) ) ;
501510}
502511
503- async function applyHotswappableChange ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswapOperation : HotswapOperation ) : Promise < void > {
512+ async function applyHotswapOperation ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswapOperation : HotswapOperation ) : Promise < void > {
504513 // note the type of service that was successfully hotswapped in the User-Agent
505514 const customUserAgent = `cdk-hotswap/success-${ hotswapOperation . service } ` ;
506515 sdk . appendCustomUserAgent ( customUserAgent ) ;
507-
508516 const resourceText = ( r : AffectedResource ) => r . description ?? `${ r . resourceType } '${ r . physicalName ?? r . logicalId } '` ;
509517
510- for ( const resource of hotswapOperation . change . resources ) {
511- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( ` ${ ICON } %s` , chalk . bold ( resourceText ( resource ) ) ) ) ) ;
512- }
518+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5402 . msg (
519+ hotswapOperation . change . resources . map ( r => format ( ` ${ ICON } %s` , chalk . bold ( resourceText ( r ) ) ) ) . join ( '\n' ) ,
520+ hotswapOperation . change ,
521+ ) ) ;
513522
514523 // if the SDK call fails, an error will be thrown by the SDK
515524 // and will prevent the green 'hotswapped!' text from being displayed
@@ -525,9 +534,10 @@ async function applyHotswappableChange(sdk: SDK, ioSpan: IMessageSpan<any>, hots
525534 throw e ;
526535 }
527536
528- for ( const resource of hotswapOperation . change . resources ) {
529- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( `${ ICON } %s %s` , chalk . bold ( resourceText ( resource ) ) , chalk . green ( 'hotswapped!' ) ) ) ) ;
530- }
537+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5403 . msg (
538+ hotswapOperation . change . resources . map ( r => format ( ` ${ ICON } %s %s` , chalk . bold ( resourceText ( r ) ) , chalk . green ( 'hotswapped!' ) ) ) . join ( '\n' ) ,
539+ hotswapOperation . change ,
540+ ) ) ;
531541
532542 sdk . removeCustomUserAgent ( customUserAgent ) ;
533543}
@@ -550,12 +560,12 @@ function formatWaiterErrorResult(result: WaiterResult) {
550560 return main ;
551561}
552562
553- async function logNonHotswappableChanges (
563+ async function logRejectedChanges (
554564 ioSpan : IMessageSpan < any > ,
555- nonHotswappableChanges : RejectedChange [ ] ,
565+ rejectedChanges : RejectedChange [ ] ,
556566 hotswapMode : HotswapMode ,
557567) : Promise < void > {
558- if ( nonHotswappableChanges . length === 0 ) {
568+ if ( rejectedChanges . length === 0 ) {
559569 return ;
560570 }
561571 /**
@@ -566,9 +576,9 @@ async function logNonHotswappableChanges(
566576 * This logic prevents us from logging that change as non-hotswappable when we hotswap it.
567577 */
568578 if ( hotswapMode === 'hotswap-only' ) {
569- nonHotswappableChanges = nonHotswappableChanges . filter ( ( change ) => change . hotswapOnlyVisible === true ) ;
579+ rejectedChanges = rejectedChanges . filter ( ( change ) => change . hotswapOnlyVisible === true ) ;
570580
571- if ( nonHotswappableChanges . length === 0 ) {
581+ if ( rejectedChanges . length === 0 ) {
572582 return ;
573583 }
574584 }
@@ -581,8 +591,8 @@ async function logNonHotswappableChanges(
581591 messages . push ( format ( '%s %s' , chalk . red ( '⚠️' ) , chalk . red ( 'The following non-hotswappable changes were found:' ) ) ) ;
582592 }
583593
584- for ( const rejection of nonHotswappableChanges ) {
585- messages . push ( ' ' + nonHotswappableChangeMessage ( rejection . change ) ) ;
594+ for ( const { change } of rejectedChanges ) {
595+ messages . push ( ' ' + nonHotswappableChangeMessage ( change ) ) ;
586596 }
587597 messages . push ( '' ) ; // newline
588598
0 commit comments