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