Skip to content

Commit 4921410

Browse files
feat: run expo prebuild, install detox, jest, expo config for detox
1 parent 03a0666 commit 4921410

File tree

85 files changed

+5705
-2266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5705
-2266
lines changed

.ls-lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ ignore:
1313
- packages/*/node_modules
1414
- apps/*/node_modules
1515
- storybook-static
16+
- apps/mobile/ios
17+
- apps/mobile/android
18+
- apps/mobile/artifacts

apps/mobile/.detoxrc.cjs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/** @type {Detox.DetoxConfig} */
2+
module.exports = {
3+
logger: {
4+
level: process.env.CI ? 'debug' : undefined,
5+
},
6+
testRunner: {
7+
args: {
8+
$0: 'jest',
9+
config: 'e2e/jest.config.cjs',
10+
},
11+
jest: {
12+
setupTimeout: 120000,
13+
},
14+
},
15+
artifacts: {
16+
plugins: {
17+
log: process.env.CI ? 'failing' : undefined,
18+
screenshot: 'failing',
19+
},
20+
},
21+
apps: {
22+
'ios.release': {
23+
type: 'ios.app',
24+
build:
25+
'xcodebuild -workspace ios/leatherwalletmobile.xcworkspace -scheme leatherwalletmobile -configuration Release -sdk iphonesimulator -arch x86_64 -derivedDataPath ios/build',
26+
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/leatherwalletmobile.app',
27+
},
28+
'android.release': {
29+
type: 'android.apk',
30+
build:
31+
'cd android && ./gradlew :app:assembleRelease :app:assembleAndroidTest -DtestBuildType=release && cd ..',
32+
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
33+
},
34+
},
35+
devices: {
36+
simulator: {
37+
type: 'ios.simulator',
38+
device: {
39+
type: 'iPhone 15',
40+
os: '17.4',
41+
},
42+
},
43+
emulator: {
44+
type: 'android.emulator',
45+
device: {
46+
avdName: 'pixel_4',
47+
},
48+
},
49+
},
50+
configurations: {
51+
'ios.release': {
52+
device: 'simulator',
53+
app: 'ios.release',
54+
},
55+
'android.release': {
56+
device: 'emulator',
57+
app: 'android.release',
58+
},
59+
},
60+
};

apps/mobile/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ yarn-error.*
3434
# typescript
3535
*.tsbuildinfo
3636

37+
# Detox artifacts
38+
artifacts/

apps/mobile/android/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Android/IntelliJ
6+
#
7+
build/
8+
.idea
9+
.gradle
10+
local.properties
11+
*.iml
12+
*.hprof
13+
.cxx/
14+
15+
# Bundle artifacts
16+
*.jsbundle

