Skip to content

基于微软CodePush项目, 适配code-push-cli和react-native-code-push 搭建自己的react native热更新服务

License

Notifications You must be signed in to change notification settings

learnFork/code-push-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodePush Server source

CodePush Server is a CodePush progam server! microsoft CodePush cloud is slow in China, we can use this to build our's. I use qiniu to store the files, because it's simple and quick! Or you can use local storage, just modify config.js file, it's simple configure.

EXAMPLE

shell命令行端

$ code-push login http://codepush.19910225.com:8080

访问:http://codepush-managerment.19910225.com:8080

客户端eg.

CodePushDemo

INSTALL

$ cd /path/to/code-push-server
$ mysql -uroot -e"create database codepush default charset utf8;"
$ mysql -uroot codepush < ./sql/codepush.sql
$ mysql -uroot codepush < ./sql/codepush-v0.1.1.sql
$ mysql -uroot codepush < ./sql/codepush-v0.1.5.sql
$ npm install

CONFIG

$ vim config/config.js

read config.js

Storage mode [local/qiniu]

RUN

$ node ./bin/www

or point config file and ENV

$ CONFIG_FILE=/path/to/config.js NODE_ENV=production node ./bin/www

notice. you have to change loginSecret in config.js for security.

Default listen Host/Port 127.0.0.1/3000

you can change like this.

$ PORT=3000 HOST=127.0.0.1 NODE_ENV=production node ./bin/www

code-push-cli

Use code-push-cli manager CodePushServer

$ npm install code-push-cli@lastest -g
$ code-push login http://127.0.0.1:3000 #login in browser account:admin password:123456

code-push-cli source

react-native-code-push

$ cd /path/to/project
$ npm install react-native-code-push@lastest

config react-native project

Follow the react-native-code-push docs, addition iOS add a new entry named CodePushServerURL, whose value is the key of ourself CodePushServer URL. Andriod use the new CodePush constructor in MainApplication point CodePushServerUrl

iOS eg. in file Info.plist

...
<key>CodePushDeploymentKey</key>
<string>YourCodePushKey</string>
<key>CodePushServerURL</key>
<string>YourCodePushServerUrl</string>
...

Android eg. in file MainApplication.java

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new CodePush(
         "YourKey",
         MainApplication.this,
         BuildConfig.DEBUG,
         "YourCodePushServerUrl" 
      )
  );
}

react-native-code-push source

Production Manage

use pm2 to manage process.

$ npm install pm2 -g
$ cp config/config.js /path/to/production/config.js
$ vim /path/to/production/config.js #configure your env.
$ cp docs/process.yml /path/to/production/process.yml
$ vim /path/to/production/process.yml #configure your env.
$ pm2 start /path/to/production/process.yml

Use CodePush Web manage apps

add codePushWebUrl config in ./config/config.js

eg.

...
"common": {
  "loginSecret": "CodePushServer",
  "codePushWebUrl": "Your CodePush Web address",
}
...

License

MIT License read

About

基于微软CodePush项目, 适配code-push-cli和react-native-code-push 搭建自己的react native热更新服务

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.3%
  • HTML 5.7%
  • CSS 1.0%