Dashboard (content library, publishing queue with approvals, inbox, team management, AI runs), Meta connector, branded PDF reports, agent skills, and Docker packaging (Dockerfile, docker-compose with Caddy HTTPS, backup and path-relocation scripts). Client data, live data and secrets are excluded via .gitignore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
998 B
JavaScript
22 lines
998 B
JavaScript
// Minimal .env loader (no dependency). Reads <project root>/.env
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
export const PROJECT_ROOT = path.resolve(here, "..", "..");
|
|
|
|
export function loadEnv() {
|
|
// Docker's env_file keeps stray spaces/tabs after "=", which breaks tokens. Trim everything we read.
|
|
for (const [k, v] of Object.entries(process.env)) if (/^[A-Z0-9_]+$/.test(k) && v !== v.trim()) process.env[k] = v.trim();
|
|
const file = path.join(PROJECT_ROOT, ".env");
|
|
if (!fs.existsSync(file)) return;
|
|
for (const line of fs.readFileSync(file, "utf8").split(/\r?\n/)) {
|
|
const m = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);
|
|
if (!m || line.trim().startsWith("#")) continue;
|
|
let v = m[2];
|
|
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) v = v.slice(1, -1);
|
|
if (!(m[1] in process.env)) process.env[m[1]] = v;
|
|
}
|
|
}
|