Skip to content

Commit 3a8d923

Browse files
author
Kai Guo
committed
Upgrade sample apps to 61
1 parent af2664e commit 3a8d923

File tree

24 files changed

+2234
-3269
lines changed

24 files changed

+2234
-3269
lines changed

.circleci/config.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ jobs:
156156
name: Installing Yarn dependencies
157157
command: yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn
158158
- save-cache: *cache_save_yarn
159+
- restore_cache:
160+
key: 1-gems-{{ checksum "example/ios/Gemfile.lock" }}
161+
- run:
162+
name: Install CocoaPods
163+
command: cd example/ios && bundle check || bundle install --path vendor/bundle
164+
- save_cache:
165+
key: 1-gems-{{ checksum "example/ios/Gemfile.lock" }}
166+
paths:
167+
- vendor/bundle
168+
- run:
169+
name: Install pod dependencies
170+
command: cd example/ios && bundle exec pod install
159171
- run:
160172
name: Build iOS app
161173
command: yarn build:e2e:ios
@@ -184,9 +196,12 @@ jobs:
184196
- save-cache: *cache_save_gradle_build
185197

186198
# Build and test
199+
- run:
200+
name: Bundle
201+
command: mkdir example/android/app/src/main/assets && npx react-native bundle --platform android --dev false --entry-file example/index.js --bundle-output example/android/app/src/main/assets/index.android.bundle --assets-dest example/android/app/src/main/res/
187202
- run:
188203
name: Build Android apk
189-
command: cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2
204+
command: cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2 -x bundleReleaseJsAndAssets
190205

191206
- persist_to_workspace:
192207
root: ~/async_storage

.circleci/scripts/run_android_e2e.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ MAX_RETRIES=60 # wait max 5 minutes for emu to boot
1111
build_apk() {
1212
echo
1313
echo "[Detox e2e] Building APK"
14+
eval "mkdir example/android/app/src/main/assets"
15+
eval "npx react-native bundle --platform android --dev false --entry-file example/index.js --bundle-output example/android/app/src/main/assets/index.android.bundle --assets-dest example/android/app/src/main/res/"
1416
cd "example/android"
15-
eval "./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release"
17+
eval "./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release -x bundleReleaseJsAndAssets"
1618
cd ${ROOT_DIR}
1719
}
1820

.circleci/scripts/run_ios_e2e.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ ENTRY_FILE="example/index.js"
55
BUNDLE_FILE="$RESOURCE_DIR/main.jsbundle"
66
EXTRA_PACKAGER_ARGS="--entry-file=$ENTRY_FILE"
77

