-
Notifications
You must be signed in to change notification settings - Fork 842
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
Pull stack templates from hackage packages #2681
Comments
I would also like to propose that this new templating system use a different mechanism than Each template would have a
Why is this better? Because now my text editor can understand these files better! Also, we can have descriptions. We already have a way of having descriptions, but it isn't used by anything yet - #1571 This would also be a great place for resolving #1390, by having |
From my perspective if we could specify relevant bits of "stack.yaml" including resolver, and setup. It would be quite easy to add template for |
That's a good point, @tolysz ! It may well make sense to allow a subset of |
I think it makes more sense to have the templates be separate packages in the format of |
Perhaps it does make sense to have them be packages directly. One issue is that we will need some per-template metadata, for the file renaming. Perhaps we just auto-rename the cabal file, and hope that no other files need to be renamed? |
It's not as pretty, but I think that something more like |
Please make that at least |
That makes sense. Both specifically due to the issues with GH as well as the way that it will make it easy to add more sources of templates as desired. Could also have a |
@SASinestro That's a really interesting idea. When I proposed the idea it was intended for packages that were already downloaded/installed...it'd be cool if there were a convention to reference. It'd be even cooler of *: were something that you could add new protocols to as well. For example, you could add a gitlabs: github-enterprise: bitbucket: etc...based off of a package name convention. For example:
Network requests would make future tab completion potentially a bit slow though, at least on the first hit. Perhaps without a protocol it defaults to locally downloaded packages? P.S. For commercial success I think github enterprise would be crucial, I have seen several places require it. |
@mgsloan I agree completely on the new templating system. Maybe it's a possibility already, but I would really like to see the templates transform into a directory that reflects what a real project would look like, then you would use variables to trigger different paths to be used to set up the project differently. For example, rather than having postgres-yesod postgres-mysql postgres-minimal, you really only have one template with a bunch of flags that switch out key files in the file system. There are several benefits to this:
Example:
This would also allow more details to be moved out into configuration files which allow for fast failure, and less modification of project files like Foundation. |
Could we unify everything by just allowing packages in general, instead of just from hackage? What I mean is: stack already has concepts of referring to packages from:
Those encompass every place you can currently get a template from, and more. What if we just reuse the normal package resolution process used when stack needs to find a package to use as a dependency, that is:
That would allow a huge amount of flexibility and configurability without adding much cognitive load, since stackers already need to understand most all of how that works (where stack gets a package from and how you override it). And then we could dump a lot of the specialized stuff we currently use for 'stack new' without losing any abilities. For To be clear, what I am proposing is:
|
Seeing as the latest reference to this issue is from last summer, I figured I'd revive it. I have a few questions:
I think stack templates are a valuable tool for beginners so I've been considering to build a few domain-specific ones; my only doubt is on how much to invest on it if the format is going to change. Thanks! |
I think
|
With These would then typically point to a |
hmm, even though the
|
ah; turns out it's just that it can't do it from a relative directory! crazy. running with the full path works. |
The help text should be accurate in the new release, at least. |
I think that the fact that it doesn't support relative paths is a regression. Afaik it used to work a few years ago. |
Hi, Stack templates repo README mentions that templates are no longer maintained because the way Stack handles templates will change in this issue. But I see no update for a few months now. I think this is a major setback for new Haskell users. When learning a new language, scaffolding is a nice way to start (e.g. with tests, for a ReST API, database access, etc.) and quickly prototype something. But the templates have been broken for some time, and we see no move here. What's the status please? It looks like this issue was flagged for 1.9.1 release but 1.9.1 is released and this issue has not been updated... I'm getting worried this gets forgotten 😢 |
The changelog for the recent 1.9.1 release says that #4039 was implemented, allowing 'namespaced templates' like |
Hey, first off, thanks everyone who's worked on this in the past, I've found templates are super helpful to get up and running on a new project :) One thing I was wondering was if this project initialization code could be exposed as a library. Looking through examples there doesn't seem to be anything Stack specific, so if it was possible to expose the functionality so that other tools could use it that would be awesome. There's several tools that support project initialization (stack, cabal, summoner, probably more), and if they could all use the same underlying mechanism that would be great and give users a more consistent experience, regardless of what their preferred build tool is. |
We ended up in a different direction with namespaced templates in #4039, closing. |
In commercialhaskell/stack-templates#55 , https://github.com/lethjakman proposes that we allow hackage packages to come with their templates. This might look something like
stack init yesod:basic
Doing just
stack init yesod
might enumerate the list of available templates, or, if there is just one, default to that template. So, here's how this would work:If there is a colon in the name, treat it as a
pkg-name:template-name
, telling exactly which package to pull the template fromOtherwise, check if the template is available from our templates repo. If it isn't check if it is a hackage package name, download that package, and pull out the list of templates from the source distribution.
If the requested package template is missing, or otherwise ambiguous, give the user the list of templates found in the package.
What should the directory convention be in the source distribution? I'm thinking that it should be
templates/template-name/...
. This way, we can also enumerate the dirs undertemplates
The text was updated successfully, but these errors were encountered: