git.iko.soy/rowtype-yoga/purs-eval
on main help sign in
.github/workflows/release.yml+7−8
since splitsnapshots
unifiedsplit
@@ -7,29 +7,28 @@ jobs:
7 release:
7 release:
8 runs-on: ubuntu-latest
8 runs-on: ubuntu-latest
9 steps:
9 steps:
10− - uses: google-github-actions/release-please-action@v4
10+ - uses: googleapis/release-please-action@v5
11 id: release
11 id: release
12 with:
12 with:
13 release-type: node
13 release-type: node
14− package-name: purs-eval
15− - uses: actions/checkout@v4
14+ - uses: actions/checkout@v7
16 if: ${{ steps.release.outputs.release_created }}
15 if: ${{ steps.release.outputs.release_created }}
17− - uses: cachix/install-nix-action@v26
16+ - uses: cachix/install-nix-action@v31
18 if: ${{ steps.release.outputs.release_created }}
17 if: ${{ steps.release.outputs.release_created }}
19 with:
18 with:
20 extra_nix_config: |
19 extra_nix_config: |
21 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
20 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
22− - uses: cachix/cachix-action@v14
21+ - uses: cachix/cachix-action@v17
23 if: ${{ steps.release.outputs.release_created }}
22 if: ${{ steps.release.outputs.release_created }}
24 with:
23 with:
25 name: klarkc
24 name: klarkc
26 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
25 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
27 - run: |
26 - run: |
28− nix build
27+ nix build .#npm
29 mkdir -p dist
28 mkdir -p dist
30− cp result/bin/purs-eval dist
29+ cp result dist/purs-eval
31 if: ${{ steps.release.outputs.release_created }}
30 if: ${{ steps.release.outputs.release_created }}
32− - uses: actions/setup-node@v4
31+ - uses: actions/setup-node@v7
33 if: ${{ steps.release.outputs.release_created }}
32 if: ${{ steps.release.outputs.release_created }}
34 with:
33 with:
35 node-version: 18
34 node-version: 18
.github/workflows/test.yml+3−3
@@ -5,12 +5,12 @@ jobs:
5 tests:
5 tests:
6 runs-on: ubuntu-latest
6 runs-on: ubuntu-latest
7 steps:
7 steps:
8− - uses: actions/checkout@v4
8+ - uses: actions/checkout@v7
9− - uses: cachix/install-nix-action@v26
9+ - uses: cachix/install-nix-action@v31
10 with:
10 with:
11 extra_nix_config: |
11 extra_nix_config: |
12 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
12 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
13− - uses: cachix/cachix-action@v14
13+ - uses: cachix/cachix-action@v17
14 with:
14 with:
15 name: klarkc
15 name: klarkc
16 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
16 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
.github/workflows/todo.ymlnew file+14
@@ -0,0 +1,14 @@
1+name: "Run TODO to Issue"
2+on:
3+ push:
4+ branches:
5+ - main
6+jobs:
7+ build:
8+ runs-on: "ubuntu-latest"
9+ steps:
10+ - uses: "actions/checkout@v7"
11+ - name: "TODO to Issue"
12+ uses: "alstr/todo-to-issue-action@v5"
13+ with:
14+ IDENTIFIERS: '[{"name": "TODO", "labels": ["help wanted"]}, {"name": "FIXME", "labels": ["bug"]}]'
.github/workflows/update-flake-lock.yml+4−4
@@ -9,18 +9,18 @@ jobs:
9 runs-on: ubuntu-latest
9 runs-on: ubuntu-latest
10 steps:
10 steps:
11 - name: Checkout repository
11 - name: Checkout repository
12− uses: actions/checkout@v4
12+ uses: actions/checkout@v7
13 - name: Install Nix
13 - name: Install Nix
14− uses: cachix/install-nix-action@v26
14+ uses: cachix/install-nix-action@v31
15 with:
15 with:
16 extra_nix_config: |
16 extra_nix_config: |
17 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
17 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
18− - uses: cachix/cachix-action@v14
18+ - uses: cachix/cachix-action@v17
19 with:
19 with:
20 name: klarkc
20 name: klarkc
21 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
21 authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
22 - name: Update flake.lock
22 - name: Update flake.lock
23− uses: DeterminateSystems/update-flake-lock@v21
23+ uses: DeterminateSystems/update-flake-lock@v29
24 with:
24 with:
25 commit-msg: "build(deps): Bump flake.lock dependencies"
25 commit-msg: "build(deps): Bump flake.lock dependencies"
26 pr-title: "Update flake.lock"
26 pr-title: "Update flake.lock"
CHANGELOG.md+12
@@ -1,5 +1,17 @@
1# Changelog
1# Changelog
2
2
3+## [1.5.0](https://github.com/rowtype-yoga/purs-eval/compare/v1.4.1...v1.5.0) (2024-07-11)
4+
5+
6+### Features
7+
8+* upgrade purs-nix and change mock server to httpurple ([ddaad01](https://github.com/rowtype-yoga/purs-eval/commit/ddaad01eed68afa45f584c807ed577abc565c247))
9+
10+
11+### Bug Fixes
12+
13+* npm published version not running ([3f1a295](https://github.com/rowtype-yoga/purs-eval/commit/3f1a29567365000f57e6b2c9c54c55448c3a83c7))
14+
3## [1.4.1](https://github.com/klarkc/purs-eval/compare/v1.4.0...v1.4.1) (2023-08-21)
15## [1.4.1](https://github.com/klarkc/purs-eval/compare/v1.4.0...v1.4.1) (2023-08-21)
4
16
5
17
README.md+3−3
@@ -1,5 +1,5 @@
1# purs-eval
1# purs-eval
2−A simple PureScript expression evaluation tool
2+A simple PureScript expression evaluation tool. It uses [try.purescript.org](https://try.purescript.org) as a compilation backend; for this reason, it currently does not support embedding local files or modules.
3
3
4## Usage
4## Usage
5
5
@@ -10,10 +10,10 @@ EXAMPLE="module Main where\nimport Effect.Console (log)\nmain = log \"hello from
10echo -e $EXAMPLE | npx purs-eval
10echo -e $EXAMPLE | npx purs-eval
11
11
12# With nix
12# With nix
13−echo -e $EXAMPLE | nix run github:klarkc/purs-eval
13+echo -e $EXAMPLE | nix run github:rowtype-yoga/purs-eval
14
14
15# Pipe node (>v18)
15# Pipe node (>v18)
16−echo -e $EXAMPLE | nix run github:klarkc/purs-eval | nix run nixpkgs#nodejs -- --experimental-network-imports --input-type module
16+echo -e $EXAMPLE | nix run github:rowtype-yoga/purs-eval | nix run nixpkgs#nodejs -- --experimental-network-imports --input-type module
17
17
18# or with npx
18# or with npx
19echo -e $EXAMPLE | npx purs-eval | node --experimental-network-imports --input-type module
19echo -e $EXAMPLE | npx purs-eval | node --experimental-network-imports --input-type module
flake.lock+74−168
@@ -1,26 +1,5 @@
1{
1{
2 "nodes": {
2 "nodes": {
3− "deadnix": {
4− "inputs": {
5− "fenix": "fenix",
6− "naersk": "naersk",
7− "nixpkgs": "nixpkgs_5",
8− "utils": "utils"
9− },
10− "locked": {
11− "lastModified": 1656370114,
12− "narHash": "sha256-XBbSWeBuF6Ck0jc634yAp2hjPXWM2JyRDPCdK0dh3w4=",
13− "owner": "astro",
14− "repo": "deadnix",
15− "rev": "9f450f7250ad7680cb5f12ce5985cc18496c2d5f",
16− "type": "github"
17− },
18− "original": {
19− "owner": "astro",
20− "repo": "deadnix",
21− "type": "github"
22− }
23− },
24 "docs-search": {
3 "docs-search": {
25 "flake": false,
4 "flake": false,
26 "locked": {
5 "locked": {
@@ -37,26 +16,22 @@
37 "type": "github"
16 "type": "github"
38 }
17 }
39 },
18 },
40− "fenix": {
19+ "flake-utils": {
41− "inputs": {
42− "nixpkgs": "nixpkgs_3",
43− "rust-analyzer-src": "rust-analyzer-src"
44− },
45 "locked": {
20 "locked": {
46− "lastModified": 1655533500,
21+ "lastModified": 1644229661,
47− "narHash": "sha256-qJJmLVoMYfDLywI9MNL7sb0W/GsKQF9HDatdHm1tSl0=",
22+ "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
48− "owner": "nix-community",
23+ "owner": "numtide",
49− "repo": "fenix",
24+ "repo": "flake-utils",
50− "rev": "b6630603af13df17d0dd4df8629e9a24e6ba0fbd",
25+ "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
51 "type": "github"
26 "type": "github"
52 },
27 },
53 "original": {
28 "original": {
54− "owner": "nix-community",
29+ "owner": "numtide",
55− "repo": "fenix",
30+ "repo": "flake-utils",
56 "type": "github"
31 "type": "github"
57 }
32 }
58 },
33 },
59− "flake-utils": {
34+ "flake-utils_2": {
60 "locked": {
35 "locked": {
61 "lastModified": 1618217525,
36 "lastModified": 1618217525,
62 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
37 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -71,7 +46,7 @@
71 "type": "github"
46 "type": "github"
72 }
47 }
73 },
48 },
74− "flake-utils_2": {
49+ "flake-utils_3": {
75 "locked": {
50 "locked": {
76 "lastModified": 1618217525,
51 "lastModified": 1618217525,
77 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
52 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -86,7 +61,7 @@
86 "type": "github"
61 "type": "github"
87 }
62 }
88 },
63 },
89− "flake-utils_3": {
64+ "flake-utils_4": {
90 "locked": {
65 "locked": {
91 "lastModified": 1618217525,
66 "lastModified": 1618217525,
92 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
67 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -116,6 +91,44 @@
116 "type": "github"
91 "type": "github"
117 }
92 }
118 },
93 },
94+ "httpurple-argonaut": {
95+ "flake": false,
96+ "locked": {
97+ "lastModified": 1655138308,
98+ "narHash": "sha256-tWTgc2gERJLkv+XzK4HtqJJbqvw10svVu1cmXFADtls=",
99+ "owner": "sigma-andex",
100+ "repo": "purescript-httpurple-argonaut",
101+ "rev": "3187fba4fe0682849b4acbf215e6a6fc1f6493de",
102+ "type": "github"
103+ },
104+ "original": {
105+ "owner": "sigma-andex",
106+ "repo": "purescript-httpurple-argonaut",
107+ "type": "github"
108+ }
109+ },
110+ "lint-utils": {
111+ "inputs": {
112+ "flake-utils": "flake-utils",
113+ "nixpkgs": [
114+ "purs-nix",
115+ "nixpkgs"
116+ ]
117+ },
118+ "locked": {
119+ "lastModified": 1707777931,
120+ "narHash": "sha256-PsPb5xMBZ9dPDP04o9vqKEUIEG80Z84/74fPuOMs0ZI=",
121+ "owner": "homotopic",
122+ "repo": "lint-utils",
123+ "rev": "5f11e3e51d8f1aa4ed62a89e90f05953931e105a",
124+ "type": "github"
125+ },
126+ "original": {
127+ "owner": "homotopic",
128+ "repo": "lint-utils",
129+ "type": "github"
130+ }
131+ },
119 "make-shell": {
132 "make-shell": {
120 "locked": {
133 "locked": {
121 "lastModified": 1634940815,
134 "lastModified": 1634940815,
@@ -148,31 +161,13 @@
148 "type": "github"
161 "type": "github"
149 }
162 }
150 },
163 },
151− "naersk": {
152− "inputs": {
153− "nixpkgs": "nixpkgs_4"
154− },
155− "locked": {
156− "lastModified": 1655042882,
157− "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
158− "owner": "nix-community",
159− "repo": "naersk",
160− "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
161− "type": "github"
162− },
163− "original": {
164− "owner": "nix-community",
165− "repo": "naersk",
166− "type": "github"
167− }
168− },
169 "nixpkgs": {
164 "nixpkgs": {
170 "locked": {
165 "locked": {
171− "lastModified": 1703499205,
166+ "lastModified": 1704161960,
172− "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=",
167+ "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=",
173 "owner": "NixOS",
168 "owner": "NixOS",
174 "repo": "nixpkgs",
169 "repo": "nixpkgs",
175− "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870",
170+ "rev": "63143ac2c9186be6d9da6035fa22620018c85932",
176 "type": "github"
171 "type": "github"
177 },
172 },
178 "original": {
173 "original": {
@@ -183,66 +178,6 @@
183 }
178 }
184 },
179 },
185 "nixpkgs_2": {
180 "nixpkgs_2": {
186− "locked": {
187− "lastModified": 1646506091,
188− "narHash": "sha256-sWNAJE2m+HOh1jtXlHcnhxsj6/sXrHgbqVNcVRlveK4=",
189− "owner": "NixOS",
190− "repo": "nixpkgs",
191− "rev": "3e644bd62489b516292c816f70bf0052c693b3c7",
192− "type": "github"
193− },
194− "original": {
195− "owner": "NixOS",
196− "ref": "nixpkgs-unstable",
197− "repo": "nixpkgs",
198− "type": "github"
199− }
200− },
201− "nixpkgs_3": {
202− "locked": {
203− "lastModified": 1655400192,
204− "narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=",
205− "owner": "nixos",
206− "repo": "nixpkgs",
207− "rev": "3d7435c638baffaa826b85459df0fff47f12317d",
208− "type": "github"
209− },
210− "original": {
211− "owner": "nixos",
212− "ref": "nixos-unstable",
213− "repo": "nixpkgs",
214− "type": "github"
215− }
216− },
217− "nixpkgs_4": {
218− "locked": {
219− "lastModified": 1655481042,
220− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
221− "owner": "NixOS",
222− "repo": "nixpkgs",
223− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
224− "type": "github"
225− },
226− "original": {
227− "id": "nixpkgs",
228− "type": "indirect"
229− }
230− },
231− "nixpkgs_5": {
232− "locked": {
233− "lastModified": 1655481042,
234− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
235− "owner": "NixOS",
236− "repo": "nixpkgs",
237− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
238− "type": "github"
239− },
240− "original": {
241− "id": "nixpkgs",
242− "type": "indirect"
243− }
244− },
245− "nixpkgs_6": {
246 "locked": {
181 "locked": {
247 "lastModified": 1656549732,
182 "lastModified": 1656549732,
248 "narHash": "sha256-eILutFZGjfk2bEzfim8S/qyYc//0S1KsCeO+OWbtoR0=",
183 "narHash": "sha256-eILutFZGjfk2bEzfim8S/qyYc//0S1KsCeO+OWbtoR0=",
@@ -291,17 +226,16 @@
291 },
226 },
292 "ps-tools": {
227 "ps-tools": {
293 "inputs": {
228 "inputs": {
294− "deadnix": "deadnix",
295 "make-shell": "make-shell_2",
229 "make-shell": "make-shell_2",
296− "nixpkgs": "nixpkgs_6",
230+ "nixpkgs": "nixpkgs_2",
297− "utils": "utils_2"
231+ "utils": "utils"
298 },
232 },
299 "locked": {
233 "locked": {
300− "lastModified": 1691537451,
234+ "lastModified": 1704567308,
301− "narHash": "sha256-9dnX6E7eWVm8xhHDeA3AmkvhqcWRo6RJ4z6Vrn65cFs=",
235+ "narHash": "sha256-WbFPIkKLtyQOPBUjintckKIYnfs7MvIbmfVsLRSAPlc=",
302 "owner": "purs-nix",
236 "owner": "purs-nix",
303 "repo": "purescript-tools",
237 "repo": "purescript-tools",
304− "rev": "675cd35bc9255f9c2b1f6f6784ef41b9773202e8",
238+ "rev": "ac626313141cbee78f06eb3c5e90359f695aef9b",
305 "type": "github"
239 "type": "github"
306 },
240 },
307 "original": {
241 "original": {
@@ -314,74 +248,46 @@
314 "inputs": {
248 "inputs": {
315 "docs-search": "docs-search",
249 "docs-search": "docs-search",
316 "get-flake": "get-flake",
250 "get-flake": "get-flake",
251+ "lint-utils": "lint-utils",
317 "make-shell": "make-shell",
252 "make-shell": "make-shell",
318− "nixpkgs": "nixpkgs_2",
253+ "nixpkgs": "nixpkgs",
319 "parsec": "parsec",
254 "parsec": "parsec",
320 "ps-tools": "ps-tools",
255 "ps-tools": "ps-tools",
321− "utils": "utils_3"
256+ "utils": "utils_2"
322 },
257 },
323 "locked": {
258 "locked": {
324− "lastModified": 1691603627,
259+ "lastModified": 1711996073,
325− "narHash": "sha256-bsJh6PCDF9+hSuk/dbTtSXdma0VvjFejN6weHPt7cyU=",
260+ "narHash": "sha256-NDV8q9qtpKjHgIcMVBgdNqEfhpfK1d19rHYNa7yq0Qs=",
326 "owner": "purs-nix",
261 "owner": "purs-nix",
327 "repo": "purs-nix",
262 "repo": "purs-nix",
328− "rev": "8729b7fbb02822df3fb3988bae94b276e50ca6fc",
263+ "rev": "8caa40f7fe69b9fcd05baae04c4ec9eb43953e2e",
329 "type": "github"
264 "type": "github"
330 },
265 },
331 "original": {
266 "original": {
332 "owner": "purs-nix",
267 "owner": "purs-nix",
333− "ref": "ps-0.15",
334 "repo": "purs-nix",
268 "repo": "purs-nix",
335 "type": "github"
269 "type": "github"
336 }
270 }
337 },
271 },
338 "root": {
272 "root": {
339 "inputs": {
273 "inputs": {
274+ "httpurple-argonaut": "httpurple-argonaut",
340− "nixpkgs": "nixpkgs",
275+ "nixpkgs": [
276+ "purs-nix",
277+ "nixpkgs"
278+ ],
341 "npmlock2nix": "npmlock2nix",
279 "npmlock2nix": "npmlock2nix",
342 "ps-tools": [
280 "ps-tools": [
343 "purs-nix",
281 "purs-nix",
344 "ps-tools"
282 "ps-tools"
345 ],
283 ],
346 "purs-nix": "purs-nix",
284 "purs-nix": "purs-nix",
347− "utils": "utils_4"
285+ "utils": "utils_3"
348− }
349− },
350− "rust-analyzer-src": {
351− "flake": false,
352− "locked": {
353− "lastModified": 1655507737,
354− "narHash": "sha256-o+AqNsjL6o2RHh4InZHQVpkmqg570YFJL4Db8mKq+fs=",
355− "owner": "rust-lang",
356− "repo": "rust-analyzer",
357− "rev": "12dd81092e37df28b7a3591cae9675e668927198",
358− "type": "github"
359− },
360− "original": {
361− "owner": "rust-lang",
362− "ref": "nightly",
363− "repo": "rust-analyzer",
364− "type": "github"
365 }
286 }
366 },
287 },
367 "utils": {
288 "utils": {
368− "locked": {
369− "lastModified": 1653893745,
370− "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
371− "owner": "numtide",
372− "repo": "flake-utils",
373− "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
374− "type": "github"
375− },
376− "original": {
377− "owner": "numtide",
378− "repo": "flake-utils",
379− "type": "github"
380− }
381− },
382− "utils_2": {
383 "inputs": {
289 "inputs": {
384− "flake-utils": "flake-utils"
290+ "flake-utils": "flake-utils_2"
385 },
291 },
386 "locked": {
292 "locked": {
387 "lastModified": 1656044990,
293 "lastModified": 1656044990,
@@ -398,9 +304,9 @@
398 "type": "github"
304 "type": "github"
399 }
305 }
400 },
306 },
401− "utils_3": {
307+ "utils_2": {
402 "inputs": {
308 "inputs": {
403− "flake-utils": "flake-utils_2"
309+ "flake-utils": "flake-utils_3"
404 },
310 },
405 "locked": {
311 "locked": {
406 "lastModified": 1656044990,
312 "lastModified": 1656044990,
@@ -417,9 +323,9 @@
417 "type": "github"
323 "type": "github"
418 }
324 }
419 },
325 },
420− "utils_4": {
326+ "utils_3": {
421 "inputs": {
327 "inputs": {
422− "flake-utils": "flake-utils_3"
328+ "flake-utils": "flake-utils_4"
423 },
329 },
424 "locked": {
330 "locked": {
425 "lastModified": 1658606827,
331 "lastModified": 1658606827,
flake.nix+30−20
@@ -1,12 +1,18 @@
1{
1{
2 inputs =
2 inputs =
3 {
3 {
4− nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+ purs-nix.url = "github:purs-nix/purs-nix";
5− npmlock2nix.url = "github:nix-community/npmlock2nix";
6− npmlock2nix.flake = false;
7− ps-tools.follows = "purs-nix/ps-tools";
5+ nixpkgs.follows = "purs-nix/nixpkgs";
8− purs-nix.url = "github:purs-nix/purs-nix/ps-0.15";
9 utils.url = "github:ursi/flake-utils";
6 utils.url = "github:ursi/flake-utils";
7+ ps-tools.follows = "purs-nix/ps-tools";
8+ npmlock2nix = {
9+ url = "github:nix-community/npmlock2nix";
10+ flake = false;
11+ };
12+ httpurple-argonaut = {
13+ url = "github:sigma-andex/purescript-httpurple-argonaut";
14+ flake = false;
15+ };
10 };
16 };
11
17
12 outputs = { self, utils, ... }@inputs:
18 outputs = { self, utils, ... }@inputs:
@@ -15,25 +21,24 @@
15 inherit inputs;
21 inherit inputs;
16 # Limited by ps-tools
22 # Limited by ps-tools
17 systems = [ "x86_64-linux" "x86_64-darwin" ];
23 systems = [ "x86_64-linux" "x86_64-darwin" ];
18− make-pkgs = system: import inputs.nixpkgs {
19− inherit system;
20− # required by npmlock2nix
21− config.permittedInsecurePackages = [
22− "nodejs-16.20.2"
23− ];
24− };
25 }
24 }
26− ({ pkgs, system, ... }:
25+ ({ pkgs, system, ... }@ctx:
27 let
26 let
28 inherit (pkgs) nodejs;
27 inherit (pkgs) nodejs;
29 npm = import inputs.npmlock2nix { inherit pkgs; };
28 npm = import inputs.npmlock2nix { inherit pkgs; };
30 node_modules = npm.v2.node_modules { src = ./.; inherit nodejs; } + /node_modules;
29 node_modules = npm.v2.node_modules { src = ./.; inherit nodejs; } + /node_modules;
31− ps-tools = inputs.ps-tools.legacyPackages.${system};
32− inherit (ps-tools.for-0_15) purescript purs-tidy purescript-language-server;
30+ inherit (ctx.ps-tools) purescript purs-tidy purescript-language-server;
33 purs-nix = inputs.purs-nix { inherit system; };
31 purs-nix = inputs.purs-nix { inherit system; };
34 affjax-node_ = pkgs.lib.recursiveUpdate purs-nix.ps-pkgs.affjax-node {
32 affjax-node_ = pkgs.lib.recursiveUpdate purs-nix.ps-pkgs.affjax-node {
35 purs-nix-info.foreign."Affjax.Node" = { inherit node_modules; };
33 purs-nix-info.foreign."Affjax.Node" = { inherit node_modules; };
36 };
34 };
35+ # TODO use httpurple-argonaut from official index
36+ httpurple-argonaut_ = purs-nix.build
37+ {
38+ name = "httpurple-argonaut";
39+ src.path = inputs.httpurple-argonaut;
40+ info.dependencies = [ "argonaut" "console" "effect" "either" "httpurple" "prelude"];
41+ };
37 ps =
42 ps =
38 purs-nix.purs
43 purs-nix.purs
39 {
44 {
@@ -48,10 +53,8 @@
48 argonaut-codecs
53 argonaut-codecs
49 argonaut-generic
54 argonaut-generic
50 effect
55 effect
51− httpure
56+ httpurple
52− node-buffer
57+ httpurple-argonaut_
53− node-process
54− node-streams-aff
55 test-unit
58 test-unit
56 parsing
59 parsing
57 ];
60 ];
@@ -68,9 +71,16 @@
68 };
71 };
69
72
70 packages =
73 packages =
71− with ps;
72 {
74 {
73 default = app { inherit name; };
75 default = app { inherit name; };
76+ # npm version does not publish a nix-store path
77+ npm = pkgs.runCommand
78+ "purs-eval-npm"
79+ {}
80+ ''
81+ echo "#!/usr/bin/env node" > $out
82+ tail -n +2 ${packages.default}/bin/purs-eval >> $out
83+ '';
74 };
84 };
75
85
76 checks.test = test.check { };
86 checks.test = test.check { };
package-lock.json+2−2
@@ -11,7 +11,7 @@
11 "devDependencies": {
11 "devDependencies": {
12 "xhr2": "^0.2.1"
12 "xhr2": "^0.2.1"
13 },
13 },
14− "version": "1.4.1"
14+ "version": "1.5.0"
15 },
15 },
16 "node_modules/xhr2": {
16 "node_modules/xhr2": {
17 "version": "0.2.1",
17 "version": "0.2.1",
@@ -31,5 +31,5 @@
31 "dev": true
31 "dev": true
32 }
32 }
33 },
33 },
34− "version": "1.4.1"
34+ "version": "1.5.0"
35}
35}
package.json+1−1
@@ -4,5 +4,5 @@
4 "devDependencies": {
4 "devDependencies": {
5 "xhr2": "^0.2.1"
5 "xhr2": "^0.2.1"
6 },
6 },
7− "version": "1.4.1"
7+ "version": "1.5.0"
8}
8}
test/Test/Compiler/ServerMock.purs+28−66
@@ -1,11 +1,7 @@
1module Test.Compiler.ServerMock (settings, setupSrv) where
1module Test.Compiler.ServerMock (settings, setupSrv) where
2
2
3−import Prelude (Unit, ($), (==), (>>=), (<<<), unit, pure, bind, const, discard)
3+import Prelude (Unit, ($), (<<<), unit, pure, bind, const)
4−import Control.Apply ((*>))
5−import Control.Monad.Error.Class (throwError, liftMaybe)
6−import Control.Monad.Reader.Trans (ReaderT, ask, runReaderT)
7−import Control.Monad.Trans.Class (lift)
8−import Data.Argonaut.Core (Json, stringify)
4+import Data.Argonaut.Core (Json)
9import Data.Argonaut.Decode (JsonDecodeError, printJsonDecodeError)
5import Data.Argonaut.Decode (JsonDecodeError, printJsonDecodeError)
10import Data.Argonaut.Decode.Class (class DecodeJson, decodeJson)
6import Data.Argonaut.Decode.Class (class DecodeJson, decodeJson)
11import Data.Argonaut.Decode.Generic (genericDecodeJson)
7import Data.Argonaut.Decode.Generic (genericDecodeJson)
@@ -17,19 +13,13 @@ import Data.Functor ((<$>))
17import Data.Generic.Rep (class Generic)
13import Data.Generic.Rep (class Generic)
18import Data.Maybe (Maybe(Nothing))
14import Data.Maybe (Maybe(Nothing))
19import Data.Newtype (class Newtype, unwrap, wrap)
15import Data.Newtype (class Newtype, unwrap, wrap)
16+import Node.HTTP.Types (ServerResponse)
20−import Effect
17+import Effect (Effect)
21import Effect.Aff (Aff, bracket)
18import Effect.Aff (Aff, bracket)
22import Effect.Class (liftEffect)
19import Effect.Class (liftEffect)
23import Effect.Exception (Error, error)
20import Effect.Exception (Error, error)
24−import HTTPure.Request (Request)
21+import HTTPurple (RouteDuplex', Method(Post), (/), ResponseHeaders, noArgs, mkRoute, serve, ok, notFound, toJson)
25−import HTTPure.Response (ResponseM, Response, ok)
22+import HTTPurple.Json.Argonaut (jsonEncoder)
26−import HTTPure.Server (serve)
27−import HTTPure.Lookup ((!!))
28−import HTTPure.Method (Method(Post))
29−import HTTPure.Body (class Body)
30−import HTTPure.Headers (header)
31−import Node.Stream.Aff (write, end, fromStringUTF8)
32−import Node.HTTP (responseAsStream)
33import Compiler (Settings, Code, SuccessResult)
23import Compiler (Settings, Code, SuccessResult)
34
24
35
25
@@ -51,26 +41,6 @@ successToJson = (encodeJson :: SuccessResult_ -> Json) <<< wrap
51successFromJson_ :: Json -> Either Error SuccessResult
41successFromJson_ :: Json -> Either Error SuccessResult
52successFromJson_ json = unwrap <$> (error <<< printJsonDecodeError) `lmap` (decodeJson json :: Either JsonDecodeError SuccessResult_)
42successFromJson_ json = unwrap <$> (error <<< printJsonDecodeError) `lmap` (decodeJson json :: Either JsonDecodeError SuccessResult_)
53
43
54−newtype Json_ = Json_ Json
55−
56−derive instance Newtype Json_ _
57−
58−instance Body Json_ where
59− defaultHeaders _ = pure $ header "Content-Type" "application/json"
60− write json res = do
61− let stream = responseAsStream res
62− body' <- liftEffect $ fromStringUTF8 $ stringify $ unwrap $ json
63− write stream body'
64− end stream
65−
66−type ServerMock = ReaderT Code (ReaderT Request Aff)
67−
68−askRes :: ServerMock Code
69−askRes = ask
70−
71−askReq :: ServerMock Request
72−askReq = lift ask
73−
74settings :: Settings
44settings :: Settings
75settings = { protocol: "http"
45settings = { protocol: "http"
76 , hostname: "localhost"
46 , hostname: "localhost"
@@ -78,38 +48,30 @@ settings = { protocol: "http"
78 , parser: successFromJson_
48 , parser: successFromJson_
79 }
49 }
80
50
81−validatePath :: ServerMock Unit
51+data Route = Compile
82−validatePath = do
52+
83− let invalidPath = error "invalid path"
53+derive instance Generic Route _
84− missingPath = error "missing path"
54+
85− req <- askReq
55+route :: RouteDuplex' Route
86− p <- liftMaybe missingPath $ req.path !! 0
56+route = mkRoute
87− case p == "compile" of
57+ { "Compile": "compile" / noArgs
88− true -> pure unit
58+ }
89− false -> throwError invalidPath
59+
90−
60+
91−validateMethod :: ServerMock Unit
61+mkRouter
92−validateMethod = askReq >>= case _ of
62+ :: forall a.
93− { method: Post } -> pure unit
63+ String
94− _ -> throwError $ error "invalid method"
64+ -> { method :: Method, route :: Route | a }
95−
65+ -> Aff { headers :: ResponseHeaders, status :: Int , writeBody :: ServerResponse -> Aff Unit }
96−validate :: ServerMock Unit
66+mkRouter js = case _ of
97−validate = validatePath *> validateMethod
98−
99−answer :: ServerMock Response
100−answer = do
101− res <- askRes
102− let json :: Json_
103− json = wrap $ successToJson { js: res, warnings: Nothing }
67+ { route: Compile, method: Post } -> ok $ toJson jsonEncoder $ successToJson { js, warnings: Nothing }
104− ok json
68+ _ -> notFound
105−
106−runServerMock :: Code -> Request -> ResponseM
107−runServerMock res req = runReaderT (runReaderT (validate *> answer) res) req
108
69
109launchServerMock :: Code -> Aff (Effect Unit)
70launchServerMock :: Code -> Aff (Effect Unit)
110−launchServerMock res = do
71+launchServerMock c = liftEffect do
72+ let router = mkRouter c
111− close <- liftEffect $ serve settings.port (\req -> runServerMock res req) $ pure unit
73+ close <- serve { port: settings.port } { route, router }
112− pure $ close $ pure unit
74+ pure $ close $ pure unit
113
75
114setupSrv :: forall b. Code -> Aff b -> Aff b
76setupSrv :: forall b. Code -> Aff b -> Aff b
115setupSrv code act = bracket (launchServerMock code) liftEffect (const act)
77setupSrv code act = bracket (launchServerMock code) liftEffect (const act)