Add zero-Docker bootstrap for instant local development spin-up
This commit is contained in:
83
scripts/setup/writeAgentEnv.ts
Normal file
83
scripts/setup/writeAgentEnv.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { copyFileSync, existsSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
const root = join(import.meta.dir, "..", "..");
|
||||
const serverEnvPath = join(root, "server", ".env");
|
||||
const viteEnvPath = join(root, "vite", ".env");
|
||||
const viteExamplePath = join(root, "vite", ".env.example");
|
||||
|
||||
const genUrlSafeBase64 = ({ bytes }: { bytes: number }): string =>
|
||||
randomBytes(bytes)
|
||||
.toString("base64")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/g, "");
|
||||
|
||||
if (existsSync(serverEnvPath)) {
|
||||
console.log("[writeAgentEnv] server/.env already exists — skipping generation");
|
||||
} else {
|
||||
const passThrough = [
|
||||
"STRIPE_SANDBOX_CLIENT_ID",
|
||||
"STRIPE_SANDBOX_SECRET_KEY",
|
||||
"STRIPE_SANDBOX_WEBHOOK_SECRET",
|
||||
"STRIPE_LIVE_CLIENT_ID",
|
||||
"STRIPE_LIVE_SECRET_KEY",
|
||||
"STRIPE_LIVE_WEBHOOK_SECRET",
|
||||
"ANTHROPIC_API_KEY",
|
||||
"RESEND_API_KEY",
|
||||
"RESEND_DOMAIN",
|
||||
"SVIX_API_KEY",
|
||||
"POSTHOG_API_KEY",
|
||||
"POSTHOG_HOST",
|
||||
] as const;
|
||||
|
||||
const passLines = passThrough
|
||||
.map((k) => `${k}=${process.env[k] ?? ""}`)
|
||||
.join("\n");
|
||||
|
||||
const content = `# -----------------------------------------------------------------------
|
||||
# Generated by scripts/setup/writeAgentEnv.ts
|
||||
# Delete this file and re-run bun dev:agent to regenerate.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
# Per-agent random secrets
|
||||
BETTER_AUTH_SECRET=${genUrlSafeBase64({ bytes: 64 })}
|
||||
ENCRYPTION_IV=${genUrlSafeBase64({ bytes: 16 })}
|
||||
ENCRYPTION_PASSWORD=${genUrlSafeBase64({ bytes: 64 })}
|
||||
|
||||
# Local services
|
||||
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/autumn
|
||||
CACHE_URL=redis://localhost:6379
|
||||
CACHE_URL_US_EAST=redis://localhost:6379
|
||||
REDIS_URL=redis://localhost:6379
|
||||
|
||||
# ElasticMQ (local SQS, per-agent isolated queue)
|
||||
SQS_QUEUE_URL=http://localhost:9324/000000000000/autumn.fifo
|
||||
AWS_REGION=us-east-1
|
||||
AWS_ACCESS_KEY_ID=x
|
||||
AWS_SECRET_ACCESS_KEY=x
|
||||
|
||||
# ClickHouse (local)
|
||||
TINYBIRD_CLICKHOUSE_URL=http://localhost:8123
|
||||
|
||||
# App URLs
|
||||
BETTER_AUTH_URL=http://localhost:8080
|
||||
CLIENT_URL=http://localhost:3000
|
||||
STRIPE_WEBHOOK_URL=http://localhost:8080
|
||||
|
||||
# Static team-wide (pass-through from process.env)
|
||||
${passLines}
|
||||
|
||||
# Environment
|
||||
NODE_ENV=development
|
||||
`;
|
||||
|
||||
writeFileSync(serverEnvPath, content);
|
||||
console.log("[writeAgentEnv] Wrote server/.env");
|
||||
}
|
||||
|
||||
if (!existsSync(viteEnvPath) && existsSync(viteExamplePath)) {
|
||||
copyFileSync(viteExamplePath, viteEnvPath);
|
||||
console.log("[writeAgentEnv] Wrote vite/.env from .env.example");
|
||||
}
|
||||
Reference in New Issue
Block a user