Files
gstack/bin/gstack-gbrain-supabase-provision
T
Garry TanandClaude Fable 5 9b8f8d7767 test: supabase-provision runs in-process — 16.5s -> 0.45s
bin/gstack-gbrain-supabase-provision (482-line bash) becomes a 26-line
bun-shebang entry over a new importable lib/gbrain-supabase-provision.ts
with an injected-deps seam (fetch/env/stdout/sleep — D7: args, never
env-mutation-before-import). The 33 spawn-per-test cases run in-process
against the same Bun.serve mocks; exactly one spawn smoke keeps the
shebang/CLI/receipt contract covered.

Byte-compat proven by a 25-case differential harness (old bash bin from
git vs new, same mock): stdout, stderr, exit codes identical across all
subcommands, JSON/plain modes, and error paths. Egress receipts stay
per-attempt, receipt-before-send, fail-closed (scanner updated:
SHELL_SINKS -> MODULE_SINKS). No-op sleep injection makes retry/backoff
paths instant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-15 08:58:33 -07:00

27 lines
1.1 KiB
TypeScript
Executable File

#!/usr/bin/env -S bun run
/**
* gstack-gbrain-supabase-provision — Supabase Management API wrapper for
* /setup-gbrain path 2a (auto-provision). Thin entry: all logic lives in
* lib/gbrain-supabase-provision.ts so tests can drive it in-process with
* injected fetch/env/sleep instead of spawning a process per test.
*
* Rewritten from bash to TypeScript; filename and exec semantics unchanged —
* callers shell out to this path and the bun shebang resolves at runtime
* (same pattern as bin/gstack-gbrain-detect). CLI surface, stdout/stderr
* shapes, env handling (SUPABASE_ACCESS_TOKEN / DB_PASS / SUPABASE_API_BASE),
* and exit codes are unchanged; run --help for the full contract.
*
* Egress receipts stay fail-closed at the API-call layer (sink
* "supabase-provision", receipt-before-send) — see the module header.
*/
import { runProvision } from '../lib/gbrain-supabase-provision';
runProvision(process.argv.slice(2)).then(
(code) => process.exit(code),
(error) => {
process.stderr.write(`gstack-gbrain-supabase-provision: ${(error as Error)?.stack ?? error}\n`);
process.exit(1);
},
);