Repository navigation
Allow entrypoints to be defined and called by plugins. - #3327
Conversation
Commands can contain a type property. The only allowed value currently is 'entrypoint'. This declares the command as hidden from the CLI. It will not appear in the help screen, nor can it be called from there. However, entrypoint type commands can be called by plugins via the new PluginManager.spawn(commandsArray) method. In contrast to PluginManager.run() this method allows access to entrypoint commands and can be used to enter a plugin internal sub lifecycle. With this mechanism in place, plugins can expose their own lifecycle events which become then part of the global lifecycle and can be hooked again by dependent plugins.
|
@eahefnawy @pmuens This is the solution for the workaround I mentioned in my upcoming blog post. Can you please have a look. The difference is, that you now call this.serverless.pluginManager.spawn([ ... ]) to enter the plugins exposed lifecycle instead of run. Additionally these entrypoint commands are no longer shown in the help screen and they are not exposed to the CLI. |
|
Here is how the AWSDeploy plugin could integrate into the lifecycle and With this approach the AWSDeploy would expose the following hooks that can awsDeploy:deploy:prepare Does that sound feasible? BTW: The noDeploy interception could be then'd after the spawn as it does not really belong to the cleanup lifecycle event |
|
I remember that there was a major feature request (GitHub issue) for implementing plugin dependencies. In my opinion this is solved here too. It enables plugin references and plugin availability checks can be done via pluginManager anyways. If this is accepted, we can also link to this issue |
|
I tested the functionality completely with the changes done to the AWSDeploy plugin (code snippets above). Everything works -> plugin execution, help screen and the awsDeploy command cannot be accessed from the CLI! See here: HyperBrain#1 As soon as this is merged I'll create a PR for the AWSDeploy plugin changes and connect the serverless-aws-alias plugin to the new semantics to make it better and more stable. |
|
@eahefnawy I extended the pluginManager tests to check everything regarding the spawn() command and additionally the run() command. This now makes sure that everything works and proves that this is a non-breaking change ;-) |
eahefnawy
left a comment
There was a problem hiding this comment.
Thanks for this PR Frank, and for adding the changes we discussed.
Looks G2M 😊
Commands can contain an optional type property. The only allowed value currently is 'entrypoint'. This declares the command as hidden from the CLI. It will not appear in the help screen, nor can it be called from there.
However, entrypoint type commands can be called by plugins via the new PluginManager.spawn(commandsArray) method. In contrast to PluginManager.run() this method allows access to entrypoint commands and can be used to enter a plugin internal sub lifecycle. With this mechanism in place, plugins can expose their own lifecycle events which become then part of the global lifecycle and can be hooked again by dependent plugins.
What did you implement:
Closes #XXXXX
How did you implement it:
How can we verify it:
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO