@reddb-io/client 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +49 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reddb-io/client",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Thin remote-only RedDB driver. Downloads the `red_client` binary on install. Speaks RedWire/gRPC/HTTP. Embedded URIs (memory://, file://, red:///path) are rejected — use @reddb-io/sdk for those.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/postinstall.js CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  import { createRequire } from 'node:module'
30
30
  import { fileURLToPath } from 'node:url'
31
- import { dirname, join } from 'node:path'
31
+ import { dirname, join, sep } from 'node:path'
32
32
  import { existsSync, mkdirSync, writeFileSync, chmodSync } from 'node:fs'
33
33
 
34
34
  import { fetchReleaseAsset } from './src/internal/asset-fetcher/index.js'
@@ -45,16 +45,58 @@ if (process.env.REDDB_SKIP_POSTINSTALL === '1') {
45
45
  process.exit(0)
46
46
  }
47
47
 
48
- main().catch((err) => {
49
- process.stderr.write(
50
- `@reddb-io/client: postinstall could not download red_client (${err.message}).\n`
51
- + ` The package will still install. To use the binary you can:\n`
52
- + ` - set REDDB_CLIENT_BIN=/path/to/red_client\n`
53
- + ` - or install it manually from https://github.com/${DEFAULT_REPO}/releases\n`,
48
+ // Workspace-local install detection — see drivers/js/postinstall.js for
49
+ // the matching guard and rationale. connect() in this package doesn't need
50
+ // the binary anyway; the helper CLI is the only consumer.
51
+ if (!HERE.includes(`${sep}node_modules${sep}`)) {
52
+ process.stdout.write(
53
+ '@reddb-io/client: skipping postinstall running from a workspace checkout (no node_modules/).\n' +
54
+ ' connect() works without the binary. If you also want the red_client CLI:\n' +
55
+ ' cargo build --release --bin red_client -p reddb-io-client --no-default-features\n' +
56
+ ' export REDDB_CLIENT_BIN="$PWD/target/release/red_client"\n' +
57
+ ' Set REDDB_SKIP_POSTINSTALL=1 to silence this message.\n',
54
58
  )
55
59
  process.exit(0)
60
+ }
61
+
62
+ main().catch((err) => {
63
+ process.stderr.write(formatFailure(err))
64
+ process.exit(0)
56
65
  })
57
66
 
67
+ function formatFailure(err) {
68
+ const repo = process.env.REDDB_POSTINSTALL_REPO || DEFAULT_REPO
69
+ if (err && err.code === 'UNSUPPORTED_PLATFORM') {
70
+ return (
71
+ `@reddb-io/client: no prebuilt red_client binary for ${process.platform}/${process.arch}.\n`
72
+ + ` Note: connect() itself does not need the binary — it is only used as a CLI helper.\n`
73
+ + ` Options:\n`
74
+ + ` - build from source: https://github.com/${repo}#build-from-source\n`
75
+ + ` - or set REDDB_CLIENT_BIN=/path/to/red_client.\n`
76
+ )
77
+ }
78
+ if (err && err.code === 'ASSET_NOT_FOUND') {
79
+ return (
80
+ `@reddb-io/client: release asset not found at ${err.url}\n`
81
+ + ` The GitHub Release for this client version likely has not been\n`
82
+ + ` published yet. The driver still installs and connect() works\n`
83
+ + ` without the binary; this only affects the bundled CLI helper.\n`
84
+ + ` To unblock:\n`
85
+ + ` 1. Pull a specific tag and rebuild:\n`
86
+ + ` REDDB_POSTINSTALL_VERSION=v1.0.5 npm rebuild @reddb-io/client\n`
87
+ + ` 2. Or download red_client manually and export REDDB_CLIENT_BIN.\n`
88
+ + ` Releases: https://github.com/${repo}/releases\n`
89
+ )
90
+ }
91
+ return (
92
+ `@reddb-io/client: postinstall could not download red_client (${err && err.message}).\n`
93
+ + ` The package itself still installs (connect() does not need the binary).\n`
94
+ + ` To get the bundled CLI working:\n`
95
+ + ` - set REDDB_CLIENT_BIN=/path/to/red_client\n`
96
+ + ` - or install it manually from https://github.com/${repo}/releases\n`
97
+ )
98
+ }
99
+
58
100
  async function main() {
59
101
  const repo = process.env.REDDB_POSTINSTALL_REPO || DEFAULT_REPO
60
102
  const tag = process.env.REDDB_POSTINSTALL_VERSION