Files
cfw-autumn/scripts/dw/helpers/shell.ts
amianthus 25e920bbd3 feat(dw): 🎸 parallel agent worktrees with isolated infra + test harness
bun dw spins up a fully isolated per-worktree dev stack: Neon DB branch,
Dragonfly + ElasticMQ via docker compose, portless aliases, tmux
session, and emulate.dev Google OAuth. Workers, dev server, vite,
checkout, and stripe-listen run as concurrently siblings. bun setup-test
auto-runs on first dw and seeds unit-test-org via
clearOrg+setupOrg+ensureDefaultStripeAccount with 13 features + team
invites for all 5 useautumn.com members. Hardcoded localhost URLs in
test scenarios now read AUTUMN_TEST_BASE_URL/AUTUMN_TEST_VITE_URL.
preload-env.ts loads .env.local so bun t/cm/setup-test route to the
worktree server. 1265-line scripts/dw.ts split into scripts/dw/ module
(index + commands + helpers). server/src/db/initDrizzle.ts reverted to
upstream (search_path concerns solved by per-branch Neon isolation).
Workers enabled in agent worktrees now that SQS is per-worktree via
ElasticMQ.
2026-05-16 02:02:43 +01:00

45 lines
1.1 KiB
TypeScript

import Bun from "bun";
export function log(msg: string): void {
console.log(`[dw] ${msg}`);
}
export function fatal(msg: string): never {
console.error(`[dw] ${msg}`);
process.exit(1);
}
export function sh(
cmd: string,
args: string[],
opts: { cwd?: string; env?: Record<string, string>; stdin?: string } = {},
): { stdout: string; stderr: string; code: number } {
const proc = Bun.spawnSync([cmd, ...args], {
cwd: opts.cwd,
env: opts.env ?? (process.env as Record<string, string>),
stdin: opts.stdin ? new TextEncoder().encode(opts.stdin) : undefined,
stdout: "pipe",
stderr: "pipe",
});
return {
stdout: new TextDecoder().decode(proc.stdout).trim(),
stderr: new TextDecoder().decode(proc.stderr).trim(),
code: proc.exitCode ?? 1,
};
}
// Like sh() but streams stdio so the caller can watch progress in real time.
export function shInherit(
cmd: string,
args: string[],
opts: { cwd?: string; env?: Record<string, string> } = {},
): number {
const proc = Bun.spawnSync([cmd, ...args], {
cwd: opts.cwd,
env: opts.env ?? (process.env as Record<string, string>),
stdout: "inherit",
stderr: "inherit",
});
return proc.exitCode ?? 1;
}