1.0.9 • Published 1 year ago

@np-dev/rn-deploy v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

React Native Deploy helper

Install

  • Install rn-deploy
npm install -g @np-dev/rn-deploy
OR
npm install --save-dev @np-dev/rn-deploy

Commands

  • rn-deploy codepush ${platform} ${environment}
  • platform: ios or android or all
  • environment: dev - .env, staging - .env.staging, production - .env.production
  • For example:
rn-deploy codepush ios dev
rn-deploy codepush android dev
rn-deploy codepush all dev

.env example

DEPLOY_CODEPUSH_TOKEN = 'User token from codepush'
IOS_DEPLOY_TOKEN = 'IOS token from codepush'
ANDROID_DEPLOY_TOKEN = 'Android token from codepush'
ANDROID_CODEPUSH_URL = 'Android project'
IOS_CODEPUSH_URL = 'IOS project'

Sync CodePush with S3

  • Add to .env or .env.codepush_s3
AWS_REGION = ''
AWS_BUCKET_NAME = ''
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
AWS_ENDPOINT = 'For custom s3 server'
AWS_FORCE_PATH_STYLE = true
  • Add @np-dev/react-native-code-push to package.json
yarn add @np-dev/react-native-code-push
  • or
npm i @np-dev/react-native-code-push
  • In the app, when your app check for updates, add the following code:
import codePush, {RemotePackage} from '@np-dev/react-native-code-push';

const remoteVersion: RemotePackage | null = await codePush.checkForUpdate();

let downloadUrl: string | undefined;
if (remoteVersion.packageHash) {
  // Send head request to check if the file is available
  const S3Url = 'https://packages.s3.ap-southeast-1.amazonaws.com/' + remoteVersion.packageHash;
  const checkS3 = await fetch(S3Url, {
    method: 'HEAD',
  });
  if (checkS3.status === 200) {
    downloadUrl = S3Url;
  }
}
codePush.sync(
  {
    installMode: codePush.InstallMode.IMMEDIATE,
    downloadUrl,
  },
  syncStatusChangedCallback,
  codePushDownloadDidProgress,
  codePushDownloadCompleted,
);
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago