Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use patch-package #1304

Merged
merged 3 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"metro": "0.55.0",
"metro-react-native-babel-preset": "0.53.0",
"octonode": "0.9.5",
"patch-package": "6.2.0",
"prettier": "1.16.4",
"react-dom": "16.8.4",
"react-native-cli": "2.0.1",
Expand Down
13 changes: 13 additions & 0 deletions patches/detox+14.7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/detox/android/detox/build.gradle b/node_modules/detox/android/detox/build.gradle
index 145b20e..e94ec74 100644
--- a/node_modules/detox/android/detox/build.gradle
+++ b/node_modules/detox/android/detox/build.gradle
@@ -6,7 +6,7 @@ def _ext = rootProject.ext

def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 28
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '28.0.3'
-def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 18
+def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 19
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 28
def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion : '1.2.0'
def _kotlinStdlib = _ext.has('detoxKotlinStdlib') ? _ext.detoxKotlinStdlib : 'kotlin-stdlib-jdk8'
669 changes: 669 additions & 0 deletions patches/react-native+0.59.10.patch

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions patches/react-native-aes-crypto+1.2.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/node_modules/react-native-aes-crypto/android/build.gradle b/node_modules/react-native-aes-crypto/android/build.gradle
index a23a3ff..c195ac2 100644
--- a/node_modules/react-native-aes-crypto/android/build.gradle
+++ b/node_modules/react-native-aes-crypto/android/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
- compileSdkVersion 26
- buildToolsVersion '27.0.3'
+ compileSdkVersion 28
+ buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 19
- targetSdkVersion 22
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
}
@@ -19,7 +19,7 @@ android {
}

