mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
It's needed to be able to process commands as introduced by plugins without a need of processing Serverless instance
43 lines
990 B
JavaScript
43 lines
990 B
JavaScript
'use strict';
|
|
|
|
const BbPromise = require('bluebird');
|
|
|
|
const cliCommandsSchema = require('../cli/commands-schema');
|
|
const download = require('../utils/downloadTemplateFromRepo');
|
|
|
|
class Install {
|
|
constructor(serverless, options) {
|
|
this.serverless = serverless;
|
|
this.options = options;
|
|
|
|
this.commands = {
|
|
install: {
|
|
...cliCommandsSchema.get('install'),
|
|
},
|
|
};
|
|
|
|
this.hooks = {
|
|
'install:install': async () => BbPromise.bind(this).then(this.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);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = Install;
|