diff --git a/lib/plugins/install.js b/lib/plugins/install.js index 394fcaa2c5e..e0b1026b914 100644 --- a/lib/plugins/install.js +++ b/lib/plugins/install.js @@ -4,6 +4,7 @@ const BbPromise = require('bluebird'); const cliCommandsSchema = require('../cli/commands-schema'); const download = require('../utils/downloadTemplateFromRepo'); +const { legacy, log, progress, style } = require('@serverless/utils/log'); class Install { constructor(serverless, options) { @@ -22,20 +23,23 @@ class Install { } async install() { - return download - .downloadTemplateFromRepo(this.options.url, this.options.name) - .then((serviceName) => { - const message = [ - `Successfully installed "${serviceName}" `, - `${ - this.options.name && this.options.name !== serviceName - ? `as "${this.options.name}"` - : '' - }`, - ].join(''); - - this.serverless.cli.log(message); - }); + const commandRunStartTime = Date.now(); + progress.get('main').notice(`Downloading service from provided url: ${this.options.url}`); + const serviceName = await download.downloadTemplateFromRepo( + this.options.url, + this.options.name + ); + const message = [ + `Successfully installed "${serviceName}" `, + `${ + this.options.name && this.options.name !== serviceName ? `as "${this.options.name}"` : '' + }`, + ].join(''); + + legacy.log(message); + log.notice.success( + `${message} ${style.aside(`(${Math.floor((Date.now() - commandRunStartTime) / 1000)}s)`)}` + ); } } diff --git a/lib/utils/downloadTemplateFromRepo.js b/lib/utils/downloadTemplateFromRepo.js index 416e4b1d849..e4f626786aa 100644 --- a/lib/utils/downloadTemplateFromRepo.js +++ b/lib/utils/downloadTemplateFromRepo.js @@ -13,7 +13,7 @@ const renameService = require('./renameService').renameService; const ServerlessError = require('../serverless-error'); const copyDirContentsSync = require('./fs/copyDirContentsSync'); const dirExistsSync = require('./fs/dirExistsSync'); -const log = require('./log/serverlessLog'); +const { legacy } = require('@serverless/utils/log'); /** * Returns directory path @@ -291,7 +291,7 @@ async function downloadTemplateFromRepo(inputUrl, templateName, downloadPath, op } if (!options.silent) { - log(`Downloading and installing "${serviceName}"...`); + legacy.log(`Downloading and installing "${serviceName}"...`); } if (isPlainGitURL(inputUrl)) { diff --git a/test/unit/lib/plugins/install.test.js b/test/unit/lib/plugins/install.test.js index 7e051307191..f5293f6510e 100644 --- a/test/unit/lib/plugins/install.test.js +++ b/test/unit/lib/plugins/install.test.js @@ -16,7 +16,6 @@ describe('Install', () => { let install; let serverless; let cwd; - let logSpy; let serviceDir; @@ -33,7 +32,6 @@ describe('Install', () => { install = new Install(serverless); return serverless.init().then(() => { install.serverless.cli = new serverless.classes.CLI(); - logSpy = sinon.spy(install.serverless.cli, 'log'); }); }); @@ -112,12 +110,7 @@ describe('Install', () => { downloadStub.resolves('remote-service'); return install.install().then(() => { - const installationMessage = logSpy.args.filter((arg) => - arg[0].includes('installed "remote-service"') - ); - expect(downloadStub).to.have.been.calledOnce; - expect(installationMessage[0]).to.have.lengthOf(1); }); }); @@ -127,12 +120,7 @@ describe('Install', () => { downloadStub.resolves('remote-service'); return install.install().then(() => { - const installationMessage = logSpy.args.filter((arg) => - arg[0].includes('installed "remote-service" as "remote"') - ); - expect(downloadStub).to.have.been.calledOnce; - expect(installationMessage[0]).to.have.lengthOf(1); }); }); });