From cb983af6fd4e1ecf0a857b22892daf1646c8865c Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Wed, 25 Jan 2023 13:28:32 -0500 Subject: [PATCH] feat(react-native): upgrade react-native to 0.71.1 (#14584) (cherry picked from commit 41fc2ebbedb04b594e90eef614f2e6ebeb570edf) --- .../react-native/executors/run-ios.json | 12 +- e2e/react-native/src/react-native.test.ts | 14 +- package.json | 2 +- packages/detox/migrations.json | 9 + packages/detox/package.json | 2 +- .../application/application.spec.ts | 20 +- .../files/app/.detoxrc.json.template | 6 +- .../files/app/environment.js.template | 24 -- .../files/app/jest.config.json.template | 9 +- packages/detox/src/utils/versions.ts | 2 +- packages/expo/package.json | 2 +- packages/expo/plugins/metro-resolver.ts | 26 ++ .../application/application.spec.ts | 12 +- packages/expo/src/utils/versions.ts | 2 +- .../react-native/docs/run-ios-examples.md | 2 +- packages/react-native/migrations.json | 77 +++++ packages/react-native/package.json | 4 +- .../react-native/plugins/metro-resolver.ts | 36 ++- .../build-android/build-android.impl.ts | 5 +- .../executors/run-android/run-android.impl.ts | 4 +- .../src/executors/run-ios/schema.json | 10 +- .../application/application.spec.ts | 8 +- .../src/generators/application/application.ts | 28 +- .../application/files/app/.ruby-version | 1 + .../application/files/app/Gemfile.template | 6 + .../files/app/android/app/_BUCK.template | 55 ---- .../app/android/app/build.gradle.template | 288 +++++------------- .../files/app/android/app/build_defs.bzl | 19 -- .../__lowerCaseName__/DetoxTest.java.template | 10 +- .../ReactNativeFlipper.java.template | 6 +- .../app/src/main/AndroidManifest.xml.template | 6 +- .../MainActivity.java.template | 39 +-- .../MainApplication.java.template | 67 ++-- ...inApplicationReactNativeHost.java.template | 116 ------- .../MainComponentsRegistry.java.template | 36 --- ...onTurboModuleManagerDelegate.java.template | 48 --- .../app/src/main/jni/CMakeLists.txt.template | 6 - .../jni/MainApplicationModuleProvider.cpp | 32 -- .../main/jni/MainApplicationModuleProvider.h | 16 - ...nApplicationTurboModuleManagerDelegate.cpp | 45 --- ...ationTurboModuleManagerDelegate.h.template | 38 --- .../src/main/jni/MainComponentsRegistry.cpp | 65 ---- .../jni/MainComponentsRegistry.h.template | 32 -- .../app/android/app/src/main/jni/OnLoad.cpp | 11 - .../ReactNativeFlipper.java.template | 20 ++ .../files/app/android/build.gradle.template | 49 +-- .../files/app/android/gradle.properties | 4 + .../app/android/settings.gradle.template | 19 +- .../files/app/ios/Podfile.template | 26 +- .../project.pbxproj.template | 6 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../xcshareddata/contents.xcworkspacedata | 10 + .../files/app/ios/__className__/AppDelegate.h | 6 +- .../ios/__className__/AppDelegate.mm.template | 121 +------- .../app/ios/__className__/Info.plist.template | 4 +- .../react-native/src/generators/init/init.ts | 3 +- .../generators/init/lib/gitignore-entries.ts | 27 +- .../upgrade-native/upgrade-native.ts | 22 +- .../src/utils/chmod-android-gradle-files.ts | 21 ++ packages/react-native/src/utils/chmod-task.ts | 16 - packages/react-native/src/utils/versions.ts | 28 +- yarn.lock | 8 +- 62 files changed, 494 insertions(+), 1162 deletions(-) delete mode 100644 packages/detox/src/generators/application/files/app/environment.js.template create mode 100644 packages/react-native/src/generators/application/files/app/.ruby-version create mode 100644 packages/react-native/src/generators/application/files/app/Gemfile.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/_BUCK.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/build_defs.bzl delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/CMakeLists.txt.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template delete mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp create mode 100644 packages/react-native/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template delete mode 100644 packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/contents.xcworkspacedata create mode 100644 packages/react-native/src/utils/chmod-android-gradle-files.ts delete mode 100644 packages/react-native/src/utils/chmod-task.ts diff --git a/docs/generated/packages/react-native/executors/run-ios.json b/docs/generated/packages/react-native/executors/run-ios.json index 7b3c83f3ae6d2..14c1d95305376 100644 --- a/docs/generated/packages/react-native/executors/run-ios.json +++ b/docs/generated/packages/react-native/executors/run-ios.json @@ -38,8 +38,14 @@ "simulator": { "type": "string", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: `iPhone X (12.1)`.", - "default": "iPhone 13", - "examples": ["iPhone 13", "iPhone X"], + "default": "iPhone 14", + "examples": [ + "iPhone 14", + "iPhone 13", + "iPhone 12", + "iPhone 11", + "iPhone X" + ], "x-priority": "important" }, "device": { @@ -84,7 +90,7 @@ "default": true } }, - "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:run-ios\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Run on a simulator\" %}\nTo see all the avaiable simulators, run command:\n\n```bash\nxcrun simctl list\n```\n\nThe `simulator` option allows you to launch your iOS app in a specific simulator:\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"simulator\": \"iPhone 13 Pro\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Run on a device\" %}\nThe `device` option allows you to launch your iOS app in a specific device.\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"device\": \"deviceName\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Run the Debug/Release app\" %}\nThe `xcodeConfiguration` option allows to specify the xcode configuartion, such as `Debug` or `Release`.\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"xcodeConfiguration\": \"Release\"\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n" + "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:run-ios\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Run on a simulator\" %}\nTo see all the avaiable simulators, run command:\n\n```bash\nxcrun simctl list\n```\n\nThe `simulator` option allows you to launch your iOS app in a specific simulator:\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"simulator\": \"iPhone 14 Pro\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Run on a device\" %}\nThe `device` option allows you to launch your iOS app in a specific device.\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"device\": \"deviceName\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Run the Debug/Release app\" %}\nThe `xcodeConfiguration` option allows to specify the xcode configuartion, such as `Debug` or `Release`.\n\n```json\n \"run-ios\": {\n \"executor\": \"@nrwl/react-native:run-ios\",\n \"options\": {\n \"xcodeConfiguration\": \"Release\"\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n" }, "description": "Runs iOS application.", "aliases": [], diff --git a/e2e/react-native/src/react-native.test.ts b/e2e/react-native/src/react-native.test.ts index e40baf3764cd9..8629c7b8fefcb 100644 --- a/e2e/react-native/src/react-native.test.ts +++ b/e2e/react-native/src/react-native.test.ts @@ -23,11 +23,11 @@ describe('react native', () => { const componentName = uniq('component'); runCLI( - `generate @nrwl/react-native:application ${appName} --install=false` + `generate @nrwl/react-native:application ${appName} --install=false --no-interactive` ); - runCLI(`generate @nrwl/react-native:library ${libName}`); + runCLI(`generate @nrwl/react-native:library ${libName} --no-interactive`); runCLI( - `generate @nrwl/react-native:component ${componentName} --project=${libName} --export` + `generate @nrwl/react-native:component ${componentName} --project=${libName} --export --no-interactive` ); updateFile(`apps/${appName}/src/app/App.tsx`, (content) => { @@ -70,7 +70,7 @@ describe('react native', () => { it('should create storybook with application', async () => { const appName = uniq('my-app'); runCLI( - `generate @nrwl/react-native:application ${appName} --install=false` + `generate @nrwl/react-native:application ${appName} --install=false --no-interactive` ); runCLI( `generate @nrwl/react-native:storybook-configuration ${appName} --generateStories --no-interactive` @@ -99,7 +99,7 @@ describe('react native', () => { it('should upgrade native for application', async () => { const appName = uniq('my-app'); runCLI( - `generate @nrwl/react-native:application ${appName} --install=false` + `generate @nrwl/react-native:application ${appName} --install=false --no-interactive` ); expect(() => @@ -114,7 +114,7 @@ describe('react native', () => { const componentName = uniq('component'); runCLI( - `generate @nrwl/react-native:library ${libName} --buildable --publishable --importPath=${proj}/${libName}` + `generate @nrwl/react-native:library ${libName} --buildable --publishable --importPath=${proj}/${libName} --no-interactive` ); runCLI( `generate @nrwl/react-native:component ${componentName} --project=${libName} --export` @@ -129,7 +129,7 @@ describe('react native', () => { it('sync npm dependencies for autolink', async () => { const appName = uniq('my-app'); runCLI( - `generate @nrwl/react-native:application ${appName} --install=false` + `generate @nrwl/react-native:application ${appName} --install=false --no-interactive` ); // Add npm package with native modules updateFile(join('package.json'), (content) => { diff --git a/package.json b/package.json index 2a384ae3f775f..90d48325c6e3d 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,7 @@ "lockfile-lint": "^4.7.6", "magic-string": "~0.26.2", "memfs": "^3.0.1", - "metro-resolver": "^0.73.3", + "metro-resolver": "^0.74.1", "mini-css-extract-plugin": "~2.4.7", "minimatch": "3.0.5", "next-sitemap": "^3.1.10", diff --git a/packages/detox/migrations.json b/packages/detox/migrations.json index f7740364d1353..fbe6e0b0eb185 100644 --- a/packages/detox/migrations.json +++ b/packages/detox/migrations.json @@ -183,6 +183,15 @@ "alwaysAddToPackageJson": false } } + }, + "15.6.2": { + "version": "15.6.2-beta.0", + "packages": { + "detox": { + "version": "20.1.1", + "alwaysAddToPackageJson": false + } + } } } } diff --git a/packages/detox/package.json b/packages/detox/package.json index 52cfab6d1f1c5..4991d746fe351 100644 --- a/packages/detox/package.json +++ b/packages/detox/package.json @@ -32,7 +32,7 @@ "@nrwl/workspace": "file:../workspace" }, "peerDependencies": { - "detox": "^20.0.3" + "detox": "^20.1.1" }, "builders": "./executors.json", "ng-update": { diff --git a/packages/detox/src/generators/application/application.spec.ts b/packages/detox/src/generators/application/application.spec.ts index aa7d510ee3046..3a850c4068ecb 100644 --- a/packages/detox/src/generators/application/application.spec.ts +++ b/packages/detox/src/generators/application/application.spec.ts @@ -60,14 +60,14 @@ describe('detox application generator', () => { binaryPath: '../../my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -134,14 +134,14 @@ describe('detox application generator', () => { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -208,14 +208,14 @@ describe('detox application generator', () => { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -282,14 +282,14 @@ describe('detox application generator', () => { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -368,7 +368,7 @@ describe('detox application generator', () => { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.eas': { @@ -387,7 +387,7 @@ describe('detox application generator', () => { binaryPath: '../../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app', build: - "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); diff --git a/packages/detox/src/generators/application/files/app/.detoxrc.json.template b/packages/detox/src/generators/application/files/app/.detoxrc.json.template index acf04a68ea889..c3a59bf5798c6 100644 --- a/packages/detox/src/generators/application/files/app/.detoxrc.json.template +++ b/packages/detox/src/generators/application/files/app/.detoxrc.json.template @@ -4,12 +4,12 @@ "apps": { "ios.debug": { "type": "ios.app", - "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Debug-iphonesimulator/<%= appClassName %>.app" }, "ios.release": { "type": "ios.app", - "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "build": "cd <%= offsetFromRoot %><%= appRoot %>/ios && xcodebuild -workspace <%= appClassName %>.xcworkspace -scheme <%= appClassName %> -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", "binaryPath": "<%= offsetFromRoot %><%= appRoot %>/ios/build/Build/Products/Release-iphonesimulator/<%= appClassName %>.app" }, <% if (framework === 'expo') { %> @@ -51,7 +51,7 @@ "simulator": { "type": "ios.simulator", "device": { - "type": "iPhone 13" + "type": "iPhone 14" } }, "emulator": { diff --git a/packages/detox/src/generators/application/files/app/environment.js.template b/packages/detox/src/generators/application/files/app/environment.js.template deleted file mode 100644 index e2e63abf623a0..0000000000000 --- a/packages/detox/src/generators/application/files/app/environment.js.template +++ /dev/null @@ -1,24 +0,0 @@ -// setup from https://github.com/wix/Detox/blob/master/docs/Guide.Jest.md#e2eenvironmentjs -const { - DetoxCircusEnvironment, - SpecReporter, - WorkerAssignReporter, -} = require('detox/runners/jest-circus'); - -class CustomDetoxEnvironment extends DetoxCircusEnvironment { - constructor(config, context) { - super(config, context); - - // Can be safely removed, if you are content with the default value (=300000ms) - this.initTimeout = 300000; - - // This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level. - // This is strictly optional. - this.registerListeners({ - SpecReporter, - WorkerAssignReporter, - }); - } -} - -module.exports = CustomDetoxEnvironment; diff --git a/packages/detox/src/generators/application/files/app/jest.config.json.template b/packages/detox/src/generators/application/files/app/jest.config.json.template index 8f12472b3e320..c0fc9c6dffbf3 100644 --- a/packages/detox/src/generators/application/files/app/jest.config.json.template +++ b/packages/detox/src/generators/application/files/app/jest.config.json.template @@ -1,9 +1,12 @@ { "preset": "<%= offsetFromRoot %>jest.preset", - "testEnvironment": "./environment", - "testRunner": "jest-circus/runner", "testTimeout": 120000, - "reporters": ["detox/runners/jest/streamlineReporter"], + "maxWorkers": 1, + "globalSetup": "detox/runners/jest/globalSetup", + "globalTeardown": "detox/runners/jest/globalTeardown", + "reporters": ["detox/runners/jest/reporter"], + "testEnvironment": "detox/runners/jest/testEnvironment", + "verbose": true, "setupFilesAfterEnv": ["/test-setup.ts"], "transform": { "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nrwl/react/plugins/jest", diff --git a/packages/detox/src/utils/versions.ts b/packages/detox/src/utils/versions.ts index 1d19de2b4654a..7754c80543961 100644 --- a/packages/detox/src/utils/versions.ts +++ b/packages/detox/src/utils/versions.ts @@ -1,4 +1,4 @@ export const nxVersion = require('../../package.json').version; -export const detoxVersion = '20.0.3'; +export const detoxVersion = '20.1.1'; export const testingLibraryJestDom = '5.16.5'; diff --git a/packages/expo/package.json b/packages/expo/package.json index 65e01c5a87c21..8c326c1861de8 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -36,7 +36,7 @@ "chalk": "^4.1.0", "enhanced-resolve": "^5.8.3", "fs-extra": "^11.1.0", - "metro-resolver": "^0.73.3", + "metro-resolver": "^0.74.1", "node-fetch": "^2.6.7", "tar-fs": "^2.1.1", "tsconfig-paths": "^4.1.2", diff --git a/packages/expo/plugins/metro-resolver.ts b/packages/expo/plugins/metro-resolver.ts index 27b95cdb24813..b25dcb1bf5e4a 100644 --- a/packages/expo/plugins/metro-resolver.ts +++ b/packages/expo/plugins/metro-resolver.ts @@ -26,6 +26,13 @@ export function getResolveRequest(extensions: string[]) { const { resolveRequest, ...context } = _context; const resolvedPath = + resolveRequestFromContext( + resolveRequest, + _context, + realModuleName, + platform, + debug + ) || defaultMetroResolver(context, realModuleName, platform, debug) || tsconfigPathsResolver( context, @@ -42,6 +49,25 @@ export function getResolveRequest(extensions: string[]) { }; } +function resolveRequestFromContext( + resolveRequest: Function, + context: any, + realModuleName: string, + platform: string, + debug: boolean +) { + try { + return resolveRequest(context, realModuleName, platform); + } catch { + if (debug) + console.log( + chalk.cyan( + `[Nx] Unable to resolve with default resolveRequest: ${realModuleName}` + ) + ); + } +} + /** * This function try to resolve path using metro's default resolver * @returns path if resolved, else undefined diff --git a/packages/expo/src/generators/application/application.spec.ts b/packages/expo/src/generators/application/application.spec.ts index 8017202110339..a8c4f7b3e6a14 100644 --- a/packages/expo/src/generators/application/application.spec.ts +++ b/packages/expo/src/generators/application/application.spec.ts @@ -144,7 +144,7 @@ describe('app', () => { binaryPath: '../../../apps/my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.eas': { @@ -163,7 +163,7 @@ describe('app', () => { binaryPath: '../../../apps/my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -219,7 +219,7 @@ describe('app', () => { binaryPath: '../../apps/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.eas': { @@ -238,7 +238,7 @@ describe('app', () => { binaryPath: '../../apps/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -295,7 +295,7 @@ describe('app', () => { binaryPath: '../../apps/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.eas': { @@ -314,7 +314,7 @@ describe('app', () => { binaryPath: '../../apps/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); diff --git a/packages/expo/src/utils/versions.ts b/packages/expo/src/utils/versions.ts index 6e0dd04624d2d..442b4e864cb65 100644 --- a/packages/expo/src/utils/versions.ts +++ b/packages/expo/src/utils/versions.ts @@ -22,7 +22,7 @@ export const reactNativeWebVersion = '~0.18.10'; export const reactNativeSvgTransformerVersion = '1.0.0'; export const reactNativeSvgVersion = '13.4.0'; -export const metroVersion = '0.73.3'; +export const metroVersion = '0.74.1'; export const testingLibraryReactNativeVersion = '11.5.0'; export const testingLibraryJestNativeVersion = '5.3.0'; diff --git a/packages/react-native/docs/run-ios-examples.md b/packages/react-native/docs/run-ios-examples.md index 3ad05723debf2..0055c229e9b42 100644 --- a/packages/react-native/docs/run-ios-examples.md +++ b/packages/react-native/docs/run-ios-examples.md @@ -34,7 +34,7 @@ The `simulator` option allows you to launch your iOS app in a specific simulator "run-ios": { "executor": "@nrwl/react-native:run-ios", "options": { - "simulator": "iPhone 13 Pro" + "simulator": "iPhone 14 Pro" } } ``` diff --git a/packages/react-native/migrations.json b/packages/react-native/migrations.json index a0fb58976d9ae..e7ff8920239ce 100644 --- a/packages/react-native/migrations.json +++ b/packages/react-native/migrations.json @@ -1109,6 +1109,83 @@ "alwaysAddToPackageJson": false } } + }, + "15.6.2": { + "version": "15.6.2-beta.0", + "packages": { + "react-native": { + "version": "0.71.1", + "alwaysAddToPackageJson": false + }, + "@types/react-native": { + "version": "0.71.0", + "alwaysAddToPackageJson": false + }, + "metro-resolver": { + "version": "0.74.1", + "alwaysAddToPackageJson": false + }, + "metro-babel-register": { + "version": "0.74.1", + "alwaysAddToPackageJson": false + }, + "metro-config": { + "version": "0.74.1", + "alwaysAddToPackageJson": false + }, + "metro-react-native-babel-preset": { + "version": "0.74.1", + "alwaysAddToPackageJson": false + }, + "metro-react-native-babel-transformer": { + "version": "0.74.1", + "alwaysAddToPackageJson": false + }, + "react-native-config": { + "version": "1.4.12", + "alwaysAddToPackageJson": false + }, + "@testing-library/jest-native": { + "version": "5.4.1", + "alwaysAddToPackageJson": false + }, + "react-native-svg": { + "version": "13.7.0", + "alwaysAddToPackageJson": false + }, + "@babel/runtime": { + "version": "7.20.7", + "alwaysAddToPackageJson": false + }, + "@react-native-community/cli": { + "version": "10.1.3", + "alwaysAddToPackageJson": false + }, + "@react-native-community/cli-platform-android": { + "version": "10.1.3", + "alwaysAddToPackageJson": false + }, + "@react-native-community/cli-platform-ios": { + "version": "10.1.1", + "alwaysAddToPackageJson": false + }, + "@types/node": { + "version": "18.11.18", + "alwaysAddToPackageJson": false + }, + "react": { + "version": "18.2.0", + "alwaysAddToPackageJson": false + }, + "react-dom": { + "version": "18.2.0", + "alwaysAddToPackageJson": false + }, + "react-test-renderer": { + "version": "18.2.0", + "alwaysAddToPackageJson": false + } + } } } } diff --git a/packages/react-native/package.json b/packages/react-native/package.json index c599eb451d017..b7fad7bf897b1 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -36,13 +36,13 @@ "enhanced-resolve": "^5.8.3", "fs-extra": "^11.1.0", "ignore": "^5.0.4", - "metro-resolver": "^0.73.3", + "metro-resolver": "^0.74.1", "minimatch": "3.0.5", "node-fetch": "^2.6.7", "tsconfig-paths": "^4.1.2" }, "peerDependencies": { - "react-native": "^0.70.6" + "react-native": "^0.71.1" }, "builders": "./executors.json", "ng-update": { diff --git a/packages/react-native/plugins/metro-resolver.ts b/packages/react-native/plugins/metro-resolver.ts index 4c2ab744c51b7..b25dcb1bf5e4a 100644 --- a/packages/react-native/plugins/metro-resolver.ts +++ b/packages/react-native/plugins/metro-resolver.ts @@ -19,22 +19,29 @@ export function getResolveRequest(extensions: string[]) { realModuleName: string, platform: string | null ) { - const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true'; + const debug = process.env.NX_REACT_NATIVE_DEBUG === 'true'; - if (DEBUG) console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`)); + if (debug) console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`)); const { resolveRequest, ...context } = _context; const resolvedPath = - defaultMetroResolver(context, realModuleName, platform, DEBUG) || + resolveRequestFromContext( + resolveRequest, + _context, + realModuleName, + platform, + debug + ) || + defaultMetroResolver(context, realModuleName, platform, debug) || tsconfigPathsResolver( context, extensions, realModuleName, platform, - DEBUG + debug ) || - pnpmResolver(extensions, context, realModuleName, DEBUG); + pnpmResolver(extensions, context, realModuleName, debug); if (resolvedPath) { return resolvedPath; } @@ -42,6 +49,25 @@ export function getResolveRequest(extensions: string[]) { }; } +function resolveRequestFromContext( + resolveRequest: Function, + context: any, + realModuleName: string, + platform: string, + debug: boolean +) { + try { + return resolveRequest(context, realModuleName, platform); + } catch { + if (debug) + console.log( + chalk.cyan( + `[Nx] Unable to resolve with default resolveRequest: ${realModuleName}` + ) + ); + } +} + /** * This function try to resolve path using metro's default resolver * @returns path if resolved, else undefined diff --git a/packages/react-native/src/executors/build-android/build-android.impl.ts b/packages/react-native/src/executors/build-android/build-android.impl.ts index 9895cf9f99544..7e2eba95adbcd 100644 --- a/packages/react-native/src/executors/build-android/build-android.impl.ts +++ b/packages/react-native/src/executors/build-android/build-android.impl.ts @@ -2,8 +2,8 @@ import { ExecutorContext } from '@nrwl/devkit'; import { join } from 'path'; import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink'; import { ChildProcess, spawn } from 'child_process'; -import { chmodSync } from 'fs'; import { ReactNativeBuildOptions } from './schema'; +import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files'; export interface ReactNativeBuildOutput { success: boolean; } @@ -17,8 +17,7 @@ export default async function* buildAndroidExecutor( const projectRoot = context.projectsConfigurations.projects[context.projectName].root; ensureNodeModulesSymlink(context.root, projectRoot); - chmodSync(join(projectRoot, 'android', 'gradlew'), 0o775); - chmodSync(join(projectRoot, 'android', 'gradlew.bat'), 0o775); + chmodAndroidGradlewFiles(join(projectRoot, 'android')); try { await runCliBuild(context.root, projectRoot, options); diff --git a/packages/react-native/src/executors/run-android/run-android.impl.ts b/packages/react-native/src/executors/run-android/run-android.impl.ts index e360a10483122..d1dfcf88df813 100644 --- a/packages/react-native/src/executors/run-android/run-android.impl.ts +++ b/packages/react-native/src/executors/run-android/run-android.impl.ts @@ -10,6 +10,7 @@ import { import { chmodSync } from 'fs'; import { ReactNativeRunAndroidOptions } from './schema'; import { runCliStart } from '../start/start.impl'; +import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files'; export interface ReactNativeRunAndroidOutput { success: boolean; @@ -24,8 +25,7 @@ export default async function* runAndroidExecutor( const projectRoot = context.projectsConfigurations.projects[context.projectName].root; ensureNodeModulesSymlink(context.root, projectRoot); - chmodSync(join(context.root, projectRoot, 'android', 'gradlew'), 0o775); - chmodSync(join(context.root, projectRoot, 'android', 'gradlew.bat'), 0o775); + chmodAndroidGradlewFiles(join(projectRoot, 'android')); if (options.sync) { displayNewlyAddedDepsMessage( diff --git a/packages/react-native/src/executors/run-ios/schema.json b/packages/react-native/src/executors/run-ios/schema.json index 1e6e65217adb8..f8acdfe170814 100644 --- a/packages/react-native/src/executors/run-ios/schema.json +++ b/packages/react-native/src/executors/run-ios/schema.json @@ -35,8 +35,14 @@ "simulator": { "type": "string", "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: `iPhone X (12.1)`.", - "default": "iPhone 13", - "examples": ["iPhone 13", "iPhone X"], + "default": "iPhone 14", + "examples": [ + "iPhone 14", + "iPhone 13", + "iPhone 12", + "iPhone 11", + "iPhone X" + ], "x-priority": "important" }, "device": { diff --git a/packages/react-native/src/generators/application/application.spec.ts b/packages/react-native/src/generators/application/application.spec.ts index e52938ae156bf..2ee892e0fd011 100644 --- a/packages/react-native/src/generators/application/application.spec.ts +++ b/packages/react-native/src/generators/application/application.spec.ts @@ -120,14 +120,14 @@ describe('app', () => { binaryPath: '../../../apps/my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../../apps/my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); @@ -168,14 +168,14 @@ describe('app', () => { binaryPath: '../../apps/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, 'ios.release': { binaryPath: '../../apps/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app', build: - "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet", + "cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet", type: 'ios.app', }, }); diff --git a/packages/react-native/src/generators/application/application.ts b/packages/react-native/src/generators/application/application.ts index 16a0eb52cdd94..4230011e34ade 100644 --- a/packages/react-native/src/generators/application/application.ts +++ b/packages/react-native/src/generators/application/application.ts @@ -1,10 +1,5 @@ +import { join } from 'path'; import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; -import { Schema } from './schema'; -import { runPodInstall } from '../../utils/pod-install-task'; -import { runChmod } from '../../utils/chmod-task'; -import { runSymlink } from '../../utils/symlink-task'; -import { addLinting } from '../../utils/add-linting'; -import { addJest } from '../../utils/add-jest'; import { convertNxGenerator, Tree, @@ -12,12 +7,19 @@ import { GeneratorCallback, joinPathFragments, } from '@nrwl/devkit'; + +import { runPodInstall } from '../../utils/pod-install-task'; +import { runSymlink } from '../../utils/symlink-task'; +import { addLinting } from '../../utils/add-linting'; +import { addJest } from '../../utils/add-jest'; +import { chmodAndroidGradlewFilesTask } from '../../utils/chmod-android-gradle-files'; + import { normalizeOptions } from './lib/normalize-options'; import initGenerator from '../init/init'; -import { join } from 'path'; import { addProject } from './lib/add-project'; import { createApplicationFiles } from './lib/create-application-files'; import { addDetox } from './lib/add-detox'; +import { Schema } from './schema'; export async function reactNativeApplicationGenerator( host: Tree, @@ -51,13 +53,8 @@ export async function reactNativeApplicationGenerator( join(host.root, options.iosProjectRoot), options.install ); - const chmodTaskGradlew = runChmod( - join(host.root, options.androidProjectRoot, 'gradlew'), - 0o775 - ); - const chmodTaskGradlewBat = runChmod( - join(host.root, options.androidProjectRoot, 'gradlew.bat'), - 0o775 + const chmodTaskGradlew = chmodAndroidGradlewFilesTask( + join(host.root, options.androidProjectRoot) ); if (!options.skipFormat) { @@ -71,8 +68,7 @@ export async function reactNativeApplicationGenerator( detoxTask, symlinkTask, podInstallTask, - chmodTaskGradlew, - chmodTaskGradlewBat + chmodTaskGradlew ); } diff --git a/packages/react-native/src/generators/application/files/app/.ruby-version b/packages/react-native/src/generators/application/files/app/.ruby-version new file mode 100644 index 0000000000000..49cdd668e1c82 --- /dev/null +++ b/packages/react-native/src/generators/application/files/app/.ruby-version @@ -0,0 +1 @@ +2.7.6 diff --git a/packages/react-native/src/generators/application/files/app/Gemfile.template b/packages/react-native/src/generators/application/files/app/Gemfile.template new file mode 100644 index 0000000000000..567e59805c4a7 --- /dev/null +++ b/packages/react-native/src/generators/application/files/app/Gemfile.template @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby File.read(File.join(__dir__, '.ruby-version')).strip + +gem 'cocoapods', '~> 1.11', '>= 1.11.3' diff --git a/packages/react-native/src/generators/application/files/app/android/app/_BUCK.template b/packages/react-native/src/generators/application/files/app/android/app/_BUCK.template deleted file mode 100644 index 9359ab06b6661..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/_BUCK.template +++ /dev/null @@ -1,55 +0,0 @@ -# To learn about Buck see [Docs](https://buckbuild.com/). -# To run your application with Buck: -# - install Buck -# - `npm start` - to start the packager -# - `cd android` -# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` -# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck -# - `buck install -r android/app` - compile, install and run application -# - -load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") - -lib_deps = [] - -create_aar_targets(glob(["libs/*.aar"])) - -create_jar_targets(glob(["libs/*.jar"])) - -android_library( - name = "all-libs", - exported_deps = lib_deps, -) - -android_library( - name = "app-code", - srcs = glob([ - "src/main/java/**/*.java", - ]), - deps = [ - ":all-libs", - ":build_config", - ":res", - ], -) - -android_build_config( - name = "build_config", - package = "com.<%= lowerCaseName %>", -) - -android_resource( - name = "res", - package = "com.<%= lowerCaseName %>", - res = "src/main/res", -) - -android_binary( - name = "app", - keystore = "//android/keystores:debug", - manifest = "src/main/AndroidManifest.xml", - package_type = "debug", - deps = [ - ":app-code", - ], -) diff --git a/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template b/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template index fd310745d4459..a7f1a40c0d7fe 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template @@ -1,131 +1,89 @@ apply plugin: "com.android.application" apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" +apply plugin: "com.facebook.react" import com.android.build.OutputFile -import org.apache.tools.ant.taskdefs.condition.Os /** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation. If none specified and - * // "index.android.js" exists, it will be used. Otherwise "index.js" is - * // default. Can be overridden with ENTRY_FILE environment variable. - * entryFile: "index.android.js", - * - * // https://reactnative.dev/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. */ - -project.ext.react = [ - // the entry file for bundle generation - entryFile: "<%= entryFile %>", - enableHermes: true, // clean and rebuild if changing -] - -apply from: "../../node_modules/react-native/react.gradle" +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen + // codegenDir = file("../node_modules/react-native-codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] + entryFile = file("../../<%= entryFile %>") +} /** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. + * Set this to true to create four separate APKs instead of one, + * one for each native architecture. This is useful if you don't + * use App Bundles (https://developer.android.com/guide/app-bundle/) + * and want to have separate APKs to upload to the Play Store. */ def enableSeparateBuildPerCPUArchitecture = false /** - * Run Proguard to shrink the Java bytecode in release builds. + * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = false /** - * The preferred build flavor of JavaScriptCore. + * The preferred build flavor of JavaScriptCore (JSC) * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that - * give correct results when using with locales other than en-US. Note that + * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and that value will be read here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ -def enableHermes = project.ext.react.get("enableHermes", false); - -/** - * Architectures to build native code for. + * Private function to get the list of Native Architectures you want to build. + * This reads the value from reactNativeArchitectures in your gradle.properties + * file and works together with the --active-arch-only flag of react-native run-android. */ def reactNativeArchitectures() { def value = project.getProperties().get("reactNativeArchitectures") @@ -137,77 +95,17 @@ android { compileSdkVersion rootProject.ext.compileSdkVersion + namespace "com.<%= lowerCaseName %>" defaultConfig { applicationId "com.<%= lowerCaseName %>" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" - buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() <% if (e2eTestRunner === 'detox') { %> - testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type + testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - missingDimensionStrategy 'detox', 'full' <% } %> - - if (isNewArchitectureEnabled()) { - // We configure the CMake build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - cmake { - arguments "-DPROJECT_BUILD_DIR=$buildDir", - "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", - "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", - "-DNODE_MODULES_DIR=$rootDir/../node_modules", - "-DANDROID_STL=c++_shared" - } - } - if (!enableSeparateBuildPerCPUArchitecture) { - ndk { - abiFilters (*reactNativeArchitectures()) - } - } - } - } - - if (isNewArchitectureEnabled()) { - // We configure the NDK build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - cmake { - path "$projectDir/src/main/jni/CMakeLists.txt" - } - } - def reactAndroidProjectDir = project(':ReactAndroid').projectDir - def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - afterEvaluate { - // If you wish to add a custom TurboModule or component locally, - // you should uncomment this line. - // preBuild.dependsOn("generateCodegenArtifactsFromSchema") - preDebugBuild.dependsOn(packageReactNdkDebugLibs) - preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) - - // Due to a bug inside AGP, we have to explicitly set a dependency - // between configureCMakeDebug* tasks and the preBuild tasks. - // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 - configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild) - configureCMakeDebug.dependsOn(preDebugBuild) - reactNativeArchitectures().each { architecture -> - tasks.findByName("configureCMakeDebug[${architecture}]")?.configure { - dependsOn("preDebugBuild") - } - tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure { - dependsOn("preReleaseBuild") - } - } - } } splits { @@ -237,7 +135,6 @@ android { minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" <% if (e2eTestRunner === 'detox') { %> - // Detox-specific additions to pro-guard proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" <% } %> } @@ -261,70 +158,27 @@ android { } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - - //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:+" // From node_modules + <% if (e2eTestRunner === 'detox') { %> + androidTestImplementation('com.wix:detox:+') + implementation 'androidx.appcompat:appcompat:1.1.0' + <% } %> + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") implementation project(':react-native-config') - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" - - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { - exclude group:'com.facebook.fbjni' - } + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { - exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { - exclude group:'com.facebook.flipper' - } - - if (enableHermes) { - //noinspection GradleDynamicVersion - implementation("com.facebook.react:hermes-engine:+") { // From node_modules - exclude group:'com.facebook.fbjni' - } + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } - - <% if (e2eTestRunner === 'detox') { %> - androidTestImplementation(project(path: ":detox")) - <% } %> -} - -if (isNewArchitectureEnabled()) { - // If new architecture is enabled, we let you build RN from source - // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. - // This will be applied to all the imported transtitive dependency. - configurations.all { - resolutionStrategy.dependencySubstitution { - substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")) - .because("On New Architecture we're building React Native from source") - substitute(module("com.facebook.react:hermes-engine")) - .using(project(":ReactAndroid:hermes-engine")) - .because("On New Architecture we're building Hermes from source") - } - } -} - -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.implementation - into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) - -def isNewArchitectureEnabled() { - // To opt-in for the New Architecture, you can either: - // - Set `newArchEnabled` to true inside the `gradle.properties` file - // - Invoke gradle with `-newArchEnabled=true` - // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` - return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" -} diff --git a/packages/react-native/src/generators/application/files/app/android/app/build_defs.bzl b/packages/react-native/src/generators/application/files/app/android/app/build_defs.bzl deleted file mode 100644 index fff270f8d1d48..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/build_defs.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Helper definitions to glob .aar and .jar targets""" - -def create_aar_targets(aarfiles): - for aarfile in aarfiles: - name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] - lib_deps.append(":" + name) - android_prebuilt_aar( - name = name, - aar = aarfile, - ) - -def create_jar_targets(jarfiles): - for jarfile in jarfiles: - name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] - lib_deps.append(":" + name) - prebuilt_jar( - name = name, - binary_jar = jarfile, - ) diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template index 4cd0b0f9dcc63..d9fdbd959f949 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +++ b/packages/react-native/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template @@ -15,21 +15,15 @@ import androidx.test.rule.ActivityTestRule; @RunWith(AndroidJUnit4.class) @LargeTest public class DetoxTest { - // Replace 'MainActivity' with the value of android:name entry in - // in AndroidManifest.xml - @Rule + @Rule // (2) public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); @Test public void runDetoxTests() { - // This is optional - in case you've decided to integrate TestButler - // See https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#8-test-butler-support-optional - // TestButlerProbe.assertReadyIfInstalled(); - DetoxConfig detoxConfig = new DetoxConfig(); detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; - detoxConfig.rnContextLoadTimeoutSec = (com.<%= lowerCaseName %>.BuildConfig.DEBUG ? 180 : 60); + detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); Detox.runTests(mActivityRule, detoxConfig); } diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template index 943a5ba7b78ed..98ee2683e5296 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +++ b/packages/react-native/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template @@ -17,7 +17,6 @@ import com.facebook.flipper.plugins.inspector.DescriptorMapping; import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.react.ReactFlipperPlugin; import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; import com.facebook.react.ReactInstanceEventListener; import com.facebook.react.ReactInstanceManager; @@ -25,13 +24,16 @@ import com.facebook.react.bridge.ReactContext; import com.facebook.react.modules.network.NetworkingModule; import okhttp3.OkHttpClient; +/** + * Class responsible of loading Flipper inside your React Native application. This is the debug + * flavor of it. Here you can add your own plugins and customize the Flipper setup. + */ public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (FlipperUtils.shouldEnableFlipper(context)) { final FlipperClient client = AndroidFlipperClient.getInstance(context); client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new ReactFlipperPlugin()); client.addPlugin(new DatabasesFlipperPlugin(context)); client.addPlugin(new SharedPreferencesFlipperPlugin(context)); client.addPlugin(CrashReporterPlugin.getInstance()); diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template index 2a750fbcf2080..f9fabb2492ab1 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +++ b/packages/react-native/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template @@ -1,5 +1,4 @@ - + @@ -9,7 +8,8 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:networkSecurityConfig="@xml/network_security_config"> ; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; -import com.facebook.react.ReactRootView; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactActivityDelegate; public class MainActivity extends ReactActivity { @@ -16,33 +17,19 @@ public class MainActivity extends ReactActivity { } /** - * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and - * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer - * (Paper). + * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link + * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React + * (aka React 18) with two boolean flags. */ @Override protected ReactActivityDelegate createReactActivityDelegate() { - return new MainActivityDelegate(this, getMainComponentName()); - } - - public static class MainActivityDelegate extends ReactActivityDelegate { - public MainActivityDelegate(ReactActivity activity, String mainComponentName) { - super(activity, mainComponentName); - } - - @Override - protected ReactRootView createRootView() { - ReactRootView reactRootView = new ReactRootView(getContext()); - // If you opted-in for the New Architecture, we enable the Fabric Renderer. - reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED); - return reactRootView; - } - - @Override - protected boolean isConcurrentRootEnabled() { - // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18). - // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html - return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; - } + return new DefaultReactActivityDelegate( + this, + getMainComponentName(), + // If you opted-in for the New Architecture, we enable the Fabric Renderer. + DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled + // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). + DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled + ); } } diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template index 0592e9e692f87..e584b4422e7fd 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +++ b/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template @@ -1,23 +1,20 @@ package com.<%= lowerCaseName %>; import android.app.Application; -import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; -import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; -import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; -import com.facebook.react.config.ReactFeatureFlags; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader; -import com.<%= lowerCaseName %>.newarchitecture.MainApplicationReactNativeHost; -import java.lang.reflect.InvocationTargetException; import java.util.List; +import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = - new ReactNativeHost(this) { + new DefaultReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; @@ -36,57 +33,31 @@ public class MainApplication extends Application implements ReactApplication { protected String getJSMainModuleName() { return "<%= entryFile %>"; } - }; - private final ReactNativeHost mNewArchitectureNativeHost = - new MainApplicationReactNativeHost(this); + @Override + protected boolean isNewArchEnabled() { + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; + } + + @Override + protected Boolean isHermesEnabled() { + return BuildConfig.IS_HERMES_ENABLED; + } + }; @Override public ReactNativeHost getReactNativeHost() { - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - return mNewArchitectureNativeHost; - } else { - return mReactNativeHost; - } + return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); - // If you opted-in for the New Architecture, we enable the TurboModule system - ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - } - - /** - * Loads Flipper in React Native templates. Call this in the onCreate method with something like - * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - * - * @param context - * @param reactInstanceManager - */ - private static void initializeFlipper( - Context context, ReactInstanceManager reactInstanceManager) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("com.<%= lowerCaseName %>.ReactNativeFlipper"); - aClass - .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) - .invoke(null, context, reactInstanceManager); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + // If you opted-in for the New Architecture, we load the native entry point for this app. + DefaultNewArchitectureEntryPoint.load(); } + ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template deleted file mode 100644 index 8f74cc044d3b1..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template +++ /dev/null @@ -1,116 +0,0 @@ -package com.<%= lowerCaseName %>.newarchitecture; - -import android.app.Application; -import androidx.annotation.NonNull; -import com.facebook.react.PackageList; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.ReactNativeHost; -import com.facebook.react.ReactPackage; -import com.facebook.react.ReactPackageTurboModuleManagerDelegate; -import com.facebook.react.bridge.JSIModulePackage; -import com.facebook.react.bridge.JSIModuleProvider; -import com.facebook.react.bridge.JSIModuleSpec; -import com.facebook.react.bridge.JSIModuleType; -import com.facebook.react.bridge.JavaScriptContextHolder; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.UIManager; -import com.facebook.react.fabric.ComponentFactory; -import com.facebook.react.fabric.CoreComponentsRegistry; -import com.facebook.react.fabric.FabricJSIModuleProvider; -import com.facebook.react.fabric.ReactNativeConfig; -import com.facebook.react.uimanager.ViewManagerRegistry; -import com.<%= lowerCaseName %>.BuildConfig; -import com.<%= lowerCaseName %>.newarchitecture.components.MainComponentsRegistry; -import com.<%= lowerCaseName %>.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate; -import java.util.ArrayList; -import java.util.List; - -/** - * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both - * TurboModule delegates and the Fabric Renderer. - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -public class MainApplicationReactNativeHost extends ReactNativeHost { - public MainApplicationReactNativeHost(Application application) { - super(application); - } - - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } - - @Override - protected List getPackages() { - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new MyReactNativePackage()); - // TurboModules must also be loaded here providing a valid TurboReactPackage implementation: - // packages.add(new TurboReactPackage() { ... }); - // If you have custom Fabric Components, their ViewManagers should also be loaded here - // inside a ReactPackage. - return packages; - } - - @Override - protected String getJSMainModuleName() { - return "<%= entryFile %>"; - } - - @NonNull - @Override - protected ReactPackageTurboModuleManagerDelegate.Builder - getReactPackageTurboModuleManagerDelegateBuilder() { - // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary - // for the new architecture and to use TurboModules correctly. - return new MainApplicationTurboModuleManagerDelegate.Builder(); - } - - @Override - protected JSIModulePackage getJSIModulePackage() { - return new JSIModulePackage() { - @Override - public List getJSIModules( - final ReactApplicationContext reactApplicationContext, - final JavaScriptContextHolder jsContext) { - final List specs = new ArrayList<>(); - - // Here we provide a new JSIModuleSpec that will be responsible of providing the - // custom Fabric Components. - specs.add( - new JSIModuleSpec() { - @Override - public JSIModuleType getJSIModuleType() { - return JSIModuleType.UIManager; - } - - @Override - public JSIModuleProvider getJSIModuleProvider() { - final ComponentFactory componentFactory = new ComponentFactory(); - CoreComponentsRegistry.register(componentFactory); - - // Here we register a Components Registry. - // The one that is generated with the template contains no components - // and just provides you the one from React Native core. - MainComponentsRegistry.register(componentFactory); - - final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); - - ViewManagerRegistry viewManagerRegistry = - new ViewManagerRegistry( - reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)); - - return new FabricJSIModuleProvider( - reactApplicationContext, - componentFactory, - ReactNativeConfig.DEFAULT_CONFIG, - viewManagerRegistry); - } - }); - return specs; - } - }; - } -} diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template deleted file mode 100644 index 4c896506cf071..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template +++ /dev/null @@ -1,36 +0,0 @@ -package com.<%= lowerCaseName %>.newarchitecture.components; - -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.fabric.ComponentFactory; -import com.facebook.soloader.SoLoader; - -/** - * Class responsible to load the custom Fabric Components. This class has native methods and needs a - * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ - * folder for you). - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -@DoNotStrip -public class MainComponentsRegistry { - static { - SoLoader.loadLibrary("fabricjni"); - } - - @DoNotStrip private final HybridData mHybridData; - - @DoNotStrip - private native HybridData initHybrid(ComponentFactory componentFactory); - - @DoNotStrip - private MainComponentsRegistry(ComponentFactory componentFactory) { - mHybridData = initHybrid(componentFactory); - } - - @DoNotStrip - public static MainComponentsRegistry register(ComponentFactory componentFactory) { - return new MainComponentsRegistry(componentFactory); - } -} diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template deleted file mode 100644 index c16d98218a20f..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template +++ /dev/null @@ -1,48 +0,0 @@ -package com.<%= lowerCaseName %>.newarchitecture.modules; - -import com.facebook.jni.HybridData; -import com.facebook.react.ReactPackage; -import com.facebook.react.ReactPackageTurboModuleManagerDelegate; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.soloader.SoLoader; -import java.util.List; - -/** - * Class responsible to load the TurboModules. This class has native methods and needs a - * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ - * folder for you). - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -public class MainApplicationTurboModuleManagerDelegate - extends ReactPackageTurboModuleManagerDelegate { - - private static volatile boolean sIsSoLibraryLoaded; - - protected MainApplicationTurboModuleManagerDelegate( - ReactApplicationContext reactApplicationContext, List packages) { - super(reactApplicationContext, packages); - } - - protected native HybridData initHybrid(); - - native boolean canCreateTurboModule(String moduleName); - - public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder { - protected MainApplicationTurboModuleManagerDelegate build( - ReactApplicationContext context, List packages) { - return new MainApplicationTurboModuleManagerDelegate(context, packages); - } - } - - @Override - protected synchronized void maybeLoadOtherSoLibraries() { - if (!sIsSoLibraryLoaded) { - // If you change the name of your application .so file in the Android.mk file, - // make sure you update the name here as well. - SoLoader.loadLibrary("<%= lowerCaseName %>_appmodules"); - sIsSoLibraryLoaded = true; - } - } -} diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/CMakeLists.txt.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/CMakeLists.txt.template deleted file mode 100644 index 37d2e36d113cf..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/CMakeLists.txt.template +++ /dev/null @@ -1,6 +0,0 @@ - -cmake_minimum_required(VERSION 3.13) -# Define the library name here. -project(<%= lowerCaseName %>_appmodules) -# This file includes all the necessary to let you build your application with the New Architecture. -include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake) diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp deleted file mode 100644 index 26162dd872338..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "MainApplicationModuleProvider.h" - -#include -#include - -namespace facebook { -namespace react { - -std::shared_ptr MainApplicationModuleProvider( - const std::string &moduleName, - const JavaTurboModule::InitParams ¶ms) { - // Here you can provide your own module provider for TurboModules coming from - // either your application or from external libraries. The approach to follow - // is similar to the following (for a library called `samplelibrary`: - // - // auto module = samplelibrary_ModuleProvider(moduleName, params); - // if (module != nullptr) { - // return module; - // } - // return rncore_ModuleProvider(moduleName, params); - - // Module providers autolinked by RN CLI - auto rncli_module = rncli_ModuleProvider(moduleName, params); - if (rncli_module != nullptr) { - return rncli_module; - } - - return rncore_ModuleProvider(moduleName, params); -} - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h deleted file mode 100644 index b38ccf53fd49b..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include - -#include - -namespace facebook { -namespace react { - -std::shared_ptr MainApplicationModuleProvider( - const std::string &moduleName, - const JavaTurboModule::InitParams ¶ms); - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp deleted file mode 100644 index 5fd688c509d17..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "MainApplicationTurboModuleManagerDelegate.h" -#include "MainApplicationModuleProvider.h" - -namespace facebook { -namespace react { - -jni::local_ref -MainApplicationTurboModuleManagerDelegate::initHybrid( - jni::alias_ref) { - return makeCxxInstance(); -} - -void MainApplicationTurboModuleManagerDelegate::registerNatives() { - registerHybrid({ - makeNativeMethod( - "initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid), - makeNativeMethod( - "canCreateTurboModule", - MainApplicationTurboModuleManagerDelegate::canCreateTurboModule), - }); -} - -std::shared_ptr -MainApplicationTurboModuleManagerDelegate::getTurboModule( - const std::string &name, - const std::shared_ptr &jsInvoker) { - // Not implemented yet: provide pure-C++ NativeModules here. - return nullptr; -} - -std::shared_ptr -MainApplicationTurboModuleManagerDelegate::getTurboModule( - const std::string &name, - const JavaTurboModule::InitParams ¶ms) { - return MainApplicationModuleProvider(name, params); -} - -bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule( - const std::string &name) { - return getTurboModule(name, nullptr) != nullptr || - getTurboModule(name, {.moduleName = name}) != nullptr; -} - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template deleted file mode 100644 index f0571580140e3..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -#include -#include - -namespace facebook { -namespace react { - -class MainApplicationTurboModuleManagerDelegate - : public jni::HybridClass< - MainApplicationTurboModuleManagerDelegate, - TurboModuleManagerDelegate> { - public: - // Adapt it to the package you used for your Java class. - static constexpr auto kJavaDescriptor = - "Lcom/<%= lowerCaseName %>/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;"; - - static jni::local_ref initHybrid(jni::alias_ref); - - static void registerNatives(); - - std::shared_ptr getTurboModule( - const std::string &name, - const std::shared_ptr &jsInvoker) override; - std::shared_ptr getTurboModule( - const std::string &name, - const JavaTurboModule::InitParams ¶ms) override; - - /** - * Test-only method. Allows user to verify whether a TurboModule can be - * created by instances of this class. - */ - bool canCreateTurboModule(const std::string &name); -}; - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp deleted file mode 100644 index 54f598a486ade..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "MainComponentsRegistry.h" - -#include -#include -#include -#include -#include - -namespace facebook { -namespace react { - -MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {} - -std::shared_ptr -MainComponentsRegistry::sharedProviderRegistry() { - auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); - - // Autolinked providers registered by RN CLI - rncli_registerProviders(providerRegistry); - - // Custom Fabric Components go here. You can register custom - // components coming from your App or from 3rd party libraries here. - // - // providerRegistry->add(concreteComponentDescriptorProvider< - // AocViewerComponentDescriptor>()); - return providerRegistry; -} - -jni::local_ref -MainComponentsRegistry::initHybrid( - jni::alias_ref, - ComponentFactory *delegate) { - auto instance = makeCxxInstance(delegate); - - auto buildRegistryFunction = - [](EventDispatcher::Weak const &eventDispatcher, - ContextContainer::Shared const &contextContainer) - -> ComponentDescriptorRegistry::Shared { - auto registry = MainComponentsRegistry::sharedProviderRegistry() - ->createComponentDescriptorRegistry( - {eventDispatcher, contextContainer}); - - auto mutableRegistry = - std::const_pointer_cast(registry); - - mutableRegistry->setFallbackComponentDescriptor( - std::make_shared( - ComponentDescriptorParameters{ - eventDispatcher, contextContainer, nullptr})); - - return registry; - }; - - delegate->buildRegistryFunction = buildRegistryFunction; - return instance; -} - -void MainComponentsRegistry::registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid), - }); -} - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template deleted file mode 100644 index f3af506cb7589..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace facebook { -namespace react { - -class MainComponentsRegistry - : public facebook::jni::HybridClass { - public: - // Adapt it to the package you used for your Java class. - constexpr static auto kJavaDescriptor = - "Lcom/<%= lowerCaseName %>/newarchitecture/components/MainComponentsRegistry;"; - - static void registerNatives(); - - MainComponentsRegistry(ComponentFactory *delegate); - - private: - static std::shared_ptr - sharedProviderRegistry(); - - static jni::local_ref initHybrid( - jni::alias_ref, - ComponentFactory *delegate); -}; - -} // namespace react -} // namespace facebook diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp b/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp deleted file mode 100644 index c569b6e865dab..0000000000000 --- a/packages/react-native/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "MainApplicationTurboModuleManagerDelegate.h" -#include "MainComponentsRegistry.h" - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { - return facebook::jni::initialize(vm, [] { - facebook::react::MainApplicationTurboModuleManagerDelegate:: - registerNatives(); - facebook::react::MainComponentsRegistry::registerNatives(); - }); -} diff --git a/packages/react-native/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template b/packages/react-native/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template new file mode 100644 index 0000000000000..1b6b639092c35 --- /dev/null +++ b/packages/react-native/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template @@ -0,0 +1,20 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + *

This source code is licensed under the MIT license found in the LICENSE file in the root + * directory of this source tree. + */ +package com.<%= lowerCaseName %>; + +import android.content.Context; +import com.facebook.react.ReactInstanceManager; + +/** + * Class responsible of loading Flipper inside your React Native application. This is the release + * flavor of it so it's empty as we don't want to load Flipper. + */ +public class ReactNativeFlipper { + public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { + // Do nothing as we don't want to initialize Flipper on Release. + } +} diff --git a/packages/react-native/src/generators/application/files/app/android/build.gradle.template b/packages/react-native/src/generators/application/files/app/android/build.gradle.template index 61af99b6f96bb..8c76706aa4ff5 100644 --- a/packages/react-native/src/generators/application/files/app/android/build.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/build.gradle.template @@ -2,56 +2,33 @@ buildscript { ext { - buildToolsVersion = "31.0.0" + buildToolsVersion = "33.0.0" minSdkVersion = 21 - compileSdkVersion = 31 - targetSdkVersion = 31 - <% if (e2eTestRunner === 'detox') { %> - kotlinVersion = '1.7.10' - <% } %> + compileSdkVersion = 33 + targetSdkVersion = 33 + kotlinVersion = "1.7.21" - if (System.properties['os.arch'] == "aarch64") { - // For M1 Users we need to use the NDK 24 which added support for aarch64 - ndkVersion = "24.0.8215888" - } else { - // Otherwise we default to the side-by-side NDK version from AGP. - ndkVersion = "21.4.7075529" - } + // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. + ndkVersion = "23.1.7779620" } repositories { google() mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.2.1") + classpath("com.android.tools.build:gradle:7.3.1") classpath("com.facebook.react:react-native-gradle-plugin") - classpath("de.undercouch:gradle-download-task:5.0.1") - <% if (e2eTestRunner === 'detox') { %> - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - <% } %> - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") } } allprojects { repositories { + <% if (e2eTestRunner === 'detox') { %> maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url("$rootDir/../node_modules/react-native/android") - } - maven { - // Android JSC is installed from npm - url("$rootDir/../node_modules/jsc-android/dist") - } - mavenCentral { - // We don't want to fetch react-native from Maven Central as there are - // older versions over there. - content { - excludeGroup "com.facebook.react" - } + // https://wix.github.io/Detox/docs/introduction/project-setup + url("$rootDir/../node_modules/detox/Detox-android") } - google() - maven { url 'https://www.jitpack.io' } + <% } %> } -} +} \ No newline at end of file diff --git a/packages/react-native/src/generators/application/files/app/android/gradle.properties b/packages/react-native/src/generators/application/files/app/android/gradle.properties index fa4feae5f1902..e4af465e8a185 100644 --- a/packages/react-native/src/generators/application/files/app/android/gradle.properties +++ b/packages/react-native/src/generators/application/files/app/android/gradle.properties @@ -38,3 +38,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # to write custom TurboModules/Fabric components OR use libraries that # are providing them. newArchEnabled=false + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true diff --git a/packages/react-native/src/generators/application/files/app/android/settings.gradle.template b/packages/react-native/src/generators/application/files/app/android/settings.gradle.template index 8fcce31e02357..6fa18cefb0730 100644 --- a/packages/react-native/src/generators/application/files/app/android/settings.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/settings.gradle.template @@ -1,22 +1,7 @@ rootProject.name = '<%= className %>' include ':react-native-config' -project(':react-native-config').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-config/android') - -<% if (e2eTestRunner === 'detox') { %> -include ':detox' -project(':detox').projectDir = new File(rootProject.projectDir, '../node_modules/detox/android/detox') -<% } %> - -apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); -applyNativeModulesSettingsGradle(settings) - +project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') +apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' includeBuild('../node_modules/react-native-gradle-plugin') - -if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { - include(":ReactAndroid") - project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') - include(":ReactAndroid:hermes-engine") - project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') -} diff --git a/packages/react-native/src/generators/application/files/app/ios/Podfile.template b/packages/react-native/src/generators/application/files/app/ios/Podfile.template index 1fb4f468a0532..0d20002ed3865 100644 --- a/packages/react-native/src/generators/application/files/app/ios/Podfile.template +++ b/packages/react-native/src/generators/application/files/app/ios/Podfile.template @@ -2,8 +2,25 @@ require_relative '<%= offsetFromRoot %>../node_modules/react-native/scripts/reac require_relative '<%= offsetFromRoot %>../node_modules/@react-native-community/cli-platform-ios/native_modules' require_relative '<%= offsetFromRoot %>../node_modules/@nrwl/react-native/nx_post_install' -platform :ios, '12.4' -install! 'cocoapods', :deterministic_uuids => false +platform :ios, min_ios_version_supported +prepare_react_native_project! + +# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. +# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded +# +# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` +# ```js +# module.exports = { +# dependencies: { +# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), +# ``` +flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled + +linkage = ENV['USE_FRAMEWORKS'] +if linkage != nil + Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green + use_frameworks! :linkage => linkage.to_sym +end target '<%= className %>' do config = use_native_modules! @@ -16,14 +33,13 @@ target '<%= className %>' do # Hermes is now enabled by default. Disable by setting this flag to false. # Upcoming versions of React Native may rely on get_default_flags(), but # we make it explicit here to aid in the React Native upgrade process. - # disabled hermes due to issue https://github.com/facebook/react-native/issues/34599 https://github.com/facebook/react-native/issues/34608 - :hermes_enabled => false, + :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. - :flipper_configuration => FlipperConfiguration.enabled, + :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template b/packages/react-native/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template index 480e31e88ada9..e1562dda2444f 100644 --- a/packages/react-native/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +++ b/packages/react-native/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template @@ -492,6 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -517,6 +518,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -562,7 +564,7 @@ COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -633,7 +635,7 @@ COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d68d..0000000000000 --- a/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/contents.xcworkspacedata b/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/contents.xcworkspacedata new file mode 100644 index 0000000000000..b711c275d9110 --- /dev/null +++ b/packages/react-native/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.h b/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.h index ef1de86a2a80a..5d2808256ca07 100644 --- a/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.h +++ b/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.h @@ -1,8 +1,6 @@ -#import +#import #import -@interface AppDelegate : UIResponder - -@property (nonatomic, strong) UIWindow *window; +@interface AppDelegate : RCTAppDelegate @end diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template b/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template index 3ffcb6f42b2a7..7c42f8c5adab6 100644 --- a/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +++ b/packages/react-native/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template @@ -1,85 +1,17 @@ #import "AppDelegate.h" -#import #import -#import - -#import - -#if RCT_NEW_ARCH_ENABLED -#import -#import -#import -#import -#import -#import - -#import - -static NSString *const kRNConcurrentRoot = @"concurrentRoot"; - -@interface AppDelegate () { - RCTTurboModuleManager *_turboModuleManager; - RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; - std::shared_ptr _reactNativeConfig; - facebook::react::ContextContainer::Shared _contextContainer; -} -@end -#endif @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - RCTAppSetupPrepareApp(application); - - RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - -#if RCT_NEW_ARCH_ENABLED - _contextContainer = std::make_shared(); - _reactNativeConfig = std::make_shared(); - _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); - _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; - bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; -#endif - - NSDictionary *initProps = [self prepareInitialProps]; - UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"<%= className %>", initProps); - - if (@available(iOS 13.0, *)) { - rootView.backgroundColor = [UIColor systemBackgroundColor]; - } else { - rootView.backgroundColor = [UIColor whiteColor]; - } + self.moduleName = @"<%= className %>"; + // You can add your custom initial props in the dictionary below. + // They will be passed down to the ViewController used by React Native. + self.initialProps = @{}; - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [UIViewController new]; - rootViewController.view = rootView; - self.window.rootViewController = rootViewController; - [self.window makeKeyAndVisible]; - return YES; -} - -/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. -/// -/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html -/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). -/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`. -- (BOOL)concurrentRootEnabled -{ - // Switch this bool to turn on and off the concurrent root - return true; -} - -- (NSDictionary *)prepareInitialProps -{ - NSMutableDictionary *initProps = [NSMutableDictionary new]; - -#ifdef RCT_NEW_ARCH_ENABLED - initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); -#endif - - return initProps; + return [super application:application didFinishLaunchingWithOptions:launchOptions]; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge @@ -91,43 +23,14 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; #endif } -#if RCT_NEW_ARCH_ENABLED - -#pragma mark - RCTCxxBridgeDelegate - -- (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge -{ - _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge - delegate:self - jsInvoker:bridge.jsCallInvoker]; - return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); -} - -#pragma mark RCTTurboModuleManagerDelegate - -- (Class)getModuleClassFromName:(const char *)name -{ - return RCTCoreModulesClassProvider(name); -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - jsInvoker:(std::shared_ptr)jsInvoker -{ - return nullptr; -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - initParams: - (const facebook::react::ObjCTurboModule::InitParams &)params -{ - return nullptr; -} - -- (id)getModuleInstanceFromClass:(Class)moduleClass +/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. +/// +/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html +/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). +/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`. +- (BOOL)concurrentRootEnabled { - return RCTAppSetupDefaultModuleFromClass(moduleClass); + return true; } -#endif - @end diff --git a/packages/react-native/src/generators/application/files/app/ios/__className__/Info.plist.template b/packages/react-native/src/generators/application/files/app/ios/__className__/Info.plist.template index f943833b04fcd..27af648595f5e 100644 --- a/packages/react-native/src/generators/application/files/app/ios/__className__/Info.plist.template +++ b/packages/react-native/src/generators/application/files/app/ios/__className__/Info.plist.template @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion - 1 + $(CURRENT_PROJECT_VERSION) LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/packages/react-native/src/generators/init/init.ts b/packages/react-native/src/generators/init/init.ts index fcce186663911..b75e6e0cf9124 100644 --- a/packages/react-native/src/generators/init/init.ts +++ b/packages/react-native/src/generators/init/init.ts @@ -10,9 +10,9 @@ import { import { Schema } from './schema'; import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; import { addBabelInputs } from '@nrwl/js/src/utils/add-babel-inputs'; - import { jestInitGenerator } from '@nrwl/jest'; import { detoxInitGenerator } from '@nrwl/detox'; +import { babelPresetReactVersion } from '@nrwl/react/src/utils/versions'; import { babelRuntimeVersion, @@ -101,6 +101,7 @@ export function updateDependencies(host: Tree) { 'react-native-config': reactNativeConfigVersion, '@react-native-async-storage/async-storage': reactNativeAsyncStorageAsyncStorageVersion, + '@babel/preset-react': babelPresetReactVersion, ...(isPnpm ? { 'metro-config': metroVersion, // metro-config is used by metro.config.js diff --git a/packages/react-native/src/generators/init/lib/gitignore-entries.ts b/packages/react-native/src/generators/init/lib/gitignore-entries.ts index bb6d828f332ce..ad505f00eb57a 100644 --- a/packages/react-native/src/generators/init/lib/gitignore-entries.ts +++ b/packages/react-native/src/generators/init/lib/gitignore-entries.ts @@ -1,6 +1,11 @@ +// template from https://github.com/facebook/react-native/blob/main/template/_gitignore export const gitIgnoreEntriesForReactNative = ` # React Native +# OSX +# +.DS_Store + # Xcode # build/ @@ -19,7 +24,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -**/ios/.xcode.env.local +ios/.xcode.env.local # Android/IntelliJ # @@ -29,20 +34,16 @@ build/ local.properties *.iml *.hprof +.cxx/ +*.keystore +!debug.keystore # node.js # -.yarn/ node_modules/ npm-debug.log yarn-error.log -# BUCK -buck-out/ -\.buckd/ -*.keystore -!debug.keystore - # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the @@ -59,6 +60,12 @@ buck-out/ *.jsbundle # Ruby / CocoaPods -**/ios/Pods/ -**/vendor/bundle/ +/ios/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage `; diff --git a/packages/react-native/src/generators/upgrade-native/upgrade-native.ts b/packages/react-native/src/generators/upgrade-native/upgrade-native.ts index 4bd20c02ed825..fe883de1349e5 100644 --- a/packages/react-native/src/generators/upgrade-native/upgrade-native.ts +++ b/packages/react-native/src/generators/upgrade-native/upgrade-native.ts @@ -3,7 +3,6 @@ * It would replace the Android and iOS folder entirely. */ import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; -import { UpgradeNativeConfigureSchema } from './schema'; import { convertNxGenerator, Tree, @@ -11,12 +10,13 @@ import { GeneratorCallback, readProjectConfiguration, } from '@nrwl/devkit'; -import { join } from 'path'; -import { createNativeFiles } from './lib/create-native-files'; -import { existsSync, removeSync } from 'fs-extra'; +import { existsSync } from 'fs'; import { runPodInstall } from '../../utils/pod-install-task'; -import { runChmod } from '../../utils/chmod-task'; +import { chmodAndroidGradlewFilesTask } from '../../utils/chmod-android-gradle-files'; + +import { createNativeFiles } from './lib/create-native-files'; +import { UpgradeNativeConfigureSchema } from './schema'; export async function reactNativeUpgradeNativeGenerator( host: Tree, @@ -44,17 +44,9 @@ export async function reactNativeUpgradeNativeGenerator( createNativeFiles(host, schema, appProjectRoot); const podInstallTask = runPodInstall(iosProjectRoot, schema.install); - const chmodTaskGradlew = runChmod(join(androidProjectRoot, 'gradlew'), 0o775); - const chmodTaskGradlewBat = runChmod( - join(androidProjectRoot, 'gradlew.bat'), - 0o775 - ); + const chmodTaskGradlew = chmodAndroidGradlewFilesTask(androidProjectRoot); - return runTasksInSerial( - podInstallTask, - chmodTaskGradlew, - chmodTaskGradlewBat - ); + return runTasksInSerial(podInstallTask, chmodTaskGradlew); } export default reactNativeUpgradeNativeGenerator; diff --git a/packages/react-native/src/utils/chmod-android-gradle-files.ts b/packages/react-native/src/utils/chmod-android-gradle-files.ts new file mode 100644 index 0000000000000..0bbd1066dd2c4 --- /dev/null +++ b/packages/react-native/src/utils/chmod-android-gradle-files.ts @@ -0,0 +1,21 @@ +import { GeneratorCallback, logger } from '@nrwl/devkit'; +import { chmodSync } from 'fs'; +import { join } from 'path'; + +export function chmodAndroidGradlewFiles(androidFolder: string) { + chmodSync(join(androidFolder, 'gradlew'), 0o775); + chmodSync(join(androidFolder, 'gradlew.bat'), 0o775); +} + +export function chmodAndroidGradlewFilesTask( + androidFolder: string +): GeneratorCallback { + return () => { + logger.info(`chmod android gradlew files under ${androidFolder}`); + try { + chmodAndroidGradlewFiles(androidFolder); + } catch { + throw new Error(`chmod failed gradlew file under ${androidFolder}`); + } + }; +} diff --git a/packages/react-native/src/utils/chmod-task.ts b/packages/react-native/src/utils/chmod-task.ts deleted file mode 100644 index a71d8b89f59c4..0000000000000 --- a/packages/react-native/src/utils/chmod-task.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { chmodSync } from 'fs'; -import { GeneratorCallback, logger } from '@nrwl/devkit'; - -export function runChmod( - file: string, - mode: number | string -): GeneratorCallback { - return () => { - logger.info(`chmod ${mode} ${file}`); - try { - chmodSync(file, mode); - } catch { - throw new Error(`chmod failed for ${file}`); - } - }; -} diff --git a/packages/react-native/src/utils/versions.ts b/packages/react-native/src/utils/versions.ts index 728a1b17e7b12..0ff0f41c9159a 100644 --- a/packages/react-native/src/utils/versions.ts +++ b/packages/react-native/src/utils/versions.ts @@ -1,30 +1,30 @@ export const nxVersion = require('../../package.json').version; -export const reactNativeVersion = '0.70.6'; -export const typesReactNativeVersion = '0.70.6'; +export const reactNativeVersion = '0.71.1'; +export const typesReactNativeVersion = '0.71.0'; -export const typesNodeVersion = '16.11.7'; +export const typesNodeVersion = '18.11.18'; -export const metroVersion = '0.73.3'; +export const metroVersion = '0.74.1'; -export const reactNativeCommunityCli = '9.3.2'; -export const reactNativeCommunityCliIos = '9.3.0'; -export const reactNativeCommunityCliAndroid = '9.3.1'; +export const reactNativeCommunityCli = '10.1.3'; +export const reactNativeCommunityCliIos = '10.1.1'; +export const reactNativeCommunityCliAndroid = '10.1.3'; -export const reactVersion = '18.1.0'; -export const reactDomVersion = '18.1.0'; -export const reactTestRendererVersion = '18.1.0'; +export const reactVersion = '18.2.0'; +export const reactDomVersion = '18.2.0'; +export const reactTestRendererVersion = '18.2.0'; export const typesReactVersion = '18.0.26'; -export const reactNativeConfigVersion = '1.4.11'; +export const reactNativeConfigVersion = '1.4.12'; export const reactNativeAsyncStorageAsyncStorageVersion = '1.17.11'; export const testingLibraryReactNativeVersion = '11.5.0'; -export const testingLibraryJestNativeVersion = '5.3.0'; +export const testingLibraryJestNativeVersion = '5.4.1'; export const jestReactNativeVersion = '18.0.0'; export const reactNativeSvgTransformerVersion = '1.0.0'; -export const reactNativeSvgVersion = '13.6.0'; +export const reactNativeSvgVersion = '13.7.0'; -export const babelRuntimeVersion = '7.20.1'; +export const babelRuntimeVersion = '7.20.7'; diff --git a/yarn.lock b/yarn.lock index 750c73081db6d..50dbc204eb005 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17522,10 +17522,10 @@ methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== -metro-resolver@^0.73.3: - version "0.73.3" - resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.73.3.tgz#dc21ca03c8aeb0bc05fe4e8c318791e213bde9d7" - integrity sha512-XbiZ22MaFFchaErNfqeW9ZPPRpiQEIylhtlja9/5QzNgAcAWbfIGY0Ok39XyVyWjX4Ab8YAwQUeCqyO48ojzZQ== +metro-resolver@^0.74.1: + version "0.74.1" + resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.74.1.tgz#62c1313bf8ff02b86d6cdd9294306d718970caac" + integrity sha512-1Ju7bvUnmy1lmsYwhujWsP4qxBVfVF7CkKiUCRolUbyZzGgymyVGXVN5yEnbXXNHgBAOlr4+2KKYjoXzhXBo4g== dependencies: absolute-path "^0.0.0"