Skip to content

Commit

Permalink
Merge pull request #7 from Soomgo-Mobile/sync-8.3.0
Browse files Browse the repository at this point in the history
Sync to upstream (react-native-code-push@master)
  • Loading branch information
floydkim authored Jul 21, 2024
2 parents 7999637 + ad7dcae commit 070094d
Show file tree
Hide file tree
Showing 13 changed files with 599 additions and 346 deletions.
94 changes: 94 additions & 0 deletions .azurepipelines/test-rn-code-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
trigger:
- master

pr:
- master

variables:
- name: api-level
value: '27'

pool:
vmImage: 'macOS-12'

stages:
- stage: RunTests
displayName: 'Run Android & IOS tests'
jobs:
- job: TestAndroid
timeoutInMinutes: 120
displayName: 'Test android'
steps:

- script: |
adb devices
displayName: 'Start adb server'
- script: |
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-$(api-level);google_apis;x86"
displayName: 'Download system image'
- script: |
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestEmulator --abi google_apis/x86 --package 'system-images;android-$(api-level);google_apis;x86' --device "Nexus 6P"
displayName: 'Creating Android emulator'
- script: |
$ANDROID_HOME/emulator/emulator -avd TestEmulator -noaudio -no-window -no-snapshot-save -no-boot-anim -memory 6144 &
displayName: 'Start Android emulator'
- script: |
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
displayName: 'Wait for emulator to boot'
- script: |
adb shell settings put global window_animation_scale 0.0
displayName: 'Disable animations and transitions'
- script: |
adb shell settings put global transition_animation_scale 0.0
displayName: 'Disable animations and transitions'
- script: |
adb shell settings put global animator_duration_scale 0.0
displayName: 'Disable animations and transitions'
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
displayName: 'Change Java version'

- script: |
npm install
displayName: 'Package Installation'
- script: |
npm run build:tests && npm run test:setup:android
displayName: 'Setup Android tests'
- script: |
npm run test:fast:android
displayName: 'Run Android test'
- job: TestIOS
timeoutInMinutes: 120
displayName: 'Test IOS'
steps:

- script: |
npm install
displayName: 'Install dependencies'
- script: |
npm run build:tests && npm run test:setup:ios
displayName: 'Setup iOS tests'
- script: |
npm run test:fast:ios
displayName: 'Run tests'
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,7 @@ ipch/
Ankh.NoLoad

# RN New Version App Generation
Examples/testapp_rn
Examples/testapp_rn

# Android debug build files (conflict ignoring #Visual Studio files)
!android/app/src/debug/
41 changes: 20 additions & 21 deletions CodePush.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,42 +625,41 @@ function codePushify(options = {}) {
sharedCodePushOptions.setUpdateChecker(options.updateChecker);
sharedCodePushOptions.setFallbackToAppCenter(options.fallbackToAppCenter);

var decorator = (RootComponent) => {
const extended = class CodePushComponent extends React.Component {
const decorator = (RootComponent) => {
class CodePushComponent extends React.Component {
constructor(props) {
super(props);
this.rootComponentRef = React.createRef();
}

componentDidMount() {
if (options.checkFrequency === CodePush.CheckFrequency.MANUAL) {
CodePush.notifyAppReady();
} else {
let rootComponentInstance = this.refs.rootComponent;
const rootComponentInstance = this.rootComponentRef.current;

let syncStatusCallback;
if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
syncStatusCallback = rootComponentInstance.codePushStatusDidChange;
if (rootComponentInstance instanceof React.Component) {
syncStatusCallback = syncStatusCallback.bind(rootComponentInstance);
}
syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
}

let downloadProgressCallback;
if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress;
if (rootComponentInstance instanceof React.Component) {
downloadProgressCallback = downloadProgressCallback.bind(rootComponentInstance);
}
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
}

let handleBinaryVersionMismatchCallback;
if (rootComponentInstance && rootComponentInstance.codePushOnBinaryVersionMismatch) {
handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch;
if (rootComponentInstance instanceof React.Component) {
handleBinaryVersionMismatchCallback = handleBinaryVersionMismatchCallback.bind(rootComponentInstance);
}
handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch.bind(rootComponentInstance);
}

CodePush.sync(options, syncStatusCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback);

if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
ReactNative.AppState.addEventListener("change", (newState) => {
newState === "active" && CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
if (newState === "active") {
CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
}
});
}
}
Expand All @@ -669,17 +668,17 @@ function codePushify(options = {}) {
render() {
const props = {...this.props};

// we can set ref property on class components only (not stateless)
// check it by render method
if (RootComponent.prototype.render) {
props.ref = "rootComponent";
// We can set ref property on class components only (not stateless)
// Check it by render method
if (RootComponent.prototype && RootComponent.prototype.render) {
props.ref = this.rootComponentRef;
}

return <RootComponent {...props} />
}
}

return hoistStatics(extended, RootComponent);
return hoistStatics(CodePushComponent, RootComponent);
}

if (typeof options === "function") {
Expand Down
Loading

0 comments on commit 070094d

Please sign in to comment.