From 8184c01c7c519e05ab9f7a1ab0e0484bfce2aafd Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Thu, 7 Oct 2021 10:20:44 +0200 Subject: [PATCH] refactor(CLI): Change stack update progress logging method --- lib/plugins/aws/lib/monitorStack.js | 37 ++++++++--------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/lib/plugins/aws/lib/monitorStack.js b/lib/plugins/aws/lib/monitorStack.js index e028cff68..ad0dedcf6 100644 --- a/lib/plugins/aws/lib/monitorStack.js +++ b/lib/plugins/aws/lib/monitorStack.js @@ -7,7 +7,6 @@ const identity = require('ext/function/identity'); const ServerlessError = require('../../../serverless-error'); const { log, legacy, progress, style } = require('@serverless/utils/log'); -const mainProgress = progress.get('main'); const validStatuses = new Set(['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'DELETE_COMPLETE']); const normalizerPattern = /(? @@ -99,27 +91,20 @@ module.exports = { legacy.write(chalk.yellow('.')); } - if (event.ResourceType !== 'AWS::CloudFormation::Stack') { + if (action !== 'create' && event.ResourceType !== 'AWS::CloudFormation::Stack') { if (eventStatus && eventStatus.endsWith('PROGRESS')) { - inProgressResources.add(event.LogicalResourceId); + progress + .get(`cf-deploy-${event.LogicalResourceId}`) + .notice( + style.aside( + ` ${eventStatus} - ${event.ResourceType} - ${event.LogicalResourceId}` + ) + ); } else if (eventStatus && eventStatus.endsWith('COMPLETE')) { - completedResources.add(event.LogicalResourceId); - inProgressResources.delete(event.LogicalResourceId); + progress.get(`cf-deploy-${event.LogicalResourceId}`).remove(); } } - if ((completedResources.size || inProgressResources.size) && action !== 'create') { - const progressMessagePrefix = (() => { - if (action === 'update') return 'Updating'; - if (action === 'delete') return 'Removing'; - throw new Error(`Unrecgonized action: ${action}`); - })(); - mainProgress.notice( - `${progressMessagePrefix} CloudFormation stack (${completedResources.size}/${ - completedResources.size + inProgressResources.size - })` - ); - } // Prepare for next monitoring action loggedEventIds.add(event.EventId); }); @@ -184,8 +169,6 @@ module.exports = { stackStatus, stackLatestError, firstEventId, - inProgressResources, - completedResources, }); }); },