8-
98
build_project() {
109
echo "[Detox e2e] Building iOS project"
1110
eval "xcodebuild \
12-
-project example/ios/AsyncStorageExample.xcodeproj \
11+
-workspace example/ios/AsyncStorageExample.xcworkspace \
1312
-scheme AsyncStorageExample \
1413
-configuration Release \
1514
-sdk iphonesimulator \
@@ -69,7 +68,6 @@ run_simulator() {
6968
fi
7069
}
7170

72-
7371
build_project
7472

7573
sleep 2

.flowconfig

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

@@ -31,42 +30,51 @@ emoji=true
3130
esproposal.optional_chaining=enable
3231
esproposal.nullish_coalescing=enable
3332

34-
module.system=haste
35-
module.system.haste.use_name_reducers=true
36-
# get basename
37-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38-
# strip .js or .js.flow suffix
39-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40-
# strip .ios suffix
41-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44-
module.system.haste.paths.blacklist=.*/__tests__/.*
45-
module.system.haste.paths.blacklist=.*/__mocks__/.*
46-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
4836

4937
munge_underscores=true
5038

51-
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'
39+
server.max_workers=1
5240

5341
# Support the library import in examples
5442
module.name_mapper='^\@react-native-community/async-storage$' -> '<PROJECT_ROOT>/lib/AsyncStorage.js'
5543

56-
module.file_ext=.js
57-
module.file_ext=.jsx
58-
module.file_ext=.json
59-
module.file_ext=.native.js
44+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
45+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
46+
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'
6047

6148
suppress_type=$FlowIssue
6249
suppress_type=$FlowFixMe
6350
suppress_type=$FlowFixMeProps
6451
suppress_type=$FlowFixMeState
6552

66-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
67-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
68-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
54+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6955
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
7056

57+
[lints]
58+
sketchy-null-number=warn
59+
sketchy-null-mixed=warn
60+
sketchy-number=warn
61+
untyped-type-import=warn
62+
nonstrict-import=warn
63+
deprecated-type=warn
64+
unsafe-getters-setters=warn
65+
inexact-spread=warn
66+
unnecessary-invariant=warn
67+
signature-verification-failure=warn
68+
deprecated-utility=error
69+
70+
[strict]
71+
deprecated-type
72+
nonstrict-import
73+
sketchy-null
74+
unclear-type
75+
unsafe-getters-setters
76+
untyped-import
77+
untyped-type-import
78+
7179
[version]
72-
^0.92.0
80+
^0.105.0

example/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/
60+
Podfile.lock

example/android/app/build.gradle

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ import com.android.build.OutputFile
7676
project.ext.react = [
7777
cliPath: "./node_modules/react-native/local-cli/cli.js",
7878
entryFile: "./example/index.js",
79-
root: "../../../"
79+
root: "../../../",
80+
enableHermes: false,
81+
bundleInDebug: false,
82+
bundleInRelease: true
8083
]
8184

8285

@@ -98,6 +101,28 @@ def enableSeparateBuildPerCPUArchitecture = false
98101
*/
99102
def enableProguardInReleaseBuilds = false
100103

104+
/**
105+
* The preferred build flavor of JavaScriptCore.
106+
*
107+
* For example, to use the international variant, you can use:
108+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
109+
*
110+
* The international variant includes ICU i18n library and necessary data
111+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
112+
* give correct results when using with locales other than en-US. Note that
113+
* this variant is about 6MiB larger per architecture than default.
114+
*/
115+
def jscFlavor = 'org.webkit:android-jsc:+'
116+
117+
/**
118+
* Whether to enable the Hermes VM.
119+
*
120+
* This should be set on project.ext.react and mirrored here. If it is not set
121+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
122+
* and the benefits of using Hermes will therefore be sharply reduced.
123+
*/
124+
def enableHermes = project.ext.react.get("enableHermes", false);
125+
101126
android {
102127
compileSdkVersion rootProject.ext.compileSdkVersion
103128

@@ -158,12 +183,20 @@ android {
158183

159184
dependencies {
160185
implementation project(':rnAsyncStorage')
161-
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
162186
implementation "com.facebook.react:react-native:+" // From node_modules
163187

164188
// tests
165189
androidTestImplementation ('com.wix:detox:+') { transitive = true }
166190
androidTestImplementation 'junit:junit:4.12'
191+
192+
193+
if (enableHermes) {
194+
def hermesPath = "../../../node_modules/hermes-engine/android/";
195+
debugImplementation files(hermesPath + "hermes-debug.aar")
196+
releaseImplementation files(hermesPath + "hermes-release.aar")
197+
} else {
198+
implementation jscFlavor
199+
}
167200
}
168201

169202
// Run this once to be able to run the application with BUCK
@@ -172,3 +205,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
172205
from configurations.compile
173206
into 'libs'
174207
}
208+
209+
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
23
package="com.asyncstorageexample">
34

45
<uses-permission android:name="android.permission.INTERNET" />

example/android/app/src/main/java/com/asyncstorageexample/MainApplication.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package com.asyncstorageexample;
22

33
import android.app.Application;
4-
4+
import android.content.Context;
5+
import com.facebook.react.PackageList;
56
import com.facebook.react.ReactApplication;
67
import com.facebook.react.ReactNativeHost;
78
import com.facebook.react.ReactPackage;
89
import com.facebook.react.shell.MainReactPackage;
910
import com.facebook.soloader.SoLoader;
1011
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
1112

13+
import java.lang.reflect.InvocationTargetException;
1214
import java.util.Arrays;
1315
import java.util.List;
1416

@@ -22,10 +24,10 @@ public boolean getUseDeveloperSupport() {
2224

2325
@Override
2426
protected List<ReactPackage> getPackages() {
25-
return Arrays.<ReactPackage>asList(
26-
new MainReactPackage(),
27-
new AsyncStoragePackage()
28-
);
27+
@SuppressWarnings("UnnecessaryLocalVariable")
28+
List<ReactPackage> packages = new PackageList(this).getPackages();
29+
packages.add(new AsyncStoragePackage());
30+
return packages;
2931
}
3032

3133
@Override

example/android/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ buildscript {
77
minSdkVersion = 19
88
compileSdkVersion = 28
99
targetSdkVersion = 28
10-
supportLibVersion = "28.0.0"
1110
detoxKotlinVersion = kotlinVersion
1211
}
1312
repositories {
1413
google()
1514
jcenter()
1615
}
1716
dependencies {
18-
classpath 'com.android.tools.build:gradle:3.4.1'
17+
classpath 'com.android.tools.build:gradle:3.4.2'
1918
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2019
}
2120
}
@@ -30,5 +29,7 @@ allprojects {
3029
url "$rootDir/../../node_modules/react-native/android"
3130
}
3231
maven { url "$rootDir/../../node_modules/detox/Detox-android" }
32+
maven { url "https://jitpack.io" }
33+
maven { url "$rootDir/../../node_modules/jsc-android/dist" }
3334
}
3435
}

example/android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222

2323
# Enable dedicated thread pool executor
2424
AsyncStorage_dedicatedExecutor=true
25+
26+
android.useAndroidX=true
27+
android.enableJetifier=true

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
66

example/android/settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
rootProject.name = 'AsyncStorageExample'
22

3+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
4+
35
include ':app'
46
include ':rnAsyncStorage'
57

6-
78
project(':rnAsyncStorage').projectDir = new File(rootProject.projectDir, '../../android')

0 commit comments

Comments
 (0)