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