1import { getAccountUsername } from '@expo/config';
2import { ConfigPlugin, createRunOncePlugin, AndroidConfig, IOSConfig } from 'expo/config-plugins';
3
4const pkg = require('expo-updates/package.json');
5
6// when making changes to this config plugin, ensure the same changes are also made in eas-cli and build-tools
7
8const withUpdates: ConfigPlugin<{ expoUsername?: string } | void> = (config, props = {}) => {
9  // The username will be passed from the CLI when the plugin is automatically used.
10  const expoUsername = (props || {}).expoUsername ?? getAccountUsername(config);
11
12  config = AndroidConfig.Updates.withUpdates(config, { expoUsername });
13  config = IOSConfig.Updates.withUpdates(config, { expoUsername });
14  return config;
15};
16
17export default createRunOncePlugin(withUpdates, pkg.name, pkg.version);
18