Skip to content
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

Make generator support installing remote templates #251

Closed
fmvilas opened this issue Mar 16, 2020 · 5 comments · Fixed by #261
Closed

Make generator support installing remote templates #251

fmvilas opened this issue Mar 16, 2020 · 5 comments · Fixed by #261
Assignees
Labels

Comments

@fmvilas
Copy link
Member

fmvilas commented Mar 16, 2020

Changes this issue must introduce:

  1. The syntax must now be something like ag [options] <asyncapi> <templatePath|templateUrl|templatePackageName|templateGitUrl>
  2. All templates are now treated as "remote".
  3. Rename the -w, --watch flag to --watch-template. Let's leave -w, --watch for "watching" the AsyncAPI file. Show a warning when the template directory under node_modules is not a symlink (i.e., it's a remote template).
  4. Slightly change the meaning of --force-install. It will now install the template and its dependencies.
  5. Remove the -t, --templates <templateDir> flag. Keep reading to know why.

Installation is handled by the npm install command, which supports the following syntax:

npm install [<@scope>/]<name>
npm install [<@scope>/]<name>@<tag>
npm install [<@scope>/]<name>@<version>
npm install [<@scope>/]<name>@<version range>
npm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
npm install <tarball file>
npm install <tarball url>
npm install <folder>

Therefore, the current -t, --templates <templateDir> flag can be removed and will always point to the node_modules folder of the generator. That will allow us to benefit from the npm cache system too.

FAQ

What if I have a local template? Will I have to place it inside node_modules?

No, you can keep working as usual. npm install will create a symlink to your folder and will place it under node_modules.

Why depending on npm install?

It is much easier for us to rely on npm to do the job. We get a lot for free, including the cache —and a mechanism to skip it. In any case, we already had a dependency on npm when we decided to convert templates to npm packages (#219).

@fmvilas fmvilas added this to the Make Generator stable milestone Mar 16, 2020
@fmvilas fmvilas self-assigned this Mar 18, 2020
@fmvilas
Copy link
Member Author

fmvilas commented Mar 18, 2020

I'm starting work on this.

@jonaslagoni
Copy link
Member

Are you going to keep the local way for remote templates i.e. ag http://github.com/somerepo ./path/to/docs <<template name>> or is it going to be something else? 😄

@fmvilas
Copy link
Member Author

fmvilas commented Mar 18, 2020

Happy that you ask. I just updated the description with what I think this issue should modify :)

@fmvilas
Copy link
Member Author

fmvilas commented Mar 20, 2020

While working on this, I realized the --force-install flag doesn't make sense anymore. Or, another way to see it is that the --force-download is not necessary and we'll have to slightly change the meaning of --force-install and it will not take into account the existence of node_modules anymore.

I'm updating the description with the following:

Changes this issue must introduce:

1. The syntax must now be something like `ag [options] <asyncapi> <templatePath|templateUrl|templatePackageName|templateGitUrl>`
1. All templates are now treated as "remote".
1. Rename the `-w, --watch` flag to `--watch-template`. Let's leave `-w, --watch` for "watching" the AsyncAPI file. Show a warning when the template directory under `node_modules` is not a symlink (i.e., it's a remote template).
-> 1. Slightly change the meaning of `--force-install`. It will now install the template **and** its dependencies.
1. Remove the `-t, --templates <templateDir>` flag. Keep reading to know why.
...

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.35.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants