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

Namespaced templates #4039

Closed
snoyberg opened this Issue May 24, 2018 · 13 comments

Comments

Projects
None yet
5 participants
@snoyberg
Contributor

snoyberg commented May 24, 2018

Problem There is no clear criteria right now for which templates should be included in the stack-templates repo. No one person has control over this repo, making it difficult for tutorial authors to rely on it in their documentation. The output of stack templates can be overwhelming.

Proposed solution Introduce namespacing into the template concept. There definitely room to modify this, but as an initial proposal that keeps backwards compatibility, let's consider:

  • A template name github:username/template can be found on the repo https://github.com/username/stack-templates, on the master branch, in the file template.hsfiles
  • The github: leader is for future proofing, if someone wants to add support for Gitlab, Bitbucket, or others
  • If github: is left off, it is filled in automatically, so that username/template is treated as github:username/template
  • Similarly, if the username namespacing is left off, e.g. template, the assumed username is commercialhaskell, falling back to the current behavior

Then, as an example, the Yesod templates could end up being referred to as yesodweb/postgres, etc.

To deal with the overwhelming output from stack templates: what if we have a README.md or similar file in commercialhaskell/stack-templates which is downloaded and displayed to the user explaining a few of the common templates, and then pointing to a Wiki page or similar where people can share more templates.

@SkyWriter

This comment has been minimized.

Member

SkyWriter commented May 24, 2018

I love the idea! This would also address the problem of the templates being hardly documented. Wiki is a media rich enough to help steering in the fogs.

@Blaisorblade

This comment has been minimized.

Collaborator

Blaisorblade commented May 24, 2018

FWIW, SBT also uses Github-based namespacing for templates, I’ve never heard complaints (unlike other features) and there seems to be quite some support for it: https://www.scala-sbt.org/1.0/docs/sbt-new-and-Templates.html.
Also FWIW: those templates are entire repos (which makes them a bit easier to navigate than packing all files in a repo, and allows having separate repos in a single organization), and discovery also happens elsewhere.

@SkyWriter

This comment has been minimized.

Member

SkyWriter commented May 24, 2018

Having a whole repo dedicated to a template sounds like a reasonable option to me.

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented May 24, 2018

I didn't mention it in the initial bit, but I'm not opposed to moving beyond the hsfiles system to something like whole-repo systems. We'd have to figure out appropriate naming to make it all work nicely, and how to do variable replacement, but I don't see anything insurmountable. But I'd rather focus on fixing the biggest concerns people are raising first, especially since it should be a relatively minor amount of code.

@SkyWriter

This comment has been minimized.

Member

SkyWriter commented May 24, 2018

I think I can get my hands dirty with this issue. Was just looking around to get some more Haskell in my systems.

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented May 25, 2018

Awesome, go for it @SkyWriter!

@alexanderkjeldaas

This comment has been minimized.

Contributor

alexanderkjeldaas commented May 25, 2018

It seems like some of the discussion lately has been that the templates are all different and it's unclear which to use. Github repos have some metrics that can help:

  • Last commit date (how stale is it)
  • Number of stars
@nh2

This comment has been minimized.

Collaborator

nh2 commented Jun 3, 2018

A template name github:username/template can be found on the repo https://github.com/username/stack-templates, on the master branch, in the file template.hsfiles

Maybe I'm missing something, but why go for the short syntax of github:username/template instead of just using URLs directly?

I'd even find that more convenient, if I can directly copy them in from my browser or the other way around.

Or is the idea here that you'd actually type these characters down, so we'd like them to be short?

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jun 3, 2018

@SkyWriter

This comment has been minimized.

Member

SkyWriter commented Jun 4, 2018

Maybe I'm missing something, but why go for the short syntax of github:username/template instead of just using URLs directly?

Also, full URLs are already supported.

@nh2

This comment has been minimized.

Collaborator

nh2 commented Jun 11, 2018

OK, makes sense!

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jun 24, 2018

Addressed by #4103

@snoyberg snoyberg closed this Jun 24, 2018

@SkyWriter

This comment has been minimized.

Member

SkyWriter commented Jun 24, 2018

Darn, missed it by just a couple o' days! Anyways, glad it's landed.

snoyberg added a commit that referenced this issue Jul 4, 2018

snoyberg added a commit that referenced this issue Jul 4, 2018

snoyberg added a commit that referenced this issue Jul 4, 2018

snoyberg added a commit that referenced this issue Jul 4, 2018

Merge pull request #4129 from commercialhaskell/better-stack-templates
Get stack templates help from Github file #4039

mihaimaruseac added a commit that referenced this issue Jul 29, 2018

Merge pull request #4168 from johnmendonca/4039-pt2-template-name-spec
Issue #4039 - Spec for template name parsing in `stack new`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment