mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
class ServerlessPlugin {
|
|
constructor(serverless, options) {
|
|
this.serverless = serverless;
|
|
this.options = options;
|
|
|
|
this.commands = {
|
|
welcome: {
|
|
usage: 'Helps you start your first Serverless plugin',
|
|
lifecycleEvents: ['hello', 'world'],
|
|
options: {
|
|
message: {
|
|
usage:
|
|
'Specify the message you want to deploy ' +
|
|
'(e.g. "--message \'My Message\'" or "-m \'My Message\'")',
|
|
required: true,
|
|
shortcut: 'm',
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
this.hooks = {
|
|
'before:welcome:hello': this.beforeWelcome.bind(this),
|
|
'welcome:hello': this.welcomeUser.bind(this),
|
|
'welcome:world': this.displayHelloMessage.bind(this),
|
|
'after:welcome:world': this.afterHelloWorld.bind(this),
|
|
};
|
|
}
|
|
|
|
beforeWelcome() {
|
|
this.serverless.cli.log('Hello from Serverless!');
|
|
}
|
|
|
|
welcomeUser() {
|
|
this.serverless.cli.log('Your message:');
|
|
}
|
|
|
|
displayHelloMessage() {
|
|
this.serverless.cli.log(`${this.options.message}`);
|
|
}
|
|
|
|
afterHelloWorld() {
|
|
this.serverless.cli.log('Please come again!');
|
|
}
|
|
}
|
|
|
|
module.exports = ServerlessPlugin;
|