diff --git a/src/Serverless.d.ts b/src/Serverless.d.ts index f5096921..7c3e9f2d 100644 --- a/src/Serverless.d.ts +++ b/src/Serverless.d.ts @@ -46,7 +46,24 @@ declare namespace Serverless { individually?: boolean } + type CommandsDefinition = Record< + string, + { + lifecycleEvents?: string[] + commands?: CommandsDefinition + usage?: string + options?: { + [name: string]: { + type: string + usage: string + required?: boolean + shortcut?: string + } + } + } + > + interface PluginManager { spawn(command: string): Promise } -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index c787f17a..adafe7a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,11 +16,27 @@ export class TypeScriptPlugin { serverless: Serverless.Instance options: Serverless.Options hooks: { [key: string]: Function } + commands: Serverless.CommandsDefinition constructor(serverless: Serverless.Instance, options: Serverless.Options) { this.serverless = serverless this.options = options + this.commands = { + invoke: { + commands: { + local: { + options: { + watch: { + type: 'boolean', + usage: 'Watch file changes and re-invoke automatically the function' + } + } + } + } + } + } + this.hooks = { 'before:run:run': async () => { await this.compileTs()