New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-code-push

Package Overview
Dependencies
Maintainers
11
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-code-push - npm Package Compare versions

Comparing version 5.7.0 to 6.0.0

android/.project

24

docs/api-android.md
### Java API Reference (Android)
### API for React Native 0.60 version and above
Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the CodePush plugin by placing these values in string resources.
* __Public Key__ - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. CodePush automatically gets this property and enables the Code Signing feature. For example:
```xml
<string moduleConfig="true" name="CodePushPublicKey">your-public-key</string>
```
* __Server Url__ - used for specifying CodePush Server Url.
The Default value: "https://codepush.appcenter.ms/" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. CodePush automatically gets this property and will use this path to send requests. For example:
```xml
<string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string>
```
### API for React Native lower than 0.60
The Java API is made available by importing the `com.microsoft.codepush.react.CodePush` class into your `MainActivity.java` file, and consists of a single public class named `CodePush`.

@@ -19,5 +37,5 @@

- __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing) section for more details about Code Signing Feature.
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appcenter.ms/"` is overridden by value specfied in `serverUrl`.
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appcenter.ms/"` is overridden by value specified in `serverUrl`.

@@ -50,3 +68,3 @@ ##### Builder

* __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](#code-signing) section for more detailed information about purpose of this parameter.
* __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more detailed information about purpose of this parameter.

@@ -53,0 +71,0 @@ * __public CodePush build()__ - return configured `CodePush` instance.

83

docs/multi-deployment-testing-android.md

@@ -7,10 +7,14 @@ ### Android

The [Android Gradle plugin](http://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release), which in turn are generated as properties on the `BuildConfig` class that you can reference from your Java code. This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release). This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
To set this up, perform the following steps:
1. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
**For React Native >= v0.60**
2. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
2. Find the `android { buildTypes {} }` section and define `resValue` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively.
```groovy

@@ -23,2 +27,56 @@ android {

// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
resValue "string", "CodePushDeploymentKey", '""'
...
}
releaseStaging {
...
resValue "string", "CodePushDeploymentKey", '"<INSERT_STAGING_KEY>"'
// Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
// Add the following line if not already there
matchingFallbacks = ['release']
...
}
release {
...
resValue "string", "CodePushDeploymentKey", '"<INSERT_PRODUCTION_KEY>"'
...
}
}
...
}
```
*NOTE: Remember to remove the key from `strings.xml` if you are configuring the deployment key in the build process*
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
**For React Native v0.29 - v0.59**
1. Open up your `MainApplication.java` file and make the following changes:
```java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
...
);
}
```
2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
3. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
```groovy
android {
...
buildTypes {
debug {
...
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
buildConfigField "String", "CODEPUSH_KEY", '""'

@@ -47,4 +105,2 @@ ...

*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*

@@ -54,17 +110,2 @@

**For React Native >= v0.29**
Open up your `MainApplication.java` file and make the following changes:
```java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
...
);
}
```
**For React Native v0.19 - v0.28**

@@ -111,2 +152,2 @@

And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
## Android Setup
* [Plugin Installation (Android)](#plugin-installation-android)
* [Plugin Installation and Configuration for React Native 0.60 version and above](#plugin-installation-and-configuration-for-react-native-060-version-and-above-android)
* [Plugin Installation for React Native lower than 0.60 (Android)](#plugin-installation-for-react-native-lower-than-060-android)
* [Plugin Installation (Android - RNPM)](#plugin-installation-android---rnpm)
* [Plugin Installation (Android - Manual)](#plugin-installation-android---manual)
* [Plugin Configuration (Android)](#plugin-configuration-android)
* [For React Native >= v0.29](#for-react-native--v029)
* [Plugin Configuration for React Native lower than 0.60 (Android)](#plugin-configuration-for-react-native-lower-than-060-android)
* [For React Native v0.29 - v0.59](#for-react-native-v029---v059)
* [For newly created React Native application](#for-newly-created-react-native-application)

@@ -15,8 +16,60 @@ * [For existing native application](#for-existing-native-application)

* [WIX React Native Navigation applications (ver 1.x)](#wix-react-native-navigation-applications)
* [Code Signing setup](#code-signing-setup)
* [Code Signing setup](#code-signing-setup)
In order to integrate CodePush into your Android project, please perform the following steps:
### Plugin Installation (Android)
### Plugin Installation and Configuration for React Native 0.60 version and above (Android)
1. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
```gradle
...
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
...
```
2. Update the `MainApplication.java` file to use CodePush via the following changes:
```java
...
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...
// 2. Override the getJSBundleFile method in order to let
// the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
}
```
3. Add the Deployment key to `strings.xml`:
To let the CodePush runtime know which deployment it should query for updates, open your app's `strings.xml` file and add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. The "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production.
Your `strings.xml` should looks like this:
```xml
<resources>
<string name="app_name">AppName</string>
<string moduleConfig="true" name="CodePushDeploymentKey">DeploymentKey</string>
</resources>
```
*Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)*
### Plugin Installation for React Native lower than 0.60 (Android)
In order to accommodate as many developer preferences as possible, the CodePush plugin supports Android installation via two mechanisms:

@@ -44,5 +97,5 @@

2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retreive this value by running `code-push deployment ls <appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `code-push deployment ls <appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-android) section to complete the setup.
And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-for-react-native-lower-than-060-android) section to complete the setup.

@@ -77,3 +130,3 @@ #### Plugin Installation (Android - Manual)

### Plugin Configuration (Android)
### Plugin Configuration for React Native lower than 0.60 (Android)

@@ -84,3 +137,3 @@ *NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.*

#### For React Native >= v0.29
#### For React Native v0.29 - v0.59

@@ -368,7 +421,7 @@ ##### For newly created React Native application

#### Code Signing setup
### Code Signing setup
Starting with CLI version **2.1.0** you can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant code-push documentation section](https://github.com/Microsoft/code-push/tree/master/cli#code-signing). In order to use Public Key for Code Signing you need to do following steps:
1. Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:

@@ -390,5 +443,5 @@ ```xml

