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

Function patchProjectAsync

packages/patch-project/src/cli/patchProjectAsync.ts:24–75  ·  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

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

Callers 1

index.tsFile · 0.90

Calls 10

resolveFromExpoCliFunction · 0.90
getConfigFunction · 0.90
platformSanityCheckAsyncFunction · 0.90
requireFunction · 0.85
ensureValidPlatformsFunction · 0.85
removePatchFilesAsyncFunction · 0.85
joinMethod · 0.80
setNodeEnvFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…