1import { getConfig } from '@expo/config'; 2 3import { findUpProjectRootOrAssert } from '../utils/findUp'; 4import { queryAndGenerateAsync, selectAndGenerateAsync } from './generate'; 5import { Options } from './resolveOptions'; 6import { DestinationResolutionProps } from './templates'; 7 8export async function customizeAsync(files: string[], options: Options, extras: any[]) { 9 // Locate the project root based on the process current working directory. 10 // This enables users to run `npx expo customize` from a subdirectory of the project. 11 const projectRoot = findUpProjectRootOrAssert(process.cwd()); 12 13 // Get the static path (defaults to 'web/') 14 // Doesn't matter if expo is installed or which mode is used. 15 const { exp } = getConfig(projectRoot, { 16 skipSDKVersionRequirement: true, 17 }); 18 19 // Create the destination resolution props which are used in both 20 // the query and select functions. 21 const props: DestinationResolutionProps = { 22 webStaticPath: exp.web?.staticPath ?? 'web', 23 }; 24 25 // If the user provided files, we'll generate them without prompting. 26 if (files.length) { 27 return queryAndGenerateAsync(projectRoot, { 28 files, 29 props, 30 extras, 31 }); 32 } 33 34 // Otherwise, we'll prompt the user to select which files to generate. 35 await selectAndGenerateAsync(projectRoot, { 36 props, 37 extras, 38 }); 39} 40