apps/mobile/android/app/build.gradle

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
3+
apply plugin: "com.facebook.react"
4+
5+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
6+
7+
/**
8+
* This is the configuration block to customize your React Native Android app.
9+
* By default you don't need to apply any configuration, just uncomment the lines you need.
10+
*/
11+
react {
12+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
13+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
14+
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
15+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
16+
17+
// Use Expo CLI to bundle the app, this ensures the Metro config
18+
// works correctly with Expo projects.
19+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
20+
bundleCommand = "export:embed"
21+
22+
/* Folders */
23+
// The root of your project, i.e. where "package.json" lives. Default is '..'
24+
// root = file("../")
25+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
26+
// reactNativeDir = file("../node_modules/react-native")
27+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
28+
// codegenDir = file("../node_modules/@react-native/codegen")
29+
30+
/* Variants */
31+
// The list of variants to that are debuggable. For those we're going to
32+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
33+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
34+
// debuggableVariants = ["liteDebug", "prodDebug"]
35+
36+
/* Bundling */
37+
// A list containing the node command and its flags. Default is just 'node'.
38+
// nodeExecutableAndArgs = ["node"]
39+
40+
//
41+
// The path to the CLI configuration file. Default is empty.
42+
// bundleConfig = file(../rn-cli.config.js)
43+
//
44+
// The name of the generated asset file containing your JS bundle
45+
// bundleAssetName = "MyApplication.android.bundle"
46+
//
47+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
48+
// entryFile = file("../js/MyApplication.android.js")
49+
//
50+
// A list of extra flags to pass to the 'bundle' commands.
51+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
52+
// extraPackagerArgs = []
53+
54+
/* Hermes Commands */
55+
// The hermes compiler command to run. By default it is 'hermesc'
56+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
57+
//
58+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
59+
// hermesFlags = ["-O", "-output-source-map"]
60+
}
61+
62+
/**
63+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
64+
*/
65+
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
66+
67+
/**
68+
* The preferred build flavor of JavaScriptCore (JSC)
69+
*
70+
* For example, to use the international variant, you can use:
71+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
72+
*
73+
* The international variant includes ICU i18n library and necessary data
74+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
75+
* give correct results when using with locales other than en-US. Note that
76+
* this variant is about 6MiB larger per architecture than default.
77+
*/
78+
def jscFlavor = 'org.webkit:android-jsc:+'
79+
80+
android {
81+
ndkVersion rootProject.ext.ndkVersion
82+
83+
buildToolsVersion rootProject.ext.buildToolsVersion
84+
compileSdk rootProject.ext.compileSdkVersion
85+
86+
namespace 'io.leather.mobilewallet'
87+
defaultConfig {
88+
// detox-plugin-default-config
89+
testBuildType System.getProperty('testBuildType', 'debug')
90+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
91+
applicationId 'io.leather.mobilewallet'
92+
minSdkVersion rootProject.ext.minSdkVersion
93+
targetSdkVersion rootProject.ext.targetSdkVersion
94+
versionCode 1
95+
versionName "1.0.0"
96+
}
97+
signingConfigs {
98+
debug {
99+
storeFile file('debug.keystore')
100+
storePassword 'android'
101+
keyAlias 'androiddebugkey'
102+
keyPassword 'android'
103+
}
104+
}
105+
buildTypes {
106+
debug {
107+
signingConfig signingConfigs.debug
108+
}
109+
release {
110+
// Caution! In production, you need to generate your own keystore file.
111+
// see https://reactnative.dev/docs/signed-apk-android.
112+
signingConfig signingConfigs.debug
113+
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
114+
minifyEnabled enableProguardInReleaseBuilds
115+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
116+
// Detox-specific additions to pro-guard
117+
def detoxProguardRulesPath = new File(["node", "--print", "require.resolve('detox/package.json')"].execute(null, rootDir).text.trim(), "../android/detox/proguard-rules-app.pro")
118+
proguardFile(detoxProguardRulesPath)
119+
120+
}
121+
}
122+
packagingOptions {
123+
jniLibs {
124+
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
125+
}
126+
}
127+
}
128+
129+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
130+
// Accepts values in comma delimited lists, example:
131+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
132+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
133+
// Split option: 'foo,bar' -> ['foo', 'bar']
134+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
135+
// Trim all elements in place.
136+
for (i in 0..<options.size()) options[i] = options[i].trim();
137+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
138+
options -= ""
139+
140+
if (options.length > 0) {
141+
println "android.packagingOptions.$prop += $options ($options.length)"
142+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
143+
options.each {
144+
android.packagingOptions[prop] += it
145+
}
146+
}
147+
}
148+
149+
dependencies {
150+
androidTestImplementation('com.wix:detox:+')
151+
implementation 'androidx.appcompat:appcompat:1.6.1'
152+
// The version of react-native is set by the React Native Gradle Plugin
153+
implementation("com.facebook.react:react-android")
154+
155+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
156+
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
157+
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
158+
159+
if (isGifEnabled) {
160+
// For animated gif support
161+
implementation("com.facebook.fresco:animated-gif:${reactAndroidLibs.versions.fresco.get()}")
162+
}
163+
164+
if (isWebpEnabled) {
165+
// For webp support
166+
implementation("com.facebook.fresco:webpsupport:${reactAndroidLibs.versions.fresco.get()}")
167+
if (isWebpAnimatedEnabled) {
168+
// Animated webp support
169+
implementation("com.facebook.fresco:animated-webp:${reactAndroidLibs.versions.fresco.get()}")
170+
}
171+
}
172+
173+
if (hermesEnabled.toBoolean()) {
174+
implementation("com.facebook.react:hermes-android")
175+
} else {
176+
implementation jscFlavor
177+
}
178+
}
179+
180+
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
181+
applyNativeModulesAppBuildGradle(project)
2.2 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# react-native-reanimated
11+
-keep class com.swmansion.reanimated.** { *; }
12+
-keep class com.facebook.react.turbomodule.** { *; }
13+
14+
# Add any project specific keep options here:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.leather.mobilewallet;
2+
3+
import com.wix.detox.Detox;
4+
import com.wix.detox.config.DetoxConfig;
5+
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import androidx.test.ext.junit.runners.AndroidJUnit4;
11+
import androidx.test.filters.LargeTest;
12+
import androidx.test.rule.ActivityTestRule;
13+
14+
@RunWith(AndroidJUnit4.class)
15+
@LargeTest
16+
public class DetoxTest {
17+
@Rule
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
DetoxConfig detoxConfig = new DetoxConfig();
23+
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
24+
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
25+
detoxConfig.rnContextLoadTimeoutSec = (io.leather.mobilewallet.BuildConfig.DEBUG ? 180 : 60);
26+
27+
Detox.runTests(mActivityRule, detoxConfig);
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
6+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:replace="android:usesCleartextTraffic" />
7+
</manifest>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET"/>
3+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
<uses-permission android:name="android.permission.VIBRATE"/>
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7+
<queries>
8+
<intent>
9+
<action android:name="android.intent.action.VIEW"/>
10+
<category android:name="android.intent.category.BROWSABLE"/>
11+
<data android:scheme="https"/>
12+
</intent>
13+
</queries>
14+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:networkSecurityConfig="@xml/network_security_config">
15+
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
16+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
17+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
18+
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN"/>
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
<intent-filter>
24+
<action android:name="android.intent.action.VIEW"/>
25+
<category android:name="android.intent.category.DEFAULT"/>
26+
<category android:name="android.intent.category.BROWSABLE"/>
27+
<data android:scheme="myapp"/>
28+
<data android:scheme="io.leather.mobilewallet"/>
29+
</intent-filter>
30+
</activity>
31+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
32+
</application>
33+
</manifest>

0 commit comments

Comments
 (0)