mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
refactor(CLI): Change stack update progress logging method
This commit is contained in:
parent
7c91cde7ac
commit
8184c01c7c
@ -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 = /(?<!^)([A-Z])/g;
|
||||
@ -27,14 +26,7 @@ module.exports = {
|
||||
cfData,
|
||||
stackUrl,
|
||||
options,
|
||||
{
|
||||
loggedEventIds = new Set(),
|
||||
stackStatus = null,
|
||||
stackLatestError = null,
|
||||
firstEventId = null,
|
||||
inProgressResources = new Set(),
|
||||
completedResources = new Set(),
|
||||
}
|
||||
{ loggedEventIds = new Set(), stackStatus = null, stackLatestError = null, firstEventId = null }
|
||||
) {
|
||||
return wait(options.frequency || process.env.SLS_AWS_MONITORING_FREQUENCY || 5000)
|
||||
.then(() =>
|
||||
@ -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,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user