orez 0.2.27 → 0.2.29

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 (150) hide show
  1. package/package.json +3 -4
  2. package/src/admin/admin-data.test.ts +0 -348
  3. package/src/admin/http-proxy.ts +0 -252
  4. package/src/admin/log-store.ts +0 -192
  5. package/src/admin/server.ts +0 -471
  6. package/src/admin/ui.ts +0 -1322
  7. package/src/bench/proxy-throughput.bench.ts +0 -343
  8. package/src/bench/serial-mutations.bench.ts +0 -270
  9. package/src/browser.ts +0 -203
  10. package/src/cf-do/.wrangler/cache/cf.json +0 -1
  11. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
  12. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
  13. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
  14. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/0ffaabee41a60e04dd0eb7db3073f0a40139e6a97ccd26823967acb652b89a7b.sqlite +0 -0
  15. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite +0 -0
  16. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-shm +0 -0
  17. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-wal +0 -0
  18. package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-insertion-facade.js +0 -11
  19. package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-loader.entry.ts +0 -134
  20. package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-insertion-facade.js +0 -11
  21. package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-loader.entry.ts +0 -134
  22. package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js +0 -1059
  23. package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js.map +0 -8
  24. package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js +0 -1059
  25. package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js.map +0 -8
  26. package/src/cf-do/ARCHITECTURE.md +0 -93
  27. package/src/cf-do/CHAT_E2E.md +0 -213
  28. package/src/cf-do/watermark.test.ts +0 -103
  29. package/src/cf-do/watermark.ts +0 -118
  30. package/src/cf-do/worker.ts +0 -1041
  31. package/src/cf-do/wrangler.toml +0 -11
  32. package/src/cf-pglite/README.md +0 -19
  33. package/src/change-tracking.ts +0 -25
  34. package/src/child-process.test.ts +0 -147
  35. package/src/child-process.ts +0 -90
  36. package/src/cli-entry.ts +0 -72
  37. package/src/cli.test.ts +0 -40
  38. package/src/cli.ts +0 -1214
  39. package/src/config.ts +0 -150
  40. package/src/do-sql-tracking.test.ts +0 -19
  41. package/src/do-sql-tracking.ts +0 -19
  42. package/src/index.ts +0 -1215
  43. package/src/integration/integration.test.ts +0 -517
  44. package/src/integration/native-binary.guard.test.ts +0 -13
  45. package/src/integration/native-startup.test.ts +0 -44
  46. package/src/integration/replication-latency.test.ts +0 -428
  47. package/src/integration/restore-live-stress.test.ts +0 -433
  48. package/src/integration/restore-reset.test.ts +0 -400
  49. package/src/integration/restore.test.ts +0 -274
  50. package/src/integration/test-permissions.ts +0 -147
  51. package/src/load-config.ts +0 -46
  52. package/src/log.ts +0 -96
  53. package/src/mutex.ts +0 -47
  54. package/src/pg-proxy-browser.singledb.test.ts +0 -233
  55. package/src/pg-proxy-browser.ts +0 -2022
  56. package/src/pg-proxy-do-backend.test.ts +0 -3890
  57. package/src/pg-proxy-do-backend.ts +0 -7191
  58. package/src/pg-proxy.ts +0 -1087
  59. package/src/pg-sqlite-compiler/README.md +0 -53
  60. package/src/pg-sqlite-compiler/catalog/seed.ts +0 -524
  61. package/src/pg-sqlite-compiler/fixtures/pgsqlite/arithmetic.json +0 -307
  62. package/src/pg-sqlite-compiler/fixtures/pgsqlite/array.json +0 -377
  63. package/src/pg-sqlite-compiler/fixtures/pgsqlite/cast.json +0 -12
  64. package/src/pg-sqlite-compiler/fixtures/pgsqlite/catalog.json +0 -447
  65. package/src/pg-sqlite-compiler/fixtures/pgsqlite/create-table.json +0 -32
  66. package/src/pg-sqlite-compiler/fixtures/pgsqlite/datetime.json +0 -397
  67. package/src/pg-sqlite-compiler/fixtures/pgsqlite/enum.json +0 -337
  68. package/src/pg-sqlite-compiler/fixtures/pgsqlite/insert.json +0 -337
  69. package/src/pg-sqlite-compiler/fixtures/pgsqlite/json.json +0 -537
  70. package/src/pg-sqlite-compiler/fixtures/pgsqlite/misc.json +0 -1837
  71. package/src/pg-sqlite-compiler/index.ts +0 -73
  72. package/src/pg-sqlite-compiler/integration.test.ts +0 -136
  73. package/src/pg-sqlite-compiler/passes/ast-utils.ts +0 -113
  74. package/src/pg-sqlite-compiler/passes/catalog.ts +0 -65
  75. package/src/pg-sqlite-compiler/passes/datetime.ts +0 -74
  76. package/src/pg-sqlite-compiler/passes/index.ts +0 -49
  77. package/src/pg-sqlite-compiler/passes/types.ts +0 -156
  78. package/src/pg-sqlite-compiler/smoke.test.ts +0 -69
  79. package/src/pg-sqlite-compiler/test/catalog.test.ts +0 -171
  80. package/src/pg-sqlite-compiler/test/corpus.test.ts +0 -161
  81. package/src/pg-sqlite-compiler/test/datetime.oracle.test.ts +0 -102
  82. package/src/pg-sqlite-compiler/test/oracle.ts +0 -237
  83. package/src/pg-sqlite-compiler/test/types.test.ts +0 -109
  84. package/src/pg-sqlite-compiler/types.ts +0 -63
  85. package/src/pglite-ipc.test.ts +0 -116
  86. package/src/pglite-ipc.ts +0 -266
  87. package/src/pglite-manager.ts +0 -557
  88. package/src/pglite-web-proxy.test.ts +0 -57
  89. package/src/pglite-web-proxy.ts +0 -221
  90. package/src/pglite-web-worker.ts +0 -152
  91. package/src/pglite-worker-thread.ts +0 -253
  92. package/src/port.ts +0 -25
  93. package/src/process-title.ts +0 -9
  94. package/src/recovery.ts +0 -155
  95. package/src/replication/change-tracker.test.ts +0 -357
  96. package/src/replication/change-tracker.ts +0 -279
  97. package/src/replication/handler.test.ts +0 -511
  98. package/src/replication/handler.ts +0 -1190
  99. package/src/replication/pgoutput-encoder.test.ts +0 -697
  100. package/src/replication/pgoutput-encoder.ts +0 -373
  101. package/src/replication/tcp-replication.test.ts +0 -876
  102. package/src/replication/zero-compat.test.ts +0 -1150
  103. package/src/restore-stress.test.ts +0 -188
  104. package/src/s3-local.ts +0 -203
  105. package/src/shim/hooks.mjs +0 -120
  106. package/src/shim/register.mjs +0 -4
  107. package/src/sqlite-mode/apply-mode.ts +0 -224
  108. package/src/sqlite-mode/index.ts +0 -15
  109. package/src/sqlite-mode/native-binary.ts +0 -89
  110. package/src/sqlite-mode/package-resolve.ts +0 -17
  111. package/src/sqlite-mode/resolve-mode.ts +0 -80
  112. package/src/sqlite-mode/shim-template.ts +0 -159
  113. package/src/sqlite-mode/sqlite-mode.test.ts +0 -427
  114. package/src/sqlite-mode/types.ts +0 -30
  115. package/src/vite-plugin.ts +0 -67
  116. package/src/wasm-sqlite.test.ts +0 -537
  117. package/src/worker/browser-admin.ts +0 -52
  118. package/src/worker/browser-build-config.test.ts +0 -71
  119. package/src/worker/browser-build-config.ts +0 -109
  120. package/src/worker/browser-embed-admin.test.ts +0 -75
  121. package/src/worker/browser-embed.ts +0 -345
  122. package/src/worker/cf-patches.ts +0 -384
  123. package/src/worker/embed-integration.test.ts +0 -321
  124. package/src/worker/index.ts +0 -138
  125. package/src/worker/shims/fastify.test.ts +0 -255
  126. package/src/worker/shims/fastify.ts +0 -306
  127. package/src/worker/shims/http-service.test.ts +0 -355
  128. package/src/worker/shims/http-service.ts +0 -293
  129. package/src/worker/shims/node-stub.ts +0 -290
  130. package/src/worker/shims/oxfmt.ts +0 -3
  131. package/src/worker/shims/postgres-browser.ts +0 -59
  132. package/src/worker/shims/postgres-socket.test.ts +0 -576
  133. package/src/worker/shims/postgres-socket.ts +0 -310
  134. package/src/worker/shims/postgres.test.ts +0 -364
  135. package/src/worker/shims/postgres.ts +0 -1454
  136. package/src/worker/shims/sqlite-browser.test.ts +0 -233
  137. package/src/worker/shims/sqlite-browser.ts +0 -175
  138. package/src/worker/shims/sqlite.test.ts +0 -786
  139. package/src/worker/shims/sqlite.ts +0 -978
  140. package/src/worker/shims/stream-browser.ts +0 -15
  141. package/src/worker/shims/ws-browser.test.ts +0 -205
  142. package/src/worker/shims/ws-browser.ts +0 -248
  143. package/src/worker/shims/ws.test.ts +0 -288
  144. package/src/worker/shims/ws.ts +0 -467
  145. package/src/worker/shims/zero-process-env.ts +0 -11
  146. package/src/worker/types.ts +0 -75
  147. package/src/worker/worker-integration.test.ts +0 -223
  148. package/src/worker/worker.test.ts +0 -136
  149. package/src/worker/zero-cache-embed-cf.ts +0 -463
  150. package/src/worker/zero-cache-embed.ts +0 -277
