CodePush 1.1 (beta) released

04 Nov 2015 - byJonathan Carter

As part of our commitment to respond quickly to all of the great developer feedback we’ve been getting, we’ve released an update to the CodePush service, management CLI and client SDKs for both Cordova and React Native. You can update any of these components immediately via NPM, and then refer to the docs, which have been updated to account for the changes.

The 1.1 update includes a handful of bug fixes (thanks for everyone who helped report issues!) that we hope will improve reliability. Additionally, we also addressed the following feature requests that should help enable some important/common scenarios.

CodePush.sync()

Our client SDKs already included APIs which allowed your apps to check for the presence of an update and then subsequently download and apply it, customizing the user experience however you wished. While we think this “advanced API” is critical in allowing unexpected and custom scenarios to be more easily achievable, we also wanted to provide an API that allowed some common experiences to be possible with very little code. After talking to many users, we were able to infer a common user experience that we encapsulated in a new API method called codePush.sync.

CodePush.sync().then((status) => {
    if (status == codePush.SyncStatus.UPDATE_APPLIED) {
        // Do any neccessary work here before the app
        // is restarted in order to apply the update
    }
});

The sync method performs the update check, and handles displaying a notification to end-users when available. If a release is optional, the displayed dialog will allow ignoring it; otherwise, if the release is marked as mandatory, the end-user is required to install it before moving forward (this is useful for internal and testing scenarios). Additionally, you can choose to display your release description in the update notification and customize any string used in the dialog (e.g. buttons, header text).

We hope this helps lower the barrier for getting started with CodePush, and we are interested in helping simplify other scenarios beyond what sync currently provides (e.g. enable “silent mode” background updates). Check out the docs on this new method for more info (React Native, Cordova).

Release promotion

A very common release practice is to submit an update to a dev or staging environment, test it, and then “promote” that update to your production environment. While this was possible previously by using the code-push release command in our CLI, it wasn’t optimized for making this experience as simple as possible.

To better accomodate this common scenario, we introduced a new command to the management CLI called promote that simply allows you to copy the contents and metadata (e.g. description, app store version, mandatory) from one deployment to another.

code-push promote <appName> <sourceDeploymentName> <targetDeploymentName>

With this addition, you can now easily do migrations between deployments (dev->staging, staging->production, etc.), which we hope should make your development process even smoother when using CodePush. Refer to the management CLI’s documentation for more information.

CI integration/“headless releases”

Enabling “continuous delivery” workflows are really important to us, and our current authentication support in the CLI didn’t lend itself very well to running “headlessly” in a CI environment. To better support this, we have made three improvements to the CLI:

  1. There is a new code-push access-key add command that allows you to generate new access tokens that can be used to login from a CI server. When you run code-push access-key ls, the list will display the description of the key so that you can revoke it as soon as you no longer need it.

  2. The existing code-push login command now accepts a --accessKey flag that allows you to authenticate using a created access key, as opposed to launching a browser to authenticate with either GitHub or your Microsoft account.

  3. The existing code-push logout command now accepts a --local flag that allows you to specify that you want to logout of the current user session (e.g. remove the session file from the machine), but that you don’t want to delete the key from the server. This way you can reuse a key for all your builds in a CI environment, but you don’t need to worry about leaving any authentication credentials lying around on the build machine.

With the ability to create and authenticate with new keys, you can now easily script release automation in your CI environment. Moving forward, we plan to provide even better integration experiences with certain CI solutions, but in the meantime, we hope that this helps unblocks folks who would like to implement a CodePush-based continuous delivery workflow. Refer to the management CLI’s documentation for more information.

Thank you!

It has been an absolute pleasure to engage with the Cordova and React Native communities thus far, and we want to continue saying thank you for all the bug reports, feedback, usage and overall awesomeness! We have many more improvements coming soon, and we would love to hear any any all suggestions, shout outs, hate mail, etc. that you have, so feel free to ping us.