|
6 | 6 | stack templates
|
7 | 7 | ~~~
|
8 | 8 |
|
9 |
| -`stack templates` provides information about how to find templates available for |
10 |
| -`stack new`. |
11 |
| - |
12 |
| -Stack provides multiple templates to start a new project from. You can specify |
13 |
| -one of these templates following your project name in the `stack new` command: |
14 |
| - |
15 |
| -~~~text |
16 |
| -stack new my-rio-project rio |
17 |
| -Downloading template "rio" to create project "my-rio-project" in my-rio-project/ ... |
18 |
| -Looking for .cabal or package.yaml files to use to init the project. |
19 |
| -Using cabal packages: |
20 |
| -- my-rio-project/ |
21 |
| -
|
22 |
| -Selecting the best among 18 snapshots... |
23 |
| -
|
24 |
| -* Matches ... |
25 |
| -
|
26 |
| -Selected resolver: ... |
27 |
| -Initialising configuration using resolver: ... |
28 |
| -Total number of user packages considered: 1 |
29 |
| -Writing configuration to file: my-rio-project/stack.yaml |
30 |
| -All done. |
31 |
| -<Stack root>\templates\rio.hsfiles: 10.10 KiB downloaded... |
32 |
| -~~~ |
33 |
| - |
34 |
| -The default templates repository is |
35 |
| -https://github.com/commercialhaskell/stack-templates. You can download templates |
36 |
| -from a different GitHub user by prefixing the username and a slash. Command: |
37 |
| - |
38 |
| -~~~text |
39 |
| -stack new my-yesod-project yesodweb/simple |
40 |
| -~~~ |
41 |
| - |
42 |
| -Then template file `simple.hsfiles` would be downloaded from GitHub repository |
43 |
| -`yesodweb/stack-templates`. |
44 |
| - |
45 |
| -You can even download templates from a service other that GitHub, such as |
46 |
| -[GitLab](https://gitlab.com) or [Bitbucket](https://bitbucket.com). For example, |
47 |
| -command: |
48 |
| - |
49 |
| -~~~text |
50 |
| -stack new my-project gitlab:user29/foo |
51 |
| -~~~ |
52 |
| - |
53 |
| -Template file `foo.hsfiles` would be downloaded from GitLab, user account |
54 |
| -`user29`, repository `stack-templates`. |
55 |
| - |
56 |
| -If you need more flexibility, you can specify the full URL of the template. |
57 |
| -Command: |
58 |
| - |
59 |
| -~~~text |
60 |
| -stack new my-project https://my-site.com/content/template9.hsfiles |
61 |
| -~~~ |
62 |
| - |
63 |
| -(The `.hsfiles` extension is optional; it will be added if it's not specified.) |
64 |
| - |
65 |
| -Alternatively you can use a local template by specifying the path. Command: |
66 |
| - |
67 |
| -~~~text |
68 |
| -stack new project <path_to_template>/template.hsfiles |
69 |
| -~~~ |
70 |
| - |
71 |
| -As a starting point for creating your own templates, you can use the |
72 |
| -["simple" template](https://github.com/commercialhaskell/stack-templates/blob/master/simple.hsfiles). |
73 |
| -The |
74 |
| -[stack-templates repository](https://github.com/commercialhaskell/stack-templates#readme) |
75 |
| -provides an introduction into creating templates. |
| 9 | +`stack templates` provides information about project templates used with the |
| 10 | +[`stack new` command](new_command.md). |
| 11 | + |
| 12 | +Project templates are specified in `.hsfiles` files. The format of those files |
| 13 | +is documented at the |
| 14 | +[`commercialhaskell/stack-templates`](https://github.com/commercialhaskell/stack-templates#project-template-format) |
| 15 | +repository on GitHub. |
| 16 | + |
| 17 | +Any GitHub, GitLab or Bitbucket repository named `stack-templates` can provide |
| 18 | +project template files. For example, a template file |
| 19 | +`username/stack-templates/my-template.hsfiles` on GitHub can be identified as |
| 20 | +`username/my-template` when using `stack new`. The relevant service can be |
| 21 | +specified by a prefix: `github:` for [GitHub](https://github.com/) (the default |
| 22 | +service), `gitlab:` for [GitLab](https://gitlab.com), or `bitbucket:` for |
| 23 | +[Bitbucket](https://bitbucket.com). |
| 24 | + |
| 25 | +[`commercialhaskell/stack-templates`](https://github.com/commercialhaskell/stack-templates#project-template-format) |
| 26 | +on GitHub is the default repository for project templates. Its username |
| 27 | +(`commercialhaskell`) does not need to be specified when using `stack new`. |
| 28 | + |
| 29 | +The project template that `stack new` uses by default is named `new-template` |
| 30 | +and provided at the default repository. |
| 31 | + |
| 32 | +The default repository provides 24 other project templates. Its Wiki provides |
| 33 | +a description of some of those templates and information about the location of |
| 34 | +other templates. |
0 commit comments