Skip to content

Commit

Permalink
Remove non flake files and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Jun 12, 2024
1 parent dd34844 commit 3e2f04d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
nix develop ..#cardano-addresses-js-shell --command npm run typedoc
- name: 'Demo'
run: 'nix-build -A demo -o result-demo'
git add -f dist
nix build ..#cardano-addresses-demo-js -o result-demo
- name: 'Prepare Documentation'
run: |
mkdir ../_build
Expand Down
26 changes: 14 additions & 12 deletions jsapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,39 @@ This package comprises of four parts:

### NodeJS module: Building and testing

Start a `nix-shell` in *this directory* (not the top-level) and run:
Start a `nix develop .#cardano-addresses-js-shell` in the repo top-level directory and run:

```shell
$ nix develop .#cardano-addresses-js-shell
$ cd jsapi
$ nix-shell
[nix-shell:~/iohk/cardano-addresses/jsapi]$ npm install && npm run build
$ npm install && npm run build
...
[nix-shell:~/iohk/cardano-addresses/jsapi]$ npm run test
$ npm run test
```

Behind the scenes, this will use Nix to make the `ghcjs` build of the `cardano-addresses` library. The path to this Javascript file is stored in the `$CARDANO_ADDRESSES_JS` environment variable.

### Haskell module: Building and testing

To try it out run `nix-shell` from the repo top-level directory:
To try it out run `nix develop .#` from the repo top-level directory:

```shell
$ nix-shell
[nix-shell:~/iohk/cardano-addresses]$ js-unknown-ghcjs-cabal build cardano-addresses-jsapi:jsapi-test
[nix-shell:~/iohk/cardano-addresses]$ node dist-newstyle/build/js-ghcjs/ghcjs-8.10.4/cardano-addresses-jsapi-3.5.0/t/jsapi-test/build/jsapi-test/jsapi-test.jsexe/all.js
$ nix develop .#
$ cd jsapi
$ js-unknown-ghcjs-cabal build cardano-addresses-jsapi:jsapi-test
$ node dist-newstyle/build/js-ghcjs/ghcjs-8.10.4/cardano-addresses-jsapi-3.5.0/t/jsapi-test/build/jsapi-test/jsapi-test.jsexe/all.js
```

That test initializes the api from a JS function that is called from `Main.hs`. To build `.js` file that might be easier to use from a JS app run:

```shell
$ nix-build jsapi/default.nix -A cardano-addresses-js
/nix/store/dw0xwvjvwac68i2a4dkkpx4mw8yji9z8-cardano-addresses-js-3.5.0
$ nix build .#cardano-addresses-js
$ tree ./result
./result
result
├── cardano-addresses-jsapi.cjs.js
└── cardano-addresses-jsapi.js
├── cardano-addresses-jsapi.esm.js
├── cardano-addresses-jsapi.js
└── cardano-addresses-jsapi.mjs
```

This replaces the regular `runmain.js` with `jsapi/glue/runmain.js`. That exposes a single function you can call and pass in a continuation.
Expand Down
11 changes: 0 additions & 11 deletions jsapi/default.nix

This file was deleted.

1 change: 0 additions & 1 deletion jsapi/shell.nix

This file was deleted.

17 changes: 9 additions & 8 deletions jsbits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ ghcjs.
Build and run CLI:

```terminal
$ nix-build release.nix -A ghcjs.cardano-address.x86_64-linux
$ node ./result/bin/cardano-address.jsexe/all.js --help
$ node ./result/bin/cardano-address.jsexe/all.js recovery-phrase generate
$ nix build .#ghc810-javascript-unknown-ghcjs:cardano-addresses-cli:exe:cardano-address
$ ./result/bin/cardano-address --help
$ ./result/bin/cardano-address recovery-phrase generate
```

Execute library unit tests:
```terminal
$ nix-build release.nix -A ghcjs.checks.cardano-addresses.unit.x86_64-linux
$ nix build .#checks.x86_64-linux.ghc810-javascript-unknown-ghcjs:cardano-addresses:test:unit
$ cat result/test-stdout
```

## With Cabal in nix-shell
Expand All @@ -26,16 +27,16 @@ The `nix-shell` development environment provides
Build and run CLI:

```terminal
$ nix-shell
[nix-shell:~/iohk/cardano-addresses]$ js-unknown-ghcjs-cabal --builddir=dist-ghcjs build all
$ nix develop
$ js-unknown-ghcjs-cabal --builddir=dist-ghcjs build all
...
[nix-shell:~/iohk/cardano-addresses]$ js-unknown-ghcjs-cabal --builddir=dist-ghcjs run cardano-addresses-cli:exe:cardano-address
$ js-unknown-ghcjs-cabal --builddir=dist-ghcjs run cardano-addresses-cli:exe:cardano-address
...
/home/rodney/iohk/cardano-addresses/dist-ghcjs/build/wasm32-none/ghcjs-8.6.5/cardano-addresses-cli-3.3.0/x/cardano-address/build/cardano-address/cardano-address: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
cardano-address: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
[nix-shell:~/iohk/cardano-addresses]$ node dist-ghcjs/build/wasm32-none/ghcjs-8.6.5/cardano-addresses-cli-3.3.0/x/cardano-address/build/cardano-address/cardano-address.jsexe/all.js recovery-phrase generate
$ node dist-ghcjs/build/wasm32-none/ghcjs-8.6.5/cardano-addresses-cli-3.3.0/x/cardano-address/build/cardano-address/cardano-address.jsexe/all.js recovery-phrase generate
culture fringe exercise stumble gold current balance ....
```

Expand Down
1 change: 1 addition & 0 deletions nix/cardano-addresses-js.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ stdenv.mkDerivation rec {
checkPhase = ''
node --check $out/cardano-addresses-jsapi.js
node --check $out/cardano-addresses-jsapi.cjs.js
# TODO find a way to remove the duplicates or disable just that check
# node --experimental-modules --check $out/cardano-addresses-jsapi.mjs
echo "syntax check OK"
'';
Expand Down
1 change: 0 additions & 1 deletion shell.nix

This file was deleted.

0 comments on commit 3e2f04d

Please sign in to comment.