mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
refactor(CLI): Modern logs for upgrade command
This commit is contained in:
parent
2787ea07a9
commit
9b5e6b1237
@ -42,10 +42,18 @@ module.exports = class Standalone {
|
||||
}
|
||||
|
||||
async upgrade() {
|
||||
mainProgress.notice('Resolving latest standalone version', { isMainEvent: true });
|
||||
const tagName = await standaloneUtils.resolveLatestTag();
|
||||
const latestVersion = tagName.slice(1);
|
||||
if (latestVersion === currentVersion) {
|
||||
this.serverless.cli.log('Already at latest version');
|
||||
legacy.log('Already at latest version');
|
||||
log.notice.skip(
|
||||
`Already at latest version ${style.aside(
|
||||
`(${Math.floor(
|
||||
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
|
||||
)}s)`
|
||||
)}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const currentMajor = Number(currentVersion.split('.')[0]);
|
||||
@ -64,7 +72,8 @@ module.exports = class Standalone {
|
||||
'CANNOT_UPGRADE_MAJOR'
|
||||
);
|
||||
}
|
||||
this.serverless.cli.log('Downloading new version...');
|
||||
legacy.log('Downloading new version...');
|
||||
mainProgress.notice('Downloading latest standalone version', { isMainEvent: true });
|
||||
const executableUrl = standaloneUtils.resolveUrl(tagName);
|
||||
const standaloneResponse = await fetch(executableUrl);
|
||||
if (!standaloneResponse.ok) {
|
||||
@ -78,17 +87,21 @@ module.exports = class Standalone {
|
||||
await pipeline(standaloneResponse.body, fs.createWriteStream(BINARY_TMP_PATH));
|
||||
await fsp.rename(BINARY_TMP_PATH, BINARY_PATH);
|
||||
await fsp.chmod(BINARY_PATH, 0o755);
|
||||
this.serverless.cli.log(`Successfully upgraded to ${tagName}`);
|
||||
legacy.log(`Successfully upgraded to ${tagName}`);
|
||||
log.notice.success(
|
||||
`Successfully upgraded to ${tagName} ${style.aside(
|
||||
`(${Math.floor((Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000)}s)`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
async uninstall() {
|
||||
const commandRunStartTime = Date.now();
|
||||
mainProgress.notice('Uninstalling standalone binary', { isMainEvent: true });
|
||||
await fse.remove(path.dirname(BINARY_PATH));
|
||||
legacy.log('Uninstalled');
|
||||
log.notice.success(
|
||||
`Standalone binary uninstalled ${style.aside(
|
||||
`(${Math.floor((Date.now() - commandRunStartTime) / 1000)}s)`
|
||||
`(${Math.floor((Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000)}s)`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user