@@ -20,6 +20,8 @@ PureScript package manager and build tool powered by [Dhall][dhall] and
20
20
- [ Configuration file format] ( #configuration-file-format )
21
21
- [ Commands] ( #commands )
22
22
- [ Package management] ( #package-management )
23
+ - [ Listing available packages] ( #listing-available-packages )
24
+ - [ Adding and overriding dependencies] ( #adding-and-overriding-dependencies )
23
25
- [ Building, bundling and testing a project] ( #building-bundling-and-testing-a-project )
24
26
- [ Can I use this with ` psc-package ` ?] ( #can-i-use-this-with-psc-package )
25
27
- [ ` psc-package-local-setup ` ] ( #psc-package-local-setup )
@@ -78,7 +80,9 @@ This last command will create a bunch of files:
78
80
```
79
81
80
82
Convention note: ` spago ` expects your source files to be in ` src/ ` and your
81
- test files in ` test/ ` .
83
+ test files in ` test/ ` .
84
+ It is possible to include additional source paths when running some commands,
85
+ like ` build ` , ` test ` or ` repl ` .
82
86
83
87
Let's take a look at the two [ Dhall] [ dhall ] configuration files that ` spago ` requires:
84
88
- ` packages.dhall ` : this file is meant to contain the * totality* of the packages
@@ -152,6 +156,70 @@ $ spago install
152
156
..then ` spago ` will download all the ` dependencies ` listed in ` spago.dhall ` (and
153
157
store them in the ` .spago ` folder).
154
158
159
+ #### Listing available packages
160
+
161
+ It is sometimes useful to know which packages are contained in our package set
162
+ (e.g. to see which version we're using, or to search for packages).
163
+
164
+ You can get a complete list of the packages your ` packages.dhall ` imports (together
165
+ with their versions and URLs) by running:
166
+
167
+ ``` bash
168
+ $ spago list-packages
169
+ ```
170
+
171
+ #### Adding and overriding dependencies
172
+
173
+ Let's say I'm a user of the ` react-basic ` package. Now, let's say I stumble upon a bug
174
+ in there, but thankfully I figure how to fix it. So I fork it, add my fix, and push
175
+ to my fork.
176
+ Now if I want to use this fork in the current project, how can I tell ` spago ` to do it?
177
+
178
+ We have a ` overrides ` record in ` packages.dhall ` just for that! And in this case it
179
+ might look like this:
180
+
181
+ ``` haskell
182
+ let overrides =
183
+ { react- basic =
184
+ upstream. react- basic
185
+ ⫽ { repo =
186
+ " https://github.com/my-user/purescript-react-basic.git"
187
+ , version =
188
+ " my-branch-with-the-fix"
189
+ }
190
+ }
191
+ ```
192
+
193
+ Note: currently support only branches and tags work as a ` version ` , and tags are
194
+ recommended over branches (as for example if you push new commits to a branch,
195
+ ` spago ` won't pick them up unless you delete the ` .spago ` folder).
196
+ Commit hashes are not supported yet, but hopefully will be at some point.
197
+
198
+ If a package is not in the upstream package-set, you can add it in a similar way,
199
+ by changing the ` additions ` record in the ` packages.dhall ` file.
200
+ E.g. if we want to add the ` facebook ` package:
201
+
202
+ ``` haskell
203
+ let additions =
204
+ { facebook =
205
+ mkPackage
206
+ [ " console"
207
+ , " aff"
208
+ , " prelude"
209
+ , " foreign"
210
+ , " foreign-generic"
211
+ , " errors"
212
+ , " effect"
213
+ ]
214
+ " https://github.com/Unisay/purescript-facebook.git"
215
+ " v0.3.0"
216
+ }
217
+ ```
218
+
219
+ Once you verify that your application builds with the added packages, we would of
220
+ course very much love if you could pull request it to the Upstream package-set,
221
+ [ spacchetti] [ spacchetti ] ❤️🍝
222
+
155
223
### Building, bundling and testing a project
156
224
157
225
We can then build the project and its dependencies by running:
@@ -203,7 +271,7 @@ Bundling first...
203
271
Bundle succeeded and output file to index.js
204
272
Make module succeeded and output file to index.js
205
273
206
- > node -e " console.log(require('./index).main)"
274
+ $ node -e " console.log(require('./index).main)"
207
275
[Function]
208
276
```
209
277
@@ -217,6 +285,16 @@ You should add some tests.
217
285
Tests succeeded.
218
286
```
219
287
288
+ And last but not least, you can spawn a PureScript repl!
289
+ As with the ` build ` and ` test ` commands, you can add custom source paths
290
+ to load, and pass options to the underlying ` purs repl ` by just putting
291
+ them after ` -- ` .
292
+ E.g. the following opens a repl on ` localhost:3200 ` :
293
+
294
+ ``` bash
295
+ $ spago repl -- --port 3200
296
+ ```
297
+
220
298
## Can I use this with ` psc-package ` ?
221
299
222
300
Yes! Though the scope of the integration is limited to helping your
@@ -270,6 +348,11 @@ leave the `require`s still in.
270
348
To fill them in you should use the proper js tool of the day, at the time of
271
349
writing [ ParcelJS] [ parcel ] looks like a good option.
272
350
351
+ > So I added a new package to the ` packages.dhall ` , why is ` spago ` not installing it?
352
+
353
+ Adding a package to the package-set just includes it in the set of possible packages you
354
+ can depend on. However if you wish ` spago ` to install it you should then add it to
355
+ the ` dependencies ` list in your ` spago.dhall ` .
273
356
274
357
[ spacchetti ] : https://github.com/spacchetti/spacchetti
275
358
[ dhall ] : https://github.com/dhall-lang/dhall-lang
0 commit comments