mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
es7
This commit is contained in:
@@ -38,6 +38,7 @@ let CheckForUpdateTestApp = React.createClass({
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.row}>
|
||||
|
||||
@@ -18,20 +18,13 @@ let FirstUpdateTest = createTestCaseComponent(
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate()
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -17,21 +17,14 @@ let NewUpdateTest = createTestCaseComponent(
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate()
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NewUpdateTest;
|
||||
export default NewUpdateTest;
|
||||
@@ -18,19 +18,14 @@ let NoRemotePackageTest = createTestCaseComponent(
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return an update if there is none on the server");
|
||||
}
|
||||
});
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert(!update, "checkForUpdate should not return an update if there is none on the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = NoRemotePackageTest;
|
||||
export default NoRemotePackageTest;
|
||||
@@ -15,24 +15,17 @@ let RemotePackageAppVersionNewerTest = createTestCaseComponent(
|
||||
"RemotePackageAppVersionNewerTest",
|
||||
"should drop the update when the server reports one with a newer binary version",
|
||||
() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.0.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.0.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return an update if remote package is of a different binary version");
|
||||
}
|
||||
});
|
||||
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;
|
||||
export default RemotePackageAppVersionNewerTest;
|
||||
@@ -18,19 +18,14 @@ let SamePackageTest = createTestCaseComponent(
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
throw new Error("checkForUpdate should not return a package when local package is identical");
|
||||
}
|
||||
});
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate();
|
||||
assert(!update, "checkForUpdate should not return a package when local package is identical");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SamePackageTest;
|
||||
export default SamePackageTest;
|
||||
@@ -20,21 +20,14 @@ let SwitchDeploymentKeyTest = createTestCaseComponent(
|
||||
let mockAcquisitionSdk = createMockAcquisitionSdk(serverPackage, localPackage, deploymentKey);
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
CodePush.getCurrentPackage = () => {
|
||||
return Promise.resolve(localPackage);
|
||||
}
|
||||
return Promise.resolve();
|
||||
CodePush.getCurrentPackage = async () => {
|
||||
return localPackage;
|
||||
};
|
||||
},
|
||||
() => {
|
||||
return CodePush.checkForUpdate(deploymentKey)
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote));
|
||||
} else {
|
||||
throw new Error("checkForUpdate did not return the update from the server");
|
||||
}
|
||||
});
|
||||
async () => {
|
||||
let update = await CodePush.checkForUpdate(deploymentKey)
|
||||
assert.deepEqual(update, Object.assign(serverPackage, PackageMixins.remote), "checkForUpdate did not return the update from the server");
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = SwitchDeploymentKeyTest;
|
||||
export default SwitchDeploymentKeyTest;
|
||||
@@ -49,4 +49,4 @@ let DownloadProgressTest = createTestCaseComponent(
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = DownloadProgressTest;
|
||||
export default DownloadProgressTest;
|
||||
@@ -1,27 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let {
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
} from "react-native";
|
||||
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
let IsFirstRunTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
componentDidMount() {
|
||||
CodePush.getCurrentPackage()
|
||||
.then((localPackage) => {
|
||||
if (localPackage.isFirstRun) {
|
||||
this.setState({ passed: true });
|
||||
} else {
|
||||
this.setState({ passed: false });
|
||||
}
|
||||
});
|
||||
async componentDidMount() {
|
||||
let localPackage = await CodePush.getCurrentPackage();
|
||||
if (localPackage.isFirstRun) {
|
||||
this.setState({ passed: true });
|
||||
} else {
|
||||
this.setState({ passed: false });
|
||||
}
|
||||
},
|
||||
render() {
|
||||
let text = "Testing...";
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import CodePush from "react-native-code-push";
|
||||
let NativeCodePush = React.NativeModules.CodePush;
|
||||
let PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
import createMockAcquisitionSdk from "../../utils/mockAcquisitionSdk";
|
||||
|
||||
let {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
let IsFailedUpdateTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
componentDidMount() {
|
||||
async componentDidMount() {
|
||||
let serverPackage = {
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
@@ -39,20 +38,14 @@ let IsFailedUpdateTest = React.createClass({
|
||||
let mockConfiguration = { appVersion : "1.5.0" };
|
||||
CodePush.setUpTestDependencies(mockAcquisitionSdk, mockConfiguration, NativeCodePush);
|
||||
|
||||
CodePush.notifyApplicationReady()
|
||||
.then(() => {
|
||||
return CodePush.checkForUpdate();
|
||||
})
|
||||
.then((remotePackage) => {
|
||||
if (remotePackage.failedInstall) {
|
||||
this.setState({ passed: true });
|
||||
} else {
|
||||
return remotePackage.download();
|
||||
}
|
||||
})
|
||||
.then((localPackage) => {
|
||||
return localPackage && localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
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...";
|
||||
|
||||
@@ -11,6 +11,7 @@ let {
|
||||
|
||||
let IsFailedUpdateTest = React.createClass({
|
||||
componentDidMount() {
|
||||
// Should trigger a rollback.
|
||||
CodePush.restartApp();
|
||||
},
|
||||
render() {
|
||||
|
||||
@@ -10,18 +10,15 @@ let NotifyApplicationReadyTest = React.createClass({
|
||||
getInitialState() {
|
||||
return {};
|
||||
},
|
||||
componentDidMount() {
|
||||
CodePush.notifyApplicationReady()
|
||||
.then(() => {
|
||||
if (Platform.OS === "android") {
|
||||
return NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=android&dev=true");
|
||||
} else if (Platform.OS === "ios") {
|
||||
return NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/PassNotifyApplicationReadyTest.includeRequire.runModule.bundle?platform=ios&dev=true");
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
CodePush.restartApp();
|
||||
});
|
||||
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 (
|
||||
|
||||
@@ -1,51 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
import React from "react-native";
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import CodePush from "react-native-code-push";
|
||||
let RCTTestModule = React.NativeModules.TestModule;
|
||||
let NativeCodePush = React.NativeModules.CodePush;
|
||||
let PackageMixins = require("react-native-code-push/package-mixins.js")(NativeCodePush);
|
||||
|
||||
let {
|
||||
AppRegistry,
|
||||
Platform,
|
||||
Text,
|
||||
View,
|
||||
} = React;
|
||||
|
||||
let RollbackTest = React.createClass({
|
||||
componentDidMount() {
|
||||
let remotePackage = {
|
||||
description: "Angry flappy birds",
|
||||
appVersion: "1.5.0",
|
||||
label: "2.4.0",
|
||||
isMandatory: false,
|
||||
isAvailable: true,
|
||||
updateAppVersion: false,
|
||||
packageHash: "hash241",
|
||||
packageSize: 1024
|
||||
};
|
||||
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"
|
||||
CodePush.notifyApplicationReady()
|
||||
.then(() => {
|
||||
NativeCodePush.downloadAndReplaceCurrentBundle("http://10.0.3.2:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.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"
|
||||
CodePush.notifyApplicationReady()
|
||||
.then(() => {
|
||||
NativeCodePush.downloadAndReplaceCurrentBundle("http://localhost:8081/CodePushDemoAppTests/InstallUpdateTests/resources/RollbackTestBundleV1Pass.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);
|
||||
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -21,13 +21,10 @@ let InstallModeImmediateTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -22,16 +22,11 @@ let InstallModeOnNextRestartTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
|
||||
})
|
||||
.then(() => {
|
||||
CodePush.restartApp();
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
await localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
|
||||
CodePush.restartApp();
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -21,16 +21,11 @@ let InstallModeOnNextResumeTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeOnNextResume);
|
||||
})
|
||||
.then(() => {
|
||||
CodePush.restartApp();
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
await localPackage.install(NativeCodePush.codePushInstallModeOnNextResume);
|
||||
CodePush.restartApp();
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -21,13 +21,10 @@ let IsFailedUpdateTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -21,13 +21,10 @@ let IsFirstRunTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download();
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -21,20 +21,13 @@ let IsPendingTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeOnNextRestart);
|
||||
})
|
||||
.then((localPackage) => {
|
||||
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
|
||||
return CodePush.getCurrentPackage();
|
||||
})
|
||||
.then((localPackage) => {
|
||||
assert(localPackage.isPending, "isPending should be set to \"true\" after an install");
|
||||
});
|
||||
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");
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -21,13 +21,10 @@ let NotifyApplicationReadyTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -21,13 +21,10 @@ let RollbackTest = createTestCaseComponent(
|
||||
}
|
||||
|
||||
remotePackage = Object.assign(remotePackage, PackageMixins.remote);
|
||||
return Promise.resolve();
|
||||
},
|
||||
() => {
|
||||
remotePackage.download()
|
||||
.then((localPackage) => {
|
||||
return localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
});
|
||||
async () => {
|
||||
let localPackage = await remotePackage.download()
|
||||
return await localPackage.install(NativeCodePush.codePushInstallModeImmediate);
|
||||
},
|
||||
/*passAfterRun*/ false
|
||||
);
|
||||
|
||||
@@ -18,18 +18,17 @@ function createTestCaseComponent(displayName, description, setUp, runTest, passA
|
||||
done: false,
|
||||
};
|
||||
},
|
||||
componentDidMount() {
|
||||
setUp()
|
||||
.then(runTest)
|
||||
.then(() => {
|
||||
if (passAfterRun) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
async componentDidMount() {
|
||||
try {
|
||||
await setUp();
|
||||
await runTest();
|
||||
if (passAfterRun) {
|
||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react-native');
|
||||
var {
|
||||
import React, {
|
||||
AppRegistry,
|
||||
Dimensions,
|
||||
Image,
|
||||
@@ -9,84 +8,85 @@ var {
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} = React;
|
||||
} from "react-native";
|
||||
|
||||
var Button = require("react-native-button");
|
||||
import Button from "react-native-button";
|
||||
import CodePush from "react-native-code-push";
|
||||
|
||||
var CodePush = require('react-native-code-push');
|
||||
|
||||
var CodePushDemoApp = React.createClass({
|
||||
sync() {
|
||||
var self = this;
|
||||
CodePush.sync(
|
||||
{
|
||||
updateDialog: true,
|
||||
installMode: CodePush.InstallMode.ON_NEXT_RESUME
|
||||
},
|
||||
function(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 and will be run when the app next resumes.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UNKNOWN_ERROR:
|
||||
self.setState({
|
||||
syncMessage: "An unknown error occurred.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
let CodePushDemoApp = React.createClass({
|
||||
async sync() {
|
||||
let self = this;
|
||||
try {
|
||||
return await CodePush.sync(
|
||||
{
|
||||
updateDialog: true,
|
||||
installMode: CodePush.InstallMode.ON_NEXT_RESUME
|
||||
},
|
||||
(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 and will be run when the app next resumes.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
case CodePush.SyncStatus.UNKNOWN_ERROR:
|
||||
self.setState({
|
||||
syncMessage: "An unknown error occurred.",
|
||||
progress: false
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
(progress) => {
|
||||
self.setState({
|
||||
progress: progress
|
||||
});
|
||||
}
|
||||
},
|
||||
function(progress) {
|
||||
self.setState({
|
||||
progress: progress
|
||||
});
|
||||
}
|
||||
).catch(function(error) {
|
||||
);
|
||||
} catch (error) {
|
||||
CodePush.log(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return { };
|
||||
},
|
||||
|
||||
render() {
|
||||
var syncView;
|
||||
var syncButton;
|
||||
var progressView;
|
||||
let syncView, syncButton, progressView;
|
||||
|
||||
if (this.state.syncMessage) {
|
||||
syncView = (
|
||||
@@ -120,7 +120,7 @@ var CodePushDemoApp = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
let styles = StyleSheet.create({
|
||||
image: {
|
||||
marginTop: 50,
|
||||
width: Dimensions.get('window').width - 100,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
* on the same Wi-Fi network.
|
||||
*/
|
||||
|
||||
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.includeRequire.runModule.bundle?dev=true&platform=ios"];
|
||||
//jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.includeRequire.runModule.bundle?dev=true&platform=ios"];
|
||||
|
||||
/**
|
||||
* OPTION 2
|
||||
@@ -45,7 +45,7 @@
|
||||
* see http://facebook.github.io/react-native/docs/runningondevice.html
|
||||
*/
|
||||
|
||||
//jsCodeLocation = [CodePush bundleURL];
|
||||
jsCodeLocation = [CodePush bundleURL];
|
||||
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
|
||||
moduleName:@"CodePushDemoApp"
|
||||
|
||||
@@ -44,6 +44,6 @@
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string></string>
|
||||
<key>CodePushDeploymentKey</key>
|
||||
<string>5c73310a-cc93-4aa5-bf9f-81c6b648232c</string>
|
||||
<string>deployment-key-here</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1 +1 @@
|
||||
require("./crossplatformdemo.js");
|
||||
import "./crossplatformdemo.js";
|
||||
@@ -1 +1 @@
|
||||
require("./crossplatformdemo.js");
|
||||
import "./crossplatformdemo.js";
|
||||
Reference in New Issue
Block a user