chore: checkpoint admin restore state

This commit is contained in:
john
2026-06-30 20:26:33 +08:00
parent f2172322fd
commit f9a7584ad4
63 changed files with 7555 additions and 1030 deletions
+19 -10
View File
@@ -4,18 +4,27 @@ import { fileURLToPath } from 'node:url';
const projectRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
function loadEnvFile(filePath) {
if (!fs.existsSync(filePath)) return;
for (const line of fs.readFileSync(filePath, 'utf8').split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const eq = trimmed.indexOf('=');
if (eq < 0) continue;
const key = trimmed.slice(0, eq).trim();
const value = trimmed.slice(eq + 1).trim();
if (!process.env[key]) process.env[key] = value;
}
}
export function loadProjectEnv() {
for (const file of ['.env', '.env.local']) {
const filePath = path.join(projectRoot, file);
if (!fs.existsSync(filePath)) continue;
for (const line of fs.readFileSync(filePath, 'utf8').split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const eq = trimmed.indexOf('=');
if (eq < 0) continue;
const key = trimmed.slice(0, eq).trim();
const value = trimmed.slice(eq + 1).trim();
if (!process.env[key]) process.env[key] = value;
loadEnvFile(path.join(projectRoot, file));
}
const memindRoot = process.env.MEMIND_LIB_ROOT?.trim();
if (memindRoot) {
for (const file of ['.env', '.env.local']) {
loadEnvFile(path.join(memindRoot, file));
}
}
return projectRoot;