MCPcopy Create free account
hub / github.com/expo/expo / patchProjectAsync

Function patchProjectAsync

packages/patch-project/src/cli/patchProjectAsync.ts:29–78  ·  view source on GitHub ↗
(
  projectRoot: string,
  options: {
    /** List of platforms to prebuild. */
    platforms: ModPlatform[];
    /** Should delete the native folders after attempting to prebuild. @default false */
    clean?: boolean;
    /** URL or file path to the prebuild template. */
    template?: string;
    /** The options to pass to the `git diff` command. */
    diffOptions?: string[];
    /** The directory to save the patch files. @default `cng-patches` */
    patchRoot?: string;
  }
)

Source from the content-addressed store, hash-verified

27 * Entry point into the patch-project process.
28 */
29export async function patchProjectAsync(
30 projectRoot: string,
31 options: {
32 /** List of platforms to prebuild. */
33 platforms: ModPlatform[];
34 /** Should delete the native folders after attempting to prebuild. @default false */
35 clean?: boolean;
36 /** URL or file path to the prebuild template. */
37 template?: string;
38 /** The options to pass to the `git diff` command. */
39 diffOptions?: string[];
40 /** The directory to save the patch files. @default `cng-patches` */
41 patchRoot?: string;
42 }
43): Promise<void> {
44 const { ensureValidPlatforms } = require(
45 resolveFromExpoCli(projectRoot, 'build/src/prebuild/resolveOptions')
46 ) as typeof import('@expo/cli/src/prebuild/resolveOptions');
47 consumeConfigEnvMode();
48 globalThis.__DEV__ = true;
49 const envInfo = loadProjectEnv(projectRoot, { mode: 'development' });
50 logLoadedEnv(envInfo);
51
52 const { exp } = await getConfig(projectRoot);
53 const patchRoot = options.patchRoot || 'cng-patches';
54
55 // Warn if the project is attempting to prebuild an unsupported platform (iOS on Windows).
56 options.platforms = ensureValidPlatforms(options.platforms);
57
58 for (const platform of options.platforms) {
59 await platformSanityCheckAsync({ exp, projectRoot, platform });
60
61 const workingDirectories = await createWorkingDirectoriesAsync(projectRoot, platform);
62 try {
63 await removePatchFilesAsync(patchRoot, platform);
64 await fs.mkdir(path.join(projectRoot, patchRoot), { recursive: true });
65
66 await patchProjectForPlatformAsync({
67 projectRoot,
68 platform,
69 workingDirectories,
70 patchRoot,
71 exp,
72 options,
73 });
74 } finally {
75 await fs.rm(workingDirectories.rootDir, { recursive: true, force: true });
76 }
77 }
78}
79
80async function patchProjectForPlatformAsync({
81 projectRoot,

Callers 2

index.tsFile · 0.90

Calls 12

resolveFromExpoCliFunction · 0.90
consumeConfigEnvModeFunction · 0.90
loadProjectEnvFunction · 0.90
logLoadedEnvFunction · 0.90
getConfigFunction · 0.90
platformSanityCheckAsyncFunction · 0.90
ensureValidPlatformsFunction · 0.85
removePatchFilesAsyncFunction · 0.85
requireFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected