import fs from 'fs';
import os from 'os';
import path from 'path';
import { fileURLToPath } from 'url';
import {
applyConfigToProcessEnv,
getPilotDeckConfigPath,
readPilotDeckConfigFile,
} from './services/pilotdeckConfig.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const REPO_ROOT = path.resolve(__dirname, '../..');
function applyDerivedRuntimeEnv() {
const { config } = readPilotDeckConfigFile();
applyConfigToProcessEnv(config);
}
export function getRepoRootDir() {
return REPO_ROOT;
}
export function getPilotDeckConfigFilePath() {
return getPilotDeckConfigPath();
}
export function hasPilotDeckConfigFile() {
return fs.existsSync(getPilotDeckConfigPath());
}
export function assertRequiredPilotDeckEnv() {
return [];
}
export function loadRootPilotDeckEnv() {
applyDerivedRuntimeEnv();
if (!process.env.DATABASE_PATH) {
process.env.DATABASE_PATH = path.join(process.env.PILOT_HOME || path.join(os.homedir(), '.pilotdeck'), 'auth.db');
}
return hasPilotDeckConfigFile();
}
loadRootPilotDeckEnv();