1import { ExpoConfig, getAccountUsername } from '@expo/config'; 2import { compileModsAsync, ModPlatform } from '@expo/config-plugins'; 3import { getPrebuildConfigAsync } from '@expo/prebuild-config'; 4 5import { logConfig } from '../config/configAsync'; 6import * as Log from '../log'; 7import { env } from '../utils/env'; 8import { 9 getOrPromptForBundleIdentifier, 10 getOrPromptForPackage, 11} from '../utils/getOrPromptApplicationId'; 12 13export async function configureProjectAsync( 14 projectRoot: string, 15 { 16 platforms, 17 }: { 18 platforms: ModPlatform[]; 19 } 20): Promise<ExpoConfig> { 21 let bundleIdentifier: string | undefined; 22 if (platforms.includes('ios')) { 23 // Check bundle ID before reading the config because it may mutate the config if the user is prompted to define it. 24 bundleIdentifier = await getOrPromptForBundleIdentifier(projectRoot); 25 } 26 let packageName: string | undefined; 27 if (platforms.includes('android')) { 28 // Check package before reading the config because it may mutate the config if the user is prompted to define it. 29 packageName = await getOrPromptForPackage(projectRoot); 30 } 31 32 let { exp: config } = await getPrebuildConfigAsync(projectRoot, { 33 platforms, 34 packageName, 35 bundleIdentifier, 36 expoUsername(config) { 37 return getAccountUsername(config); 38 }, 39 }); 40 41 // compile all plugins and mods 42 config = await compileModsAsync(config, { 43 projectRoot, 44 platforms, 45 assertMissingModProviders: false, 46 }); 47 48 if (env.EXPO_DEBUG) { 49 Log.log(); 50 Log.log('Evaluated config:'); 51 logConfig(config); 52 Log.log(); 53 } 54 55 return config; 56} 57