Skip to content

Commit b68dad5

Browse files
committed
update test template for react native v0.81
1 parent f5daf57 commit b68dad5

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

test/template/android/app/src/main/java/com/testcodepush/MainApplication.kt

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,38 @@ import android.app.Application
44
import com.facebook.react.PackageList
55
import com.facebook.react.ReactApplication
66
import com.facebook.react.ReactHost
7+
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
78
import com.facebook.react.ReactNativeHost
89
import com.facebook.react.ReactPackage
9-
import com.facebook.react.common.annotations.UnstableReactNativeAPI
10-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1110
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1211
import com.facebook.react.defaults.DefaultReactNativeHost
13-
import com.facebook.react.soloader.OpenSourceMergedSoMapping
14-
import com.facebook.soloader.SoLoader
12+
1513
import com.microsoft.codepush.react.CodePush
1614

17-
@OptIn(UnstableReactNativeAPI::class)
1815
class MainApplication : Application(), ReactApplication {
1916

20-
override val reactNativeHost: ReactNativeHost =
17+
override val reactNativeHost: ReactNativeHost =
2118
object : DefaultReactNativeHost(this) {
22-
override fun getPackages(): List<ReactPackage> {
23-
val packages = PackageList(this).packages
24-
// Packages that cannot be autolinked yet can be added manually here, for example:
25-
// packages.add(new MyReactNativePackage());
26-
return packages
27-
}
28-
19+
override fun getPackages(): List<ReactPackage> =
20+
PackageList(this).packages.apply {
21+
// Packages that cannot be autolinked yet can be added manually here, for example:
22+
// add(MyReactNativePackage())
23+
}
24+
2925
override fun getJSMainModuleName(): String = "index"
3026
override fun getJSBundleFile(): String = CodePush.getJSBundleFile()
31-
27+
3228
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
3329

3430
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
3531
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
3632
}
3733

38-
override val reactHost: ReactHost get() = getDefaultReactHost(this, reactNativeHost)
34+
override val reactHost: ReactHost
35+
get() = getDefaultReactHost(applicationContext, reactNativeHost)
3936

4037
override fun onCreate() {
4138
super.onCreate()
42-
SoLoader.init(this, OpenSourceMergedSoMapping)
43-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
44-
// If you opted-in for the New Architecture, we load the native entry point for this app.
45-
load()
46-
}
39+
loadReactNative(this)
4740
}
48-
49-
}
41+
}

test/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RNAndroid extends Platform.Android implements RNPlatform {
8686
// we use hard-coded deployment key and server url in app.json
8787
return Q.Promise<void>((resolve, reject) => {
8888
TestUtil.replaceString(androidMainActivityPath, "\"main\"", `"${TestConfig.TestAppName}"`);
89-
TestUtil.replaceString(AndroidManifest, "android:allowBackup=\"true\"", "android:allowBackup=\"true\"" + "\n\t" + "android:usesCleartextTraffic=\"true\"");
89+
TestUtil.replaceString(AndroidManifest, "\\${usesCleartextTraffic}", "true");
9090
resolve(null);
9191
});
9292
}
@@ -117,7 +117,7 @@ class RNAndroid extends Platform.Android implements RNPlatform {
117117
const string = path.join(innerprojectDirectory, "android", "app", "src", "main", "res", "values", "strings.xml");
118118
TestUtil.replaceString(string, TestUtil.SERVER_URL_PLACEHOLDER, this.getServerUrl());
119119
TestUtil.replaceString(string, TestUtil.ANDROID_KEY_PLACEHOLDER, this.getDefaultDeploymentKey());
120-
TestUtil.replaceString(AndroidManifest, "android:allowBackup=\"false\"", "android:allowBackup=\"false\"" + "\n\t" + "android:usesCleartextTraffic=\"true\"");
120+
TestUtil.replaceString(AndroidManifest, "\\${usesCleartextTraffic}", "true");
121121

122122

123123
return Q<void>(null);
@@ -342,7 +342,7 @@ class RNProjectManager extends ProjectManager {
342342
.then(TestUtil.getProcessOutput.bind(undefined, `npx expo prebuild --clean`, { cwd: path.join(projectDirectory, TestConfig.TestAppName) }))
343343
.then(() => { return null; });
344344
} else {
345-
return TestUtil.getProcessOutput("npx @react-native-community/cli init " + appName + " --version 0.80.1 --install-pods", { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
345+
return TestUtil.getProcessOutput("npx @react-native-community/cli init " + appName + " --version 0.81.5 --install-pods", { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
346346
.then((e) => { console.log(`"npx @react-native-community/cli init ${appName}" success. cwd=${projectDirectory}`); return e; })
347347
.then(this.copyTemplate.bind(this, templatePath, projectDirectory))
348348
.then<void>(TestUtil.getProcessOutput.bind(undefined, TestConfig.thisPluginInstallString, { cwd: path.join(projectDirectory, TestConfig.TestAppName) }))

0 commit comments

Comments
 (0)