chore: include remaining workspace changes

This commit is contained in:
Nathan Flurry 2026-03-10 21:55:57 -07:00
parent ea7c36a8e7
commit f0f2576289
17 changed files with 693 additions and 192 deletions

View file

@ -1,10 +1,14 @@
import { existsSync, readFileSync } from "node:fs";
import { resolve } from "node:path";
import { dirname, resolve } from "node:path";
const DEVELOPMENT_ENV_FILES = [".env.development.local", ".env.development"] as const;
const LOCAL_DEV_BETTER_AUTH_SECRET = "sandbox-agent-factory-development-only-change-me";
const LOCAL_DEV_APP_URL = "http://localhost:4173";
function decodeQuotedEnvValue(value: string): string {
return value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, "\t");
}
function loadEnvFile(path: string): void {
const source = readFileSync(path, "utf8");
for (const line of source.split(/\r?\n/)) {
@ -29,7 +33,7 @@ function loadEnvFile(path: string): void {
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
) {
value = value.slice(1, -1);
value = decodeQuotedEnvValue(value.slice(1, -1));
}
process.env[key] = value;
}
@ -44,14 +48,27 @@ export function loadDevelopmentEnvFiles(cwd = process.cwd()): string[] {
return [];
}
const loaded: string[] = [];
for (const fileName of DEVELOPMENT_ENV_FILES) {
const path = resolve(cwd, fileName);
if (!existsSync(path)) {
continue;
const searchDirs: string[] = [];
let current = resolve(cwd);
for (;;) {
searchDirs.push(current);
const parent = dirname(current);
if (parent === current) {
break;
}
current = parent;
}
const loaded: string[] = [];
for (const dir of searchDirs) {
for (const fileName of DEVELOPMENT_ENV_FILES) {
const path = resolve(dir, fileName);
if (!existsSync(path) || loaded.includes(path)) {
continue;
}
loadEnvFile(path);
loaded.push(path);
}
loadEnvFile(path);
loaded.push(path);
}
return loaded;
}