feat: add support for configurable hooks libraries - #334
Conversation
| ] | ||
| ], | ||
| "hooks": { | ||
| "@asyncapi/generator-hooks": "hookFunctionName" |
There was a problem hiding this comment.
Will it be better to provide upper in example section at least one hook with defined name?
There was a problem hiding this comment.
What do you mean? in example section we provide examples of hooks that you rather put locally in your template, writing own hooks library is like advanced usage in my opinion
this config example shows usage of our official hooks library, you do not have to add to config your local hooks
There was a problem hiding this comment.
Yes, but assume i'm newbie. I just read Hooks section, now read this section and see specify exact name of the hook. And now i ask, what exactly hook name is? This has not been mentioned before.
So, sure, you do not need to give names to local hooks, but example of hook with name will increase understanding of the concept, from my point of view.
There was a problem hiding this comment.
how about now? I added some more content 87a9dfd
There was a problem hiding this comment.
I still think that one example is better than long description 😄 , but nevertheless questions are described now in docs. So it's fine.
fmvilas
left a comment
There was a problem hiding this comment.
Looks good. Just left a suggestion and agree with @Tenischev comments but overall looks great.
Regarding tests, I think we should introduce integration (snapshot maybe) tests for these features, would be easier than doing unit tests. Not now though.
| ] | ||
| ], | ||
| "hooks": { | ||
| "@asyncapi/generator-hooks": "hookFunctionName" |
There was a problem hiding this comment.
I still think that one example is better than long description 😄 , but nevertheless questions are described now in docs. So it's fine.
Co-authored-by: Fran Méndez <fmvilas@gmail.com>
|
Kudos, SonarCloud Quality Gate passed!
|
|
🎉 This PR is included in version 0.46.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
generate:beforeand others become a hook type. Hook name is the name of hook function. you do not have to always provide it but it is a must have for hooks libararies and you enable a hook by referring it's nameregisterfunction is no longer needed as part of the hook which enables easier testing. You write a regular functon and expose it grouped by hook type:jsfile and local hooks traversing refactored to usexfsfor async walking as we use in other parts of the generatorxfsthat didn't work well withmock-fs. Then with quick refactor to stop usingxfsin favor ofklawthings were getting better but this would require larger refactor to kind outxfsfrom the project.MIGRATION PATHS
This PR is a breaking change and you need to adjust your templates hooks, if you have one. There are 2 paths to follow here:
Related issue(s)
See also #318