text: const fs = require('fs').promises;
  const yaml = require('js-yaml');
  const { getVersion, isBeta } = require('./version-helper');
  
  async function readManifest() {
    const input = await fs.readFile('src/manifest.yml', 'utf8');
    const data = yaml.safeLoad(input);
    return data;
  }
  
  async function buildManifest() {
    const data = await readManifest();
    data.version = getVersion();
    if (process.env.TARGET === 'selfHosted') {
      data.browser_specific_settings.gecko.update_url = 'https://github.com/violentmonkey/violentmonkey/releases/download/beta/updates.json';
    }
    if (isBeta()) {
      // Do not support i18n in beta version
      data.name = 'Violentmonkey BETA';
    }
    return data;
  }
  
  async function buildUpdatesList(version, url) {
    const manifest = await readManifest();
    const data = {
      addons: {
        [manifest.browser_specific_settings.gecko.id]: {
          updates: [
            {
              version,
              update_link: url,
            },
          ],
        }
      },
    };
    return data;
  }
  
  exports.readManifest = readManifest;
  exports.buildManifest = buildManifest;
  exports.buildUpdatesList = buildUpdatesList;
  