mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 20:01:27 +00:00
chore: include remaining workspace changes
This commit is contained in:
parent
ea7c36a8e7
commit
f0f2576289
17 changed files with 693 additions and 192 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue