@reddb-io/sdk 1.5.0 → 1.6.0
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 +42 -3
- package/package.json +1 -1
- package/postinstall.js +34 -24
package/README.md
CHANGED
|
@@ -31,9 +31,48 @@ import { connect } from 'npm:@reddb-io/sdk'
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
The `postinstall` script downloads the matching `red` binary from GitHub
|
|
34
|
-
Releases into `node_modules/@reddb-io/sdk/bin/`. If
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
Releases into `node_modules/@reddb-io/sdk/bin/`. If the download fails (no
|
|
35
|
+
network, 404, unsupported platform) the install now **fails loud** with an
|
|
36
|
+
actionable multi-line message — it no longer silently ships an empty `bin/`
|
|
37
|
+
that explodes the first time you call `connect()`. See the next section
|
|
38
|
+
for the supported offline paths.
|
|
39
|
+
|
|
40
|
+
## Offline / restricted-network installs
|
|
41
|
+
|
|
42
|
+
If your CI or workstation has no network during `npm install`, or your
|
|
43
|
+
environment blocks postinstall scripts entirely, opt out explicitly and
|
|
44
|
+
point the driver at a binary you provide yourself:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 1. Install the SDK without trying to download the engine.
|
|
48
|
+
REDDB_SKIP_POSTINSTALL=1 npm install @reddb-io/sdk
|
|
49
|
+
|
|
50
|
+
# 2. At runtime, tell connect() where the red binary lives.
|
|
51
|
+
export REDDB_BIN=/path/to/red # canonical, per ADR 0006
|
|
52
|
+
# (REDDB_BINARY_PATH is a deprecated alias kept for the rollout window.)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Three ways to get a `red` binary:
|
|
56
|
+
|
|
57
|
+
- Install the latest stable release with the official installer and use
|
|
58
|
+
`REDDB_BIN="$(command -v red)"`:
|
|
59
|
+
```bash
|
|
60
|
+
curl -fsSL https://raw.githubusercontent.com/reddb-io/reddb/main/install.sh | bash
|
|
61
|
+
```
|
|
62
|
+
- Build from a workspace checkout of `reddb-io/reddb`:
|
|
63
|
+
```bash
|
|
64
|
+
cargo build --release --bin red
|
|
65
|
+
export REDDB_BIN="$PWD/target/release/red"
|
|
66
|
+
```
|
|
67
|
+
- Download a prebuilt asset from the releases page and drop it at
|
|
68
|
+
`<package>/bin/red[.exe]`:
|
|
69
|
+
<https://github.com/reddb-io/reddb/releases>
|
|
70
|
+
|
|
71
|
+
When `REDDB_SKIP_POSTINSTALL=1` is set the postinstall script prints a one-line
|
|
72
|
+
notice and exits 0; without it, any download failure exits non-zero so the
|
|
73
|
+
install surfaces the problem immediately. If you forget to provide the
|
|
74
|
+
binary, `connect()` raises a clear `binary "red" not found` error that names
|
|
75
|
+
`REDDB_BIN` as the override.
|
|
37
76
|
|
|
38
77
|
## Quickstart
|
|
39
78
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reddb-io/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Official embedded RedDB SDK — launches a local red binary over stdio JSON-RPC. Use @reddb-io/client for remote HTTP, gRPC, and RedWire.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/postinstall.js
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
* via the vendored asset fetcher.
|
|
7
7
|
* - Targets the GitHub release matching this package's version.
|
|
8
8
|
* - Drops the binary at `<package>/bin/red[.exe]` and chmods +x on Unix.
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* - Intentional skip paths (workspace checkout, REDDB_SKIP_POSTINSTALL=1)
|
|
10
|
+
* exit 0 quietly. Any unintentional failure (no network, 404, asset
|
|
11
|
+
* fetcher error, unsupported platform) prints an actionable multi-line
|
|
12
|
+
* message to stderr and exits 1 so `npm install` fails loud — never
|
|
13
|
+
* ships a package with an empty bin/ that explodes later at connect().
|
|
12
14
|
*
|
|
13
15
|
* Override hooks (env vars):
|
|
14
|
-
* REDDB_SKIP_POSTINSTALL=1 do nothing
|
|
16
|
+
* REDDB_SKIP_POSTINSTALL=1 do nothing, exit 0 (caller will provide
|
|
17
|
+
* the binary via REDDB_BIN or a vendored
|
|
18
|
+
* copy at bin/red[.exe])
|
|
15
19
|
* REDDB_POSTINSTALL_VERSION=… pull a different release tag
|
|
16
20
|
* REDDB_POSTINSTALL_REPO=… pull from a fork (default: reddb-io/reddb)
|
|
17
21
|
*/
|
|
@@ -54,17 +58,32 @@ if (!HERE.includes(`${sep}node_modules${sep}`)) {
|
|
|
54
58
|
|
|
55
59
|
main().catch((err) => {
|
|
56
60
|
process.stderr.write(formatFailure(err))
|
|
57
|
-
process.exit(
|
|
61
|
+
process.exit(1)
|
|
58
62
|
})
|
|
59
63
|
|
|
60
64
|
function formatFailure(err) {
|
|
61
65
|
const repo = process.env.REDDB_POSTINSTALL_REPO || DEFAULT_REPO
|
|
66
|
+
const escapeHatches =
|
|
67
|
+
` Escape hatches (any one of these will unblock the install):\n` +
|
|
68
|
+
` - Skip the download and provide the binary yourself:\n` +
|
|
69
|
+
` REDDB_SKIP_POSTINSTALL=1 npm install\n` +
|
|
70
|
+
` then at runtime: export REDDB_BIN=/path/to/red\n` +
|
|
71
|
+
` - Or install red via the official installer and point at it:\n` +
|
|
72
|
+
` curl -fsSL https://raw.githubusercontent.com/${repo}/main/install.sh | bash\n` +
|
|
73
|
+
` export REDDB_BIN="$(command -v red)"\n` +
|
|
74
|
+
` - Or build from a workspace checkout of ${repo}:\n` +
|
|
75
|
+
` cargo build --release --bin red\n` +
|
|
76
|
+
` export REDDB_BIN="$PWD/target/release/red"\n` +
|
|
77
|
+
` - Or download the binary manually from\n` +
|
|
78
|
+
` https://github.com/${repo}/releases\n` +
|
|
79
|
+
` and place it at <package>/bin/red[.exe]\n`
|
|
80
|
+
|
|
62
81
|
if (err && err.code === 'UNSUPPORTED_PLATFORM') {
|
|
63
82
|
return (
|
|
64
83
|
`reddb: no prebuilt red binary for ${process.platform}/${process.arch}.\n` +
|
|
65
|
-
`
|
|
66
|
-
`
|
|
67
|
-
|
|
84
|
+
` Building from source is required for this platform:\n` +
|
|
85
|
+
` https://github.com/${repo}#build-from-source\n` +
|
|
86
|
+
escapeHatches
|
|
68
87
|
)
|
|
69
88
|
}
|
|
70
89
|
if (err && err.code === 'ASSET_NOT_FOUND') {
|
|
@@ -72,25 +91,16 @@ function formatFailure(err) {
|
|
|
72
91
|
`reddb: release asset not found at ${err.url}\n` +
|
|
73
92
|
` Common cause: the GitHub Release for this SDK version has not\n` +
|
|
74
93
|
` been published yet (or your platform's binary was not produced\n` +
|
|
75
|
-
` for that release).
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
` curl -fsSL https://raw.githubusercontent.com/${repo}/main/install.sh | bash\n` +
|
|
79
|
-
` export REDDB_BIN="$(command -v red)"\n` +
|
|
80
|
-
` 2. Or pull a specific tag explicitly and re-run postinstall:\n` +
|
|
81
|
-
` REDDB_POSTINSTALL_VERSION=v1.0.5 npm rebuild @reddb-io/sdk\n` +
|
|
82
|
-
` 3. Or skip the download entirely and provide the binary yourself:\n` +
|
|
83
|
-
` REDDB_SKIP_POSTINSTALL=1 (re-install), then export REDDB_BIN=…\n` +
|
|
84
|
-
` Releases: https://github.com/${repo}/releases\n`
|
|
94
|
+
` for that release). You can also pull a specific tag explicitly:\n` +
|
|
95
|
+
` REDDB_POSTINSTALL_VERSION=v1.0.5 npm rebuild @reddb-io/sdk\n` +
|
|
96
|
+
escapeHatches
|
|
85
97
|
)
|
|
86
98
|
}
|
|
87
99
|
return (
|
|
88
|
-
`reddb: postinstall could not download the binary (${err && err.message}).\n` +
|
|
89
|
-
`
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
` - or download manually from https://github.com/${repo}/releases\n` +
|
|
93
|
-
` - or set REDDB_BIN=/path/to/red.\n`
|
|
100
|
+
`reddb: postinstall could not download the red binary (${(err && err.message) || err}).\n` +
|
|
101
|
+
` Install failed — the SDK will not work without a binary at\n` +
|
|
102
|
+
` <package>/bin/red[.exe] or pointed at by REDDB_BIN.\n` +
|
|
103
|
+
escapeHatches
|
|
94
104
|
)
|
|
95
105
|
}
|
|
96
106
|
|