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

4039 namespaced templates #4103

Merged
merged 17 commits into from
Jun 24, 2018

Conversation

lylek
Copy link
Contributor

@lylek lylek commented Jun 21, 2018

  • 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:, or bitbucket:.
  • Changelog.md has been updated
  • Help text for stack new has been updated
  • Tested this by temporarily adding a trace in the downloadTemplate function, to see the request it was using to download the template, and trying various new and old forms of the template name. Also created a local template and made sure that still took priority over a remote download.
  • I would have liked to add an integration test, but it's hard to test things that download from remote URLs. There isn't currently a way to stub that out.
  • Added documentation for the web site in the doc subdirectory. Unfortunately I'm not sure how to build that, to make sure it looks right.

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),
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that sounds good.

\ 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\
Copy link
Contributor

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

Copy link
Contributor Author

@lylek lylek Jun 22, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

parseRepoPathWithService service path =
case T.splitOn "/" path of
[user, name] -> Just $ RepoTemplatePath service user name
[name] -> Just $ RepoTemplatePath service defaultRepoUser name
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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|]
Copy link
Contributor

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|]

Copy link
Contributor Author

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.

lylek added 3 commits June 23, 2018 18:47
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.
@lylek
Copy link
Contributor Author

lylek commented Jun 24, 2018

OK, I've adjusted the pull request as discussed. Well, one slight difference: it still accepts github:foo as an alternative to foo, defaulting to the commercialstack user, but will no longer accept gitlab:foo or bitbucket:foo with no username.

Copy link
Contributor

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

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 this pull request may close these issues.

4 participants