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