-
Notifications
You must be signed in to change notification settings - Fork 841
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
4039 namespaced templates #4103
4039 namespaced templates #4103
Conversation
…to 4039-namespaced-templates
doc/GUIDE.md
Outdated
@@ -1574,13 +1580,36 @@ Selected resolver: lts-3.2 | |||
Wrote project config to: /home/michael/my-yesod-project/stack.yaml | |||
``` | |||
|
|||
Alternatively you can use your own templates by specifying the path: | |||
The default `stack-templates` repository is on [Github](https://github.com), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a link directly to the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do. There's also a direct link to the repo later in the section.
different Github user by prefixing the username and a slash: | ||
|
||
``` | ||
stack new my-yesod-project yesodweb/yesod-simple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be worth specifying exactly how this is resolved: user yesodweb
, repo stack-templates
, file yesod-simple.hsfiles
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that sounds good.
src/Stack/Options/NewParser.hs
Outdated
\ For example: foo or foo.hsfiles or ~/foo or\ | ||
\ https://example.com/foo.hsfiles")) <*> | ||
help "Name of a template - can take the form\ | ||
\ [service:][username/]template with optional service name\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps more accurate would be:
[[service:]username/]template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually you can write github:foo
and it will pull the template foo
from GitHub with the username commercialhaskell
in the stack-templates
repo. So either the service or the username can be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. In that case, I think it would be better to change the behavior, otherwise we'll be granting special status to the commercialhaskell account on other services when we don't necessarily control it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought that might be odd too. I'll change the code.
src/Stack/Types/TemplateName.hs
Outdated
parseRepoPathWithService service path = | ||
case T.splitOn "/" path of | ||
[user, name] -> Just $ RepoTemplatePath service user name | ||
[name] -> Just $ RepoTemplatePath service defaultRepoUser name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting this line and defaultRepoUser
should change the behavior as described above regarding commercialhaskell
on other services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. That would prevent commercialhaskell
being used as the default for other services. But it would also break the simple case where only a template name is supplied. Another function will have to be created to handle that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, we end up here in the case where just a single name is given, thanks.
case sv of | ||
Github -> [|RepoPath $ RepoTemplatePath Github u t|] | ||
Gitlab -> [|RepoPath $ RepoTemplatePath Gitlab u t|] | ||
Bitbucket -> [|RepoPath $ RepoTemplatePath Bitbucket u t|] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about this part, since I'm not clear about what it does exactly.
Could it do without the pattern match and just be:
RepoPath (RepoTemplatePath sv u t) -> [|RepoPath $ RepoTemplatePath sv u t|]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that would cause TemplateHaskell to complain that there is no instance of something-or-other class. (Rep
?) The alternative is to define an instance of that class, but Michael's recommendation was that it wasn't worth it.
Now no longer assumes the 'commercialhaskell' user for the location of a new template unless the service is Github.
Clarifies how template names are resolved.
OK, I've adjusted the pull request as discussed. Well, one slight difference: it still accepts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
stack new
now allows template names of the form username/foo to download from a user other than commercialstack on Github, and can be prefixed with the servicegithub:
,gitlab:
, orbitbucket:
.doc
subdirectory. Unfortunately I'm not sure how to build that, to make sure it looks right.