Skip to content

Commit e05fe4b

Browse files
committed
Merge branch 'develop'
2 parents b8621f0 + 6707b30 commit e05fe4b

File tree

124 files changed

+936
-16997
lines changed

Some content is hidden

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

124 files changed

+936
-16997
lines changed

.azurepipelines/build-rn-code-push-1es.yml

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

.azurepipelines/test-rn-code-push.yml

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

.gitignore

Lines changed: 1 addition & 3 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,3 +189,4 @@ Examples/testapp_rn
192189

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

.npmignore

Lines changed: 2 additions & 4 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
@@ -100,4 +98,4 @@ packages/
10098
.git/
10199

102100
.watchmanconfig
103-
101+
.temp/

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 };

CONTRIBUTING.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Environment setup
66

7-
`node.js` and `npm` are needed for using this project. `npm` comes bundled with the `node.js` installer. You can download the `node.js` installer here: https://nodejs.org/download/.
7+
`node.js` and `npm` are needed for using this project. `npm` comes bundled with the `node.js` installer. You can download the `node.js` installer here: <https://nodejs.org/download/>.
88

99
Once you have installed `node.js` and `npm`, install the dev dependencies for the project.
1010

@@ -15,19 +15,22 @@ npm install
1515
### Using the plugin manually
1616

1717
Follow these steps to test your modifications to the plugin manually:
18+
1819
- clone this repository
1920
- install the dependencies
2021

21-
Navigate to the root folder from your command line console and run:
22-
```
23-
npm install
24-
```
22+
Navigate to the root folder from your command line console and run:
23+
```
24+
npm install
25+
```
26+
2527
- install the plugin in a React-Native project
2628

27-
Navigate to the root folder of your React-Native project from your command line console and run:
28-
```
29-
npm install local_path_to_your_clone_of_this_repo
30-
```
29+
Navigate to the root folder of your React-Native project from your command line console and run:
30+
```
31+
npm install local_path_to_your_clone_of_this_repo
32+
```
33+
3134
- configure the plugin using the steps in the README.md
3235
- build and run your app on an emulator or device
3336

@@ -81,20 +84,23 @@ If you would like to pull the plugin from NPM rather than running the tests on t
8184
#### Default
8285

8386
To run all of the unit tests on Android and iOS:
87+
8488
```
8589
npm run test
8690
```
8791

8892
#### iOS
8993

9094
To run all of the unit tests on iOS:
95+
9196
```
9297
npm run test:ios
9398
```
9499

95100
#### Android
96101

97102
To run all of the unit tests on Android:
103+
98104
```
99105
npm run test:android
100106
```
@@ -107,26 +113,31 @@ The platforms are ordered as follows, and ran in that order:
107113
android, ios
108114

109115
To run the core unit tests on Android:
116+
110117
```
111118
CORE=true npm run test:android
112119
```
113120

114121
To run all of the unit tests on iOS and pull the plugin from NPM:
122+
115123
```
116124
NPM=true npm run test:ios
117125
```
118126

119127
To run all of the unit tests on Android and iOS without building first:
128+
120129
```
121130
npm run test:fast
122131
```
123132

124133
To run all of the unit tests on iOS and restart the emulators:
134+
125135
```
126136
CLEAN=true npm run test:ios
127137
```
128138

129139
To run the core unit tests on Android and pull the plugin from NPM:
140+
130141
```
131142
NPM=true CORE=true npm run test:android
132143
```

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) {

0 commit comments

Comments
 (0)