generator
generator copied to clipboard
AsyncAPI generate crashes when watching a local template during development
Describe the bug
When developing a new template locally and using the --watch-template flag, the generator crashes after generating the template.
The error message on a Mac with nodenv is
[WATCHER] Watching for changes in the template directory /Users/{username}/{path}/asyncapi-go-template and in the AsyncAPI file asyncapi.yaml
Something went wrong:
Error: ENOENT: no such file or directory, lstat '/Users/{username}/.nodenv/versions/17.3.1/lib/node_modules/@asyncapi/generator/node_modules/asyncapi-go-template'
How to Reproduce
- Start a new template, for example using the generator template repository.
- Start the generator in watch mode:
ag --watch-template --output ~/Desktop/asyncapi --force-write asyncapi.yaml "$(pwd)/{your template}".
Expected behavior
The template should be rendered in the output directory and the generator should continue running, watching for changes.
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
This bug is caused by a check for a local template in cli.js. The async function that's being executed returns an error when the folder that's being checked doesn't exist. Since the template is a local one for development, it doesn't exist in the default location {global node_modules}/@asyncapi/generator/node_modules/{template name} and fs.lstat returns an error.
The error isn't being handled and the CLI crashes in the line linked above.
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
@felixjung Hey, we will pretty soon deprecate Generator CLI. We already enabled generator in AsyncAPI CLI
please use CLI with AsyncAPI CLI and if there are any issues with the watcher, these should be fixed there. After CLI installation just run asyncapi generate fromTemplate --help to learn more.
Thanks 🙏🏼