Skip to content

Commit 838e627

Browse files
authored
0.6.2 → 0.6.3 (#78)
1 parent c89bf21 commit 838e627

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

README.md

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ PureScript package manager and build tool powered by [Dhall][dhall] and
2020
- [Configuration file format](#configuration-file-format)
2121
- [Commands](#commands)
2222
- [Package management](#package-management)
23+
- [Listing available packages](#listing-available-packages)
24+
- [Adding and overriding dependencies](#adding-and-overriding-dependencies)
2325
- [Building, bundling and testing a project](#building-bundling-and-testing-a-project)
2426
- [Can I use this with `psc-package`?](#can-i-use-this-with-psc-package)
2527
- [`psc-package-local-setup`](#psc-package-local-setup)
@@ -78,7 +80,9 @@ This last command will create a bunch of files:
7880
```
7981

8082
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`.
8286

8387
Let's take a look at the two [Dhall][dhall] configuration files that `spago` requires:
8488
- `packages.dhall`: this file is meant to contain the *totality* of the packages
@@ -152,6 +156,70 @@ $ spago install
152156
..then `spago` will download all the `dependencies` listed in `spago.dhall` (and
153157
store them in the `.spago` folder).
154158

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+
155223
### Building, bundling and testing a project
156224

157225
We can then build the project and its dependencies by running:
@@ -203,7 +271,7 @@ Bundling first...
203271
Bundle succeeded and output file to index.js
204272
Make module succeeded and output file to index.js
205273

206-
> node -e "console.log(require('./index).main)"
274+
$ node -e "console.log(require('./index).main)"
207275
[Function]
208276
```
209277

@@ -217,6 +285,16 @@ You should add some tests.
217285
Tests succeeded.
218286
```
219287

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+
220298
## Can I use this with `psc-package`?
221299

222300
Yes! Though the scope of the integration is limited to helping your
@@ -270,6 +348,11 @@ leave the `require`s still in.
270348
To fill them in you should use the proper js tool of the day, at the time of
271349
writing [ParcelJS][parcel] looks like a good option.
272350

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`.
273356

274357
[spacchetti]: https://github.com/spacchetti/spacchetti
275358
[dhall]: https://github.com/dhall-lang/dhall-lang

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: spago
2-
version: 0.6.2.1
2+
version: 0.6.3.0
33
github: "spacchetti/spago"
44
license: BSD3
55
author: "Justin Woo, Fabrizio Ferrai"

0 commit comments

Comments
 (0)