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

Upgrade test apps to react native 0.59 #558

Merged
merged 17 commits into from
Apr 8, 2019
2 changes: 1 addition & 1 deletion DemoApp/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
unsafe.enable_getters_and_setters=true

[version]
^0.85.0
^0.92.0
9 changes: 6 additions & 3 deletions DemoApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.demoapp"
Expand All @@ -103,7 +106,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
include "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
}
}
buildTypes {
Expand All @@ -117,7 +120,7 @@ android {
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86-64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
Expand Down
2 changes: 1 addition & 1 deletion DemoApp/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk
Expand All @@ -16,6 +15,7 @@
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity
Expand Down
4 changes: 2 additions & 2 deletions DemoApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ buildscript {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
Expand Down
2 changes: 1 addition & 1 deletion DemoApp/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6 changes: 4 additions & 2 deletions DemoApp/app/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppState, Alert, Platform, ToastAndroid } from 'react-native';
import { createBottomTabNavigator } from 'react-navigation';
import { createBottomTabNavigator, createAppContainer } from 'react-navigation';
import Toast from 'react-native-simple-toast';

import Crashes, { UserConfirmation, ErrorAttachmentLog } from 'appcenter-crashes';
Expand All @@ -11,7 +11,7 @@ import AnalyticsScreen from './screens/AnalyticsScreen';
import CrashesScreen from './screens/CrashesScreen';
import AttachmentsProvider from './AttachmentsProvider';

export default createBottomTabNavigator(
const TabNavigator = createBottomTabNavigator(
{
AppCenter: AppCenterScreen,
Analytics: AnalyticsScreen,
Expand All @@ -26,6 +26,8 @@ export default createBottomTabNavigator(
}
);

export default createAppContainer(TabNavigator);

Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
Expand Down
2 changes: 1 addition & 1 deletion DemoApp/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset']
presets: ['module:metro-react-native-babel-preset'],
};
3 changes: 2 additions & 1 deletion DemoApp/ios/DemoApp/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
dtrabo marked this conversation as resolved.
Show resolved Hide resolved
dtrabo marked this conversation as resolved.
Show resolved Hide resolved

@property (nonatomic, strong) UIWindow *window;

Expand Down
22 changes: 14 additions & 8 deletions DemoApp/ios/DemoApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import <AppCenterReactNative/AppCenterReactNative.h>
#import <AppCenterReactNativeShared/AppCenterReactNativeShared.h>

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@import AppCenter;
Expand All @@ -33,8 +34,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if ([startAutomatically isKindOfClass:[NSNumber class]]) {
[AppCenterReactNativeShared setStartAutomatically:[startAutomatically boolValue]];
}

NSURL *jsCodeLocation;

[AppCenterReactNative register]; // Initialize AppCenter

Expand All @@ -44,12 +43,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

[AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true]; // Initialize AppCenter analytics

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"DemoApp"
initialProperties:nil
launchOptions:launchOptions];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"RnDiffApp"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
Expand All @@ -60,4 +57,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end
52 changes: 52 additions & 0 deletions DemoApp/jest/preprocessor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Your own [temporary?] transform for React Native
*/
const generate = require('@babel/generator').default;
const transformer = require('metro-react-native-babel-transformer');
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
const metroBabelRegister = require('metro-babel-register');

metroBabelRegister([]);

module.exports = {
process(src, file) {
const { ast } = transformer.transform({
filename: file,
options: {
ast: true,
dev: true,
enableBabelRuntime: false,
experimentalImportSupport: false,
hot: false,
inlineRequires: false,
minify: false,
platform: '',
projectRoot: '',
retainLines: true,
sourceType: 'unambiguous',
},
src,
plugins: metroBabelRegister.config.plugins,
});

return generate(
ast,
{
code: true,
comments: false,
compact: false,
filename: file,
retainLines: true,
sourceFileName: file,
sourceMaps: true,
},
src,
).code;
},

getCacheKey: createCacheKeyFunction([
__filename,
require.resolve('metro-react-native-babel-transformer'),
require.resolve('@babel/core/package.json'),
]),
};
17 changes: 17 additions & 0 deletions DemoApp/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/

module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
40 changes: 22 additions & 18 deletions DemoApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,43 @@
"lint": "./node_modules/.bin/eslint ."
},
"dependencies": {
"appcenter": "^1.12.2",
"appcenter-analytics": "^1.12.2",
"appcenter-crashes": "^1.12.2",
"appcenter-push": "^1.12.2",
"appcenter": "^1.13.0",
"appcenter-analytics": "^1.13.0",
"appcenter-crashes": "^1.13.0",
"appcenter-push": "^1.13.0",
"metro": "0.48.1",
"react": "16.6.3",
"react-native": "0.58.3",
"react": "16.8.3",
"react-native": "0.59.2",
"react-native-fs": "^2.9.12",
"react-native-gesture-handler": "^1.1.0",
"react-native-image-picker": "^0.28.0",
"react-native-modal-selector": "^1.0.2",
"react-native-simple-toast": "0.0.8",
"react-navigation": "^2.11.2"
"react-navigation": "^3.5.1",
"stacktrace-parser": "^0.1.4"
},
"devDependencies": {
"@babel/core": "7.2.0",
"@babel/core": "7.4.0",
"@babel/runtime": "7.4.2",
"@react-native-community/eslint-config": "0.0.3",
"babel-jest": "24.5.0",
"eslint": "5.15.3",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "0.53.1",
"react-test-renderer": "16.8.3",
"@babel/plugin-external-helpers": "7.2.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "8.2.3",
"babel-jest": "23.6.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.2.1",
"jest": "22.4.3",
"metro-react-native-babel-preset": "^0.45.3",
"prop-types": "15.6.0",
"react-test-renderer": "16.6.3"
"eslint-plugin-react": "^7.2.1"
},
"jest": {
"preset": "react-native",
"verbose": true,
"setupTestFrameworkScriptFile": "./jest/setup.js",
"setupFilesAfterEnv": [
"./jest/setup.js"
],
"setupFiles": [
"<rootDir>/node_modules/appcenter/test/AppCenterMock.js",
"<rootDir>/node_modules/appcenter-analytics/test/AppCenterAnalyticsMock.js",
Expand All @@ -51,7 +55,7 @@
"!node_modules/react-native"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
"^.+\\.js$": "<rootDir>/jest/preprocessor.js"
}
}
}
2 changes: 1 addition & 1 deletion TestApp/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
unsafe.enable_getters_and_setters=true

[version]
^0.85.0
^0.92.0
9 changes: 6 additions & 3 deletions TestApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.testapp"
Expand All @@ -103,7 +106,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
include "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
}
}
buildTypes {
Expand All @@ -117,7 +120,7 @@ android {
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86-64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
Expand Down
2 changes: 1 addition & 1 deletion TestApp/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk
Expand All @@ -16,6 +15,7 @@
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity
Expand Down
4 changes: 2 additions & 2 deletions TestApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ buildscript {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
Expand Down
2 changes: 1 addition & 1 deletion TestApp/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Loading