@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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/rescript-node",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.15",
4
4
  "description": "ReScript bindings for the Node.js standard library",
5
5
  "license": "Apache-2.0",
6
6
  "devDependencies": {
package/rescript.json CHANGED
@@ -26,6 +26,7 @@
26
26
  "NodeProcess",
27
27
  "NodeStreams",
28
28
  "NodeUrl",
29
+ "NodeUtil",
29
30
  "NodeZlib"
30
31
  ]
31
32
  }
@@ -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
- polyvariant so a typo is a compile error rather than a handler that is never
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: ([#SIGINT | #SIGTERM | #SIGHUP], unit => unit) => unit = "on"
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
@@ -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>> = ""
@@ -0,0 +1,2 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */