@@ -98,9 +98,16 @@ export const getFolderHash = async (platform: Platform, rootDir: string, verbose
98
98
99
99
// if there are no native folders, we don't need to hash anything
100
100
if ( ! hasAndroidOrIOSFolders ) {
101
+ if ( verbose ) {
102
+ console . log ( 'Skipping native files because there are no iOS/Android folders' ) ;
103
+ }
101
104
return '' ;
102
105
}
103
106
107
+ if ( verbose ) {
108
+ console . log ( 'Reading native files from git...' ) ;
109
+ }
110
+
104
111
const gitFiles = await execAsync ( 'git ls-tree -r HEAD --name-only' , {
105
112
cwd : rootDir ,
106
113
encoding : 'utf8' ,
@@ -236,13 +243,15 @@ const GENERATE_HASH_DEFAULTS: Required<GenerateHashOptions> = {
236
243
skipNodeModules : false ,
237
244
verbose : false ,
238
245
skipAppJson : false ,
246
+ skipLocalNativeFolders : false ,
239
247
} ;
240
248
241
249
type GenerateHashOptions = {
242
250
verbose ? : boolean ,
243
251
rootDir ? : string ,
244
252
skipNodeModules ? : boolean ,
245
253
skipAppJson ? : boolean ,
254
+ skipLocalNativeFolders ? : boolean ,
246
255
} ;
247
256
248
257
// this is a list of properties that should be included, lets focus on not breaking things
@@ -344,8 +353,13 @@ export const getCurrentHash = async (platform: Platform, {
344
353
skipNodeModules = GENERATE_HASH_DEFAULTS . skipNodeModules ,
345
354
verbose = GENERATE_HASH_DEFAULTS . verbose ,
346
355
skipAppJson = GENERATE_HASH_DEFAULTS . skipAppJson ,
356
+ skipLocalNativeFolders = GENERATE_HASH_DEFAULTS . skipLocalNativeFolders ,
347
357
} : GenerateHashOptions = GENERATE_HASH_DEFAULTS) => {
348
- const localNativeFoldersHash = await getFolderHash ( platform , rootDir , verbose ) ;
358
+ if ( verbose ) {
359
+ console . log ( `Getting hash for platform: ${ platform } ` ) ;
360
+ }
361
+
362
+ const localNativeFoldersHash = skipLocalNativeFolders ? '' : await getFolderHash(platform, rootDir, verbose);
349
363
350
364
const appJsonContent = skipAppJson ? '' : await getAppJsonHash(platform, rootDir, verbose);
351
365
@@ -355,7 +369,7 @@ export const getCurrentHash = async (platform: Platform, {
355
369
356
370
const nativeModuleIdentities = nativeModules.map(getModuleIdentity(platform));
357
371
if (verbose && ! skipNodeModules ) {
358
- console . log ( `Found ${ nativeModules . length } native modules (out of ${ nativeModules . length } total modules)\n${ nativeModuleIdentities . join ( '\n' ) } ` ) ;
372
+ console . log ( `Found ${ nativeModules . length } native ${ platform === Platform . all ? '' : ` ${ platform } ` } modules (out of ${ nativeModules . length } total modules)\n${ nativeModuleIdentities . join ( '\n' ) } ` ) ;
359
373
}
360
374
const stringToHashFrom = `app.json@${ appJsonContent } ;local@${ localNativeFoldersHash } ;${ nativeModuleIdentities . join ( ',' ) } ;plugins@${ appPlugins } `;
361
375
@@ -390,14 +404,23 @@ export async function verifyExpoApp(
390
404
{
391
405
verbose ,
392
406
rootDir ,
407
+ includeAppJson ,
408
+ includeLocalNativeFolders ,
393
409
} : {
394
410
verbose : boolean ;
395
411
rootDir : string ;
412
+ includeLocalNativeFolders ?: boolean ;
413
+ includeAppJson ?: boolean ;
396
414
} ,
397
415
) {
398
- if ( verbose ) { console . info ( `getting dependency hash for native dependencies in: ${ rootDir } ` ) ; }
416
+ if ( verbose ) { console . info ( `[expo-native- dependency- hash] verifying expo app in: ${ rootDir } ` ) ; }
399
417
400
- const { ios , android , all } = await generateHashes({ rootDir , verbose } );
418
+ const { ios , android , all } = await generateHashes({
419
+ rootDir ,
420
+ verbose ,
421
+ skipAppJson : ! includeAppJson ,
422
+ skipLocalNativeFolders : ! includeLocalNativeFolders ,
423
+ } );
401
424
402
425
let valueExists = false;
403
426
let hasChanged = false;
@@ -434,27 +457,38 @@ export async function verifyExpoApp(
434
457
}
435
458
}
436
459
437
- return { valueExists , hasChanged } ;
460
+ return {
461
+ valueExists , hasChanged, ios, android, all,
462
+ } ;
438
463
}
439
464
440
465
export async function updateExpoApp (
441
466
{
442
467
rootDir,
443
468
verbose,
469
+ includeAppJson,
470
+ includeLocalNativeFolders,
444
471
} : {
445
472
rootDir : string ;
446
473
verbose : boolean ;
474
+ includeAppJson ?: boolean ;
475
+ includeLocalNativeFolders ?: boolean ;
447
476
} ,
448
477
) {
449
- const { hasChanged, valueExists } = await verifyExpoApp ( { rootDir, verbose } ) ;
478
+ const {
479
+ hasChanged, valueExists, ios, android, all,
480
+ } = await verifyExpoApp ( {
481
+ rootDir,
482
+ verbose,
483
+ includeAppJson,
484
+ includeLocalNativeFolders,
485
+ } ) ;
450
486
451
487
if ( ! hasChanged && valueExists ) {
452
488
console . log ( green ( 'Hashes already up to date' ) ) ;
453
489
return ;
454
490
}
455
491
456
- const { ios, android, all } = await generateHashes ( { rootDir, verbose } ) ;
457
-
458
492
try {
459
493
const fileStr = await readFile ( Path . join ( rootDir , 'app.json' ) , 'utf8' ) ;
460
494
const prevJson = JSON . parse ( fileStr ) as { expo : ExpoConfig } ;
@@ -480,7 +514,7 @@ export async function verifyLibrary(
480
514
rootDir : string ;
481
515
} ,
482
516
) {
483
- if ( verbose ) { console . info ( `getting dependency hash for native dependencies in: ${ rootDir } ` ) ; }
517
+ if ( verbose ) { console . info ( `[expo-native- dependency- hash] verifying library in: ${ rootDir } ` ) ; }
484
518
485
519
const { ios , android , all } = await generateHashes ( {
486
520
rootDir, verbose, skipNodeModules : true , skipAppJson : true ,
0 commit comments