import { downloadLanguage, getFileId, getProjectId, listKeys, updateLocalDe, updateLocalEn, uploadLocal } from './functions';

async function execute() {
    const projectId = await getProjectId();
    const fileId = await getFileId(projectId);

    /** Update local en (source) file with potential remotely updated translations. */
    const remoteKeys = await listKeys(projectId, fileId, 'en');
    await updateLocalEn(remoteKeys);

    /** Upload local en (source) file in order to add new keys and deprecate unused keys. */
    await uploadLocal(projectId, 'en');

    /** Download updated de file. */
    await updateLocalDe(projectId, fileId);
}

async function uploadLocals() {
    const projectId = await getProjectId();
    await uploadLocal(projectId, 'de');
}

async function downloadDe() {
    const projectId = await getProjectId();
    const fileId = await getFileId(projectId);

    console.log({ projectId, fileId });
    console.log(await downloadLanguage(projectId, fileId, 'de'));
}

execute().then();
// uploadLocals().then();
// downloadDe().then();