@@ -1,11 +0,0 @@
1
- name = "zero-do"
2
- main = "worker.ts"
3
- compatibility_date = "2025-04-01"
4
-
5
- [[durable_objects.bindings]]
6
- name = "ZERO_DO"
7
- class_name = "ZeroDO"
8
-
9
- [[migrations]]
10
- tag = "v1"
11
- new_sqlite_classes = ["ZeroDO"]
@@ -1,19 +0,0 @@
1
- # CF-Compatible PGlite Build
2
-
3
- PGlite compiled without `-sMAIN_MODULE=2` and `-sALLOW_TABLE_GROWTH`
4
- for Cloudflare Workers compatibility.
5
-
6
- Key differences from standard PGlite:
7
-
8
- - No dynamic linking (extensions must be statically linked)
9
- - No `addFunction`/`removeFunction` (no runtime WASM compilation)
10
- - `ENVIRONMENT=web,worker` only (no node — avoids require("fs"))
11
- - No side modules (no dlopen/dlsym)
12
-
13
- Files:
14
-
15
- - `pglite.wasm` — CF-compatible postgres WASM binary
16
- - `pglite.data` — filesystem bundle (postgres data directory)
17
- - `pglite.js` — Emscripten JS glue
18
-
19
- Build: `cd postgres-pglite && docker run ... ./build-pglite-cf.sh`
@@ -1,25 +0,0 @@
1
- /**
2
- * orez/change-tracking — standalone entrypoint for installing and reading
3
- * the `_orez` change tracking schema against a postgres-compatible database.
4
- *
5
- * this module intentionally has no transitive dependency on pglite-manager
6
- * or any other server-only orez module. it talks to the database through
7
- * the minimal `ChangeTrackingDb` structural interface (`exec` + `query`),
8
- * so it can be imported anywhere a sql executor exists — embedded PGlite,
9
- * a worker proxy, tests, or an external host.
10
- *
11
- * usage:
12
- * import { installChangeTracking } from 'orez/change-tracking'
13
- * await installChangeTracking(db)
14
- */
15
-
16
- export {
17
- installChangeTracking,
18
- installTriggersOnShardTables,
19
- resetShardSchemaCache,
20
- getChangesSince,
21
- getCurrentWatermark,
22
- purgeConsumedChanges,
23
- } from './replication/change-tracker.js'
24
-
25
- export type { ChangeRecord, ChangeTrackingDb } from './replication/change-tracker.js'
@@ -1,147 +0,0 @@
1
- import { spawn, type ChildProcess } from 'node:child_process'
2
-
3
- import { afterEach, describe, expect, it } from 'vitest'
4
-
5
- import {
6
- isChildProcessRunning,
7
- isPidRunning,
8
- killProcessTree,
9
- waitForChildProcessExit,
10
- } from './child-process.js'
11
-
12
- const spawned = new Set<ChildProcess>()
13
-
14
- function track(child: ChildProcess): ChildProcess {
15
- spawned.add(child)
16
- child.once('close', () => spawned.delete(child))
17
- return child
18
- }
19
-
20
- function pidExists(pid: number): boolean {
21
- try {
22
- process.kill(pid, 0)
23
- return true
24
- } catch (err: any) {
25
- if (err?.code === 'ESRCH') return false
26
- throw err
27
- }
28
- }
29
-
30
- async function waitForPidExit(pid: number, timeoutMs: number): Promise<boolean> {
31
- const start = Date.now()
32
- while (Date.now() - start < timeoutMs) {
33
- if (!pidExists(pid)) return true
34
- await new Promise((resolve) => setTimeout(resolve, 25))
35
- }
36
- return !pidExists(pid)
37
- }
38
-
39
- afterEach(async () => {
40
- for (const child of spawned) {
41
- if (!isChildProcessRunning(child)) continue
42
- if (child.pid) killProcessTree(child.pid, 'SIGKILL')
43
- else child.kill('SIGKILL')
44
- await waitForChildProcessExit(child, 1000)
45
- }
46
- spawned.clear()
47
- })
48
-
49
- describe('child process helpers', () => {
50
- it('tracks whether a pid is still alive', async () => {
51
- const child = track(
52
- spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], {
53
- stdio: 'ignore',
54
- })
55
- )
56
-
57
- expect(isPidRunning(child.pid)).toBe(true)
58
-
59
- child.kill('SIGKILL')
60
- await expect(waitForChildProcessExit(child, 2000)).resolves.toBe(true)
61
- expect(isPidRunning(child.pid)).toBe(false)
62
- })
63
-
64
- it('does not confuse "signal sent" with "process exited"', async () => {
65
- const child = track(
66
- spawn(
67
- process.execPath,
68
- [
69
- '-e',
70
- "process.on('SIGTERM', () => {}); console.log('ready'); setInterval(() => {}, 1000)",
71
- ],
72
- { stdio: ['ignore', 'pipe', 'ignore'] }
73
- )
74
- )
75
-
76
- await new Promise<void>((resolve, reject) => {
77
- let output = ''
78
-
79
- const onData = (chunk: Buffer) => {
80
- output += chunk.toString()
81
- if (!output.includes('ready')) return
82
- child.stdout?.off('data', onData)
83
- resolve()
84
- }
85
-
86
- child.stdout?.on('data', onData)
87
- child.once('error', reject)
88
- child.once('close', () =>
89
- reject(new Error('child exited before signaling readiness'))
90
- )
91
- })
92
-
93
- child.kill('SIGTERM')
94
-
95
- expect(child.killed).toBe(true)
96
- expect(isChildProcessRunning(child)).toBe(true)
97
- await expect(waitForChildProcessExit(child, 100)).resolves.toBe(false)
98
-
99
- child.kill('SIGKILL')
100
- await expect(waitForChildProcessExit(child, 2000)).resolves.toBe(true)
101
- expect(isChildProcessRunning(child)).toBe(false)
102
- })
103
-
104
- it('kills a parent process and its descendants', async () => {
105
- const parent = track(
106
- spawn(
107
- process.execPath,
108
- [
109
- '-e',
110
- [
111
- "const { spawn } = require('node:child_process')",
112
- "const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { stdio: 'ignore' })",
113
- 'console.log(child.pid)',
114
- 'setInterval(() => {}, 1000)',
115
- ].join('; '),
116
- ],
117
- { stdio: ['ignore', 'pipe', 'ignore'] }
118
- )
119
- )
120
-
121
- const childPid = await new Promise<number>((resolve, reject) => {
122
- let output = ''
123
-
124
- const onData = (chunk: Buffer) => {
125
- output += chunk.toString()
126
- if (!output.includes('\n')) return
127
-
128
- const value = Number.parseInt(output.split(/\r?\n/, 1)[0]!.trim(), 10)
129
- if (Number.isInteger(value) && value > 0) {
130
- parent.stdout?.off('data', onData)
131
- resolve(value)
132
- }
133
- }
134
-
135
- parent.stdout?.on('data', onData)
136
- parent.once('error', reject)
137
- parent.once('close', () =>
138
- reject(new Error('parent exited before reporting child pid'))
139
- )
140
- })
141
-
142
- killProcessTree(parent.pid!, 'SIGKILL')
143
-
144
- await expect(waitForChildProcessExit(parent, 2000)).resolves.toBe(true)
145
- await expect(waitForPidExit(childPid, 2000)).resolves.toBe(true)
146
- })
147
- })
@@ -1,90 +0,0 @@
1
- import { spawnSync, type ChildProcess } from 'node:child_process'
2
-
3
- export function isPidRunning(pid: number | null | undefined): pid is number {
4
- if (!Number.isInteger(pid) || (pid as number) <= 0) return false
5
-
6
- try {
7
- process.kill(pid as number, 0)
8
- return true
9
- } catch (err: any) {
10
- if (err?.code === 'ESRCH') return false
11
- if (err?.code === 'EPERM') return true
12
- throw err
13
- }
14
- }
15
-
16
- export function isChildProcessRunning(
17
- child: ChildProcess | null | undefined
18
- ): child is ChildProcess {
19
- if (!child) return false
20
- return child.exitCode === null && child.signalCode === null
21
- }
22
-
23
- export async function waitForChildProcessExit(
24
- child: ChildProcess,
25
- timeoutMs: number
26
- ): Promise<boolean> {
27
- if (!isChildProcessRunning(child)) return true
28
-
29
- return await new Promise<boolean>((resolve) => {
30
- let settled = false
31
-
32
- const finish = (exited: boolean) => {
33
- if (settled) return
34
- settled = true
35
- clearTimeout(timer)
36
- child.off('exit', onExit)
37
- child.off('close', onClose)
38
- resolve(exited || !isChildProcessRunning(child))
39
- }
40
-
41
- const onExit = () => finish(true)
42
- const onClose = () => finish(true)
43
-
44
- const timer = setTimeout(() => finish(false), timeoutMs)
45
-
46
- child.once('exit', onExit)
47
- child.once('close', onClose)
48
- })
49
- }
50
-
51
- function listChildPids(pid: number): number[] {
52
- if (process.platform === 'win32') return []
53
-
54
- const result = spawnSync('pgrep', ['-P', String(pid)], {
55
- encoding: 'utf8',
56
- env: process.env,
57
- })
58
-
59
- if (result.status !== 0 || !result.stdout) return []
60
-
61
- return result.stdout
62
- .split(/\s+/)
63
- .map((value) => Number(value.trim()))
64
- .filter((value) => Number.isInteger(value) && value > 0)
65
- }
66
-
67
- export function killProcessTree(pid: number, signal: NodeJS.Signals | number): void {
68
- const seen = new Set<number>()
69
- const stack = [pid]
70
- const order: number[] = []
71
-
72
- while (stack.length > 0) {
73
- const current = stack.pop()!
74
- if (seen.has(current)) continue
75
- seen.add(current)
76
- order.push(current)
77
-
78
- for (const childPid of listChildPids(current)) {
79
- if (!seen.has(childPid)) stack.push(childPid)
80
- }
81
- }
82
-
83
- for (const current of order.reverse()) {
84
- try {
85
- process.kill(current, signal)
86
- } catch (err: any) {
87
- if (err?.code !== 'ESRCH') throw err
88
- }
89
- }
90
- }
package/src/cli-entry.ts DELETED
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // by default runs cli.js in-process. when --bump-heap (or OREZ_BUMP_HEAP=1)
4
- // is set, re-execs with --max-old-space-size at ~50% of system memory —
5
- // needed for pglite wasm workloads. default off since memory usage was reduced.
6
-
7
- import { spawn } from 'node:child_process'
8
- import { totalmem } from 'node:os'
9
- import { resolve, dirname } from 'node:path'
10
- import { fileURLToPath } from 'node:url'
11
-
12
- import { orezTitle } from './process-title.js'
13
-
14
- const currentOpts = process.env.NODE_OPTIONS || ''
15
- const bumpHeapRequested =
16
- process.argv.includes('--bump-heap') ||
17
- process.env.OREZ_BUMP_HEAP === '1' ||
18
- process.env.OREZ_BUMP_HEAP === 'true'
19
-
20
- const willRespawn =
21
- bumpHeapRequested &&
22
- !currentOpts.includes('--max-old-space-size') &&
23
- !process.env.__OREZ_SPAWNED
24
-
25
- // label the wrapper distinctly so it's not confused with the real orez process
26
- process.title = willRespawn ? orezTitle('orez [wrapper]') : orezTitle()
27
-
28
- if (willRespawn) {
29
- const memMB = Math.round(totalmem() / 1024 / 1024)
30
- const heapMB = Math.max(4096, Math.round(memMB * 0.5))
31
- const cliPath = resolve(dirname(fileURLToPath(import.meta.url)), 'cli.js')
32
-
33
- // enable --experimental-strip-types so orez.config.ts works on Node 22.6+
34
- // (Node 23.6+ has it by default; harmless if already enabled)
35
- let nodeOpts = `--max-old-space-size=${heapMB} ${currentOpts}`.trim()
36
- if (!nodeOpts.includes('--experimental-strip-types')) {
37
- const [major, minor] = process.versions.node.split('.').map(Number)
38
- if (major > 22 || (major === 22 && minor >= 6)) {
39
- nodeOpts = `--experimental-strip-types ${nodeOpts}`
40
- }
41
- }
42
-
43
- // strip --bump-heap from argv so cli.ts doesn't see it as an unknown flag
44
- const childArgs = process.argv.slice(2).filter((a) => a !== '--bump-heap')
45
-
46
- const child = spawn(process.execPath, [cliPath, ...childArgs], {
47
- env: {
48
- ...process.env,
49
- NODE_OPTIONS: nodeOpts,
50
- __OREZ_SPAWNED: '1',
51
- },
52
- stdio: 'inherit',
53
- })
54
-
55
- // forward signals to child
56
- for (const sig of ['SIGINT', 'SIGTERM'] as const) {
57
- process.on(sig, () => child.kill(sig))
58
- }
59
-
60
- child.on('exit', (code, signal) => {
61
- if (signal) process.kill(process.pid, signal)
62
- else process.exit(code ?? 1)
63
- })
64
- } else {
65
- // run cli directly — no heap bump, no wrapper process
66
- // strip --bump-heap in case it was passed but we're already the spawned child
67
- if (process.argv.includes('--bump-heap')) {
68
- process.argv = process.argv.filter((a) => a !== '--bump-heap')
69
- }
70
- const [{ runMain }, { main }] = await Promise.all([import('citty'), import('./cli.js')])
71
- runMain(main)
72
- }
package/src/cli.test.ts DELETED
@@ -1,40 +0,0 @@
1
- import { spawn } from 'node:child_process'
2
- import { resolve } from 'node:path'
3
-
4
- import { describe, it, expect } from 'vitest'
5
-
6
- function runCli(
7
- args: string[]
8
- ): Promise<{ stdout: string; stderr: string; code: number }> {
9
- return new Promise((res) => {
10
- // cli-entry.js is the actual entry (cli.js only exports `main`; runMain
11
- // is invoked from cli-entry).
12
- const child = spawn('bun', [resolve('dist/cli-entry.js'), ...args], {
13
- timeout: 10_000,
14
- env: { ...process.env, NODE_ENV: 'test' },
15
- })
16
- let stdout = ''
17
- let stderr = ''
18
- child.stdout?.on('data', (d: Buffer) => (stdout += d.toString()))
19
- child.stderr?.on('data', (d: Buffer) => (stderr += d.toString()))
20
- child.on('close', (code) => res({ stdout, stderr, code: code ?? 1 }))
21
- })
22
- }
23
-
24
- describe('cli', () => {
25
- it('shows help with --help', async () => {
26
- const { stdout, stderr } = await runCli(['--help'])
27
- const output = stdout + stderr
28
- expect(output).toContain('orez')
29
- expect(output).toContain('--pg-port')
30
- expect(output).toContain('--zero-port')
31
- expect(output).toContain('--skip-zero-cache')
32
- })
33
-
34
- it('s3 subcommand shows help', async () => {
35
- const { stdout, stderr } = await runCli(['s3', '--help'])
36
- const output = stdout + stderr
37
- expect(output).toContain('--port')
38
- expect(output).toContain('--data-dir')
39
- })
40
- })