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

feat: support for external templates #62

Closed
MathurAditya724 opened this issue Jul 30, 2024 · 9 comments
Closed

feat: support for external templates #62

MathurAditya724 opened this issue Jul 30, 2024 · 9 comments

Comments

@MathurAditya724
Copy link
Contributor

Can we add support for --template or something through which we can use external templates?

This is how the usage will be pnpm create hono@latest --template=repo_addr. I understand that we can use degit but it's mainly useful because of the hooks.

If you want I can create the PR for this

@MathurAditya724
Copy link
Contributor Author

Found this issue which is similar to this one - honojs/starter#14, we can do something similar here.

@yusukebe
Copy link
Member

Hi @MathurAditya724 !

I've also thought it would be good if create-hono could support external templates. But we have to consider whether we do or not.

Currently, we use tiged, a forked project of degit. This means create-hono gets the template with a git base. On the other hand, I'm recently been thinking create-hono should not depend on git. A similar matter is raised as the issue: #50

Or, in the future, we can't say it's 100% No that create-hono includes all template files. If so, it does not use external repositories and download templates. Then, to have degit or tiged for just the supporting external template feature does not make sense.

Anyway, this should be considered. Plus, regarding create-hono, we want to discuss not using a git- based command. Thanks!

@MathurAditya724
Copy link
Contributor Author

I propose using giget to address the dependency on git. Embedding templates in create-hono may not be necessary because giget and similar tools can cache templates once downloaded, and most users typically use only 2-3 templates.

To implement this, we can use regex to determine the appropriate git provider for the templates. I need to investigate whether giget supports custom providers, but overall, this approach seems feasible.

Please let me know if you have any further concerns or suggestions. Otherwise, I will start working on the PR so we can evaluate this approach more thoroughly.

@yusukebe
Copy link
Member

@MathurAditya724

Cool!

Shall we start to work on replacing tiged with giget (#50)? I think we have to think of these as separate issues that support external templates(#62) and replace tiged with giget (#50).

cc: @goisaki @ryuapp If you have any opinions on these issues, please share them. @MathurAditya724 can create a PR, and you can review it.

@MathurAditya724
Copy link
Contributor Author

Created the first PR for removing tiged #63, Kindly have a look

@ryuapp
Copy link
Contributor

ryuapp commented Aug 3, 2024

It's hard to support completely external community templates.
create-hono should only support external templates that have been checked by Hono community.
For those that do not apply, we will guide you on how to download them using giget or digit.

The reason is security and reliability issues.
For example, using create-hono, what the user expects to do is download a Hono template project. If we can download completely external projects, we can also download malicious ones. The same thing is possible with giget, but the reason the user use the command is to download templates, so the responsibility is clearly on you.

Therefore, I think that unless create-hono has any special functionality other than downloading templates, it should not support completely external templates. My concerns may disappear if a warning dialog is displayed.

@MathurAditya724
Copy link
Contributor Author

I will start working on the new PR for adding commander described here #63 (comment). I believe it will benefit this issue because we need the --template option.

@yusukebe
Copy link
Member

yusukebe commented Aug 3, 2024

@MathurAditya724

Still, we have to consider if it should have --template option or not.

I agree @ryuapp 's opinion:

The reason is security and reliability issues.

@MathurAditya724
Copy link
Contributor Author

MathurAditya724 commented Aug 3, 2024

For security, I agree with @ryuapp. Adding a warning banner when accessing 3rd party repositories is a good approach because hosting all the templates in a single repository can be challenging to maintain and scale.

This is how I have planned to resolve this issue, I have divided this issue into 3 parts (3 PRs) -

  1. Remove tiged, completed ✅
  2. Introduce commander so that in place of always adding the options manually we can write them in a single line, eg - pnpm create hono@latest my-app --template=cloudflare-workers -Y. This will not add functionality for external templates, only CLI options for better DX.
  3. The main PR to resolve this issue.

@MathurAditya724 MathurAditya724 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants