1import path from 'path'; 2 3const fs = jest.requireActual('fs') as typeof import('fs'); 4const template = path.join(__dirname, '../../../../../../../templates/expo-template-bare-minimum/'); 5 6export function readAllFiles(): { 7 'ios/HelloWorld/AppDelegate.mm': string; 8 'ios/Podfile': string; 9 'ios/HelloWorld.xcodeproj/project.pbxproj': string; 10 'ios/HelloWorld/Info.plist': string; 11 'ios/HelloWorld/Supporting/Expo.plist': string; 12 'android/app/src/main/AndroidManifest.xml': string; 13 'android/app/src/main/java/com/helloworld/MainActivity.java': string; 14 'android/app/src/main/java/com/helloworld/MainApplication.java': string; 15 'android/app/build.gradle': string; 16 'android/build.gradle': string; 17 'android/settings.gradle': string; 18} & Record<string, string> { 19 const files: Record<string, string | Buffer> = { 20 // This file is generated and therefore not available in the template. 21 '/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h': `\ 22 #include <memory> 23 #include <string> 24 25 #include <ReactCommon/TurboModuleManagerDelegate.h> 26 #include <fbjni/fbjni.h> 27 28 namespace facebook { 29 namespace react { 30 31 class MainApplicationTurboModuleManagerDelegate 32 : public jni::HybridClass< 33 MainApplicationTurboModuleManagerDelegate, 34 TurboModuleManagerDelegate> { 35 public: 36 // Adapt it to the package you used for your Java class. 37 static constexpr auto kJavaDescriptor = 38 "Lcom/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;"; 39 40 static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>); 41 42 static void registerNatives(); 43 44 std::shared_ptr<TurboModule> getTurboModule( 45 const std::string name, 46 const std::shared_ptr<CallInvoker> jsInvoker) override; 47 std::shared_ptr<TurboModule> getTurboModule( 48 const std::string name, 49 const JavaTurboModule::InitParams ¶ms) override; 50 51 /** 52 * Test-only method. Allows user to verify whether a TurboModule can be 53 * created by instances of this class. 54 */ 55 bool canCreateTurboModule(std::string name); 56 }; 57 58 } // namespace react 59 } // namespace facebook 60 `, 61 }; 62 63 function readFile(file: string) { 64 if (file.endsWith('.DS_Store')) return; 65 const p = path.join(template, file); 66 if (fs.statSync(p).isDirectory()) { 67 fs.readdirSync(p).forEach((f) => { 68 readFile(`${file}/${f}`); 69 }); 70 } else { 71 if (file.match(/\.(png)$/)) { 72 const contents = fs.readFileSync(p); 73 files[file] = contents; 74 } else { 75 const contents = fs.readFileSync(p, 'utf-8'); 76 files[file] = contents; 77 } 78 } 79 } 80 81 fs.readdirSync(path.join(template, 'ios')).forEach((file) => { 82 readFile(`ios/${file}`); 83 }); 84 fs.readdirSync(path.join(template, 'android')).forEach((file) => { 85 readFile(`android/${file}`); 86 }); 87 88 return files as any; 89} 90 91export default readAllFiles(); 92