@reddb-io/cli 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.
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { createRequire } from 'node:module'
|
|
23
23
|
import { fileURLToPath } from 'node:url'
|
|
24
|
-
import { dirname, join } from 'node:path'
|
|
24
|
+
import { dirname, join, sep } from 'node:path'
|
|
25
25
|
import { existsSync, mkdirSync, writeFileSync, chmodSync } from 'node:fs'
|
|
26
26
|
import { execSync } from 'node:child_process'
|
|
27
27
|
|
|
@@ -48,16 +48,57 @@ if (typeof process.env.REDDB_BIN === 'string' && process.env.REDDB_BIN !== '') {
|
|
|
48
48
|
process.exit(0)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
// Workspace-local install detection — see the matching block in
|
|
52
|
+
// drivers/js/postinstall.js for the rationale.
|
|
53
|
+
if (!HERE.includes(`${sep}node_modules${sep}`)) {
|
|
54
|
+
process.stdout.write(
|
|
55
|
+
'reddb-cli: skipping postinstall — running from a workspace checkout (no node_modules/).\n' +
|
|
56
|
+
' Build `red` locally if you need it:\n' +
|
|
57
|
+
' cargo build --release --bin red\n' +
|
|
58
|
+
' export REDDB_BIN="$PWD/target/release/red"\n' +
|
|
59
|
+
' Set REDDB_SKIP_POSTINSTALL=1 to silence this message.\n',
|
|
57
60
|
)
|
|
58
61
|
process.exit(0)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
main().catch((err) => {
|
|
65
|
+
process.stderr.write(formatFailure(err))
|
|
66
|
+
process.exit(0)
|
|
59
67
|
})
|
|
60
68
|
|
|
69
|
+
function formatFailure(err) {
|
|
70
|
+
const repo = process.env.REDDB_POSTINSTALL_REPO || DEFAULT_REPO
|
|
71
|
+
if (err && err.code === 'UNSUPPORTED_PLATFORM') {
|
|
72
|
+
return (
|
|
73
|
+
`reddb-cli: no prebuilt red binary for ${process.platform}/${process.arch}.\n` +
|
|
74
|
+
` Options:\n` +
|
|
75
|
+
` - build from source: https://github.com/${repo}#build-from-source\n` +
|
|
76
|
+
` - or set REDDB_BIN=/path/to/red.\n`
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
if (err && err.code === 'ASSET_NOT_FOUND') {
|
|
80
|
+
return (
|
|
81
|
+
`reddb-cli: release asset not found at ${err.url}\n` +
|
|
82
|
+
` The GitHub Release for this CLI version likely has not been\n` +
|
|
83
|
+
` published yet. To unblock:\n` +
|
|
84
|
+
` 1. Use the installer (latest stable red on PATH):\n` +
|
|
85
|
+
` curl -fsSL https://raw.githubusercontent.com/${repo}/main/install.sh | bash\n` +
|
|
86
|
+
` 2. Or pull a specific tag and rebuild:\n` +
|
|
87
|
+
` REDDB_POSTINSTALL_VERSION=v1.0.5 npm rebuild @reddb-io/cli\n` +
|
|
88
|
+
` 3. Or point the launcher at an existing binary:\n` +
|
|
89
|
+
` export REDDB_BIN=/path/to/red\n` +
|
|
90
|
+
` Releases: https://github.com/${repo}/releases\n`
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
return (
|
|
94
|
+
`reddb-cli: postinstall could not download the binary (${err && err.message}).\n` +
|
|
95
|
+
` The package itself still installs. To use the CLI:\n` +
|
|
96
|
+
` - run the installer: curl -fsSL https://raw.githubusercontent.com/${repo}/main/install.sh | bash\n` +
|
|
97
|
+
` - or download manually from https://github.com/${repo}/releases\n` +
|
|
98
|
+
` - or set REDDB_BIN=/path/to/red.\n`
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
61
102
|
async function main() {
|
|
62
103
|
const verdict = compareInstalled({
|
|
63
104
|
packageVersion: pkg.version,
|
package/drivers/js/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reddb-io/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Official RedDB driver — talks the native RedWire TCP protocol (mTLS), HTTP, gRPC bridge, or embedded stdio JSON-RPC. Works in Node 18+, Bun and Deno.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/drivers/js/src/index.js
CHANGED
|
@@ -167,6 +167,17 @@ export async function connect(uri, options = {}) {
|
|
|
167
167
|
)
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
// Coerce a JS query parameter to a JSON-serializable shape the server
|
|
171
|
+
// understands. The tracer scope (#355) lifts vector params: `Float32Array`
|
|
172
|
+
// and `Float64Array` round-trip as plain JSON arrays of numbers, which
|
|
173
|
+
// the embedded stdio handler maps to `Value::Vector`.
|
|
174
|
+
function serializeParam(value) {
|
|
175
|
+
if (value instanceof Float32Array || value instanceof Float64Array) {
|
|
176
|
+
return Array.from(value)
|
|
177
|
+
}
|
|
178
|
+
return value
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
function embeddedArgs(parsed) {
|
|
171
182
|
if (parsed.path) return ['rpc', '--stdio', '--path', parsed.path]
|
|
172
183
|
return ['rpc', '--stdio']
|
|
@@ -344,9 +355,27 @@ export class RedDB {
|
|
|
344
355
|
this.vault = (collection = 'red.vault') => new VaultClient(client, collection)
|
|
345
356
|
}
|
|
346
357
|
|
|
347
|
-
/**
|
|
348
|
-
|
|
349
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Execute a SQL query.
|
|
360
|
+
*
|
|
361
|
+
* Two signatures:
|
|
362
|
+
* - `query(sql)` — legacy single-arg form.
|
|
363
|
+
* - `query(sql, params)` — positional `$N` bind values. `params` is
|
|
364
|
+
* an array (JS scalars: number | string | null map to engine
|
|
365
|
+
* int/float / text / null). Indices in the SQL are 1-based
|
|
366
|
+
* (`$1`, `$2`, ...), `params` is 0-based JS-style.
|
|
367
|
+
*
|
|
368
|
+
* Returns `{ statement, affected, columns, rows }`.
|
|
369
|
+
*/
|
|
370
|
+
query(sql, params) {
|
|
371
|
+
if (params === undefined) {
|
|
372
|
+
return this.client.call('query', { sql })
|
|
373
|
+
}
|
|
374
|
+
if (!Array.isArray(params)) {
|
|
375
|
+
throw new TypeError('query: `params` must be an array')
|
|
376
|
+
}
|
|
377
|
+
const wireParams = params.map(serializeParam)
|
|
378
|
+
return this.client.call('query', { sql, params: wireParams })
|
|
350
379
|
}
|
|
351
380
|
|
|
352
381
|
/** Insert one row. Returns `{ affected, id? }`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reddb-io/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "CLI launcher for RedDB. The JS/TS app driver is published as @reddb-io/sdk.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -30,9 +30,16 @@
|
|
|
30
30
|
"url": "https://github.com/reddb-io/reddb"
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/reddb-io/reddb",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@changesets/changelog-github": "^0.7.0",
|
|
35
|
+
"@changesets/cli": "^2.31.0"
|
|
36
|
+
},
|
|
33
37
|
"scripts": {
|
|
34
38
|
"postinstall": "node drivers/js/cli-postinstall.js",
|
|
35
39
|
"test": "node drivers/js/test/smoke.test.mjs",
|
|
40
|
+
"changeset": "changeset",
|
|
41
|
+
"release:version": "changeset version && node scripts/sync-version.js",
|
|
42
|
+
"release:publish": "changeset publish",
|
|
36
43
|
"version": "node scripts/sync-version.js"
|
|
37
44
|
}
|
|
38
45
|
}
|