@reventlessdev/reventless-ppx 1.0.0-alpha.86 → 1.0.0-alpha.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/package.json +7 -5
- package/read +41 -0
package/README.md
CHANGED
|
@@ -27,6 +27,21 @@ binary** installed as an optional dependency
|
|
|
27
27
|
with no prebuilt binary (e.g. macOS x64, Linux arm64, Windows via WSL2), it is
|
|
28
28
|
built from source with the OCaml toolchain (`opam` + `dune`).
|
|
29
29
|
|
|
30
|
+
### The source reader
|
|
31
|
+
|
|
32
|
+
The same package ships `reventless-ppx-read`, which prints one ReScript file's
|
|
33
|
+
declarations as JSON, each with its span (byte offsets into the file) and source
|
|
34
|
+
text: types with their cases, fields and attributes; top-level `let`s with a
|
|
35
|
+
function's parameters and defaults; and the tests of a GWT file with their
|
|
36
|
+
scenario-id markers and step values. It is for tools that edit source in place.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx reventless-ppx-read [--bsc <path-to-bsc>] src/PlaceOrder.res
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The file is parsed by the workspace's own ReScript compiler (found under
|
|
43
|
+
`node_modules/@rescript`, or given with `--bsc`); nothing is built.
|
|
44
|
+
|
|
30
45
|
## Where it fits
|
|
31
46
|
|
|
32
47
|
This is build tooling shared across the framework and its example apps, not a
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-ppx",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.88",
|
|
4
4
|
"description": "ReScript PPX to eliminate boilerplate from Reventless application code",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"files": [
|
|
7
|
-
"bin"
|
|
7
|
+
"bin",
|
|
8
|
+
"read"
|
|
8
9
|
],
|
|
9
10
|
"bin": {
|
|
10
|
-
"reventless-ppx": "bin"
|
|
11
|
+
"reventless-ppx": "bin",
|
|
12
|
+
"reventless-ppx-read": "read"
|
|
11
13
|
},
|
|
12
14
|
"scripts": {
|
|
13
15
|
"build:ppx": "cd src && opam exec -- dune build",
|
|
@@ -16,8 +18,8 @@
|
|
|
16
18
|
"test": "./test/run.sh"
|
|
17
19
|
},
|
|
18
20
|
"optionalDependencies": {
|
|
19
|
-
"@reventlessdev/reventless-ppx-darwin-arm64": "^1.0.0-alpha.
|
|
20
|
-
"@reventlessdev/reventless-ppx-linux-x64": "^1.0.0-alpha.
|
|
21
|
+
"@reventlessdev/reventless-ppx-darwin-arm64": "^1.0.0-alpha.87",
|
|
22
|
+
"@reventlessdev/reventless-ppx-linux-x64": "^1.0.0-alpha.87"
|
|
21
23
|
},
|
|
22
24
|
"publishConfig": {
|
|
23
25
|
"registry": "https://registry.npmjs.org"
|
package/read
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Resolve and exec reventless-ppx-read, the source reader, for the current platform.
|
|
3
|
+
#
|
|
4
|
+
# reventless-ppx-read [--bsc <path-to-bsc>] <file.res>
|
|
5
|
+
#
|
|
6
|
+
# Prints the file's declarations with their spans as JSON
|
|
7
|
+
# (docs/plans/source-reader-with-spans.md). The binary ships beside ppx.exe in the
|
|
8
|
+
# per-platform package, and is found the way `bin` finds ppx.exe: sibling,
|
|
9
|
+
# nested, or hoisted to an ancestor node_modules, then a local dune build.
|
|
10
|
+
DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
+
|
|
12
|
+
case "$(uname -s)-$(uname -m)" in
|
|
13
|
+
Linux-x86_64) PKG="linux-x64" ;;
|
|
14
|
+
Linux-aarch64) PKG="linux-arm64" ;;
|
|
15
|
+
Darwin-x86_64) PKG="darwin-x64" ;;
|
|
16
|
+
Darwin-arm64) PKG="darwin-arm64" ;;
|
|
17
|
+
*) echo "reventless-ppx-read: unsupported platform $(uname -s)-$(uname -m)" >&2; exit 1 ;;
|
|
18
|
+
esac
|
|
19
|
+
|
|
20
|
+
# `-f`, then restore +x: installing from a tarball can drop the mode (see `bin`).
|
|
21
|
+
for CAND in \
|
|
22
|
+
"$DIR/../reventless-ppx-$PKG/read.exe" \
|
|
23
|
+
"$DIR/node_modules/@reventlessdev/reventless-ppx-$PKG/read.exe"; do
|
|
24
|
+
if [ -f "$CAND" ]; then chmod u+x "$CAND" 2>/dev/null; exec "$CAND" "$@"; fi
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
ANCESTOR="$DIR"
|
|
28
|
+
while [ "$ANCESTOR" != "/" ] && [ -n "$ANCESTOR" ]; do
|
|
29
|
+
ANCESTOR="$(dirname "$ANCESTOR")"
|
|
30
|
+
CAND="$ANCESTOR/node_modules/@reventlessdev/reventless-ppx-$PKG/read.exe"
|
|
31
|
+
if [ -f "$CAND" ]; then chmod u+x "$CAND" 2>/dev/null; exec "$CAND" "$@"; fi
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
# PPX development: the dune build in this package.
|
|
35
|
+
CAND="$DIR/src/_build/default/read/read.exe"
|
|
36
|
+
if [ -f "$CAND" ]; then exec "$CAND" "$@"; fi
|
|
37
|
+
|
|
38
|
+
echo "reventless-ppx-read: no binary found for $(uname -s)-$(uname -m)." >&2
|
|
39
|
+
echo " Expected read.exe in @reventlessdev/reventless-ppx-$PKG," >&2
|
|
40
|
+
echo " or a local build at $DIR/src/_build/default/read/read.exe." >&2
|
|
41
|
+
exit 1
|