From d337af875c7229e38d926f81c21308fc0dd19b32 Mon Sep 17 00:00:00 2001
From: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
Date: Tue, 21 Mar 2023 16:28:11 +0100
Subject: [PATCH] fix: declare support for `react-native` 0.72
---
.github/workflows/build.yml | 1 +
.github/workflows/rnx-build.yml | 8 ++---
Gemfile.lock | 8 ++---
android/app/build.gradle | 2 ++
android/dependencies.gradle | 1 +
android/test-app-util.gradle | 27 ++++++++++++++
example/android/gradle.properties | 2 +-
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
example/package.json | 2 +-
package.json | 2 +-
scripts/android-nightly.patch | 36 -------------------
scripts/disable-safe-area-context.patch | 36 +++++++++++++++++++
scripts/test-matrix.sh | 3 +-
yarn.lock | 4 +--
14 files changed, 83 insertions(+), 51 deletions(-)
create mode 100644 scripts/disable-safe-area-context.patch
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fc41a2f982..9f27553e68 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -235,6 +235,7 @@ jobs:
- name: Set up react-native@nightly
if: ${{ github.event_name == 'schedule' }}
run: |
+ git apply scripts/disable-safe-area-context.patch
git apply scripts/android-nightly.patch
npm run set-react-version -- nightly
shell: bash
diff --git a/.github/workflows/rnx-build.yml b/.github/workflows/rnx-build.yml
index 80b08619b2..16e91652a1 100644
--- a/.github/workflows/rnx-build.yml
+++ b/.github/workflows/rnx-build.yml
@@ -36,7 +36,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up toolchain
- uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@2.3.19
+ uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@trunk
with:
platform: android
cache-npm-dependencies: ${{ github.event.inputs.packageManager }}
@@ -68,7 +68,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up toolchain
- uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@2.3.19
+ uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@trunk
with:
platform: ios
project-root: ${{ github.event.inputs.projectRoot }}
@@ -122,7 +122,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up toolchain
- uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@2.3.19
+ uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@trunk
with:
platform: macos
project-root: ${{ github.event.inputs.projectRoot }}
@@ -156,7 +156,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up toolchain
- uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@2.3.19
+ uses: microsoft/react-native-test-app/.github/actions/setup-toolchain@trunk
with:
platform: windows
cache-npm-dependencies: ${{ github.event.inputs.packageManager }}
diff --git a/Gemfile.lock b/Gemfile.lock
index 1f7a2d49af..3322f613af 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
- CFPropertyList (3.0.5)
+ CFPropertyList (3.0.6)
rexml
ast (2.4.2)
atomos (0.1.3)
@@ -10,11 +10,11 @@ GEM
json (2.6.3)
minitest (5.18.0)
nanaimo (0.3.0)
- parallel (1.22.1)
+ parallel (1.23.0)
parser (3.2.2.0)
ast (~> 2.4.1)
rainbow (3.1.1)
- regexp_parser (2.7.0)
+ regexp_parser (2.8.0)
rexml (3.2.5)
rubocop (1.50.2)
json (~> 2.3)
@@ -50,4 +50,4 @@ DEPENDENCIES
xcodeproj
BUNDLED WITH
- 2.3.11
+ 2.4.10
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 465dc03df6..924dbc2f81 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -10,6 +10,8 @@ plugins {
id("org.jetbrains.kotlin.android")
}
+checkEnvironment()
+
def reactNativePath = file(findNodeModulesPath("react-native", rootDir))
if (autodetectReactNativeVersion || enableNewArchitecture) {
diff --git a/android/dependencies.gradle b/android/dependencies.gradle
index 7bb797f517..7f4f2ef18c 100644
--- a/android/dependencies.gradle
+++ b/android/dependencies.gradle
@@ -5,6 +5,7 @@ static String getKspVersion(String kotlinVersion) {
return [
// Run `scripts/update-ksp-versions.mjs` to update this list
// update-ksp-versions start
+ "1.8.20-1.0.11",
"1.8.10-1.0.9",
"1.8.0-1.0.9",
"1.7.22-1.0.8",
diff --git a/android/test-app-util.gradle b/android/test-app-util.gradle
index ab7c81cbc9..337e3de154 100644
--- a/android/test-app-util.gradle
+++ b/android/test-app-util.gradle
@@ -6,6 +6,33 @@ import java.security.MessageDigest
ext.manifest = null
+ext.checkEnvironment = {
+ def (major, minor, patch) = gradle.gradleVersion.findAll(/\d+/)
+ def gradleVersion = (major as int) * 10000 + (minor as int) * 100 + (patch as int)
+ if (reactNativeVersion > 0 && reactNativeVersion < 7200) {
+ if (gradleVersion < 70501 || gradleVersion >= 80000) {
+ logger.warn([
+ "Latest Gradle 7.x is required for current React Native version. ",
+ "Run the following command in the 'android' folder to install a supported version: ",
+ "./gradlew wrapper --gradle-version=7.6.1",
+ ].join(""))
+ }
+ } else {
+ // Gradle 7.5+ seems to be working with 0.72 so we will only recommend a
+ // newer version if it's older.
+ if (gradleVersion < 70501) {
+ logger.warn([
+ "Latest Gradle 8.0.x is recommended for React Native 0.72 and higher. ",
+ "Run the following command in the 'android' folder to install a supported version: ",
+ "./gradlew wrapper --gradle-version=8.0.2",
+ "\n\n",
+ "If you still need to work with older versions of React Native, ",
+ "Gradle 7.5.1+ should still work."
+ ].join(""))
+ }
+ }
+}
+
ext.findFile = { fileName ->
def currentDirPath = rootDir == null ? null : rootDir.toString()
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 4dcd112275..a951019e8f 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -29,7 +29,7 @@ android.enableJetifier=true
# Version of Flipper to use with React Native. Default value is whatever React
# Native defaults to. To disable Flipper, set it to `false`.
-#FLIPPER_VERSION=0.125.0
+#FLIPPER_VERSION=0.182.0
# Enable Fabric at runtime.
#USE_FABRIC=1
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index ae04661ee7..774fae8767 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/example/package.json b/example/package.json
index 785a943774..21e04245d7 100644
--- a/example/package.json
+++ b/example/package.json
@@ -18,7 +18,7 @@
},
"peerDependencies": {
"react": "~17.0.1 || ~18.0.0 || ~18.1.0 || ~18.2.0",
- "react-native": "^0.0.0-0 || 0.64 - 0.71 || 1000.0.0",
+ "react-native": "^0.0.0-0 || 0.64 - 0.72 || 1000.0.0",
"react-native-macos": "^0.0.0-0 || 0.64 || 0.66 || 0.68 || 0.71",
"react-native-windows": "^0.0.0-0 || 0.64 - 0.71"
},
diff --git a/package.json b/package.json
index e21e14a519..38d2db1aa6 100644
--- a/package.json
+++ b/package.json
@@ -95,7 +95,7 @@
"@react-native-community/cli-platform-ios": ">=5.0",
"mustache": "^4.0.0",
"react": "~17.0.1 || ~18.0.0 || ~18.1.0 || ~18.2.0",
- "react-native": "^0.0.0-0 || 0.64 - 0.71 || 1000.0.0",
+ "react-native": "^0.0.0-0 || 0.64 - 0.72 || 1000.0.0",
"react-native-macos": "^0.0.0-0 || 0.64 || 0.66 || 0.68 || 0.71",
"react-native-windows": "^0.0.0-0 || 0.64 - 0.71"
},
diff --git a/scripts/android-nightly.patch b/scripts/android-nightly.patch
index 1159cadc33..b29709c125 100644
--- a/scripts/android-nightly.patch
+++ b/scripts/android-nightly.patch
@@ -1,39 +1,3 @@
-diff --git a/example/App.js b/example/App.js
-index c9cd14d..f63758d 100644
---- a/example/App.js
-+++ b/example/App.js
-@@ -2,6 +2,7 @@
- import React, { useCallback, useMemo, useState } from "react";
- import {
- NativeModules,
-+ SafeAreaView,
- ScrollView,
- StatusBar,
- StyleSheet,
-@@ -10,7 +11,6 @@ import {
- useColorScheme,
- View,
- } from "react-native";
--import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
- // @ts-expect-error
- import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
- import { Colors, Header } from "react-native/Libraries/NewAppScreen";
-@@ -169,7 +169,6 @@ const App = ({ concurrentRoot }) => {
- );
-
- return (
--
-
-
- {
-
-
-
--
- );
- };
-
diff --git a/example/package.json b/example/package.json
index 9c2e1aa..94fb85e 100644
--- a/example/package.json
diff --git a/scripts/disable-safe-area-context.patch b/scripts/disable-safe-area-context.patch
new file mode 100644
index 0000000000..2403be5ceb
--- /dev/null
+++ b/scripts/disable-safe-area-context.patch
@@ -0,0 +1,36 @@
+diff --git a/example/App.js b/example/App.js
+index c9cd14d..f63758d 100644
+--- a/example/App.js
++++ b/example/App.js
+@@ -2,6 +2,7 @@
+ import React, { useCallback, useMemo, useState } from "react";
+ import {
+ NativeModules,
++ SafeAreaView,
+ ScrollView,
+ StatusBar,
+ StyleSheet,
+@@ -10,7 +11,6 @@ import {
+ useColorScheme,
+ View,
+ } from "react-native";
+-import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
+ // @ts-expect-error
+ import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
+ import { Colors, Header } from "react-native/Libraries/NewAppScreen";
+@@ -169,7 +169,6 @@ const App = ({ concurrentRoot }) => {
+ );
+
+ return (
+-
+
+
+ {
+
+
+
+-
+ );
+ };
+
diff --git a/scripts/test-matrix.sh b/scripts/test-matrix.sh
index 4cbbc625ba..8725cb2d03 100755
--- a/scripts/test-matrix.sh
+++ b/scripts/test-matrix.sh
@@ -93,6 +93,7 @@ echo
popd 1> /dev/null
prepare
# `react-native-safe-area-context` doesn't support latest New Arch changes
+git apply scripts/disable-safe-area-context.patch
sed -i '' 's/"react-native-safe-area-context": ".[.0-9]*",//' package.json
echo
@@ -137,4 +138,4 @@ echo "│ Initialize new app │"
echo "└─────────────────────┘"
echo
-yarn react-native init-test-app --destination template-example --name TemplateExample --platform android,ios
+GIT_IGNORE_FILE=".gitignore" yarn react-native init-test-app --destination template-example --name TemplateExample --platform android,ios
diff --git a/yarn.lock b/yarn.lock
index 8ec51b348a..cd3be17202 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5469,7 +5469,7 @@ __metadata:
react-native-windows: ^0.71.4
peerDependencies:
react: ~17.0.1 || ~18.0.0 || ~18.1.0 || ~18.2.0
- react-native: ^0.0.0-0 || 0.64 - 0.71 || 1000.0.0
+ react-native: ^0.0.0-0 || 0.64 - 0.72 || 1000.0.0
react-native-macos: ^0.0.0-0 || 0.64 || 0.66 || 0.68 || 0.71
react-native-windows: ^0.0.0-0 || 0.64 - 0.71
languageName: unknown
@@ -9914,7 +9914,7 @@ fsevents@^2.3.2:
"@react-native-community/cli-platform-ios": ">=5.0"
mustache: ^4.0.0
react: ~17.0.1 || ~18.0.0 || ~18.1.0 || ~18.2.0
- react-native: ^0.0.0-0 || 0.64 - 0.71 || 1000.0.0
+ react-native: ^0.0.0-0 || 0.64 - 0.72 || 1000.0.0
react-native-macos: ^0.0.0-0 || 0.64 || 0.66 || 0.68 || 0.71
react-native-windows: ^0.0.0-0 || 0.64 - 0.71
peerDependenciesMeta: