mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 07:10:36 +08:00
Merge pull request #455 from Microsoft/update-sample-app
Update sample app
This commit is contained in:
3
Examples/CodePushDemoApp/.babelrc
Normal file
3
Examples/CodePushDemoApp/.babelrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["react-native-stage-0/decorator-support"]
|
||||
}
|
||||
6
Examples/CodePushDemoApp/.buckconfig
Normal file
6
Examples/CodePushDemoApp/.buckconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
@@ -1,65 +1,41 @@
|
||||
[ignore]
|
||||
|
||||
# We fork some components by platform.
|
||||
.*/*.web.js
|
||||
.*/*.android.js
|
||||
|
||||
# Some modules have their own node_modules with overlap
|
||||
.*/node_modules/node-haste/.*
|
||||
# Ignore templates with `@flow` in header
|
||||
.*/local-cli/generator.*
|
||||
|
||||
# Ugh
|
||||
.*/node_modules/babel.*
|
||||
.*/node_modules/babylon.*
|
||||
.*/node_modules/invariant.*
|
||||
|
||||
# Ignore react and fbjs where there are overlaps, but don't ignore
|
||||
# anything that react-native relies on
|
||||
.*/node_modules/fbjs/lib/Map.js
|
||||
.*/node_modules/fbjs/lib/Promise.js
|
||||
.*/node_modules/fbjs/lib/fetch.js
|
||||
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
|
||||
.*/node_modules/fbjs/lib/isEmpty.js
|
||||
.*/node_modules/fbjs/lib/crc32.js
|
||||
.*/node_modules/fbjs/lib/ErrorUtils.js
|
||||
|
||||
# Flow has a built-in definition for the 'react' module which we prefer to use
|
||||
# over the currently-untyped source
|
||||
.*/node_modules/react/react.js
|
||||
.*/node_modules/react/lib/React.js
|
||||
.*/node_modules/react/lib/ReactDOM.js
|
||||
|
||||
# Ignore commoner tests
|
||||
.*/node_modules/commoner/test/.*
|
||||
|
||||
# See https://github.com/facebook/flow/issues/442
|
||||
.*/react-tools/node_modules/commoner/lib/reader.js
|
||||
|
||||
# Ignore jest
|
||||
.*/node_modules/jest-cli/.*
|
||||
|
||||
# Ignore Website
|
||||
.*/website/.*
|
||||
# Ignore malformed json
|
||||
.*/node_modules/y18n/test/.*\.json
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
node_modules/react-native/Libraries/react-native/react-native-interface.js
|
||||
node_modules/react-native/flow
|
||||
flow/
|
||||
|
||||
[options]
|
||||
module.system=haste
|
||||
|
||||
esproposal.class_static_fields=enable
|
||||
esproposal.class_instance_fields=enable
|
||||
|
||||
experimental.strict_type_args=true
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
|
||||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
|
||||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
|
||||
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FixMe
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
|
||||
[version]
|
||||
0.20.1
|
||||
^0.27.0
|
||||
|
||||
60
Examples/CodePushDemoApp/.gitignore
vendored
60
Examples/CodePushDemoApp/.gitignore
vendored
@@ -20,56 +20,22 @@ DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
project.xcworkspace
|
||||
|
||||
# Android/IJ
|
||||
#
|
||||
*.iml
|
||||
.idea
|
||||
.gradle
|
||||
local.properties
|
||||
|
||||
# node.js
|
||||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
main.jsbundle
|
||||
|
||||
# Intellij project files
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
#Gradle
|
||||
.gradletasknamecache
|
||||
.gradle/
|
||||
build/
|
||||
bin/
|
||||
|
||||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
*/build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
# BUCK
|
||||
buck-out/
|
||||
\.buckd/
|
||||
android/app/libs
|
||||
android/keystores/debug.keystore
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@interface CheckForUpdateTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation CheckForUpdateTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
[CodePush clearUpdates];
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/CheckForUpdateTests/CheckForUpdateTestApp", nil);
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
|
||||
- (void)testFirstUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"FirstUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testNewUpdate
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"NewUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testNoRemotePackage
|
||||
{
|
||||
|
||||
[_runner runTest:_cmd module:@"NoRemotePackageTest"];
|
||||
}
|
||||
|
||||
- (void)testRemotePackageAppVersionNewer
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"RemotePackageAppVersionNewerTest"];
|
||||
}
|
||||
|
||||
- (void)testSamePackage
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"SamePackageTest"];
|
||||
}
|
||||
|
||||
- (void)testSwitchDeploymentKey
|
||||
{
|
||||
[_runner runTest:_cmd
|
||||
module:@"SwitchDeploymentKeyTest"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
const TESTS = [
|
||||
require("./testcases/FirstUpdateTest"),
|
||||
require("./testcases/NewUpdateTest"),
|
||||
require("./testcases/NoRemotePackageTest"),
|
||||
require("./testcases/RemotePackageAppVersionNewerTest"),
|
||||
require("./testcases/SamePackageTest"),
|
||||
require("./testcases/SwitchDeploymentKeyTest")
|
||||
];
|
||||
|
||||
TESTS.forEach(
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test)
|
||||
);
|
||||
|
||||
let CheckForUpdateTestApp = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
test: null,
|
||||
};
|
||||
},
|
||||
render() {
|
||||
if (this.state.test) {
|
||||
return (
|
||||
<ScrollView>
|
||||
<this.state.test />
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.row}>
|
||||
CheckForUpdate Tests
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
style={styles.row}>
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
<Text style={styles.testDescription}>
|
||||
{test.description}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: "white",
|
||||
marginTop: 40,
|
||||
margin: 15,
|
||||
},
|
||||
row: {
|
||||
padding: 10,
|
||||
},
|
||||
testName: {
|
||||
fontWeight: "500",
|
||||
},
|
||||
testDescription: {
|
||||
fontSize: 10
|
||||
},
|
||||
separator: {
|
||||
height: 1,
|
||||
backgroundColor: "#bbbbbb",
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("CheckForUpdateTestApp", () => CheckForUpdateTestApp);
|
||||
@@ -1,32 +0,0 @@
|
||||
export let serverPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "Angry flappy birds",
|
||||
downloadUrl: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
isAvailable: true,
|
||||
isMandatory: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024,
|
||||
updateAppVersion: false
|
||||
};
|
||||
|
||||
export let localPackage = {
|
||||
downloadURL: "http://www.windowsazure.com/blobs/awperoiuqpweru",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash123",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
export let updateAppVersionPackage = {
|
||||
appVersion: "1.5.0",
|
||||
description: "",
|
||||
downloadUrl: "",
|
||||
isAvailable: false,
|
||||
isMandatory: false,
|
||||
packageHash: "",
|
||||
updateAppVersion: true
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
import { serverPackage } from "../resources/testPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const localPackage = {};
|
||||
|
||||
let FirstUpdateTest = createTestCaseComponent(
|
||||
"FirstUpdateTest",
|
||||
"should return an update when called from freshly installed binary if the server has one",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote(), failedInstall: false }), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = FirstUpdateTest;
|
||||
@@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
import { serverPackage, localPackage } from "../resources/testPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let NewUpdateTest = createTestCaseComponent(
|
||||
"NewUpdateTest",
|
||||
"should return an update when server has a package that is newer than the current one",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote(), failedInstall: false }), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NewUpdateTest;
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const serverPackage = null;
|
||||
const localPackage = {};
|
||||
|
||||
let NoRemotePackageTest = createTestCaseComponent(
|
||||
"NoRemotePackageTest",
|
||||
"should not return an update when the server has none",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert(!update, "checkForUpdate should not return an update if there is none on the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NoRemotePackageTest;
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
import { updateAppVersionPackage as serverPackage } from "../resources/testPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const localPackage = {};
|
||||
|
||||
let RemotePackageAppVersionNewerTest = createTestCaseComponent(
|
||||
"RemotePackageAppVersionNewerTest",
|
||||
"should drop the update when the server reports one with a newer binary version",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.0.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert(!update, "checkForUpdate should not return an update if remote package is of a different binary version");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = RemotePackageAppVersionNewerTest;
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
import { serverPackage } from "../resources/testPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const localPackage = serverPackage;
|
||||
|
||||
let SamePackageTest = createTestCaseComponent(
|
||||
"SamePackageTest",
|
||||
"should not return an update when the server's version is the same as the local version",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert(!update, "checkForUpdate should not return a package when local package is identical");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SamePackageTest;
|
||||
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
import { serverPackage } from "../resources/testPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const localPackage = {};
|
||||
const deploymentKey = "myKey123";
|
||||
|
||||
let SwitchDeploymentKeyTest = createTestCaseComponent(
|
||||
"SwitchDeploymentKeyTest",
|
||||
"should check for an update under the specified deployment key",
|
||||
() => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage, deploymentKey);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate(deploymentKey);
|
||||
assert.equal(JSON.stringify(update), JSON.stringify({ ...serverPackage, ...PackageMixins.remote(), failedInstall: false, deploymentKey }), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SwitchDeploymentKeyTest;
|
||||
@@ -1,39 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@interface DownloadProgressTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation DownloadProgressTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
[CodePush clearUpdates];
|
||||
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/DownloadProgressTests/DownloadProgressTestApp", nil);
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
- (void)testDownloadProgress
|
||||
{
|
||||
|
||||
[_runner runTest:_cmd module:@"DownloadProgressTest"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,78 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let TESTS = [
|
||||
require("./testcases/DownloadProgressTest")
|
||||
];
|
||||
|
||||
TESTS.forEach(
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test)
|
||||
);
|
||||
|
||||
let DownloadProgressTestApp = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
test: null,
|
||||
};
|
||||
},
|
||||
render() {
|
||||
if (this.state.test) {
|
||||
return (
|
||||
<ScrollView>
|
||||
<this.state.test />
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.row}>
|
||||
DownloadProgress Tests
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
style={styles.row}>
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
<Text style={styles.testDescription}>
|
||||
{test.description}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: "white",
|
||||
marginTop: 40,
|
||||
margin: 15,
|
||||
},
|
||||
row: {
|
||||
padding: 10,
|
||||
},
|
||||
testName: {
|
||||
fontWeight: "500",
|
||||
},
|
||||
separator: {
|
||||
height: 1,
|
||||
backgroundColor: "#bbbbbb",
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("DownloadProgressTestApp", () => DownloadProgressTestApp);
|
||||
@@ -1,47 +0,0 @@
|
||||
import { Platform } from "react-native";
|
||||
|
||||
const packages = [
|
||||
{
|
||||
downloadUrl: "smallFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
{
|
||||
downloadUrl: "mediumFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
},
|
||||
{
|
||||
downloadUrl: "largeFile",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
}
|
||||
];
|
||||
|
||||
packages.forEach((aPackage) => {
|
||||
if (Platform.OS === "android") {
|
||||
aPackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/DownloadProgressTests/resources/" + aPackage.downloadUrl;
|
||||
} else if (Platform.OS === "ios") {
|
||||
aPackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/DownloadProgressTests/resources/" + aPackage.downloadUrl;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = packages;
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
import testPackages from "../resources/TestPackages";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
const localPackage = {};
|
||||
|
||||
let saveProgress;
|
||||
|
||||
function checkReceivedAndExpectedBytesEqual() {
|
||||
assert(saveProgress, "Download progress was not reported.");
|
||||
assert.equal(
|
||||
saveProgress.receivedBytes,
|
||||
saveProgress.totalBytes,
|
||||
`Bytes do not tally: Received bytes=${saveProgress.receivedBytes} Total bytes=${saveProgress.totalBytes}`
|
||||
);
|
||||
console.log("Downloaded one package.");
|
||||
saveProgress = null;
|
||||
}
|
||||
|
||||
let DownloadProgressTest = createTestCaseComponent(
|
||||
"DownloadProgressTest",
|
||||
"should successfully download all the bytes contained in the test packages",
|
||||
() => {
|
||||
testPackages.forEach((aPackage, index) => {
|
||||
testPackages[index] = Object.assign(aPackage, PackageMixins.remote());
|
||||
});
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
let downloadProgressCallback = (downloadProgress) => {
|
||||
console.log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
|
||||
saveProgress = downloadProgress;
|
||||
};
|
||||
|
||||
// Chains promises together.
|
||||
return testPackages.reduce((aPackageDownloaded, nextPackage, index) => {
|
||||
return aPackageDownloaded
|
||||
.then(() => {
|
||||
// Skip the first time.
|
||||
index && checkReceivedAndExpectedBytesEqual();
|
||||
return nextPackage.download(downloadProgressCallback);
|
||||
})
|
||||
}, Promise.resolve());
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = DownloadProgressTest;
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,111 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RCTTest/RCTTestRunner.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTRootView.h"
|
||||
#import "RCTText.h"
|
||||
#import "CodePush.h"
|
||||
|
||||
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
|
||||
|
||||
@interface InstallUpdateTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation InstallUpdateTests
|
||||
{
|
||||
RCTTestRunner *_runner;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
#if __LP64__
|
||||
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
|
||||
#endif
|
||||
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||
[CodePush setUsingTestConfiguration:YES];
|
||||
}
|
||||
|
||||
#pragma mark Logic Tests
|
||||
- (void)testInstallModeImmediate
|
||||
{
|
||||
[self runTest:@"InstallModeImmediateTest"];
|
||||
}
|
||||
|
||||
- (void)testInstallModeOnNextResume
|
||||
{
|
||||
[self runTest:@"InstallModeOnNextResumeTest"];
|
||||
}
|
||||
|
||||
- (void)testInstallModeOnNextRestart
|
||||
{
|
||||
[self runTest:@"InstallModeOnNextRestartTest"];
|
||||
}
|
||||
|
||||
- (void)testIsFirstRun
|
||||
{
|
||||
[self runTest:@"IsFirstRunTest"];
|
||||
}
|
||||
|
||||
- (void)testNotifyApplicationReady
|
||||
{
|
||||
[self runTest:@"NotifyApplicationReadyTest"];
|
||||
}
|
||||
|
||||
- (void)testRollback
|
||||
{
|
||||
[self runTest:@"RollbackTest"];
|
||||
}
|
||||
|
||||
- (void)testIsFailedUpdate
|
||||
{
|
||||
[self runTest:@"IsFailedUpdateTest"];
|
||||
}
|
||||
|
||||
- (void)testIsPending
|
||||
{
|
||||
[self runTest:@"IsPendingTest"];
|
||||
}
|
||||
|
||||
- (void)runTest:(NSString *)testName
|
||||
{
|
||||
[CodePush clearUpdates];
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/testcases/%@.bundle?platform=ios&dev=true", testName]]
|
||||
moduleName:testName
|
||||
initialProperties:nil
|
||||
launchOptions:nil];
|
||||
rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices
|
||||
UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
vc.view = [UIView new];
|
||||
[vc.view addSubview:rootView];
|
||||
while (![self foundTestPassedText:vc.view]) {
|
||||
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)foundTestPassedText:(UIView *)view {
|
||||
BOOL foundText = NO;
|
||||
NSArray *subviews = [view subviews];
|
||||
if ([subviews count] == 0) {
|
||||
if ([view isKindOfClass:[RCTText class]] && [[((RCTText *)view) textStorage].string isEqualToString:@"Test Passed!"]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
for (UIView *subview in subviews) {
|
||||
foundText = [self foundTestPassedText:subview];
|
||||
if (foundText) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundText;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let IsFirstRunTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
async componentDidMount() {
|
||||
let localPackage = await CodePush.getCurrentPackage();
|
||||
if (localPackage.isFirstRun) {
|
||||
this.setState({ passed: true });
|
||||
} else {
|
||||
this.setState({ passed: false });
|
||||
}
|
||||
},
|
||||
render() {
|
||||
let text = "Testing...";
|
||||
if (this.state.passed !== undefined) {
|
||||
text = this.state.passed ? "Test Passed!" : "Test Failed!";
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
{text}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("IsFirstRunTest", () => IsFirstRunTest);
|
||||
@@ -1,66 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let IsFailedUpdateTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
async componentDidMount() {
|
||||
let serverPackage = {
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash241",
|
||||
packageSize: 1024
|
||||
};
|
||||
|
||||
if (Platform.OS === "android") {
|
||||
serverPackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV2.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
serverPackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV2.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
await CodePush.notifyApplicationReady()
|
||||
let remotePackage = await CodePush.checkForUpdate();
|
||||
if (remotePackage.failedInstall) {
|
||||
this.setState({ passed: true });
|
||||
} else {
|
||||
let localPackage = await remotePackage.download();
|
||||
return localPackage && await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
}
|
||||
},
|
||||
render() {
|
||||
let text = "Testing...";
|
||||
if (this.state.passed !== undefined) {
|
||||
text = this.state.passed ? "Test Passed!" : "Test Failed!";
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
{text}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);
|
||||
@@ -1,26 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let IsFailedUpdateTest = React.createClass({
|
||||
componentDidMount() {
|
||||
// Should trigger a rollback.
|
||||
CodePush.restartApp();
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Testing...
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);
|
||||
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { Platform, AppRegistry, Text, View } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const RCTTestModule = React.NativeModules.TestModule;
|
||||
|
||||
let NotifyApplicationReadyTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
async componentDidMount() {
|
||||
await CodePush.notifyApplicationReady();
|
||||
if (Platform.OS === "android") {
|
||||
await NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=android&dev=true");
|
||||
} else if (Platform.OS === "ios") {
|
||||
await NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=ios&dev=true");
|
||||
}
|
||||
|
||||
CodePush.restartApp();
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Testing...
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let InstallModeImmediateTest = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Test Passed!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("InstallModeImmediateTest", () => InstallModeImmediateTest);
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let InstallModeOnNextRestartTest = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Test Passed!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("InstallModeOnNextRestartTest", () => InstallModeOnNextRestartTest);
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let InstallModeOnNextResumeTest = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Test Passed!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("InstallModeOnNextResumeTest", () => InstallModeOnNextResumeTest);
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let NotifyApplicationReadyTest = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Test Passed!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);
|
||||
@@ -1,46 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
const RCTTestModule = React.NativeModules.TestModule;
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let RollbackTest = React.createClass({
|
||||
async componentDidMount() {
|
||||
let remotePackage = require("./remotePackage");
|
||||
remotePackage.packageHash = "hash241";
|
||||
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV2.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
await CodePush.notifyApplicationReady();
|
||||
await NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.includeRequire.runModule.bundle?platform=android&dev=true");
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV2.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
await CodePush.notifyApplicationReady()
|
||||
await NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.includeRequire.runModule.bundle?platform=ios&dev=true");
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Testing...
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
let RollbackTest = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Test Passed!
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);
|
||||
@@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let RollbackTest = React.createClass({
|
||||
componentDidMount() {
|
||||
CodePush.restartApp();
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
Testing...
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
deploymentKey: "myKey123",
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash240",
|
||||
packageSize: 1024
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let InstallModeImmediateTest = createTestCaseComponent(
|
||||
"InstallModeImmediateTest",
|
||||
"App should restart immediately to the new version after it is installed",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeImmediateTest.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeImmediateTest.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("InstallModeImmediateTest", () => InstallModeImmediateTest);
|
||||
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let InstallModeOnNextRestartTest = createTestCaseComponent(
|
||||
"InstallModeOnNextRestartTest",
|
||||
"App should boot up the new version after it is installed and restarted",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
// Genymotion forwards 10.0.3.2 to host machine's localhost
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextRestartTest.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextRestartTest.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
await localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
|
||||
CodePush.restartApp();
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("InstallModeOnNextRestartTest", () => InstallModeOnNextRestartTest);
|
||||
@@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let InstallModeOnNextResumeTest = createTestCaseComponent(
|
||||
"InstallModeOnNextResumeTest",
|
||||
"App should boot up the new version after it is installed and resumed",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextResumeTest.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassInstallModeOnNextResumeTest.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
await localPackage.install(NativeCodePush.codePushInstallModeOnNextResume);
|
||||
CodePush.restartApp();
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("InstallModeOnNextResumeTest", () => InstallModeOnNextResumeTest);
|
||||
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let IsFailedUpdateTest = createTestCaseComponent(
|
||||
"IsFailedUpdateTest",
|
||||
"After an installed update is rolled back, checkForUpdate should return a package with the failedInstall property set to \"true\"",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV1.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/IsFailedUpdateTestBundleV1.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("IsFailedUpdateTest", () => IsFailedUpdateTest);
|
||||
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let IsFirstRunTest = createTestCaseComponent(
|
||||
"IsFirstRunTest",
|
||||
"After the app is installed, the isFirstRun property on the current package should be set to \"true\"",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("IsFirstRunTest", () => IsFirstRunTest);
|
||||
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let IsPendingTest = createTestCaseComponent(
|
||||
"IsPendingTest",
|
||||
"After the app is installed, the isPending property on the installed package should be set to \"true\"",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/CheckIsFirstRunAndPassTest.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
await localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
|
||||
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
|
||||
localPackage = await CodePush.getCurrentPackage();
|
||||
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
|
||||
}
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("IsPendingTest", () => IsPendingTest);
|
||||
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let NotifyApplicationReadyTest = createTestCaseComponent(
|
||||
"NotifyApplicationReadyTest",
|
||||
"After an update, the app should remain using the installed version after multiple restarts if \"notifyApplicationReady\" is called.",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/NotifyApplicationReadyAndRestart.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/NotifyApplicationReadyAndRestart.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("NotifyApplicationReadyTest", () => NotifyApplicationReadyTest);
|
||||
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Platform, AppRegistry } from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
import createTestCaseComponent from "../../utils/createTestCaseComponent";
|
||||
import assert from "assert";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
const PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let remotePackage = require("../resources/remotePackage");
|
||||
|
||||
let RollbackTest = createTestCaseComponent(
|
||||
"RollbackTest",
|
||||
"should successfully rollback if \"notifyApplicationReady\" is not called in the installed package.",
|
||||
() => {
|
||||
if (Platform.OS === "android") {
|
||||
remotePackage.downloadUrl = "http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1.includeRequire.runModule.bundle?platform=android&dev=true"
|
||||
} else if (Platform.OS === "ios") {
|
||||
remotePackage.downloadUrl = "http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1.includeRequire.runModule.bundle?platform=ios&dev=true"
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote());
|
||||
},
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
AppRegistry.registerComponent("RollbackTest", () => RollbackTest);
|
||||
@@ -1,50 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import { DeviceEventEmitter, Text, View } from "react-native";
|
||||
|
||||
const NativeCodePush = React.NativeModules.CodePush;
|
||||
// RCTTestModule is not implemented yet for RN Android.
|
||||
const RCTTestModule = React.NativeModules.TestModule || {};
|
||||
|
||||
function createTestCaseComponent(displayName, description, setUp, runTest, passAfterRun = true) {
|
||||
let TestCaseComponent = React.createClass({
|
||||
propTypes: {
|
||||
shouldThrow: React.PropTypes.bool,
|
||||
waitOneFrame: React.PropTypes.bool,
|
||||
},
|
||||
getInitialState() {
|
||||
return {
|
||||
done: false,
|
||||
};
|
||||
},
|
||||
async componentDidMount() {
|
||||
try {
|
||||
await setUp();
|
||||
await runTest();
|
||||
if (passAfterRun) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<View style={{backgroundColor: "white", padding: 40}}>
|
||||
<Text>
|
||||
{this.state.done ? "Test Passed!" : "Testing..."}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
TestCaseComponent.displayName = displayName;
|
||||
TestCaseComponent.description = description;
|
||||
|
||||
return TestCaseComponent;
|
||||
}
|
||||
|
||||
export default createTestCaseComponent;
|
||||
@@ -1,29 +0,0 @@
|
||||
import assert from "assert";
|
||||
|
||||
function createMockAcquisitionSdk(serverPackage, localPackage, expectedDeploymentKey) {
|
||||
let AcquisitionManager = (httpRequester, configuration) => {
|
||||
expectedDeploymentKey && assert.equal(expectedDeploymentKey, configuration.deploymentKey, "checkForUpdate did not initialize Acquisition SDK with the expected deployment key");
|
||||
};
|
||||
|
||||
AcquisitionManager.prototype.queryUpdateWithCurrentPackage = (queryPackage, callback) => {
|
||||
if (localPackage) {
|
||||
localPackage.appVersion = queryPackage.appVersion;
|
||||
assert.deepEqual(queryPackage, localPackage, "checkForUpdate did not attach current package info to the acquisition request");
|
||||
}
|
||||
callback(/*err:*/ null, serverPackage);
|
||||
};
|
||||
|
||||
AcquisitionManager.prototype.reportStatusDeploy = (deployedPackage, status, callback) => {
|
||||
// No-op and return success.
|
||||
callback(null, null);
|
||||
};
|
||||
|
||||
AcquisitionManager.prototype.reportStatusDownload = (downloadedPackage, callback) => {
|
||||
// No-op and return success.
|
||||
callback(null, null);
|
||||
};
|
||||
|
||||
return AcquisitionManager;
|
||||
}
|
||||
|
||||
export default createMockAcquisitionSdk;
|
||||
66
Examples/CodePushDemoApp/android/app/BUCK
Normal file
66
Examples/CodePushDemoApp/android/app/BUCK
Normal file
@@ -0,0 +1,66 @@
|
||||
import re
|
||||
|
||||
# To learn about Buck see [Docs](https://buckbuild.com/).
|
||||
# To run your application with Buck:
|
||||
# - install Buck
|
||||
# - `npm start` - to start the packager
|
||||
# - `cd android`
|
||||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
||||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
||||
# - `buck install -r android/app` - compile, install and run application
|
||||
#
|
||||
|
||||
lib_deps = []
|
||||
for jarfile in glob(['libs/*.jar']):
|
||||
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
|
||||
lib_deps.append(':' + name)
|
||||
prebuilt_jar(
|
||||
name = name,
|
||||
binary_jar = jarfile,
|
||||
)
|
||||
|
||||
for aarfile in glob(['libs/*.aar']):
|
||||
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
|
||||
lib_deps.append(':' + name)
|
||||
android_prebuilt_aar(
|
||||
name = name,
|
||||
aar = aarfile,
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = 'all-libs',
|
||||
exported_deps = lib_deps
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = 'app-code',
|
||||
srcs = glob([
|
||||
'src/main/java/**/*.java',
|
||||
]),
|
||||
deps = [
|
||||
':all-libs',
|
||||
':build_config',
|
||||
':res',
|
||||
],
|
||||
)
|
||||
|
||||
android_build_config(
|
||||
name = 'build_config',
|
||||
package = 'com.codepushdemoapp',
|
||||
)
|
||||
|
||||
android_resource(
|
||||
name = 'res',
|
||||
res = 'src/main/res',
|
||||
package = 'com.codepushdemoapp',
|
||||
)
|
||||
|
||||
android_binary(
|
||||
name = 'app',
|
||||
package_type = 'debug',
|
||||
manifest = 'src/main/AndroidManifest.xml',
|
||||
keystore = '//android/keystores:debug',
|
||||
deps = [
|
||||
':app-code',
|
||||
],
|
||||
)
|
||||
@@ -9,7 +9,7 @@ import com.android.build.OutputFile
|
||||
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
|
||||
* bundle directly from the development server. Below you can see all the possible configurations
|
||||
* and their defaults. If you decide to add a configuration block, make sure to add it before the
|
||||
* `apply from: "react.gradle"` line.
|
||||
* `apply from: "../../node_modules/react-native/react.gradle"` line.
|
||||
*
|
||||
* project.ext.react = [
|
||||
* // the name of the generated asset file containing your JS bundle
|
||||
@@ -26,7 +26,9 @@ import com.android.build.OutputFile
|
||||
*
|
||||
* // whether to bundle JS and assets in another build variant (if configured).
|
||||
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
|
||||
* // The configuration property is in the format 'bundleIn${productFlavor}${buildType}'
|
||||
* // The configuration property can be in the following formats
|
||||
* // 'bundleIn${productFlavor}${buildType}'
|
||||
* // 'bundleIn${buildType}'
|
||||
* // bundleInFreeDebug: true,
|
||||
* // bundleInPaidRelease: true,
|
||||
* // bundleInBeta: true,
|
||||
@@ -53,12 +55,18 @@ import com.android.build.OutputFile
|
||||
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
|
||||
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
|
||||
* // for example, you might want to remove it from here.
|
||||
* inputExcludes: ["android/**", "ios/**"]
|
||||
* inputExcludes: ["android/**", "ios/**"],
|
||||
*
|
||||
* // override which node gets called and with what additional arguments
|
||||
* nodeExecutableAndArgs: ["node"]
|
||||
*
|
||||
* // supply additional arguments to the packager
|
||||
* extraPackagerArgs: []
|
||||
* ]
|
||||
*/
|
||||
|
||||
apply from: "react.gradle"
|
||||
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
|
||||
apply from: "../../node_modules/react-native/react.gradle"
|
||||
apply from: "../../../../android/codepush.gradle"
|
||||
|
||||
/**
|
||||
* Set this to true to create two separate APKs instead of one:
|
||||
@@ -73,14 +81,14 @@ def enableSeparateBuildPerCPUArchitecture = false
|
||||
/**
|
||||
* Run Proguard to shrink the Java bytecode in release builds.
|
||||
*/
|
||||
def enableProguardInReleaseBuilds = true
|
||||
def enableProguardInReleaseBuilds = false
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.microsoft.codepushdemoapp"
|
||||
applicationId "com.codepushdemoapp"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
@@ -91,9 +99,9 @@ android {
|
||||
}
|
||||
splits {
|
||||
abi {
|
||||
enable enableSeparateBuildPerCPUArchitecture
|
||||
universalApk false // Also generate an universal APK
|
||||
reset()
|
||||
enable enableSeparateBuildPerCPUArchitecture
|
||||
universalApk false // If true, also generate a universal APK
|
||||
include "armeabi-v7a", "x86"
|
||||
}
|
||||
}
|
||||
@@ -121,6 +129,13 @@ android {
|
||||
dependencies {
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
compile "com.android.support:appcompat-v7:23.0.1"
|
||||
compile "com.facebook.react:react-native:0.19.+"
|
||||
compile project(":react-native-code-push")
|
||||
compile "com.facebook.react:react-native:+" // From node_modules
|
||||
compile project(':react-native-code-push')
|
||||
}
|
||||
|
||||
// Run this once to be able to run the application with BUCK
|
||||
// puts all compile dependencies into folder libs for BUCK to use
|
||||
task copyDownloadableDepsToLibs(type: Copy) {
|
||||
from configurations.compile
|
||||
into 'libs'
|
||||
}
|
||||
|
||||
@@ -26,11 +26,14 @@
|
||||
# See http://sourceforge.net/p/proguard/bugs/466/
|
||||
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
|
||||
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
|
||||
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
|
||||
|
||||
# Do not strip any method/class that is annotated with @DoNotStrip
|
||||
-keep @com.facebook.proguard.annotations.DoNotStrip class *
|
||||
-keep @com.facebook.common.internal.DoNotStrip class *
|
||||
-keepclassmembers class * {
|
||||
@com.facebook.proguard.annotations.DoNotStrip *;
|
||||
@com.facebook.common.internal.DoNotStrip *;
|
||||
}
|
||||
|
||||
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
|
||||
@@ -42,8 +45,8 @@
|
||||
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
|
||||
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
|
||||
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
|
||||
|
||||
-dontwarn com.facebook.react.**
|
||||
|
||||
@@ -51,9 +54,9 @@
|
||||
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keep class com.squareup.okhttp.** { *; }
|
||||
-keep interface com.squareup.okhttp.** { *; }
|
||||
-dontwarn com.squareup.okhttp.**
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-dontwarn okhttp3.**
|
||||
|
||||
# okio
|
||||
|
||||
@@ -61,7 +64,3 @@
|
||||
-dontwarn java.nio.file.*
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
||||
-dontwarn okio.**
|
||||
|
||||
# stetho
|
||||
|
||||
-dontwarn com.facebook.stetho.**
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
def config = project.hasProperty("react") ? project.react : [];
|
||||
|
||||
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
|
||||
def entryFile = config.entryFile ?: "index.android.js"
|
||||
|
||||
// because elvis operator
|
||||
def elvisFile(thing) {
|
||||
return thing ? file(thing) : null;
|
||||
}
|
||||
|
||||
def reactRoot = elvisFile(config.root) ?: file("../../")
|
||||
def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
|
||||
|
||||
void runBefore(String dependentTaskName, Task task) {
|
||||
Task dependentTask = tasks.findByPath(dependentTaskName);
|
||||
if (dependentTask != null) {
|
||||
dependentTask.dependsOn task
|
||||
}
|
||||
}
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
// Grab all build types and product flavors
|
||||
def buildTypes = android.buildTypes.collect { type -> type.name }
|
||||
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
|
||||
|
||||
// When no product flavors defined, use empty
|
||||
if (!productFlavors) productFlavors.add('')
|
||||
|
||||
productFlavors.each { productFlavorName ->
|
||||
buildTypes.each { buildTypeName ->
|
||||
// Create variant and source names
|
||||
def sourceName = "${buildTypeName}"
|
||||
def targetName = "${sourceName.capitalize()}"
|
||||
if (productFlavorName) {
|
||||
sourceName = "${productFlavorName}${targetName}"
|
||||
}
|
||||
|
||||
// React js bundle directories
|
||||
def jsBundleDirConfigName = "jsBundleDir${targetName}"
|
||||
def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
|
||||
file("$buildDir/intermediates/assets/${sourceName}")
|
||||
|
||||
def resourcesDirConfigName = "jsBundleDir${targetName}"
|
||||
def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
|
||||
file("$buildDir/intermediates/res/merged/${sourceName}")
|
||||
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
|
||||
|
||||
// Bundle task name for variant
|
||||
def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets"
|
||||
|
||||
def currentBundleTask = tasks.create(
|
||||
name: bundleJsAndAssetsTaskName,
|
||||
type: Exec) {
|
||||
group = "react"
|
||||
description = "bundle JS and assets for ${targetName}."
|
||||
|
||||
// Create dirs if they are not there (e.g. the "clean" task just ran)
|
||||
doFirst {
|
||||
jsBundleDir.mkdirs()
|
||||
resourcesDir.mkdirs()
|
||||
}
|
||||
|
||||
// Set up inputs and outputs so gradle can cache the result
|
||||
inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
|
||||
outputs.dir jsBundleDir
|
||||
outputs.dir resourcesDir
|
||||
|
||||
// Set up the call to the react-native cli
|
||||
workingDir reactRoot
|
||||
|
||||
// Set up dev mode
|
||||
def devEnabled = !targetName.toLowerCase().contains("release")
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
|
||||
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
|
||||
} else {
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
|
||||
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
|
||||
}
|
||||
|
||||
enabled config."bundleIn${targetName}" ?: true
|
||||
}
|
||||
|
||||
// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
|
||||
currentBundleTask.dependsOn("merge${targetName}Resources")
|
||||
currentBundleTask.dependsOn("merge${targetName}Assets")
|
||||
|
||||
runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask)
|
||||
runBefore("processX86${targetName}Resources", currentBundleTask)
|
||||
runBefore("processUniversal${targetName}Resources", currentBundleTask)
|
||||
runBefore("process${targetName}Resources", currentBundleTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,25 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.microsoft.codepushdemoapp">
|
||||
package="com.codepushdemoapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0.0">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="16"
|
||||
android:targetSdkVersion="22" />
|
||||
|
||||
<application
|
||||
android:name=".MainApplication"
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="com.microsoft.codepushdemoapp.MainActivity"
|
||||
android:label="@string/app_name">
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.codepushdemoapp;
|
||||
|
||||
import com.facebook.react.ReactActivity;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
/**
|
||||
* Returns the name of the main component registered from JavaScript.
|
||||
* This is used to schedule rendering of the component.
|
||||
*/
|
||||
@Override
|
||||
protected String getMainComponentName() {
|
||||
return "CodePushDemoApp";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.codepushdemoapp;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
|
||||
import com.microsoft.codepush.react.CodePush;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||
@Override
|
||||
protected String getJSBundleFile() {
|
||||
return CodePush.getJSBundleFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ReactNativeHost getReactNativeHost() {
|
||||
return mReactNativeHost;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.microsoft.codepushdemoapp;
|
||||
|
||||
import com.facebook.react.ReactActivity;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
import com.microsoft.codepush.react.CodePush;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
@Override
|
||||
protected String getJSBundleFile() {
|
||||
return CodePush.getJSBundleFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the main component registered from JavaScript.
|
||||
* This is used to schedule rendering of the component.
|
||||
*/
|
||||
@Override
|
||||
protected String getMainComponentName() {
|
||||
return "CodePushDemoApp";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether dev mode should be enabled.
|
||||
* This enables e.g. the dev menu.
|
||||
*/
|
||||
@Override
|
||||
protected boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of packages used by the app. If the app uses additional views
|
||||
* or modules besides the default ones, add more packages here.
|
||||
*/
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,9 @@ allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven {
|
||||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
||||
url "$rootDir/../node_modules/react-native/android"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
Examples/CodePushDemoApp/android/keystores/BUCK
Normal file
8
Examples/CodePushDemoApp/android/keystores/BUCK
Normal file
@@ -0,0 +1,8 @@
|
||||
keystore(
|
||||
name = 'debug',
|
||||
store = 'debug.keystore',
|
||||
properties = 'debug.keystore.properties',
|
||||
visibility = [
|
||||
'PUBLIC',
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
key.store=debug.keystore
|
||||
key.alias=androiddebugkey
|
||||
key.store.password=android
|
||||
key.alias.password=android
|
||||
@@ -1,4 +1,4 @@
|
||||
rootProject.name = 'CodePushDemoApp'
|
||||
|
||||
include ':app', ':react-native-code-push'
|
||||
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../../../android/app')
|
||||
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../../../android/app')
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
-pushd Examples/CodePushDemoApp
|
||||
-react-native bundle
|
||||
-popd
|
||||
@@ -1,159 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Dimensions,
|
||||
Image,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let CodePushDemoApp = React.createClass({
|
||||
async sync() {
|
||||
let self = this;
|
||||
try {
|
||||
return await CodePush.sync(
|
||||
{
|
||||
installMode: CodePush.InstallMode.IMMEDIATE,
|
||||
},
|
||||
(syncStatus) => {
|
||||
switch(syncStatus) {
|
||||
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
|
||||
self.setState({
|
||||
syncMessage: "Checking for update."
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
|
||||
self.setState({
|
||||
syncMessage: "Downloading package."
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.AWAITING_USER_ACTION:
|
||||
self.setState({
|
||||
syncMessage: "Awaiting user action."
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.INSTALLING_UPDATE:
|
||||
self.setState({
|
||||
syncMessage: "Installing update."
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UP_TO_DATE:
|
||||
self.setState({
|
||||
syncMessage: "App up to date.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UPDATE_IGNORED:
|
||||
self.setState({
|
||||
syncMessage: "Update cancelled by user.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UPDATE_INSTALLED:
|
||||
self.setState({
|
||||
syncMessage: "Update installed.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UNKNOWN_ERROR:
|
||||
self.setState({
|
||||
syncMessage: "An unknown error occurred.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
(progress) => {
|
||||
self.setState({
|
||||
progress: progress
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
CodePush.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
CodePush.notifyApplicationReady();
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return { restartAllowed: true };
|
||||
},
|
||||
|
||||
toggleAllowRestart() {
|
||||
if (this.state.restartAllowed) {
|
||||
CodePush.disallowRestart();
|
||||
} else {
|
||||
CodePush.allowRestart();
|
||||
}
|
||||
this.setState({restartAllowed: !this.state.restartAllowed});
|
||||
},
|
||||
|
||||
render() {
|
||||
let syncView, syncButton, progressView;
|
||||
|
||||
if (this.state.syncMessage) {
|
||||
syncView = (
|
||||
<Text style={styles.messages}>{this.state.syncMessage}</Text>
|
||||
);
|
||||
} else {
|
||||
syncButton = (
|
||||
<TouchableOpacity onPress={this.sync}>
|
||||
<Text style={{color: 'green', fontSize: 17}}>Start Sync!</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.progress) {
|
||||
progressView = (
|
||||
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to CodePush!
|
||||
</Text>
|
||||
{syncButton}
|
||||
{syncView}
|
||||
{progressView}
|
||||
<Image style={styles.image} resizeMode={Image.resizeMode.contain} source={require('./images/laptop_phone_howitworks.png')}/>
|
||||
<TouchableOpacity onPress={this.toggleAllowRestart}>
|
||||
<Text style={{color: 'blue', fontSize: 17}}>Restart { this.state.restartAllowed ? "allowed" : "forbidden"}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let styles = StyleSheet.create({
|
||||
image: {
|
||||
marginTop: 50,
|
||||
width: Dimensions.get('window').width - 100,
|
||||
height: 365 * (Dimensions.get('window').width - 100) / 651,
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
paddingTop: 50
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10
|
||||
},
|
||||
messages: {
|
||||
textAlign: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('CodePushDemoApp', () => CodePushDemoApp);
|
||||
142
Examples/CodePushDemoApp/demo.js
Normal file
142
Examples/CodePushDemoApp/demo.js
Normal file
@@ -0,0 +1,142 @@
|
||||
import React, { Component } from "react";
|
||||
import {
|
||||
AppRegistry,
|
||||
Dimensions,
|
||||
Image,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
@CodePush({ checkFrequency: CodePush.CheckFrequency.MANUAL })
|
||||
class CodePushDemoApp extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = { restartAllowed: true };
|
||||
}
|
||||
|
||||
codePushStatusDidChange(syncStatus) {
|
||||
console.log(this.setState);
|
||||
switch(syncStatus) {
|
||||
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
|
||||
this.setState({ syncMessage: "Checking for update." });
|
||||
break;
|
||||
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
|
||||
this.setState({ syncMessage: "Downloading package." });
|
||||
break;
|
||||
case CodePush.SyncStatus.AWAITING_USER_ACTION:
|
||||
this.setState({ syncMessage: "Awaiting user action." });
|
||||
break;
|
||||
case CodePush.SyncStatus.INSTALLING_UPDATE:
|
||||
this.setState({ syncMessage: "Installing update." });
|
||||
break;
|
||||
case CodePush.SyncStatus.UP_TO_DATE:
|
||||
this.setState({ syncMessage: "App up to date.", progress: false });
|
||||
break;
|
||||
case CodePush.SyncStatus.UPDATE_IGNORED:
|
||||
this.setState({ syncMessage: "Update cancelled by user.", progress: false });
|
||||
break;
|
||||
case CodePush.SyncStatus.UPDATE_INSTALLED:
|
||||
this.setState({ syncMessage: "Update installed.", progress: false });
|
||||
break;
|
||||
case CodePush.SyncStatus.UNKNOWN_ERROR:
|
||||
this.setState({ syncMessage: "An unknown error occurred.", progress: false });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
codePushDownloadDidProgress(progress) {
|
||||
this.setState({ progress });
|
||||
}
|
||||
|
||||
toggleAllowRestart() {
|
||||
this.state.restartAllowed
|
||||
? CodePush.disallowRestart()
|
||||
: CodePush.allowRestart();
|
||||
|
||||
this.setState({ restartAllowed: !this.state.restartAllowed });
|
||||
}
|
||||
|
||||
sync() {
|
||||
CodePush.sync(
|
||||
{
|
||||
installMode: CodePush.InstallMode.IMMEDIATE,
|
||||
updateDialog: true
|
||||
},
|
||||
this.codePushStatusDidChange.bind(this),
|
||||
this.codePushDownloadDidProgress.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
let syncView, syncButton, progressView;
|
||||
|
||||
if (this.state.syncMessage) {
|
||||
syncView = (
|
||||
<Text style={styles.messages}>{this.state.syncMessage}</Text>
|
||||
);
|
||||
} else {
|
||||
syncButton = (
|
||||
<TouchableOpacity onPress={this.sync.bind(this)}>
|
||||
<Text style={styles.syncButton}>Start Sync!</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.progress) {
|
||||
progressView = (
|
||||
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to CodePush!
|
||||
</Text>
|
||||
{syncButton}
|
||||
{syncView}
|
||||
{progressView}
|
||||
<Image style={styles.image} resizeMode={Image.resizeMode.contain} source={require("./images/laptop_phone_howitworks.png")}/>
|
||||
<TouchableOpacity onPress={this.toggleAllowRestart.bind(this)}>
|
||||
<Text style={styles.restartToggleButton}>Restart { this.state.restartAllowed ? "allowed" : "forbidden"}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
backgroundColor: "#F5FCFF",
|
||||
paddingTop: 50
|
||||
},
|
||||
image: {
|
||||
marginTop: 50,
|
||||
width: Dimensions.get("window").width - 100,
|
||||
height: 365 * (Dimensions.get("window").width - 100) / 651,
|
||||
},
|
||||
messages: {
|
||||
textAlign: "center",
|
||||
},
|
||||
restartToggleButton: {
|
||||
color: "blue",
|
||||
fontSize: 17
|
||||
},
|
||||
syncButton: {
|
||||
color: "green",
|
||||
fontSize: 17
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: "center",
|
||||
margin: 10
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent("CodePushDemoApp", () => CodePushDemoApp);
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
|
||||
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */; };
|
||||
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
|
||||
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
|
||||
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
|
||||
@@ -20,13 +19,11 @@
|
||||
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
|
||||
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
|
||||
540D20251C76EA0400D6EF41 /* libCodePush.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 540D20241C76E4D300D6EF41 /* libCodePush.a */; };
|
||||
544161591B8BCA81000D9E25 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
|
||||
5451ACBA1B86A5B600E2A7DF /* CheckForUpdateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5451ACB81B86A5B600E2A7DF /* CheckForUpdateTests.m */; };
|
||||
5451ACEC1B86E40A00E2A7DF /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5451ACEB1B86E34300E2A7DF /* libRCTTest.a */; };
|
||||
54D774BA1B87DAF800F2ABF8 /* InstallUpdateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 54D774B91B87DAF800F2ABF8 /* InstallUpdateTests.m */; };
|
||||
54F5F2B41BF6B45D007C3CEA /* DownloadProgressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 54F5F2B31BF6B45D007C3CEA /* DownloadProgressTests.m */; };
|
||||
549D09D81D528D0A00C95E36 /* libCodePush.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 549D09CD1D528CDB00C95E36 /* libCodePush.a */; };
|
||||
549D09DA1D528D4D00C95E36 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 549D09D91D528D4D00C95E36 /* libz.tbd */; };
|
||||
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -37,13 +34,6 @@
|
||||
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
||||
remoteInfo = RCTActionSheet;
|
||||
};
|
||||
00C302B31ABCB8E700DB3ED1 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
|
||||
remoteInfo = RCTAdSupport;
|
||||
};
|
||||
00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
|
||||
@@ -100,20 +90,13 @@
|
||||
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
|
||||
remoteInfo = React;
|
||||
};
|
||||
540D20231C76E4D300D6EF41 /* PBXContainerItemProxy */ = {
|
||||
549D09CC1D528CDB00C95E36 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 81551E0A1B3B427200F5B9F1 /* CodePush.xcodeproj */;
|
||||
containerPortal = 549D09C81D528CDB00C95E36 /* CodePush.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
||||
remoteInfo = CodePush;
|
||||
};
|
||||
5451ACEA1B86E34300E2A7DF /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 5451ACE61B86E34300E2A7DF /* RCTTest.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 580C376F1AB104AF0015E709;
|
||||
remoteInfo = RCTTest;
|
||||
};
|
||||
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
|
||||
@@ -131,14 +114,13 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
|
||||
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = "<group>"; };
|
||||
00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = "../node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj"; sourceTree = "<group>"; };
|
||||
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = "<group>"; };
|
||||
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = "<group>"; };
|
||||
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = "<group>"; };
|
||||
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = "<group>"; };
|
||||
00E356EE1AD99517003FC87E /* CodePushDemoAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CodePushDemoAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = "<group>"; };
|
||||
13B07F961A680F5B00A75B9A /* CodePushDemoApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CodePushDemoApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -149,12 +131,9 @@
|
||||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = CodePushDemoApp/Info.plist; sourceTree = "<group>"; };
|
||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = CodePushDemoApp/main.m; sourceTree = "<group>"; };
|
||||
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
|
||||
5451ACB81B86A5B600E2A7DF /* CheckForUpdateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheckForUpdateTests.m; sourceTree = "<group>"; };
|
||||
5451ACE61B86E34300E2A7DF /* RCTTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTTest.xcodeproj; path = "../node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj"; sourceTree = "<group>"; };
|
||||
54D774B91B87DAF800F2ABF8 /* InstallUpdateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstallUpdateTests.m; sourceTree = "<group>"; };
|
||||
54F5F2B31BF6B45D007C3CEA /* DownloadProgressTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DownloadProgressTests.m; sourceTree = "<group>"; };
|
||||
549D09C81D528CDB00C95E36 /* CodePush.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CodePush.xcodeproj; path = ../../../ios/CodePush.xcodeproj; sourceTree = "<group>"; };
|
||||
549D09D91D528D4D00C95E36 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
|
||||
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
|
||||
81551E0A1B3B427200F5B9F1 /* CodePush.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CodePush.xcodeproj; path = ../../../ios/CodePush.xcodeproj; sourceTree = "<group>"; };
|
||||
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -163,6 +142,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -170,17 +150,16 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
540D20251C76EA0400D6EF41 /* libCodePush.a in Frameworks */,
|
||||
544161591B8BCA81000D9E25 /* libRCTText.a in Frameworks */,
|
||||
5451ACEC1B86E40A00E2A7DF /* libRCTTest.a in Frameworks */,
|
||||
549D09DA1D528D4D00C95E36 /* libz.tbd in Frameworks */,
|
||||
549D09D81D528D0A00C95E36 /* libCodePush.a in Frameworks */,
|
||||
146834051AC3E58100842450 /* libReact.a in Frameworks */,
|
||||
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
|
||||
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */,
|
||||
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
|
||||
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
|
||||
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
|
||||
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
|
||||
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
|
||||
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
|
||||
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
|
||||
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
|
||||
);
|
||||
@@ -197,14 +176,6 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
00C302B01ABCB8E700DB3ED1 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
00C302B61ABCB90400DB3ED1 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -237,25 +208,6 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
00E356EF1AD99517003FC87E /* ../CodePushDemoAppTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
54F5F2B31BF6B45D007C3CEA /* DownloadProgressTests.m */,
|
||||
5451ACB81B86A5B600E2A7DF /* CheckForUpdateTests.m */,
|
||||
54D774B91B87DAF800F2ABF8 /* InstallUpdateTests.m */,
|
||||
00E356F01AD99517003FC87E /* Supporting Files */,
|
||||
);
|
||||
path = ../CodePushDemoAppTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
00E356F01AD99517003FC87E /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
00E356F11AD99517003FC87E /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
139105B71AF99BAD00B5F7CC /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -275,6 +227,7 @@
|
||||
13B07FAE1A68108700A75B9A /* CodePushDemoApp */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
|
||||
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
|
||||
13B07FB01A68108700A75B9A /* AppDelegate.m */,
|
||||
13B07FB51A68108700A75B9A /* Images.xcassets */,
|
||||
@@ -293,18 +246,10 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
540D20201C76E4D300D6EF41 /* Products */ = {
|
||||
549D09C91D528CDB00C95E36 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
540D20241C76E4D300D6EF41 /* libCodePush.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5451ACE71B86E34300E2A7DF /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5451ACEB1B86E34300E2A7DF /* libRCTTest.a */,
|
||||
549D09CD1D528CDB00C95E36 /* libCodePush.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -320,11 +265,9 @@
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5451ACE61B86E34300E2A7DF /* RCTTest.xcodeproj */,
|
||||
81551E0A1B3B427200F5B9F1 /* CodePush.xcodeproj */,
|
||||
549D09C81D528CDB00C95E36 /* CodePush.xcodeproj */,
|
||||
146833FF1AC3E56700842450 /* React.xcodeproj */,
|
||||
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
|
||||
00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */,
|
||||
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
|
||||
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,
|
||||
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
|
||||
@@ -348,9 +291,9 @@
|
||||
83CBB9F61A601CBA00E9B192 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
549D09D91D528D4D00C95E36 /* libz.tbd */,
|
||||
13B07FAE1A68108700A75B9A /* CodePushDemoApp */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
00E356EF1AD99517003FC87E /* ../CodePushDemoAppTests */,
|
||||
83CBBA001A601CBA00E9B192 /* Products */,
|
||||
);
|
||||
indentWidth = 2;
|
||||
@@ -394,7 +337,7 @@
|
||||
13B07F871A680F5B00A75B9A /* Sources */,
|
||||
13B07F8C1A680F5B00A75B9A /* Frameworks */,
|
||||
13B07F8E1A680F5B00A75B9A /* Resources */,
|
||||
54A001DF1C0D0DAF004C3CEC /* Bundle React Native Code and Images */,
|
||||
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -412,7 +355,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0610;
|
||||
ORGANIZATIONNAME = Microsoft;
|
||||
ORGANIZATIONNAME = Facebook;
|
||||
TargetAttributes = {
|
||||
00E356ED1AD99517003FC87E = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
@@ -433,17 +376,13 @@
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = 540D20201C76E4D300D6EF41 /* Products */;
|
||||
ProjectRef = 81551E0A1B3B427200F5B9F1 /* CodePush.xcodeproj */;
|
||||
ProductGroup = 549D09C91D528CDB00C95E36 /* Products */;
|
||||
ProjectRef = 549D09C81D528CDB00C95E36 /* CodePush.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
|
||||
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 00C302B01ABCB8E700DB3ED1 /* Products */;
|
||||
ProjectRef = 00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */;
|
||||
ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
|
||||
@@ -464,10 +403,6 @@
|
||||
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
|
||||
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 5451ACE71B86E34300E2A7DF /* Products */;
|
||||
ProjectRef = 5451ACE61B86E34300E2A7DF /* RCTTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
|
||||
ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
|
||||
@@ -501,13 +436,6 @@
|
||||
remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libRCTAdSupport.a;
|
||||
remoteRef = 00C302B31ABCB8E700DB3ED1 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
@@ -557,18 +485,11 @@
|
||||
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
540D20241C76E4D300D6EF41 /* libCodePush.a */ = {
|
||||
549D09CD1D528CDB00C95E36 /* libCodePush.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libCodePush.a;
|
||||
remoteRef = 540D20231C76E4D300D6EF41 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
5451ACEB1B86E34300E2A7DF /* libRCTTest.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libRCTTest.a;
|
||||
remoteRef = 5451ACEA1B86E34300E2A7DF /* PBXContainerItemProxy */;
|
||||
remoteRef = 549D09CC1D528CDB00C95E36 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
|
||||
@@ -607,19 +528,19 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
54A001DF1C0D0DAF004C3CEC /* Bundle React Native Code and Images */ = {
|
||||
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Bundle React Native Code and Images";
|
||||
name = "Bundle React Native code and images";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "../node_modules/react-native/packager/react-native-xcode.sh";
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -628,9 +549,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5451ACBA1B86A5B600E2A7DF /* CheckForUpdateTests.m in Sources */,
|
||||
54F5F2B41BF6B45D007C3CEA /* DownloadProgressTests.m in Sources */,
|
||||
54D774BA1B87DAF800F2ABF8 /* InstallUpdateTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -670,22 +588,11 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/../node_modules/react-native/React/**",
|
||||
"$(SRCROOT)/../../../ios/**",
|
||||
"$(SRCROOT)/../node_modules/react-native/Libraries/Text/",
|
||||
);
|
||||
INFOPLIST_FILE = ../CodePushDemoAppTests/Info.plist;
|
||||
INFOPLIST_FILE = CodePushDemoAppTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -698,18 +605,7 @@
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/../node_modules/react-native/React/**",
|
||||
"$(SRCROOT)/../../../ios/**",
|
||||
"$(SRCROOT)/../node_modules/react-native/Libraries/Text/",
|
||||
);
|
||||
INFOPLIST_FILE = ../CodePushDemoAppTests/Info.plist;
|
||||
INFOPLIST_FILE = CodePushDemoAppTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -721,17 +617,19 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEAD_CODE_STRIPPING = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/../node_modules/react-native/React/**",
|
||||
"$(SRCROOT)/../../../ios/**",
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/CodePushDemoApp/Info.plist";
|
||||
INFOPLIST_FILE = CodePushDemoApp/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lz",
|
||||
"-lc++",
|
||||
);
|
||||
PRODUCT_NAME = CodePushDemoApp;
|
||||
};
|
||||
@@ -747,11 +645,12 @@
|
||||
"$(SRCROOT)/../node_modules/react-native/React/**",
|
||||
"$(SRCROOT)/../../../ios/**",
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/CodePushDemoApp/Info.plist";
|
||||
INFOPLIST_FILE = CodePushDemoApp/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lz",
|
||||
"-lc++",
|
||||
);
|
||||
PRODUCT_NAME = CodePushDemoApp;
|
||||
};
|
||||
|
||||
@@ -51,11 +51,6 @@
|
||||
BlueprintName = "CodePushDemoAppTests"
|
||||
ReferencedContainer = "container:CodePushDemoApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "CodePushTests">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "RCTRootView.h"
|
||||
|
||||
#import "CodePush.h"
|
||||
#import "RCTBundleURLProvider.h"
|
||||
#import "RCTRootView.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@@ -19,41 +9,20 @@
|
||||
{
|
||||
NSURL *jsCodeLocation;
|
||||
|
||||
/**
|
||||
* Loading JavaScript code - uncomment the one you want.
|
||||
*
|
||||
* OPTION 1
|
||||
* Load from development server. Start the server from the repository root:
|
||||
*
|
||||
* $ npm start
|
||||
*
|
||||
* To run on device, change `localhost` to the IP address of your computer
|
||||
* (you can get this by typing `ifconfig` into the terminal and selecting the
|
||||
* `inet` value under `en0:`) and make sure your computer and iOS device are
|
||||
* on the same Wi-Fi network.
|
||||
*/
|
||||
|
||||
//jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.includeRequire.runModule.bundle?dev=true&platform=ios"];
|
||||
|
||||
/**
|
||||
* OPTION 2
|
||||
* Load from pre-bundled file on disk. To re-generate the static bundle
|
||||
* from the root of your project directory, run
|
||||
*
|
||||
* $ react-native bundle --minify
|
||||
*
|
||||
* see http://facebook.github.io/react-native/docs/runningondevice.html
|
||||
*/
|
||||
|
||||
// Use React Native's RCTBundleURLProvider to resolve your JS bundle location, so that your app will load the JS bundle from the packager server during development.
|
||||
//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
|
||||
|
||||
// Use CodePush to resolve your JS bundle location, so that your app will run the version of the code distributed via CodePush
|
||||
jsCodeLocation = [CodePush bundleURL];
|
||||
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
|
||||
moduleName:@"CodePushDemoApp"
|
||||
initialProperties:nil
|
||||
launchOptions:launchOptions];
|
||||
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
UIViewController *rootViewController = [[UIViewController alloc] init];
|
||||
UIViewController *rootViewController = [UIViewController new];
|
||||
rootViewController.view = rootView;
|
||||
self.window.rootViewController = rootViewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
@@ -43,6 +38,17 @@
|
||||
<false/>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string></string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>localhost</key>
|
||||
<dict>
|
||||
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CodePushDeploymentKey</key>
|
||||
<string>deployment-key-here</string>
|
||||
</dict>
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@@ -1 +1 @@
|
||||
import "./crossplatformdemo.js";
|
||||
require("./demo");
|
||||
@@ -1 +1 @@
|
||||
import "./crossplatformdemo.js";
|
||||
require("./demo");
|
||||
@@ -3,13 +3,12 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node_modules/react-native/packager/packager.sh --root ../../"
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native": "0.19.0",
|
||||
"babel-preset-react-native-stage-0": "1.0.1",
|
||||
"react": "15.2.1",
|
||||
"react-native": "0.30.0",
|
||||
"react-native-code-push": "file:../../"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assert": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "RCTRootView.h"
|
||||
@@ -20,7 +11,7 @@
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
RCTSetLogThreshold(RCTLogLevelInfo);
|
||||
|
||||
|
||||
NSURL *jsCodeLocation;
|
||||
|
||||
jsCodeLocation = [CodePush bundleURL];
|
||||
|
||||
Reference in New Issue
Block a user