export const getManifest = async ({console, fs, path}) => {
    let manifest = false;
    try {
        console.debug(`Reading manifest file from '${path}'`);
        const data = await fs.readFile(path, 'utf8');
        manifest = JSON.parse(data);
    } catch(err0) {
        const err = new Error(`Failed to read manifest from '${path}' due to error: ` + err0.message);
        throw err;
    }
    if (!manifest?.['sap.app']?.id) {
        const err = new Error(`Invalid manifest file '${path}'. $['sap.app'].id is missing.`);
        throw err;
    }
    if (!manifest?.['sap.app']?.applicationVersion?.version) {
        const err = new Error(`Invalid manifest file '${path}'. $['sap.app'].applicationVersion.version is missing.`);
        throw err;
    }
    return manifest;
};