2. Configure `CodePush` instance to use this parameter
#### For React Native <= v0.60 you should configure the `CodePush` instance to use this parameter using one of the following approaches
* using constructor
##### Using constructor

@@ -403,6 +456,4 @@ ```java

or
##### Using builder
* using builder
```java

@@ -409,0 +460,0 @@ new CodePushBuilder("deployment-key-here",getApplicationContext())

## iOS Setup
Once you've acquired the CodePush plugin, you need to integrate it into the Xcode project of your React Native app and configure it correctly. To do this, take the following steps:
### Plugin Installation and Configuration for React Native 0.60 version and above (iOS)
### Plugin Installation (iOS)
1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies.
2. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
```objective-c
#import <CodePush/CodePush.h>
```
3. Find the following line of code, which sets the source URL for bridge for production releases:
```objective-c
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
```
4. Replace it with this line:
```objective-c
return [CodePush bundleURL];
```
This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via CodePush, this will return the location of the most recently installed update.
*NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior*
Typically, you're only going to want to use CodePush to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and CodePush, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time.
Your `sourceURLForBridge` method should look like this:
```objective-c
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [CodePush bundleURL];
#endif
}
```
5. Add the Deployment key to `Info.plist`:
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production.
*Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)*
### Plugin Installation for React Native lower than 0.60 (iOS)
In order to accommodate as many developer preferences as possible, the CodePush plugin supports iOS installation via three mechanisms:

@@ -88,3 +138,3 @@

### Plugin Configuration (iOS)
### Plugin Configuration for React Native lower than 0.60 (iOS)

@@ -101,3 +151,3 @@ *NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.*

For React Native 0.59 and above:
For React Native 0.59 - 0.59.10:

@@ -136,3 +186,3 @@ 2. Find the following line of code, which sets the source URL for bridge for production releases:

For React Native 0.59 and above:
For React Native 0.59 - 0.59.10:

@@ -139,0 +189,0 @@ ```objective-c

{
"name": "react-native-code-push",
"version": "5.7.0",
"version": "6.0.0",
"description": "React Native plugin for the CodePush service",

@@ -45,3 +45,3 @@ "main": "CodePush.js",

"android": {
"packageInstance": "new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)"
"packageInstance": "new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)"
},

@@ -48,0 +48,0 @@ "ios": {

@@ -8,2 +8,4 @@ UPDATE: Over the next few months, we will be working on a new version of CodePush that will address some of the most common performance issues our customers are facing. This updated version will allow a better experience, our team to better support CodePush moving forward and have a faster development cycle for new features.

#### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush
# React Native Module for CodePush

@@ -80,2 +82,3 @@

| v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |

@@ -82,0 +85,0 @@ We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is.

@@ -40,3 +40,3 @@ var linkTools = require('../../tools/linkToolsAndroid');

Please refer to plugin configuration section for Android at \
https://github.com/microsoft/react-native-code-push#plugin-configuration-android for more details`);
https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-configuration-for-react-native-lower-than-060-android for more details`);
}

@@ -48,3 +48,3 @@ }

Please refer to plugin installation section for Android at \
https://github.com/microsoft/react-native-code-push#plugin-installation-android---manual`);
https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-installation-android---manual`);
}

@@ -51,0 +51,0 @@

@@ -34,3 +34,3 @@ var linkTools = require('../../tools/linkToolsAndroid');

Please refer to plugin configuration section for Android at \
https://github.com/microsoft/react-native-code-push#plugin-configuration-android for more details`);
https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-configuration-for-react-native-lower-than-060-android for more details`);
}

@@ -45,3 +45,3 @@ }

Please refer to plugin installation section for Android at \
https://github.com/microsoft/react-native-code-push#plugin-installation-android---manual`);
https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md#plugin-installation-android---manual`);
} else {

@@ -68,3 +68,3 @@ var buildGradleContents = fs.readFileSync(buildGradlePath, "utf8");

} else {
var AndroidDeploymentKey = stringsResourcesContent.match(/(<string moduleConfig="true" name="reactNativeCodePush_androidDeploymentKey">.*<\/string>)/);
var AndroidDeploymentKey = stringsResourcesContent.match(/(<string moduleConfig="true" name="CodePushDeploymentKey">.*<\/string>)/);
if (AndroidDeploymentKey) {

@@ -71,0 +71,0 @@ stringsResourcesContent = stringsResourcesContent.replace(`\n\t${AndroidDeploymentKey[0]}`,"");

@@ -17,3 +17,3 @@ var fs = require("fs");

exports.codePushGradleLink = `\napply from: "../../node_modules/react-native-code-push/android/codepush.gradle"`;
exports.deploymentKeyName = "reactNativeCodePush_androidDeploymentKey";
exports.deploymentKeyName = "CodePushDeploymentKey";

@@ -20,0 +20,0 @@ exports.getMainApplicationLocation = function () {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc