Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api-compat/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const _isFirstRun: boolean = pkg.isFirstRun;
const _isMandatory: boolean = pkg.isMandatory;
const _isPending: boolean = pkg.isPending;
const _label: string = pkg.label;
const _versionLabel: string | undefined = pkg.versionLabel;
const _packageHash: string = pkg.packageHash;
const _packageSize: number = pkg.packageSize;

Expand Down
2 changes: 2 additions & 0 deletions code-push-plugin-testing-framework/script/serverUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function createDefaultResponse() {
defaultResponse.target_binary_range = "";
defaultResponse.package_hash = "";
defaultResponse.label = "";
defaultResponse.version_label = "";
defaultResponse.package_size = 0;
defaultResponse.should_run_binary_version = false;
defaultResponse.update_app_version = false;
Expand All @@ -144,6 +145,7 @@ function createUpdateResponse(mandatory, targetPlatform, randomHash) {
updateResponse.download_url = "mock.url/v0.1/public/codepush/report_status/download";
updateResponse.is_mandatory = mandatory;
updateResponse.label = "mock-update";
updateResponse.version_label = "v1";
updateResponse.package_hash = "12345-67890";
updateResponse.package_size = 12345;
updateResponse.should_run_binary_version = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ declare module 'code-push-plugin-testing-framework/script/serverUtil' {
is_disabled: boolean;
description: string;
label: string;
version_label: string;
package_hash: string;
is_mandatory: boolean;
}
Expand Down
5 changes: 3 additions & 2 deletions docs/api-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ codePush.checkForUpdate(deploymentKey: String = null, handleBinaryVersionMismatc
Queries the CodePush service to see whether the configured app deployment has an update available. By default, it will use the deployment key that is configured in your `Info.plist` file (iOS), or `strings.xml` file (Android), but you can override that by specifying a value via the optional `deploymentKey` parameter. This can be useful when you want to dynamically "redirect" a user to a specific deployment, such as allowing "early access" via an easter egg or a user setting switch.

Second optional parameter `handleBinaryVersionMismatchCallback` is an optional callback function that can be used to notify user if there are any binary update.
E.g. consider a use-case where currently installed binary version is 1.0.1 with label(codepush label) v1. Later native code was changed in the dev cycle and binary version was updated to 1.0.2. When code-push update check is triggered we ignore updates having binary version mismatch (because the update is not targeting to the binary version of currently installed app). In this case installed app (1.0.1) will ignore the update targeting version 1.0.2. You can use `handleBinaryVersionMismatchCallback` to provide a hook to handle such situations.
E.g. consider a use-case where the currently installed binary version is 1.0.1 and it runs the CodePush update whose `versionLabel` is `v1`. Later native code was changed in the dev cycle and binary version was updated to 1.0.2. When code-push update check is triggered we ignore updates having binary version mismatch (because the update is not targeting to the binary version of currently installed app). In this case installed app (1.0.1) will ignore the update targeting version 1.0.2. You can use `handleBinaryVersionMismatchCallback` to provide a hook to handle such situations.

**NOTE:**
Be cautious to use Alerts within this callback if you are developing iOS application, due to [App Store](https://developer.apple.com/app-store/review/guidelines/) review process:
Expand Down Expand Up @@ -536,9 +536,10 @@ Contains details about an update that has been downloaded locally or already ins
- __isFirstRun__: Indicates whether this is the first time the update has been run after being installed. This is useful for determining whether you would like to show a "What's New?" UI to the end user after installing an update. *(Boolean)*
- __isMandatory__: Indicates whether the update is considered mandatory. This is the value that was specified in the CLI when the update was released. *(Boolean)*
- __isPending__: Indicates whether this update is in a "pending" state. When `true`, that means the update has been downloaded and installed, but the app restart needed to apply it hasn't occurred yet, and therefore, it's changes aren't currently visible to the end-user. *(Boolean)*
- __label__: The internal label automatically given to the update by the CodePush server, such as `v5`. This value uniquely identifies the update within it's deployment. *(String)*
- __label__: The internal label automatically given to the update by the CodePush server. This value uniquely identifies the update within its deployment. *(String)*
Comment thread
miklosboros marked this conversation as resolved.
- __packageHash__: The SHA hash value of the update. *(String)*
- __packageSize__: The size of the code contained within the update, in bytes. *(Number)*
- __versionLabel__: The human-readable version label of the update within its deployment, such as `v5`, matching what the Bitrise UI and CLI show. This is `undefined` for updates downloaded by an older version of this SDK, or served by a server that does not yet provide it. *(String)*

###### Methods

Expand Down
1 change: 1 addition & 0 deletions src/acquisition-sdk/__tests__/acquisition-rest-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export var latestPackage = <types.UpdateCheckResponse>{
description: "Angry flappy birds",
target_binary_range: "1.5.0",
label: "2.4.0",
version_label: "v3",
is_mandatory: false,
is_available: true,
update_app_version: false,
Expand Down
1 change: 1 addition & 0 deletions src/acquisition-sdk/__tests__/acquisition-sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var scriptUpdateResult: acquisitionSdk.RemotePackage = {
description: latestPackage.description,
downloadUrl: latestPackage.download_url,
label: latestPackage.label,
versionLabel: latestPackage.version_label,
appVersion: latestPackage.target_binary_range,
isMandatory: latestPackage.is_mandatory,
packageHash: latestPackage.package_hash,
Expand Down
3 changes: 3 additions & 0 deletions src/acquisition-sdk/acquisition-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface Package {
deploymentKey: string;
description: string;
label: string;
// Optional because packages persisted by an older SDK have no versionLabel.
versionLabel?: string;
appVersion: string;
isMandatory: boolean;
packageHash: string;
Expand Down Expand Up @@ -165,6 +167,7 @@ export class AcquisitionManager {
deploymentKey: this._deploymentKey,
description: updateInfo.description,
label: updateInfo.label,
versionLabel: updateInfo.version_label,
appVersion: updateInfo.target_binary_range,
isMandatory: updateInfo.is_mandatory,
packageHash: updateInfo.package_hash,
Expand Down
1 change: 1 addition & 0 deletions src/acquisition-sdk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface UpdateCheckResponse {
is_disabled?: boolean;
target_binary_range: string;
/*generated*/ label?: string;
/*generated*/ version_label?: string;
/*generated*/ package_hash?: string;
package_size?: number;
should_run_binary_version?: boolean;
Expand Down
34 changes: 28 additions & 6 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ PluginTestingFramework.initializeTests(new RNProjectManager(), supportedTargetPl
assert.strictEqual(remotePackage.downloadUrl, updateResponse.download_url);
assert.strictEqual(remotePackage.isMandatory, updateResponse.is_mandatory);
assert.strictEqual(remotePackage.label, updateResponse.label);
assert.strictEqual(remotePackage.versionLabel, updateResponse.version_label);
assert.strictEqual(remotePackage.packageHash, updateResponse.package_hash);
assert.strictEqual(remotePackage.packageSize, updateResponse.package_size);
assert.strictEqual(remotePackage.deploymentKey, targetPlatform.getDefaultDeploymentKey());
Expand Down Expand Up @@ -915,17 +916,38 @@ PluginTestingFramework.initializeTests(new RNProjectManager(), supportedTargetPl
() => {
TestBuilder.it("remotePackage.download.success", false,
(done: Mocha.Done) => {
ServerUtil.updateResponse = { update_info: ServerUtil.createUpdateResponse(false, targetPlatform) };
const updateResponse = ServerUtil.createUpdateResponse(false, targetPlatform);
ServerUtil.updateResponse = { update_info: updateResponse };

/* pass the path to any file for download (here, index.js) to make sure the download completed callback is invoked */
ServerUtil.updatePackagePath = path.join(TestConfig.templatePath, "index.js");

projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
let sawUpdateAvailable = false;
let finished = false;
ServerUtil.testMessageCallback = (requestBody: any) => {
if (finished) {
return;
}
try {
if (requestBody.message === ServerUtil.TestMessage.CHECK_UPDATE_AVAILABLE) {
sawUpdateAvailable = true;
return;
}
assert.strictEqual(requestBody.message, ServerUtil.TestMessage.DOWNLOAD_SUCCEEDED);
assert(sawUpdateAvailable, "download reported before the update check");
// The local package is read back from native storage, so this covers the metadata round trip.
const localPackage: any = requestBody.args[0];
assert.strictEqual(localPackage.label, updateResponse.label);
assert.strictEqual(localPackage.versionLabel, updateResponse.version_label);
finished = true;
done();
} catch (e) {
finished = true;
done(e);
}
};

ServerUtil.expectTestMessages([
ServerUtil.TestMessage.CHECK_UPDATE_AVAILABLE,
ServerUtil.TestMessage.DOWNLOAD_SUCCEEDED])
.then(() => { done(); }, (e) => { done(e); });
projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
});

TestBuilder.it("remotePackage.download.error", false,
Expand Down
6 changes: 6 additions & 0 deletions typings/react-native-code-push.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export interface Package {
*/
label: string;

/**
* The `vN` release label of the update within its deployment, as shown in the Bitrise UI and CLI.
* Undefined for updates downloaded by an older SDK version or from a server that does not send it.
*/
versionLabel?: string;

/**
* The SHA hash value of the update.
*/
Expand Down
Loading