Skip to content

Commit

Permalink
fix(CLI): Fix log messages timing
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 17, 2021
1 parent 7eeaa10 commit 084a995
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
44 changes: 34 additions & 10 deletions lib/plugins/aws/deploy/index.js
Expand Up @@ -11,7 +11,7 @@ const validateTemplate = require('./lib/validateTemplate');
const updateStack = require('../lib/updateStack');
const existsDeploymentBucket = require('./lib/existsDeploymentBucket');
const path = require('path');
const { style, log, progress } = require('@serverless/utils/log');
const { style, log, progress, writeText } = require('@serverless/utils/log');
const memoize = require('memoizee');

class AwsDeploy {
Expand Down Expand Up @@ -119,15 +119,6 @@ class AwsDeploy {
'aws:deploy:deploy:updateStack': async () => {
if (this.serverless.service.provider.shouldNotDeploy) return;
await this.updateStack();
log.notice(
`\n${style.noticeSymbol('✔')} Service deployed to stack ${this.serverless
.getProvider('aws')
.naming.getStackName()} ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}\n`
);
},

// Deploy finalize inner lifecycle
Expand Down Expand Up @@ -158,6 +149,39 @@ class AwsDeploy {
);
}
},

'finalize': () => {
if (this.serverless.processedInput.commands.join(' ') !== 'deploy') return;
if (this.options.function) return;
if (this.serverless.service.provider.shouldNotDeploy) {
log.notice(
`\n${style.noticeSymbol('∅')} No changes to deploy. Deployment skipped. ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}`
);
return;
}
log.notice(
`\n${style.noticeSymbol('✔')} Service deployed to stack ${this.serverless
.getProvider('aws')
.naming.getStackName()} ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}\n`
);
if (this.serverless.serviceOutputs) {
for (const [section, entries] of this.serverless.serviceOutputs) {
if (typeof entries === 'string') {
writeText(`${style.aside(`${section}:`)} ${entries}`);
} else {
writeText(`${style.aside(`${section}:\n`)} ${entries.join('\n ')}`);
}
}
}
},
};
}
}
Expand Down
9 changes: 1 addition & 8 deletions lib/plugins/aws/deploy/lib/checkForChanges.js
Expand Up @@ -8,7 +8,7 @@ const BbPromise = require('bluebird');
const _ = require('lodash');
const normalizeFiles = require('../../lib/normalizeFiles');
const ServerlessError = require('../../../../serverless-error');
const { style, legacy, log } = require('@serverless/utils/log');
const { legacy } = require('@serverless/utils/log');

module.exports = {
async checkForChanges() {
Expand Down Expand Up @@ -188,13 +188,6 @@ module.exports = {

const message = ['Service files not changed. Skipping deployment...'].join('');
legacy.log(message, 'Serverless', { color: 'orange' });
log.notice(
`\n${style.noticeSymbol('∅')} No changes to deploy. Deployment skipped. ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}`
);
}
});
}
Expand Down
14 changes: 1 addition & 13 deletions lib/plugins/aws/info/display.js
@@ -1,7 +1,7 @@
'use strict';

const chalk = require('chalk');
const { style, legacy, writeText, isVerboseMode } = require('@serverless/utils/log');
const { legacy, isVerboseMode } = require('@serverless/utils/log');

module.exports = {
displayServiceInfo() {
Expand Down Expand Up @@ -183,16 +183,4 @@ module.exports = {

return message;
},

displayServiceOutputs() {
if (this.serverless.serviceOutputs && !this.serverless.service.provider.shouldNotDeploy) {
for (const [section, entries] of this.serverless.serviceOutputs) {
if (typeof entries === 'string') {
writeText(`${style.aside(`${section}:`)} ${entries}`);
} else {
writeText(`${style.aside(`${section}:\n`)} ${entries.join('\n ')}`);
}
}
}
},
};
3 changes: 0 additions & 3 deletions lib/plugins/aws/info/index.js
Expand Up @@ -28,7 +28,6 @@ class AwsInfo {
'displayFunctions',
'displayLayers',
'displayStackOutputs',
'displayServiceOutputs',
],
},
},
Expand Down Expand Up @@ -63,8 +62,6 @@ class AwsInfo {

'aws:info:displayStackOutputs': async () =>
BbPromise.bind(this).then(this.displayStackOutputs),

'aws:info:displayServiceOutputs': async () => await this.displayServiceOutputs(),
};
}
}
Expand Down

0 comments on commit 084a995

Please sign in to comment.