dependencies {
- implementation 'com.android.support:appcompat-v7:23.0.1'
+ implementation 'com.android.support:appcompat-v7:28.0.0'
compileOnly 'com.facebook.react:react-native:+'
implementation 'com.madgag.spongycastle:core:1.58.0.0'
implementation 'com.madgag.spongycastle:prov:1.54.0.0'
13 changes: 13 additions & 0 deletions patches/react-native-branch+3.1.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/react-native-branch/android/build.gradle b/node_modules/react-native-branch/android/build.gradle
index 438f0e3..3eb34a7 100755
--- a/node_modules/react-native-branch/android/build.gradle
+++ b/node_modules/react-native-branch/android/build.gradle
@@ -13,7 +13,7 @@ android {
compileSdkVersion safeExtGet('compileSdkVersion', 26)

defaultConfig {
- minSdkVersion safeExtGet('minSdkVersion', 16)
+ minSdkVersion safeExtGet('minSdkVersion', 19)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
versionName "1.0"
15 changes: 15 additions & 0 deletions patches/react-native-fabric+0.5.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/react-native-fabric/android/build.gradle b/node_modules/react-native-fabric/android/build.gradle
index 053ecfc..697b267 100644
--- a/node_modules/react-native-fabric/android/build.gradle
+++ b/node_modules/react-native-fabric/android/build.gradle
@@ -42,8 +42,8 @@ repositories {
}

dependencies {
- compile "com.facebook.react:react-native:${safeExtGet('reactNative', '+')}"
- compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
+ api "com.facebook.react:react-native:${safeExtGet('reactNative', '+')}"
+ api('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true;
}
}
22 changes: 22 additions & 0 deletions patches/react-native-i18n+2.0.15.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/node_modules/react-native-i18n/android/build.gradle b/node_modules/react-native-i18n/android/build.gradle
index 2614c62..12cbda7 100644
--- a/node_modules/react-native-i18n/android/build.gradle
+++ b/node_modules/react-native-i18n/android/build.gradle
@@ -22,5 +22,5 @@ android {
}

dependencies {
- compile "com.facebook.react:react-native:+" // From node_modules
+ api "com.facebook.react:react-native:+" // From node_modules
}
diff --git a/node_modules/react-native-i18n/android/src/main/AndroidManifest.xml b/node_modules/react-native-i18n/android/src/main/AndroidManifest.xml
index 818651f..f746bbd 100644
--- a/node_modules/react-native-i18n/android/src/main/AndroidManifest.xml
+++ b/node_modules/react-native-i18n/android/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AlexanderZaytsev.RNI18n">
- <uses-sdk android:minSdkVersion="16" />
+
</manifest>
22 changes: 22 additions & 0 deletions patches/react-native-os+1.2.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/node_modules/react-native-os/android/build.gradle b/node_modules/react-native-os/android/build.gradle
index 8b00cd6..3b1f276 100644
--- a/node_modules/react-native-os/android/build.gradle
+++ b/node_modules/react-native-os/android/build.gradle
@@ -11,8 +11,8 @@ buildscript {
apply plugin: 'com.android.library'

android {
- compileSdkVersion 23
- buildToolsVersion "23.0.1"
+ compileSdkVersion 28
+ buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 16
@@ -40,5 +40,5 @@ repositories {
}

dependencies {
- compile 'com.facebook.react:react-native:+'
+ api 'com.facebook.react:react-native:+'
}
13 changes: 13 additions & 0 deletions patches/xmlhttprequest+1.8.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/xmlhttprequest/lib/XMLHttpRequest.js b/node_modules/xmlhttprequest/lib/XMLHttpRequest.js
index 4893913..0543f38 100644
--- a/node_modules/xmlhttprequest/lib/XMLHttpRequest.js
+++ b/node_modules/xmlhttprequest/lib/XMLHttpRequest.js
@@ -12,7 +12,7 @@
*/

var Url = require("url");
-var spawn = require("child_process").spawn;
+//var spawn= require("child_process").spawn;
var fs = require("fs");

exports.XMLHttpRequest = function() {
146 changes: 4 additions & 142 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,154 +1,16 @@
#!/bin/bash
echo "PostInstall script:"

echo "0. Fix connext client"
# Replace console.error by console.log to avoid red screens
find node_modules/connext/dist -type f -name "*.js" | xargs sed -i'' -e 's/console.error/console.log/g'

echo "1. React Native nodeify..."
node_modules/.bin/rn-nodeify --install 'crypto,buffer,react-native-randombytes,vm,stream,http,https,os,url,net,fs' --hack

# We need to submit a PR for this one.
echo "2. Fix react-native-os buildTools version..."
TARGET="node_modules/react-native-os/android/build.gradle"
sed -i'' -e 's/compileSdkVersion 23/compileSdkVersion 28/' $TARGET;
sed -i'' -e 's/23.0.1/28.0.3/' $TARGET;
echo "Done"

# This one has been fixed on master
# we can remove once they release a new version
echo "3. Fix react-native-fs buildTools version..."
TARGET="node_modules/react-native-fs/android/build.gradle"
sed -i'' -e 's/compileSdkVersion 25/compileSdkVersion 28/' $TARGET;
sed -i'' -e 's/25.0.0/28.0.3/' $TARGET;
echo "Done"

# The build output from aes-js breaks the metro bundler. Until we safely upgrade
# to a new version of aes-js, we patch it by removing the erroneous line.
echo "4. Fix aes-js build ouput..."
AES_OUTPUT_FILE="node_modules/aes-js/index.js";
sed -i'' -e 's/var previous_mymodule = root.mymodule;//g' $AES_OUTPUT_FILE;

# Reported here https://github.com/skv-headless/react-native-scrollable-tab-view/issues/910
echo "5. Fix react-native-scrollable-tab-view"
TARGET="node_modules/react-native-scrollable-tab-view/SceneComponent.js"
sed -i'' -e 's/...props,/...props/' $TARGET;
echo "Done"


# This one has been fixed on master
# we can remove once they release a new version
echo "6. Fix react-native-fabric buildTools version..."
TARGET="node_modules/react-native-fabric/android/build.gradle"
sed -i'' -e 's/compileSdkVersion 23/compileSdkVersion 28/' $TARGET;
sed -i'' -e 's/23.0.1/28.0.3/' $TARGET;
echo "Done"

echo "7. Update all the modules to BuildTools 28.0.3..."
TARGET="node_modules/react-native-aes-crypto/android/build.gradle"
sed -i'' -e 's/27.0.3/28.0.3/' $TARGET;
sed -i'' -e 's/23.0.1/28.0.0/' $TARGET;
sed -i'' -e 's/26/28/' $TARGET;
sed -i'' -e 's/22/28/' $TARGET;
TARGET="node_modules/react-native-fabric/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/react-native-fs/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/react-native-keychain/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/react-native-os/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/react-native-randombytes/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/react-native-vector-icons/android/build.gradle"
sed -i'' -e 's/26.0.1/28.0.3/' $TARGET;
TARGET="node_modules/detox/android/detox/build.gradle"
sed -i'' -e 's/27.0.3/28.0.3/' $TARGET;
sed -i'' -e 's/ 25/ 28/' $TARGET;
sed -i'' -e 's/ 18/ 19/' $TARGET;
TARGET="node_modules/react-native-branch/android/build.gradle"
sed -i'' -e 's/23.0.1/28.0.3/' $TARGET;

echo "Done"

echo "8. Fix all android build warnings..."
TARGET="node_modules/react-native-aes-crypto/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-fs/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-fabric/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
sed -i'' -e 's/compile(/api(/' $TARGET;
TARGET="node_modules/react-native-i18n/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-os/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-randombytes/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-keychain/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
TARGET="node_modules/react-native-vector-icons/android/build.gradle"
sed -i'' -e 's/compile /api /' $TARGET;
echo "2. Patch npm packages"
npx patch-package

TARGET="node_modules/react-native-branch/android/build.gradle"
sed -i'' -e 's/ 23/ 28/' $TARGET;
sed -i'' -e 's/ 22/ 28/' $TARGET;
sed -i'' -e 's/ 16/ 19/' $TARGET;
sed -i'' -e 's/compile /api /' $TARGET;

echo "9. Create xcconfig files..."
echo "2. Create xcconfig files..."
echo "" > ios/debug.xcconfig
echo "" > ios/release.xcconfig


echo "10. Fix react-native-push-notification ..."
rm -rf node_modules/react-native-push-notification/.git

echo "11. Fix xmlhttprequest"
TARGET="node_modules/xmlhttprequest/lib/XMLHttpRequest.js"
sed -i'' -e 's/var spawn /\/\/var spawn/' $TARGET;

echo "12. Fix react-native-i18n"
TARGET="node_modules/react-native-i18n/android/src/main/AndroidManifest.xml"
sed -i'' -e 's/<uses-sdk android:minSdkVersion="16" \/>//' $TARGET;

# We can get rid of this once we upgrade to 0.60
# which contains a fix
echo "13. Fix react-native v0.59.8"
TARGET="node_modules/react-native/react.gradle"
if grep -q "doLast" $TARGET;
then
echo "Already patched";
else
sed -i'' -e '50i\
doLast {\
def moveFunc = { resSuffix ->\
File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");\
if (originalDir.exists()) {\
File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");\
ant.move(file: originalDir, tofile: destDir);\
}\
}\
moveFunc.curry("ldpi").call()\
moveFunc.curry("mdpi").call()\
moveFunc.curry("hdpi").call()\
moveFunc.curry("xhdpi").call()\
moveFunc.curry("xxhdpi").call()\
moveFunc.curry("xxxhdpi").call()\
}' $TARGET;
fi

echo "14. Remove UIWebview deps"
rm -rf node_modules/react-native/React/Views/RCTWebView.m
rm -rf node_modules/react-native/React/Views/RCTWebViewManager.h
rm -rf node_modules/react-native/React/Views/RCTWebViewManager.m
sed -i.bak '/RCTWebView/d' node_modules/react-native/React/React.xcodeproj/project.pbxproj
rm -rf node_modules/react-native/React/React.xcodeproj/project.pbxproj.bak

echo "15. Remove Branch examples"
rm -rf node_modules/react-native-branch/examples/
rm -rf node_modules/react-native-branch/native-tests/

echo "16. Init git submodules"
echo "3. Init git submodules"
echo "This may take a while..."
git submodule update --init
Loading