import { homedir } from 'node:os';
export function loadCredentials(options) {
    const missing = [];
    if (!options.skipDns && !process.env.IONOS_API_KEY) {
        missing.push('IONOS_API_KEY');
    }
    if (!options.skipHosting) {
        if (!process.env.PLESK_API_KEY)
            missing.push('PLESK_API_KEY');
        if (!process.env.PLESK_HOST)
            missing.push('PLESK_HOST');
    }
    if (missing.length > 0) {
        throw new Error(`Missing environment variables: ${missing.join(', ')}\n` +
            'Set them in your shell or in a .env file.');
    }
    return {
        ionos: {
            apiKey: process.env.IONOS_API_KEY ?? '',
        },
        plesk: {
            apiKey: process.env.PLESK_API_KEY ?? '',
            host: process.env.PLESK_HOST ?? '',
            sshKey: process.env.PLESK_SSH_KEY?.replace('~', homedir()),
        },
    };
}
