diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d3130dd..dc2df03e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,7 @@ default config for macOS: &macos_defaults <<: *defaults resource_class: 'medium' macos: - xcode: '11.7.0' + xcode: '12.1.0' default config for android apk builds: &android_defaults <<: *defaults @@ -147,13 +147,16 @@ jobs: command: | brew bundle --file=.circleci/Brewfile.ios --no-lock touch .watchmanconfig - node -v + echo Node $(node --version) - save-cache: *cache_save_brew - restore-cache: *cache_restore_yarn - run: name: Installing Yarn dependencies command: yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn - save-cache: *cache_save_yarn + - run: + name: Bundle JS + command: yarn bundle:ios --dev false - run: name: Install pod dependencies working_directory: example/ios @@ -187,12 +190,12 @@ jobs: # Build and test - run: - name: Bundle - 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/ + name: Bundle JS + command: yarn bundle:android --dev false - run: - name: Build Android apk + name: Build APK working_directory: example/android - command: ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2 -x bundleReleaseJsAndAssets + command: ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2 - persist_to_workspace: root: ~/async_storage diff --git a/.circleci/scripts/run_android_e2e.sh b/.circleci/scripts/run_android_e2e.sh index 156cb7b8..30b9abed 100755 --- a/.circleci/scripts/run_android_e2e.sh +++ b/.circleci/scripts/run_android_e2e.sh @@ -11,10 +11,9 @@ MAX_RETRIES=60 # wait max 5 minutes for emu to boot build_apk() { echo echo "[Detox e2e] Building APK" - eval "mkdir example/android/app/src/main/assets" - 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/" - cd "example/android" - eval "./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release -x bundleReleaseJsAndAssets" + yarn bundle:android --dev false + cd example/android + ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release cd ${ROOT_DIR} } diff --git a/.circleci/scripts/run_ios_e2e.sh b/.circleci/scripts/run_ios_e2e.sh index 720f7702..b48b11c0 100755 --- a/.circleci/scripts/run_ios_e2e.sh +++ b/.circleci/scripts/run_ios_e2e.sh @@ -1,6 +1,6 @@ #!/bin/bash -RESOURCE_DIR="$PWD/example/ios/build/Build/Products/Release-iphonesimulator/AsyncStorageExample.app" +RESOURCE_DIR="$PWD/example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app" ENTRY_FILE="example/index.js" BUNDLE_FILE="$RESOURCE_DIR/main.jsbundle" EXTRA_PACKAGER_ARGS="--entry-file=$ENTRY_FILE" @@ -9,11 +9,10 @@ build_project() { echo "[Detox e2e] Building iOS project" eval "xcodebuild \ -workspace example/ios/AsyncStorageExample.xcworkspace \ - -scheme AsyncStorageExample \ + -scheme ReactTestApp \ -configuration Release \ -sdk iphonesimulator \ -derivedDataPath example/ios/build \ - -UseModernBuildSystem=NO \ BUNDLE_FILE=$BUNDLE_FILE \ EXTRA_PACKAGER_ARGS=$EXTRA_PACKAGER_ARGS" } diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..14398053 --- /dev/null +++ b/.clang-format @@ -0,0 +1,32 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AllowShortFunctionsOnASingleLine: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Linux +ColumnLimit: 100 +Cpp11BracedListStyle: true +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '"pch\.h"' + Priority: -1 + - Regex: '^' + Priority: 2 + - Regex: '^<' + Priority: 3 + - Regex: '.\*' + Priority: 10 +IndentCaseLabels: true +IndentWidth: 4 +NamespaceIndentation: All +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyReturnTypeOnItsOwnLine: 100 +PointerAlignment: Right +SpacesBeforeTrailingComments: 2 +SpacesInContainerLiterals: false +TabWidth: 4 diff --git a/android/build.gradle b/android/build.gradle index ff8c7ad2..dac92163 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,18 +21,17 @@ def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } +configurations { + compileClasspath +} + buildscript { - // The Android Gradle plugin is only required when opening the android folder stand-alone. - // This avoids unnecessary downloads and potential conflicts when the library is included as a - // module dependency in an application project. - if (project == rootProject) { - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' - } + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' } } @@ -69,7 +68,6 @@ android { } repositories { - mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "${resolveModulePath("react-native")}/android" diff --git a/example/AsyncStorageExample.podspec b/example/AsyncStorageExample.podspec new file mode 100644 index 00000000..31a1cc7d --- /dev/null +++ b/example/AsyncStorageExample.podspec @@ -0,0 +1,23 @@ +require 'json' + +package = JSON.parse(File.read(File.join('..', 'package.json'))) + +Pod::Spec.new do |s| + s.name = 'AsyncStorageExample' + s.version = '0.0.1-dev' + s.author = { package['author']['name'] => package['author']['email'] } + s.license = package['license'] + s.homepage = package['homepage'] + s.source = { :git => package['repository']['url'] } + s.summary = 'AsyncStorage example app' + + s.ios.deployment_target = '12.0' + s.osx.deployment_target = '10.14' + + s.dependency 'React' + s.dependency 'ReactTestApp-DevSupport' + + #s.user_target_xcconfig = { 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' => '$(inherited)' } + + s.source_files = 'ios/AsyncStorageExample/**/*.{h,m,swift}' +end diff --git a/example/android/app/BUCK b/example/android/app/BUCK deleted file mode 100644 index 6a95aeb0..00000000 --- a/example/android/app/BUCK +++ /dev/null @@ -1,55 +0,0 @@ -# To learn about Buck see [Docs](https://buckbuild.com/). -# To run your application with Buck: -# - install Buck -# - `npm start` - to start the packager -# - `cd android` -# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` -# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck -# - `buck install -r android/app` - compile, install and run application -# - -load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") - -lib_deps = [] - -create_aar_targets(glob(["libs/*.aar"])) - -create_jar_targets(glob(["libs/*.jar"])) - -android_library( - name = "all-libs", - exported_deps = lib_deps, -) - -android_library( - name = "app-code", - srcs = glob([ - "src/main/java/**/*.java", - ]), - deps = [ - ":all-libs", - ":build_config", - ":res", - ], -) - -android_build_config( - name = "build_config", - package = "com.asyncstorageexample", -) - -android_resource( - name = "res", - package = "com.asyncstorageexample", - res = "src/main/res", -) - -android_binary( - name = "app", - keystore = "//android/keystores:debug", - manifest = "src/main/AndroidManifest.xml", - package_type = "debug", - deps = [ - ":app-code", - ], -) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle deleted file mode 100644 index bd93f9d4..00000000 --- a/example/android/app/build.gradle +++ /dev/null @@ -1,209 +0,0 @@ -apply plugin: "com.android.application" - -import com.android.build.OutputFile - -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation - * entryFile: "index.android.js", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] - */ - - -project.ext.react = [ - cliPath: "./node_modules/react-native/local-cli/cli.js", - entryFile: "./example/index.js", - root: "../../../", - enableHermes: false, - bundleInDebug: false, - bundleInRelease: true -] - - -apply from: "./scripts/CI.gradle" -apply from: "../../../node_modules/react-native/react.gradle" - -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false - -/** - * Run Proguard to shrink the Java bytecode in release builds. - */ -def enableProguardInReleaseBuilds = false - -/** - * 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 enableHermes = project.ext.react.get("enableHermes", false); - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - signingConfigs { - release { - storeFile file("exampleAsyncStorage.keystore") - keyAlias "asyncstorage" - keyPassword "asyncstorage" - storePassword "asyncstorage" - } - } - - defaultConfig { - applicationId "com.asyncstorageexample" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1 - versionName "1.0" - testBuildType System.getProperty('testBuildType', 'debug') - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } - } - buildTypes { - release { - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" - signingConfig signingConfigs.release - matchingFallbacks = ['release'] - } - } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - 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, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode - } - } - } -} - -dependencies { - implementation project(':rnAsyncStorage') - implementation "com.facebook.react:react-native:+" // From node_modules - - // tests - androidTestImplementation ('com.wix:detox:+') { transitive = true } - androidTestImplementation 'junit:junit:4.12' - - - if (enableHermes) { - def hermesPath = "../../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") - } else { - implementation jscFlavor - } -} - -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.compile - into 'libs' -} - -apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) \ No newline at end of file diff --git a/example/android/app/build_defs.bzl b/example/android/app/build_defs.bzl deleted file mode 100644 index fff270f8..00000000 --- a/example/android/app/build_defs.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Helper definitions to glob .aar and .jar targets""" - -def create_aar_targets(aarfiles): - for aarfile in aarfiles: - name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] - lib_deps.append(":" + name) - android_prebuilt_aar( - name = name, - aar = aarfile, - ) - -def create_jar_targets(jarfiles): - for jarfile in jarfiles: - name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] - lib_deps.append(":" + name) - prebuilt_jar( - name = name, - binary_jar = jarfile, - ) diff --git a/example/android/app/exampleAsyncStorage.keystore b/example/android/app/exampleAsyncStorage.keystore deleted file mode 100644 index e77450d7..00000000 Binary files a/example/android/app/exampleAsyncStorage.keystore and /dev/null differ diff --git a/example/android/app/proguard-rules.pro b/example/android/app/proguard-rules.pro deleted file mode 100644 index a92fa177..00000000 --- a/example/android/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/example/android/app/scripts/CI.gradle b/example/android/app/scripts/CI.gradle deleted file mode 100644 index 878ee24f..00000000 --- a/example/android/app/scripts/CI.gradle +++ /dev/null @@ -1,25 +0,0 @@ -// Fetch all dependencies upfront -task fetchDependencies() { - description 'Download all dependencies to the Gradle cache' - group 'android' - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each {config -> - if(config.canBeResolved) { - config.files - } - } - subProject.configurations.each {config -> - if(config.canBeResolved) { - // DefaultLenientConfiguration$ArtifactResolveException - try { - config.files - } catch(e) { - println e - } - - } - } - } - } -} \ No newline at end of file diff --git a/example/android/app/src/androidTest/java/com/asyncstorageexample/DetoxTest.java b/example/android/app/src/androidTest/java/com/asyncstorageexample/DetoxTest.java deleted file mode 100644 index 2ded5929..00000000 --- a/example/android/app/src/androidTest/java/com/asyncstorageexample/DetoxTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.asyncstorageexample; - -import androidx.test.filters.LargeTest; -import androidx.test.rule.ActivityTestRule; -import androidx.test.runner.AndroidJUnit4; - -import com.wix.detox.Detox; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@LargeTest -public class DetoxTest { - - @Rule - public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); - - @Test - public void runDetoxTests() throws InterruptedException { - Detox.runTests(mActivityRule); - } -} \ No newline at end of file diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 23169533..00000000 --- a/example/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index dda56d26..00000000 --- a/example/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/example/android/app/src/main/java/com/asyncstorageexample/MainActivity.java b/example/android/app/src/main/java/com/asyncstorageexample/MainActivity.java deleted file mode 100644 index 8f093117..00000000 --- a/example/android/app/src/main/java/com/asyncstorageexample/MainActivity.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.asyncstorageexample; - -import com.facebook.react.ReactActivity; - -public class MainActivity extends ReactActivity { - - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "AsyncStorageExample"; - } -} diff --git a/example/android/app/src/main/java/com/asyncstorageexample/MainApplication.java b/example/android/app/src/main/java/com/asyncstorageexample/MainApplication.java deleted file mode 100644 index 42177a10..00000000 --- a/example/android/app/src/main/java/com/asyncstorageexample/MainApplication.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.asyncstorageexample; - -import android.app.Application; -import android.content.Context; -import com.facebook.react.PackageList; -import com.facebook.react.ReactApplication; -import com.facebook.react.ReactNativeHost; -import com.facebook.react.ReactPackage; -import com.facebook.react.shell.MainReactPackage; -import com.facebook.soloader.SoLoader; -import com.reactnativecommunity.asyncstorage.AsyncStoragePackage; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.List; - -public class MainApplication extends Application implements ReactApplication { - - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } - - @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - packages.add(new AsyncStoragePackage()); - return packages; - } - - @Override - protected String getJSMainModuleName() { - return "example/index"; - } - }; - - @Override - public ReactNativeHost getReactNativeHost() { - return mReactNativeHost; - } - - @Override - public void onCreate() { - super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); - } -} diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a2f59082..00000000 Binary files a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 1b523998..00000000 Binary files a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index ff10afd6..00000000 Binary files a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 115a4c76..00000000 Binary files a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index dcd3cd80..00000000 Binary files a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 459ca609..00000000 Binary files a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 8ca12fe0..00000000 Binary files a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 8e19b410..00000000 Binary files a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index b824ebdd..00000000 Binary files a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index 4c19a13c..00000000 Binary files a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/example/android/app/src/main/res/values/strings.xml b/example/android/app/src/main/res/values/strings.xml deleted file mode 100644 index a9f943c1..00000000 --- a/example/android/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - AsyncStorageExample - diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml deleted file mode 100644 index 319eb0ca..00000000 --- a/example/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/example/android/build.gradle b/example/android/build.gradle index 89146f50..e03f6ad3 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,35 +1,26 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext { - kotlinVersion = '1.3.10' - buildToolsVersion = "28.0.3" - minSdkVersion = 19 - compileSdkVersion = 28 - targetSdkVersion = 28 - detoxKotlinVersion = kotlinVersion - } - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } -} - -allprojects { - repositories { - mavenLocal() - google() - jcenter() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url "$rootDir/../../node_modules/react-native/android" +// Fetch all dependencies upfront +task fetchDependencies() { + description 'Download all dependencies to the Gradle cache' + group 'android' + doLast { + project.rootProject.allprojects.each { subProject -> + subProject.buildscript.configurations.each { config -> + if (config.canBeResolved) { + config.files + } + } + subProject.configurations.each { config -> + if (config.canBeResolved) { + // DefaultLenientConfiguration$ArtifactResolveException + try { + config.files + } catch(e) { + println e + } + } } - maven { url "$rootDir/../../node_modules/detox/Detox-android" } - maven { url "https://jitpack.io" } - maven { url "$rootDir/../../node_modules/jsc-android/dist" } + } } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 921dcc3f..91cf0ef6 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,5 +2,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/example/android/keystores/BUCK b/example/android/keystores/BUCK deleted file mode 100644 index 88e4c31b..00000000 --- a/example/android/keystores/BUCK +++ /dev/null @@ -1,8 +0,0 @@ -keystore( - name = "debug", - properties = "debug.keystore.properties", - store = "debug.keystore", - visibility = [ - "PUBLIC", - ], -) diff --git a/example/android/keystores/debug.keystore.properties b/example/android/keystores/debug.keystore.properties deleted file mode 100644 index 121bfb49..00000000 --- a/example/android/keystores/debug.keystore.properties +++ /dev/null @@ -1,4 +0,0 @@ -key.store=debug.keystore -key.alias=androiddebugkey -key.store.password=android -key.alias.password=android diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 6cdbc4cc..2e9983e3 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,8 +1,4 @@ rootProject.name = 'AsyncStorageExample' -apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) - -include ':app' -include ':rnAsyncStorage' - -project(':rnAsyncStorage').projectDir = new File(rootProject.projectDir, '../../android') +apply from: file('../../node_modules/react-native-test-app/test-app.gradle') +applyTestAppSettings(settings) diff --git a/example/app.json b/example/app.json index 8d6c1faa..8d7fe5b0 100644 --- a/example/app.json +++ b/example/app.json @@ -5,5 +5,13 @@ { "appKey": "AsyncStorageExample" } - ] + ], + "resources": { + "android": [ + "index.android.jsbundle" + ], + "ios": [ + "index.ios.jsbundle" + ] + } } diff --git a/example/e2e/asyncstorage.e2e.js b/example/e2e/asyncstorage.e2e.js index f2ae3980..c902a244 100644 --- a/example/e2e/asyncstorage.e2e.js +++ b/example/e2e/asyncstorage.e2e.js @@ -30,9 +30,6 @@ describe('Async Storage', () => { describe('get / set / clear item test', () => { beforeAll(async () => { - if (device.getPlatform() === 'ios') { - await device.openURL({url: 'rnc-asyncstorage://unset-delegate'}); - } await test_getSetClear.tap(); }); @@ -73,9 +70,6 @@ describe('Async Storage', () => { describe('merge item test', () => { beforeAll(async () => { - if (device.getPlatform() === 'ios') { - await device.openURL({url: 'rnc-asyncstorage://unset-delegate'}); - } await test_mergeItem.tap(); }); @@ -100,35 +94,27 @@ describe('Async Storage', () => { const shoeInput = await element(by.id('testInput-shoe')); const storyText = await element(by.id('storyTextView')); - const isAndroid = device.getPlatform() === 'android'; - + let i = 0; async function performInput() { - const name = Math.random() > 0.5 ? 'Jerry' : 'Sarah'; - const age = Math.random() > 0.5 ? '21' : '23'; - const eyesColor = Math.random() > 0.5 ? 'blue' : 'green'; - const shoeSize = Math.random() > 0.5 ? '9' : '10'; - - if (!isAndroid) { - await eyesInput.tap(); - } + const name = i === 0 ? 'Jerry' : 'Sarah'; + const age = i === 0 ? '21' : '23'; + const eyesColor = i === 0 ? 'blue' : 'green'; + const shoeSize = i === 0 ? '9' : '10'; + i += 1; + + await nameInput.clearText(); await nameInput.typeText(name); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await ageInput.clearText(); await ageInput.typeText(age); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await eyesInput.clearText(); await eyesInput.typeText(eyesColor); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await shoeInput.clearText(); await shoeInput.typeText(shoeSize); await closeKeyboard.tap(); @@ -139,7 +125,7 @@ describe('Async Storage', () => { await buttonSaveItem.tap(); await restartButton.tap(); await buttonRestoreItem.tap(); - expect(storyText).toHaveText(story); + await expect(storyText).toHaveText(story); await restartButton.tap(); // merging here @@ -149,7 +135,7 @@ describe('Async Storage', () => { await buttonMergeItem.tap(); await restartButton.tap(); await buttonRestoreItem.tap(); - expect(storyText).toHaveText(newStory); + await expect(storyText).toHaveText(newStory); }); }); @@ -211,10 +197,12 @@ describe('Async Storage', () => { describe('merge item delegate test', () => { beforeAll(async () => { - if (device.getPlatform() === 'ios') { - await device.openURL({url: 'rnc-asyncstorage://set-delegate'}); - } await test_mergeItem.tap(); + await element(by.id('setDelegate_button')).tap(); + }); + + afterAll(async () => { + await element(by.id('unsetDelegate_button')).tap(); }); it('should merge items with delegate', async () => { @@ -232,35 +220,27 @@ describe('Async Storage', () => { const shoeInput = await element(by.id('testInput-shoe')); const storyText = await element(by.id('storyTextView')); - const isAndroid = device.getPlatform() === 'android'; - + let i = 0; async function performInput() { - const name = Math.random() > 0.5 ? 'Jerry' : 'Sarah'; - const age = Math.random() > 0.5 ? '21' : '23'; - const eyesColor = Math.random() > 0.5 ? 'blue' : 'green'; - const shoeSize = Math.random() > 0.5 ? '9' : '10'; - - if (!isAndroid) { - await eyesInput.tap(); - } + const name = i === 0 ? 'Jerry' : 'Sarah'; + const age = i === 0 ? '21' : '23'; + const eyesColor = i === 0 ? 'blue' : 'green'; + const shoeSize = i === 0 ? '9' : '10'; + i += 1; + + await nameInput.clearText(); await nameInput.typeText(name); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await ageInput.clearText(); await ageInput.typeText(age); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await eyesInput.clearText(); await eyesInput.typeText(eyesColor); await closeKeyboard.tap(); - if (!isAndroid) { - await eyesInput.tap(); - } + await shoeInput.clearText(); await shoeInput.typeText(shoeSize); await closeKeyboard.tap(); @@ -271,7 +251,7 @@ describe('Async Storage', () => { await buttonMergeItem.tap(); await restartButton.tap(); await buttonRestoreItem.tap(); - expect(storyText).toHaveText(story); + await expect(storyText).toHaveText(story); }); }); }); diff --git a/example/e2e/config.json b/example/e2e/config.json index 3491692a..364b8e8d 100644 --- a/example/e2e/config.json +++ b/example/e2e/config.json @@ -1,5 +1,7 @@ { - "setupFilesAfterEnv": ["./init.js"], - "testEnvironment": "node", - "testMatch": [ "**/?(*.)+(e2e).[jt]s?(x)" ] -} \ No newline at end of file + "testEnvironment": "./environment", + "testRunner": "jest-circus/runner", + "testTimeout": 120000, + "testRegex": ".*\\.e2e\\.[jt]sx?", + "reporters": ["detox/runners/jest/streamlineReporter"] +} diff --git a/example/e2e/environment.js b/example/e2e/environment.js new file mode 100644 index 00000000..ad46bec5 --- /dev/null +++ b/example/e2e/environment.js @@ -0,0 +1,23 @@ +const { + DetoxCircusEnvironment, + SpecReporter, + WorkerAssignReporter, +} = require('detox/runners/jest-circus'); + +class CustomDetoxEnvironment extends DetoxCircusEnvironment { + constructor(config) { + super(config); + + // Can be safely removed, if you are content with the default value (=300000ms) + this.initTimeout = 300000; + + // This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level. + // This is strictly optional. + this.registerListeners({ + SpecReporter, + WorkerAssignReporter, + }); + } +} + +module.exports = CustomDetoxEnvironment; diff --git a/example/e2e/init.js b/example/e2e/init.js deleted file mode 100644 index 78be9377..00000000 --- a/example/e2e/init.js +++ /dev/null @@ -1,19 +0,0 @@ -const detox = require('detox'); -const config = require('../../package.json').detox; -const adapter = require('detox/runners/jest/adapter'); - -jest.setTimeout(120000); -jasmine.getEnv().addReporter(adapter); - -beforeAll(async () => { - await detox.init(config); -}); - -beforeEach(async () => { - await adapter.beforeEach(); -}); - -afterAll(async () => { - await adapter.afterAll(); - await detox.cleanup(); -}); diff --git a/example/examples/MergeItem.js b/example/examples/MergeItem.js index 4bbf097e..81ac71a1 100644 --- a/example/examples/MergeItem.js +++ b/example/examples/MergeItem.js @@ -9,7 +9,14 @@ */ import React, {Component} from 'react'; -import {Text, View, Button, TextInput, StyleSheet} from 'react-native'; +import { + Button, + NativeModules, + StyleSheet, + Text, + TextInput, + View, +} from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'; @@ -206,6 +213,25 @@ export default class Merge extends Component { /> + +