-
-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add hooks library to generator #1304
Conversation
🦋 Changeset detectedLatest commit: 42493f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -0,0 +1,7 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding changeset as we need to release a new 2.5 version
have a look if all is clear
README.md
Outdated
|
||
1. [Nunjucks-filters](apps/nunjucks-filters): This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies seprately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't worry 1.
is always used, it is markdown feature, so you do not have to worry on proper order of numbers, see rendered version: https://github.com/asyncapi/generator/blob/aa35277c7384a2b33767cd8706da615bdcbd1292/README.md
|
||
> warning: This package doesn't support AsyncAPI 1.x anymore. We recommend to upgrade to the latest AsyncAPI version using the [AsyncAPI converter](https://github.com/asyncapi/converter-js) (You can refer to [installation guide](/apps/generator//docs//installation-guide.md)). If you need to convert documents on the fly, you may use the [Node.js](https://github.com/asyncapi/converter-js) or [Go](https://github.com/asyncapi/converter-go) converters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v1 of asyncapi was ages before, better remove it as it only confuse instead of helping
} | ||
} | ||
``` | ||
1. Some hooks support custom parameters that template's user can use to specify different behaviour of the hook. To enable these, you need to also add them to the list of your template's parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it shows up like an error but it is all good: https://github.com/asyncapi/generator/blob/aa35277c7384a2b33767cd8706da615bdcbd1292/apps/generator/docs/hooks.md#official-library
expect(file).toMatchSnapshot(); | ||
const mdFile = await readFile(path.join(outputDir, testOutputFile), 'utf8'); | ||
//react template has hooks lib enabled and generation of asyncapi document that was passed as input should work out of the box without adding @asyncapi/generator-hooks to dependencies | ||
const asyncAPIFile = await readFile(path.join(outputDir, 'asyncapi.yaml'), 'utf8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically test is extended and making sure asyncapi document also gets into output because the proper hook (without adding it to dependency) is configured
not sure it makes sense to validate in test, if it really is not added to dependencies 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it makes sense to validate in test, if it really is not added to dependencies 🤔
not sure why we need to check for asyncapi document is in output ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already answered in a meeting
for others: it is needed as before this PR, and in general, by default, generator do not output asyncapi document that it received in input. There is this generic hook for it, and it is added to our test template with this PR - so we need to make sure in test we see it in output - to confirm hooks integation works
@@ -0,0 +1,37 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken from https://github.com/asyncapi/generator-hooks
@@ -0,0 +1,33 @@ | |||
const fs = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken from https://github.com/asyncapi/generator-hooks without edits
@@ -8,6 +8,8 @@ | |||
"test": "turbo run test", | |||
"lint": "turbo lint", | |||
"lint:fix": "turbo run lint:fix", | |||
"generate:assets": "turbo run generate:assets && npm run generate:readme:toc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during work on this template, when I added new section in readme I noticed TOC is not updated - we forgot about enabling TOC update automation when monorepo was included - not it is done, also generator api docs refresh is also now fixed
@@ -1,5 +1,5 @@ | |||
{ | |||
"$schema": "https://turbo.build/schema.json", | |||
"$schema": "https://turbo.build/schema.v1.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were pointing to "latest" version and with turborepo v2 schema was showing errors (pipeline prop is not in v2)
@asyncapi/bounty_team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@Florence-Njeri can you have a look on docs changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @derberg I left a few editorial reviews on the docs. Lmk :)
Co-authored-by: Florence Njeri <[email protected]>
@Florence-Njeri thanks for detailed review, all changes applied! |
Quality Gate passedIssues Measures |
/rtm |
Resolves #1270
I added inline comments for some more context on the PR
What this PR does? from the changeset:
@asyncapi/generator-hooks
is now part ofgenerator
repo and won't be released separately. Source code is stored underapps/hooks
but the package/library name stays as it was originally for backward compatibility,@asyncapi/generator-hooks
package, known as package with a lot of different hooks used in templates, is available in the generator and you no longer have to configure it in yourpackage.json
independencies
. Package@asyncapi/generator-hooks
will no longer be published to NPM separately and is deprecated. You can still have your own hooks, and you can still store them in a separate package and configure with your template,Also, next steps after it is merged: