Skip to content

Commit

Permalink
chore(*): upgrade react-native from 0.60rc2 to 0.61.2
Browse files Browse the repository at this point in the history
Attempt to fix jest test issue while keeping react native working by installing
c7b02730c762ab8bebe45fd57cd8ea69290e99ec rn commit

The attempt didn't work out as r-n refused the commit due to the
following comment:
facebook/react-native#23326 (comment)

See my comment here for correct fix patching react-native-vector-icons:
GeekyAnts/NativeBase#2657 (comment)

Original issues letting me to ugrade react-native:
facebook/react-native#22437
facebook/react-native#22175

@warning
- jest integration tests have not been tested and might be broken due to
jest haste config removal (unlikely though).
- react-native app as not been tested (only tests) and might be broken
as well (at launch time).
- incompatibility issues may have appeared du to deprecation and
breaking changes (unlikely).
  • Loading branch information
nuKs committed Oct 24, 2019
1 parent 779cdde commit 0b30c75
Show file tree
Hide file tree
Showing 16 changed files with 2,762 additions and 474 deletions.
34 changes: 5 additions & 29 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
node_modules/react-native/Libraries/react-native/React.js

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

Expand All @@ -21,7 +13,7 @@ node_modules/react-native/Libraries/polyfills/.*
node_modules/warning/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/HMRLoadingView.js
.*/Libraries/Utilities/LoadingView.js

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*
Expand All @@ -42,27 +34,11 @@ module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
Expand Down Expand Up @@ -97,4 +73,4 @@ untyped-import
untyped-type-import

[version]
^0.103.0
^0.105.0
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
Expand All @@ -49,6 +48,7 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const goToFnMenuAdapter: GoToFnMenuAdapterType = function(goToFn: GoToFnType): O
};

// Sets up the app components' dataflow.
export default () =>
export default (): React$Node =>
<App index={AppLoader}>
{
({
Expand Down
50 changes: 27 additions & 23 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ import com.android.build.OutputFile
*/

project.ext.react = [
entryFile: "index.js"
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
Expand All @@ -102,13 +103,26 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = true

/**
* Use international variant JavaScriptCore
* 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 this variant is about 6MiB larger per architecture than default.
* The preferred build flavor of JavaScriptCore.
*
* 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
* 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 mirrored 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 useIntlJsc = false
def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down Expand Up @@ -313,6 +327,7 @@ android {
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}

}
}
}
Expand Down Expand Up @@ -393,11 +408,12 @@ dependencies {
// @note might be useful to add support libraries as in (https://github.com/denzilferreira/aware-client/blob/master/aware-tests/build.gradle)
// -> implementation "com.android.support:gridlayout-v7:$support_libs"

// JSC from node_modules
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation 'org.webkit:android-jsc:+'
implementation jscFlavor
}
}

Expand All @@ -411,15 +427,3 @@ task copyDownloadableDepsToLibs(type: Copy) {
apply plugin: 'com.google.gms.google-services'

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

// configurations.all {
// resolutionStrategy.eachDependency { details ->
// def requested = details.requested
// if (requested.group == 'com.android.support') {
// if (!requested.name.startsWith("multidex")) {
// details.useVersion "${rootProject.ext.supportLibVersion}"
// }
// }
//
// }
// }
193 changes: 111 additions & 82 deletions android/app/src/main/java/org/pnplab/flux/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,103 +50,132 @@ public void onCreate() {
BugsnagReactNative.start(this);

SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this);

String arch = System.getProperty("os.arch");
Log.i("Flux", "Current arch: " + arch);
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
// @note always display dev menu
// return true || BuildConfig.DEBUG;
return BuildConfig.DEBUG;
/**
* Loads Flipper (Facebook mobile app debugger).
*
* @param context
*/
private static void initializeFlipper(Context context) {
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.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}

@Override
protected List<ReactPackage> getPackages() {
// List<ReactPackage> list = new ArrayList<>(Arrays.asList(
// new MainReactPackage(),
// BugsnagReactNative.getPackage(),
// new RNSentryPackage(),
// new RNFSPackage(),
// new RNAppUpdatePackage(),
// new RNDevMenuPackage(),
// new LottiePackage(),
// new RNFirebasePackage(),
// new RNFirebaseMessagingPackage(),
// new SvgPackage(),
// new RNDeviceInfo(),
// new ReactVideoPackage(),
// new AwareManagerPackage(),
// new RNFluidicSliderPackage(),
// new VectorIconsPackage(),
// new RealmReactPackage(),
// new LinearGradientPackage()
// ));

@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// packages.add(new RNSentryPackage());
packages.add(new RNFSPackage());
// packages.add(new RNAppUpdatePackage());
// packages.add(new RNDevMenuPackage());
packages.add(new LottiePackage());
packages.add(new RNFirebasePackage());
packages.add(new RNFirebaseMessagingPackage());
// packages.add(new SvgPackage());
// packages.add(new RNDeviceInfo());
packages.add(new ReactVideoPackage());
packages.add(new AwareManagerPackage());
// packages.add(new RNFluidicSliderPackage());
// packages.add(new VectorIconsPackage());
// packages.add(new RealmReactPackage());
packages.add(new LinearGradientPackage());

// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());

//return packages;

// Muse is only compatible with ARM v7 devices. We avoid launch-time errors on android
// emulator (which is x86 on osx) by adding the related android module conditionally.
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
Log.e("Flux", "Android version incompatible with muse < LOLLIPOP " + android.os.Build.VERSION.SDK_INT);
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
// @note always display dev menu
// return true || BuildConfig.DEBUG;
return BuildConfig.DEBUG;
}
else {
// @note List -> SUPPORTED_ABIS `https://developer.android.com/ndk/guides/abis`
String[] archs = new String[0];
archs = Build.SUPPORTED_ABIS;
Log.d("Flux", Arrays.toString(archs));
if (!Arrays.asList(archs).contains("armeabi-v7a")) {
Log.e("Flux", "Hardware architecture incompatible with muse. armeabi-v7a is not supported.");

@Override
protected List<ReactPackage> getPackages() {
// List<ReactPackage> list = new ArrayList<>(Arrays.asList(
// new MainReactPackage(),
// BugsnagReactNative.getPackage(),
// new RNSentryPackage(),
// new RNFSPackage(),
// new RNAppUpdatePackage(),
// new RNDevMenuPackage(),
// new LottiePackage(),
// new RNFirebasePackage(),
// new RNFirebaseMessagingPackage(),
// new SvgPackage(),
// new RNDeviceInfo(),
// new ReactVideoPackage(),
// new AwareManagerPackage(),
// new RNFluidicSliderPackage(),
// new VectorIconsPackage(),
// new RealmReactPackage(),
// new LinearGradientPackage()
// ));

@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// packages.add(new RNSentryPackage());
packages.add(new RNFSPackage());
// packages.add(new RNAppUpdatePackage());
// packages.add(new RNDevMenuPackage());
packages.add(new LottiePackage());
packages.add(new RNFirebasePackage());
packages.add(new RNFirebaseMessagingPackage());
// packages.add(new SvgPackage());
// packages.add(new RNDeviceInfo());
packages.add(new ReactVideoPackage());
packages.add(new AwareManagerPackage());
// packages.add(new RNFluidicSliderPackage());
// packages.add(new VectorIconsPackage());
// packages.add(new RealmReactPackage());
packages.add(new LinearGradientPackage());

// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());

//return packages;

// Muse is only compatible with ARM v7 devices. We avoid launch-time errors on android
// emulator (which is x86 on osx) by adding the related android module conditionally.
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
Log.e("Flux", "Android version incompatible with muse < LOLLIPOP " + android.os.Build.VERSION.SDK_INT);
}
else {
Log.i("Flux", "Muse appears to be compatible.");

// Ensure muse linking is working! Indeed, armeabi-v7a ABI appears on android-x86_64 but linking still fails.
// This may simply be a build configuration issue we can resolve (ie. the muse .so isn't packaged inside the
// react-native x86_64 apk).
try {
MuseManagerAndroid.getInstance();
packages.add(new org.pnplab.flux.restingstatetask.ReactPackage(permissionManager, processPriorityPromoter));
// list.add(new MuseManagerPackage());
// packages.add(new MuseManagerPackage());
// @note List -> SUPPORTED_ABIS `https://developer.android.com/ndk/guides/abis`
String[] archs = new String[0];
archs = Build.SUPPORTED_ABIS;
Log.d("Flux", Arrays.toString(archs));
if (!Arrays.asList(archs).contains("armeabi-v7a")) {
Log.e("Flux", "Hardware architecture incompatible with muse. armeabi-v7a is not supported.");
}
catch (UnsatisfiedLinkError e) {
Log.e("Flux", "Muse lib seems to appears to be supported, however linking has failed.");
else {
Log.i("Flux", "Muse appears to be compatible.");

// Ensure muse linking is working! Indeed, armeabi-v7a ABI appears on android-x86_64 but linking still fails.
// This may simply be a build configuration issue we can resolve (ie. the muse .so isn't packaged inside the
// react-native x86_64 apk).
try {
MuseManagerAndroid.getInstance();
packages.add(new org.pnplab.flux.restingstatetask.ReactPackage(permissionManager, processPriorityPromoter));
// list.add(new MuseManagerPackage());
// packages.add(new MuseManagerPackage());
}
catch (UnsatisfiedLinkError e) {
Log.e("Flux", "Muse lib seems to appears to be supported, however linking has failed.");
}
}
}
}

return packages;
}
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
protected String getJSMainModuleName() {
return "index";
}
};

@Override
public ReactNativeHost getReactNativeHost() {
Expand Down
Loading

0 comments on commit 0b30c75

Please sign in to comment.