Skip to content

Commit 11e2e80

Browse files
committed
feat: migrate staging to latest spago, package set
and bring compiler up to date with latest Hackage release (0.15.15)
1 parent 578605e commit 11e2e80

11 files changed

Lines changed: 13387 additions & 510 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
node updateSharedConfigVersions.mjs sharedConfig.out
8282
diff src/Try/SharedConfig.purs sharedConfig.out || {
8383
echo 'PureScript and/or package set versions in "client/src/Try/SharedConfig.purs"'
84-
echo 'do not match the versions extracted from "stack.yaml" and "staging/packages.dhall".'
84+
echo 'do not match the versions extracted from "stack.yaml" and "staging/spago.yaml".'
8585
echo 'Please run "cd client && npm run updateConfigVersions". CI will fail until then.'
8686
exit 1
8787
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Most of these features can be controlled not only from the toolbar, but also usi
4747

4848
### Which Libraries Are Available?
4949

50-
Try PureScript aims to provide a complete, recent package set from <https://github.com/purescript/package-sets>. The available libraries are those listed in [`staging/spago.dhall`](./staging/spago.dhall), at the versions in the package set mentioned in [`staging/packages.dhall`](./staging/packages.dhall).
50+
Try PureScript aims to provide a complete, recent package set from <https://github.com/purescript/registry/tree/main/package-sets>. The available libraries are those listed under `package.dependencies` in [`staging/spago.yaml`](./staging/spago.yaml), at the versions in the package set named by `workspace.packageSet.registry` in that same file.
5151

5252
## Development
5353

RELEASE.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ Update the package set by doing the following. Each step is explained below:
2828

2929
```sh
3030
pushd staging
31-
spago upgrade-set
32-
cat > spago.dhall << EOF
33-
{ name = "try-purescript-server"
34-
, dependencies = [] : List Text
35-
, packages = ./packages.dhall
36-
, sources = [ "src/**/*.purs" ]
37-
}
31+
cat > spago.yaml << EOF
32+
package:
33+
name: try-purescript-server
34+
dependencies: []
35+
workspace:
36+
packageSet:
37+
registry: 0.0.1
38+
extraPackages: {}
3839
EOF
39-
spago ls packages | cut -f 1 -d ' ' | xargs spago install
40+
spago upgrade
41+
spago install $(spago ls packages --json --quiet | jq -r 'to_entries[] | select(.value.type == "registry") | .key')
4042
popd
4143
pushd client
4244
npm run updateConfigVersions
@@ -47,27 +49,35 @@ popd
4749

4850
### Step-by-Step Explanation
4951

50-
1. Update the `upstream` package set in `staging/packages.dhall`:
52+
1. Overwrite `staging/spago.yaml` with a placeholder config: an empty
53+
`dependencies` list and any valid registry package set as a seed (the exact
54+
version doesn't matter — the next step overwrites it). Starting from a clean
55+
file ensures packages dropped from the new set don't linger.
5156

52-
```
53-
$ pushd staging && spago upgrade-set && popd
54-
```
57+
2. Upgrade to the latest package set:
5558

56-
2. Set the `dependencies` key in the `spago.dhall` file to be an empty list. This will require a type annotation of `List Text`:
57-
58-
```dhall
59-
{ name = "try-purescript-server"
60-
, dependencies = [] : List Text
61-
, packages = ./packages.dhall
62-
, sources = [ "src/**/*.purs" ]
63-
}
59+
```console
60+
$ spago upgrade
6461
```
6562

66-
3. For `staging/spago.dhall`, install all packages in the package set by running this command:
63+
This rewrites `workspace.packageSet.registry` to the newest available set,
64+
replacing the seed version. Each set's JSON at
65+
<https://github.com/purescript/registry/tree/main/package-sets> records the
66+
`compiler` version it targets, which should line up with the `purescript`
67+
version in `stack.yaml` — pin the set explicitly in step 1 instead if the
68+
latest set targets a compiler you don't want.
6769

70+
3. Install every package in the new set so they're all available in the
71+
playground. This overwrites the empty `dependencies` list in
72+
`staging/spago.yaml`, then downloads, compiles, and locks them — so there's
73+
no separate `spago fetch`/`spago build` needed:
74+
75+
```console
76+
$ spago install $(spago ls packages --json --quiet | jq -r 'to_entries[] | select(.value.type == "registry") | .key')
6877
```
69-
$ spago ls packages | cut -f 1 -d ' ' | xargs spago install
70-
```
78+
79+
If a package fails to compile, remove it from `package.dependencies` in
80+
`staging/spago.yaml` and run `spago install` again.
7181

7282
4. Update the `client/src/Try/SharedConfig.purs` file by running this command in `client`:
7383

client/src/Try/SharedConfig.purs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ module Try.SharedConfig where
66
import Prelude
77

88
pursVersion :: String
9-
pursVersion = "v0.15.13"
9+
pursVersion = "v0.15.15"
1010

1111
pursReleaseUrl :: String
1212
pursReleaseUrl = "https://github.com/purescript/purescript/releases/tag/" <> pursVersion
1313

14+
-- | The registry package set version used by `staging/spago.yaml`.
1415
packageSetVersion :: String
15-
packageSetVersion = "0.15.13-20231219"
16+
packageSetVersion = "77.6.0"
1617

1718
packageSetPackageJsonUrl :: String
18-
packageSetPackageJsonUrl = "https://github.com/purescript/package-sets/blob/psc-" <> packageSetVersion <> "/packages.json"
19+
packageSetPackageJsonUrl = "https://github.com/purescript/registry/blob/main/package-sets/" <> packageSetVersion <> ".json"

client/updateSharedConfigVersions.mjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
// This script expects the current working directory to be `client`.
44
// Call it using:
55
// node updateSharedConfigVersions.mjs src/Try/SharedConfig.purs
6+
//
7+
// It keeps `SharedConfig.purs` in sync with the two sources of truth:
8+
// - the PureScript compiler version, taken from the server's `stack.yaml`
9+
// (the `purescript-X.Y.Z` extra-dep, i.e. the compiler that actually
10+
// compiles user snippets);
11+
// - the registry package set version, taken from `staging/spago.yaml`
12+
// (the `registry:` field). With Spago v1 the package set is a registry
13+
// version and no longer encodes a purs version, so the two are read
14+
// independently. The footer URLs are derived from these values inside
15+
// `SharedConfig.purs`, so only the version strings are written here.
616

717
import fs from "fs";
818
import path from "path";
@@ -15,9 +25,9 @@ if (process.argv.length <= 2) {
1525
const sharedConfigPath = process.argv[2];
1626

1727
const stackYamlPath = path.join("..", "stack.yaml");
18-
const stagingPackagesDhallPath = path.join("..", "staging", "packages.dhall");
28+
const stagingSpagoYamlPath = path.join("..", "staging", "spago.yaml");
1929
const stackYamlContent = fs.readFileSync(stackYamlPath, "utf-8");
20-
const packagesContent = fs.readFileSync(stagingPackagesDhallPath, "utf-8");
30+
const stagingSpagoYamlContent = fs.readFileSync(stagingSpagoYamlPath, "utf-8");
2131

2232
const pursVersion = stackYamlContent.split("\n")
2333
.reduce((acc, nextLine) => {
@@ -29,15 +39,15 @@ const pursVersion = stackYamlContent.split("\n")
2939
}, { found: false })
3040
.value;
3141

32-
const packageSetVersion = packagesContent
33-
.match(/https:\/\/github.com\/purescript\/package-sets\/releases\/download\/psc-([^\/]+)\/packages.dhall/)[1];
42+
const packageSetVersionMatch = stagingSpagoYamlContent.match(/registry:\s*(\S+)/);
43+
const packageSetVersion = packageSetVersionMatch ? packageSetVersionMatch[1] : undefined;
3444

3545
if (!pursVersion) {
3646
throw new Error("Failed to extract the PureScript version from the stack.yaml file. Cannot update SharedConfig.purs file.");
3747
}
3848

3949
if (!packageSetVersion) {
40-
throw new Error("Failed to extract the Package Set version from the staging/packages.dhall file. Cannot update SharedConfig.purs file.");
50+
throw new Error("Failed to extract the registry package set version (the 'registry:' field) from the staging/spago.yaml file. Cannot update SharedConfig.purs file.");
4151
}
4252

4353
const sharedConfigContent = fs.readFileSync(sharedConfigPath, "utf-8");

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ packages:
33
- "."
44

55
extra-deps:
6-
- purescript-0.15.13
6+
- purescript-0.15.15
77
- language-javascript-0.7.0.0
88
- process-1.6.13.1
99
# The Cabal library is not in Stackage

stack.yaml.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
packages:
77
- completed:
8-
hackage: purescript-0.15.13@sha256:ed7e4d3561ff6cbc7f950af2450a51f71648c47fece8b9a2b5100f0157a47615,21378
8+
hackage: purescript-0.15.15@sha256:8e2a2452b66e29dbfa8269c523487f882c7b94aa71766b06be7e51da4dc85035,21429
99
pantry-tree:
10-
sha256: f91a02104c2bb596613dca4cf460e8e218488791b8d2f1d0641cd0e73c9eb072
11-
size: 159072
10+
sha256: c70747a772ab844b7e9b86cfc57a9b22001652ad7bec457eb274df29b7110e17
11+
size: 159334
1212
original:
13-
hackage: purescript-0.15.13
13+
hackage: purescript-0.15.15
1414
- completed:
1515
hackage: language-javascript-0.7.0.0@sha256:3eab0262b8ac5621936a4beab6a0f97d0e00a63455a8b0e3ac1547b4088dae7d,3898
1616
pantry-tree:

staging/packages.dhall

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)