import { promises as fs } from 'fs';
import path from 'path';
export async function loadConfig() {
    const configPath = path.join(process.cwd(), '.appshot', 'config.json');
    try {
        const content = await fs.readFile(configPath, 'utf8');
        return JSON.parse(content);
    }
    catch (error) {
        if (error.code === 'ENOENT') {
            throw new Error('Configuration not found. Run "appshot init" first.\n(Looking for .appshot/config.json)');
        }
        throw new Error(`Failed to load configuration: ${error instanceof Error ? error.message : String(error)}`);
    }
}
export async function loadCaptions(captionsPath) {
    try {
        const content = await fs.readFile(captionsPath, 'utf8');
        return JSON.parse(content);
    }
    catch {
        // Return empty object if file doesn't exist or is invalid
        return {};
    }
}
export async function fileExists(filePath) {
    try {
        await fs.access(filePath);
        return true;
    }
    catch {
        return false;
    }
}
//# sourceMappingURL=files.js.map