@reventlessdev/rescript-node 2.0.0-alpha.14 → 2.0.0-alpha.15
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/CHANGELOG.md +13 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/rescript.json +1 -0
- package/src/NodeProcess.res +10 -3
- package/src/NodeUtil.res +52 -0
- package/src/NodeUtil.res.mjs +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 2.0.0-alpha.15 (2026-09-23)
|
|
7
|
+
|
|
8
|
+
* feat(node)!: every command-line tool reads its arguments through parseArgs ([2e41979](https://github.com/ReventlessDev/reventless-core/commit/2e41979b73646c46356e197e17eb4a3da0154c73))
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* NodeProcess.onSignal takes the new NodeProcess.signal
|
|
13
|
+
variant (SIGINT | SIGTERM | SIGHUP) instead of a polymorphic variant:
|
|
14
|
+
write onSignal(SIGINT, …) for onSignal(#SIGINT, …). Node receives the
|
|
15
|
+
same string.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
# 2.0.0-alpha.14 (2026-09-23)
|
|
7
20
|
|
|
8
21
|
### Features
|
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ Add it to your `rescript.json` dependencies:
|
|
|
45
45
|
| `NodeProcess` | the `process` global |
|
|
46
46
|
| `NodeStreams` | `node:stream`, plus the stream-shaped parts of `node:fs` and `node:readline` |
|
|
47
47
|
| `NodeUrl` | `node:url` |
|
|
48
|
+
| `NodeUtil` | `parseArgs` from `node:util` |
|
|
48
49
|
| `NodeZlib` | `node:zlib` |
|
|
49
50
|
|
|
50
51
|
Every module specifier is `node:`-prefixed. Bare `"fs"` is what bundlers alias to a browser polyfill
|
package/package.json
CHANGED
package/rescript.json
CHANGED
package/src/NodeProcess.res
CHANGED
|
@@ -40,13 +40,20 @@ external kill: (int, int) => unit = "kill"
|
|
|
40
40
|
synchronous work, while a signal handler receives the signal name and fires
|
|
41
41
|
*before* the process is committed to leaving — code that registers one and
|
|
42
42
|
expects the other's timing gets a cleanup that never runs. Signals are a
|
|
43
|
-
|
|
44
|
-
called. */
|
|
43
|
+
closed variant so a typo is a compile error rather than a handler that is
|
|
44
|
+
never called. */
|
|
45
45
|
@val @scope("process")
|
|
46
46
|
external onExit: (@as("exit") _, int => unit) => unit = "on"
|
|
47
47
|
|
|
48
|
+
/** The signals a CLI cleans up on. Each constructor compiles to the name Node
|
|
49
|
+
reads. */
|
|
50
|
+
type signal =
|
|
51
|
+
| @as("SIGINT") SIGINT
|
|
52
|
+
| @as("SIGTERM") SIGTERM
|
|
53
|
+
| @as("SIGHUP") SIGHUP
|
|
54
|
+
|
|
48
55
|
@val @scope("process")
|
|
49
|
-
external onSignal: (
|
|
56
|
+
external onSignal: (signal, unit => unit) => unit = "on"
|
|
50
57
|
|
|
51
58
|
/** The standard streams. `write`, `isTTY`, `pause` and `unref` are what the
|
|
52
59
|
interactive prompts in this repository reach for; the type is abstract so it
|
package/src/NodeUtil.res
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Bindings for `node:util`. `parseArgs` is stable from Node 20.
|
|
2
|
+
|
|
3
|
+
Node's string enums are regular variants whose constructors compile to the
|
|
4
|
+
exact strings Node reads and writes. `default` and `allowNegative` are left
|
|
5
|
+
out: the first is a string, a boolean or an array depending on the option,
|
|
6
|
+
and the second needs Node 22.4. */
|
|
7
|
+
/** An option's `type`. */
|
|
8
|
+
type optionType =
|
|
9
|
+
| @as("string") String
|
|
10
|
+
| @as("boolean") Boolean
|
|
11
|
+
|
|
12
|
+
type optionConfig = {
|
|
13
|
+
@as("type") type_: optionType,
|
|
14
|
+
short?: string,
|
|
15
|
+
multiple?: bool,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type config = {
|
|
19
|
+
args?: array<string>,
|
|
20
|
+
options: dict<optionConfig>,
|
|
21
|
+
strict?: bool,
|
|
22
|
+
allowPositionals?: bool,
|
|
23
|
+
tokens?: bool,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A token's `kind`. The constructor names avoid `Option`, which would read as
|
|
27
|
+
the standard library module at every use site. */
|
|
28
|
+
type tokenKind =
|
|
29
|
+
| @as("option") Flag
|
|
30
|
+
| @as("positional") Positional
|
|
31
|
+
| @as("option-terminator") Terminator
|
|
32
|
+
|
|
33
|
+
type token = {
|
|
34
|
+
kind: tokenKind,
|
|
35
|
+
index: int,
|
|
36
|
+
name?: string,
|
|
37
|
+
rawName?: string,
|
|
38
|
+
value?: string,
|
|
39
|
+
inlineValue?: bool,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `values` mixes strings, booleans and arrays under one object, so it is
|
|
43
|
+
abstract and read through the typed accessors below. */
|
|
44
|
+
type values
|
|
45
|
+
|
|
46
|
+
type parsed = {values: values, positionals: array<string>, tokens?: array<token>}
|
|
47
|
+
|
|
48
|
+
@module("node:util") external parseArgs: config => parsed = "parseArgs"
|
|
49
|
+
|
|
50
|
+
@get_index external string: (values, string) => option<string> = ""
|
|
51
|
+
@get_index external bool: (values, string) => option<bool> = ""
|
|
52
|
+
@get_index external strings: (values, string) => option<array<string>> = ""
|