Skip to content

Commit ac51bf4

Browse files
committed
Merge branch 'feat/new-arch' into develop
2 parents 74ef14d + 8c54e37 commit ac51bf4

Some content is hidden

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

46 files changed

+893
-733
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ proguard/
150150
# Android Studio captures folder
151151
captures/
152152

153-
# Remove after this framework is published on NPM
154-
code-push-plugin-testing-framework/node_modules
155-
156153
# Windows
157154
windows/.vs/
158155
windows/obj/
@@ -192,4 +189,4 @@ Examples/testapp_rn
192189

193190
# Android debug build files (conflict ignoring #Visual Studio files)
194191
!android/app/src/debug/
195-
.temp/
192+
.temp/

.npmignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ Recipes/
3434
bin/
3535
test/
3636

37-
# Remove after this framework is published on NPM
38-
code-push-plugin-testing-framework/
39-
4037
# Android build artifacts and Android Studio bits
38+
android/build
4139
android/app/build
4240
android/local.properties
4341
android/.gradle

AlertAdapter.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@ import React, { Platform } from "react-native";
22
let { Alert } = React;
33

44
if (Platform.OS === "android") {
5-
const { NativeModules: { CodePushDialog } } = React;
5+
function resolveNativeModule(name) {
6+
const ReactNative = require("react-native");
7+
try {
8+
const turboModule =
9+
ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
10+
? ReactNative.TurboModuleRegistry.get(name)
11+
: null;
12+
if (turboModule) return turboModule;
13+
} catch (_e) {
14+
// Ignore and fall back to legacy NativeModules.
15+
}
16+
17+
return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
18+
}
19+
20+
const CodePushDialog = resolveNativeModule("CodePushDialog");
621

722
Alert = {
823
alert(title, message, buttons) {
@@ -13,6 +28,10 @@ if (Platform.OS === "android") {
1328
const button1Text = buttons[0] ? buttons[0].text : null,
1429
button2Text = buttons[1] ? buttons[1].text : null;
1530

31+
if (!CodePushDialog) {
32+
throw "CodePushDialog native module is not installed.";
33+
}
34+
1635
CodePushDialog.showDialog(
1736
title, message, button1Text, button2Text,
1837
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
@@ -21,4 +40,4 @@ if (Platform.OS === "android") {
2140
};
2241
}
2342

24-
module.exports = { Alert };
43+
module.exports = { Alert };

CodePush.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@ import { AppState, Platform } from "react-native";
55
import log from "./logging";
66
import hoistStatics from 'hoist-non-react-statics';
77

8-
let NativeCodePush = require("react-native").NativeModules.CodePush;
8+
function resolveNativeModule(name) {
9+
const ReactNative = require("react-native");
10+
try {
11+
const turboModule =
12+
ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
13+
? ReactNative.TurboModuleRegistry.get(name)
14+
: null;
15+
if (turboModule) return turboModule;
16+
} catch (_e) {
17+
// Ignore and fall back to legacy NativeModules.
18+
}
19+
20+
return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
21+
}
22+
23+
let NativeCodePush = resolveNativeModule("CodePush");
924
const PackageMixins = require("./package-mixins")(NativeCodePush);
1025

1126
async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {

CodePush.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Pod::Spec.new do |s|
1010
s.license = package['license']
1111
s.homepage = package['homepage']
1212
s.source = { :git => 'https://github.com/srcpush/react-native-code-push.git', :tag => "v#{s.version}"}
13-
s.ios.deployment_target = '15.5'
14-
s.tvos.deployment_target = '15.5'
13+
s.ios.deployment_target = '11.0'
14+
s.tvos.deployment_target = '11.0'
1515
s.preserve_paths = '*.js'
1616
s.library = 'z'
1717
s.source_files = 'ios/CodePush/*.{h,m}'

android/app/build.gradle

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,98 @@
1-
apply plugin: "com.android.library"
2-
3-
def isNewArchitectureEnabled() {
4-
// To opt-in for the New Architecture, you can either:
5-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
6-
// - Invoke gradle with `-newArchEnabled=true`
7-
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
8-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
9-
}
1+
import groovy.json.JsonSlurper
102

11-
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
3+
apply plugin: "com.android.library"
124

13-
if (IS_NEW_ARCHITECTURE_ENABLED) {
14-
apply plugin: "com.facebook.react"
5+
def safeExtGet(prop, fallback) {
6+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
157
}
168

179
def DEFAULT_COMPILE_SDK_VERSION = 26
18-
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"
1910
def DEFAULT_TARGET_SDK_VERSION = 26
2011
def DEFAULT_MIN_SDK_VERSION = 16
2112

13+
def findReactNativePackageJson() {
14+
File currentDir = projectDir
15+
16+
while (currentDir != null) {
17+
File packageJson = new File(currentDir, "node_modules/react-native/package.json")
18+
if (packageJson.exists()) {
19+
return packageJson
20+
}
21+
22+
currentDir = currentDir.parentFile
23+
}
24+
25+
return null
26+
}
27+
28+
def getReactNativeVersion() {
29+
File packageJson = findReactNativePackageJson()
30+
if (packageJson == null) {
31+
return null
32+
}
33+
34+
def version = new JsonSlurper().parseText(packageJson.text).version
35+
return version.tokenize("-")[0]
36+
}
37+
38+
def getReactNativeMinorVersion() {
39+
def reactNativeVersion = getReactNativeVersion()
40+
if (reactNativeVersion == null) {
41+
return null
42+
}
43+
44+
def versionParts = reactNativeVersion.tokenize(".")
45+
if (versionParts.size() < 2) {
46+
return null
47+
}
48+
49+
return versionParts[1].toInteger()
50+
}
51+
52+
def reactNativeVersion = getReactNativeVersion()
53+
def reactNativeMinorVersion = getReactNativeMinorVersion()
54+
def reactNativeDependency = reactNativeMinorVersion != null && reactNativeMinorVersion < 71
55+
? "com.facebook.react:react-native:${reactNativeVersion ?: '+'}"
56+
: "com.facebook.react:react-android:${reactNativeVersion ?: '+'}"
57+
2258
android {
23-
namespace "com.microsoft.codepush.react"
59+
if (project.android.hasProperty("namespace")) {
60+
namespace "com.microsoft.codepush.react"
61+
}
2462

25-
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
26-
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
63+
compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)
2764

2865
defaultConfig {
29-
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
30-
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
66+
minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
67+
targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
3168
versionCode 1
3269
versionName "1.0"
33-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString()
70+
consumerProguardFiles "../proguard-rules.pro"
71+
}
72+
73+
sourceSets {
74+
main {
75+
java.srcDirs = ["../src/main/java"]
76+
}
77+
}
78+
79+
compileOptions {
80+
sourceCompatibility JavaVersion.VERSION_1_8
81+
targetCompatibility JavaVersion.VERSION_1_8
3482
}
3583

3684
lintOptions {
3785
abortOnError false
3886
}
87+
}
3988

40-
defaultConfig {
41-
consumerProguardFiles 'proguard-rules.pro'
42-
}
89+
repositories {
90+
google()
91+
mavenCentral()
92+
mavenLocal()
4393
}
4494

4595
dependencies {
46-
implementation "com.facebook.react:react-native:+"
47-
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
96+
implementation(reactNativeDependency)
97+
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
4898
}
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2-
32
<uses-permission android:name="android.permission.INTERNET" />
4-
5-
<application>
6-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
7-
</application>
8-
93
</manifest>
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2-
3-
<uses-permission android:name="android.permission.INTERNET" />
4-
5-
</manifest>
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.microsoft.codepush.react" />

android/app/src/main/java/com/microsoft/codepush/react/ReactHostHolder.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

android/build.gradle

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,109 @@
1-
apply plugin: 'com.android.library'
1+
import groovy.json.JsonSlurper
2+
3+
buildscript {
4+
ext {
5+
kotlinVersion = "1.9.24"
6+
}
7+
repositories {
8+
google()
9+
mavenCentral()
10+
}
11+
dependencies {
12+
classpath("com.android.tools.build:gradle:8.2.1")
13+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
14+
}
15+
}
16+
17+
apply plugin: "com.android.library"
18+
19+
def safeExtGet(prop, fallback) {
20+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
21+
}
22+
23+
def DEFAULT_COMPILE_SDK_VERSION = 26
24+
def DEFAULT_TARGET_SDK_VERSION = 26
25+
def DEFAULT_MIN_SDK_VERSION = 16
26+
27+
def findReactNativePackageJson() {
28+
File currentDir = projectDir
29+
30+
while (currentDir != null) {
31+
File packageJson = new File(currentDir, "node_modules/react-native/package.json")
32+
if (packageJson.exists()) {
33+
return packageJson
34+
}
35+
36+
currentDir = currentDir.parentFile
37+
}
38+
39+
return null
40+
}
41+
}
42+
43+
return null
44+
}
45+
46+
def getReactNativeVersion() {
47+
File packageJson = findReactNativePackageJson()
48+
if (packageJson == null) {
49+
return null
50+
}
51+
52+
def version = new JsonSlurper().parseText(packageJson.text).version
53+
return version.tokenize("-")[0]
54+
}
55+
56+
def getReactNativeMinorVersion() {
57+
def reactNativeVersion = getReactNativeVersion()
58+
if (reactNativeVersion == null) {
59+
return null
60+
}
61+
62+
def versionParts = reactNativeVersion.tokenize(".")
63+
if (versionParts.size() < 2) {
64+
return null
65+
}
66+
67+
return versionParts[1].toInteger()
68+
}
69+
70+
def reactNativeVersion = getReactNativeVersion()
71+
def reactNativeMinorVersion = getReactNativeMinorVersion()
72+
def reactNativeDependency = reactNativeMinorVersion != null && reactNativeMinorVersion < 71
73+
? "com.facebook.react:react-native:${reactNativeVersion ?: '+'}"
74+
: "com.facebook.react:react-android:${reactNativeVersion ?: '+'}"
275

376
android {
4-
namespace "com.microsoft.codepush.react"
5-
compileSdkVersion 33
77+
if (project.android.hasProperty("namespace")) {
78+
namespace "com.microsoft.codepush.react"
79+
}
80+
81+
compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)
682

783
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 33
84+
minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
85+
targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
1086
versionCode 1
1187
versionName "1.0"
88+
consumerProguardFiles "proguard-rules.pro"
1289
}
13-
}
1490

91+
compileOptions {
92+
sourceCompatibility JavaVersion.VERSION_1_8
93+
targetCompatibility JavaVersion.VERSION_1_8
94+
}
95+
96+
lintOptions {
97+
abortOnError false
98+
}
99+
}
15100
repositories {
16-
mavenLocal()
101+
google()
17102
mavenCentral()
103+
mavenLocal()
104+
}
105+
106+
dependencies {
107+
implementation(reactNativeDependency)
108+
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
18109
}

0 commit comments

Comments
 (0)