Linux Code Push环境搭建

所需环境:

数据库,nodejs,git

下载 code-push-server 仓库

git clone https://github.com/lisong/code-push-server.git

cd code-push-server && npm install

# 启动后登陆默认账号,获取access key
account: admin
password: 123456

修改默认配置,需要改动db模块配置数据库,local模块配置bundle下载配置

vi config/config.js
# 初始化数据库
./bin/db init --dbhost localhost --dbuser root --dbpassword 数据库密码
# 启动Code Push服务
./bin/www

客户端

# 全局安装微软提供的code-push-cli工具
npm install code-push-cli@latest -g


# 常用code-push命令
# 注册账号: 
code-push register

# 登陆: 
code-push login

# 查看当前登陆账号: 
code-push whoami

# 注销: 
code-push logout

# 添加项目: 
code-push app add app名称

# 删除项目: 
code-push app remove app名称

# 列出账号下的所有项目: 
code-push app list

# 显示登陆的token: 
code-push access-key ls

# 部署一个环境: 
code-push deployment add appName deploymentName

# 删除部署: 
code-push deployment rm appName

# 列出应用的部署: 
code-push deployment ls appName

# 查询部署环境的key: 
code-push deployment ls appName -k

# 例
code-push login http://localhost:3000
code-push app add CodePushDemoIos ios react-native
code-push app add CodePushDemoAndroid android react-native
# 其中Production对应的是生产的Deployment Key,Staging是开发时使用。
code-push deployment ls CodePushDemoAndroid -k

React Native配置Code Push

# 项目中导入CodePush代码
npm install --save react-native-code-push
# 关联项目
react-native link react-native-code-push
new CodePush("xxxxxxxxxxxxx", MainApplication.this, BuildConfig.DEBUG,"http://你的IP:端口/")

componentDidMount() {
    CodePush.sync({
        //启动模式三种:ON_NEXT_RESUME、ON_NEXT_RESTART、IMMEDIATE
        installMode: CodePush.InstallMode.ON_NEXT_RESTART,
        // 苹果公司和中国区安卓的热更新,是不允许弹窗提示的,所以不能设置为true
        updateDialog: false  
    });
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章