-
-
Notifications
You must be signed in to change notification settings - Fork 258
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
How to use pre-install template? #482
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue. |
@aleung Hey, thanks for raising this issue. I think it is very much related to #425. @laat tried to fix it already. Tbh it is frustrating to me that there are so many installation related issues and I could not find time to fix them yet 😞 . There are few installation-related issues that we should address imho. Atm I'm involved in major refactoring of our CI pipelines and it will take me few more days to complete and then I could jump into it and fix it (if I manage 😅 ). Unless you want to give it a try? Only one comment
Shouldn't you do what corporations do usually, setup an npm mirror in an internal network, set proxies, and basically make sure that |
@derberg Thank you for your quick response. My workaround works so it isn't in a hurry. I'm still new on this project and I'll try to see if I can contribute something.
Yes, we do have setup npm mirror. However there may be some restrictions on the modules/versions available on the mirror. It isn't a blocking issue so far but I wish my CI job can have less dependency on the environment. |
@derberg Thanks. I've looked into the test project. It should already cover the case in this issue. |
@aleung thanks for taking the time 🙇🏼 |
🎉 This issue has been resolved in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Release 1.2 enables support for latest node and npm and fixes all known installation issues. In case you see some other issues, please create a new issue. Please use |
@derberg I tried the new release and got error:
This is how I installed them in
|
@aleung the issue is that you are installing html-template here as a global dependency, this cannot work. Just take any project in node. Let's say you want to use lodash there, but do not want to add it to dependencies and instead you install it globally. Require/import will not work in this case. This is the case you try to do here. in your case we look for the module here I understand that you want to preinstall all in a docker image so later generation is super fast. Workaround 1: Workaround 2: Please let me know how it went |
Ok, then I can rollback to use my previous workaround: generate a dummy asyncapi file during Docker build to install the template. Not a problem to me. However, I saw a lot of other tools which use npm package as plugin can use global installed plugin. Since ag can be installed globally, it ought to support global installed plugin as well. |
Just to quickly mention this, the generator supports local path to templates so the following could be done if I am not mistaken:
|
Furthermore @derberg I can see there is a resolve-global package we can take advantage of. I actually see this as a great use-case given this issue as well as #523 |
Another one: requireg |
@aleung would you like to create a feature request? Didn't realize this issue is closed 😄 |
yeah, no need to create another issue. I don't want it to keep waiting again few months. I'll give it a try this week with |
@jonaslagoni Actually this issue has not been solved yet 😄 . My original issue description is about using pre-installed global template. @derberg Thanks for your active support! |
yeap, I have to admit I missed that |
PR is opened #530 |
I'm sorry to report that the global installed generator doesn't work any more in v1.5.0. Created the issue #531. |
PR ready for review |
🎉 This issue has been resolved in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reason/Context
We have all API files managed in one git repo and have CI pipeline to generate document from these files. I'm going to support asyncapi and use @asyncapi/generator to generate HTML document. The CI pipeline runs in a Docker container so I need to pre-install both generator and html-template into the Docker image.
There are several reasons that we don't want generator to install template on-the-fly: we can't secure the internet connection in the CI environment; we don't want to waste time to download in every CI job; and also our strategy is that everything in CI should be immutable. The way described in #449 to mount a volume doesn't fit for our CI neither.
I have tried to install both generator and template in Dockerfile but generator doesn't use the global installed template. It looks for template under its own node_module folder:
/usr/local/lib/node_modules/@asyncapi/generator/node_modules/
I also tried to install template using generator CLI, but the command failed because it only download and install template during generation.
Finally I made it work by adding a dummy asyncapi file into the image then generate it during Docker build:
However it's just a workaround and not looks elegant.
Description
I see there might be two alternatives to resolve the problem:
Alt#1
Generator uses the global installed template. It skips on-the-fly installation if template already exists.
Alt#2
Generator CLI provides template management command. For example
ag install-template <template>
to install the template into its node_modules folder.The text was updated successfully, but these errors were encountered: