diff --git a/CHANGELOG.md b/CHANGELOG.md index c6903211..68b75255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,21 +2,21 @@ ## 0.5.x -## 新特性 -- 针对文本增量更新进行优化,使用google `diff-match-patch` 算法计算差异 - - react-native-code-push Android客户端适配,需要合并https://github.com/Microsoft/react-native-code-push/pull/1393, 才能正常使用文本增量更新功能。 - - react-native-code-push iOS客户端适配 (需要合并https://github.com/Microsoft/react-native-code-push/pull/1399) - - react-native-code-push Windows客户端适配 (进行中) +## New Features +- Optimized for text incremental updates using Google's `diff-match-patch` algorithm + - react-native-code-push Android client adaptation, requires merging https://github.com/Microsoft/react-native-code-push/pull/1393 to use text incremental update feature + - react-native-code-push iOS client adaptation (requires merging https://github.com/Microsoft/react-native-code-push/pull/1399) + - react-native-code-push Windows client adaptation (in progress) -## fixbug +## Bug Fixes -- 修复统计数据激活数 -- 修复灰度发布bug -- rollback后增加计算和最后一次增量更新版本 +- Fixed activation count in statistics +- Fixed gray release bug +- Added calculation and last incremental update version after rollback -## 如何升级到该版本 +## How to Upgrade to This Version -### 升级数据库 +### Upgrade Database `$ npm run upgrade` @@ -27,41 +27,41 @@ or ## 0.4.x -### 新特性 +### New Features -- targetBinaryVersion 支持正则匹配, `deployments_versions`新增字段`min_version`,`max_version` - - `*` 匹配所有版本 - - `1.2.3` 匹配特定版本`1.2.3` - - `1.2`/`1.2.*` 匹配所有1.2补丁版本 +- targetBinaryVersion supports regex matching, `deployments_versions` table adds `min_version`, `max_version` fields + - `*` matches all versions + - `1.2.3` matches specific version `1.2.3` + - `1.2`/`1.2.*` matches all 1.2 patch versions - `>=1.2.3<1.3.7` - - `~1.2.3` 匹配`>=1.2.3<1.3.0` - - `^1.2.3` 匹配`>=1.2.3<2.0.0` -- 添加docker编排服务部署,更新文档 + - `~1.2.3` matches `>=1.2.3<1.3.0` + - `^1.2.3` matches `>=1.2.3<2.0.0` +- Added docker orchestration service deployment, updated documentation - Support Tencent cloud cos storageType -## 如何升级到该版本 +## How to Upgrade to This Version -- 升级数据库 +- Upgrade Database `$ ./bin/db upgrade` or `$ mysql codepush < ./sql/codepush-v0.4.0-patch.sql` -- 处理存量数据 +- Process Existing Data ``` shell $ git clone https://github.com/lisong/tools $ cd tools $ npm i - $ vim ./bin/fixMinMaxVersion //修改数据配置 - $ node ./bin/fixMinMaxVersion //出现提示 success + $ vim ./bin/fixMinMaxVersion //modify data configuration + $ node ./bin/fixMinMaxVersion //success prompt will appear ``` ## 0.3.x -- 支持灰度发布 -- 适配`code-push app add` 命令,应用不再以名字区分平台,而是以类型区分平台 - - 数据库表apps新增字段`os`,`platform` -- 完善`code-push release/release-react/release-cordova` 命令 - - 数据库表packages新增`is_disabled`,`rollout`字段 -- 适配`code-push patch`命令 -- 新增`log_report_download`,`log_report_deploy`日志表 -- 升级npm依赖包 +- Support for gray release +- Adapted to `code-push app add` command, applications are now distinguished by type rather than name + - Added `os`, `platform` fields to apps database table +- Improved `code-push release/release-react/release-cordova` commands + - Added `is_disabled`, `rollout` fields to packages database table +- Adapted to `code-push patch` command +- Added `log_report_download`, `log_report_deploy` log tables +- Upgraded npm dependencies diff --git a/README.md b/README.md index 1611e8db..7285b04e 100644 --- a/README.md +++ b/README.md @@ -22,24 +22,24 @@ CodePush Server is a CodePush progam server! microsoft CodePush cloud is slow in - oss *storage bundle file in [aliyun](https://www.aliyun.com/product/oss)* - tencentcloud *storage bundle file in [tencentcloud](https://cloud.tencent.com/product/cos)* -## 正确使用code-push热更新 +## Proper Usage of Code-Push Hot Updates -- 苹果App允许使用热更新[Apple's developer agreement](https://developer.apple.com/programs/ios/information/iOS_Program_Information_4_3_15.pdf), 为了不影响用户体验,规定必须使用静默更新。 Google Play不能使用静默更新,必须弹框告知用户App有更新。中国的android市场必须采用静默更新(如果弹框提示,App会被“请上传最新版本的二进制应用包”原因驳回)。 -- react-native 不同平台bundle包不一样,在使用code-push-server的时候必须创建不同的应用来区分(eg. CodePushDemo-ios 和 CodePushDemo-android) -- react-native-code-push只更新资源文件,不会更新java和Objective C,所以npm升级依赖包版本的时候,如果依赖包使用的本地化实现, 这时候必须更改应用版本号(ios修改Info.plist中的CFBundleShortVersionString, android修改build.gradle中的versionName), 然后重新编译app发布到应用商店。 -- 推荐使用code-push release-react 命令发布应用,该命令合并了打包和发布命令(eg. code-push release-react CodePushDemo-ios ios -d Production) -- 每次向App Store提交新的版本时,也应该基于该提交版本同时向code-push-server发布一个初始版本。(因为后面每次向code-push-server发布版本时,code-puse-server都会和初始版本比较,生成补丁版本) +- Apple Apps allow hot updates according to [Apple's developer agreement](https://developer.apple.com/programs/ios/information/iOS_Program_Information_4_3_15.pdf). To maintain a good user experience, silent updates are required. Google Play does not allow silent updates and requires a dialog to inform users about App updates. Chinese Android markets require silent updates (if a dialog prompt is shown, the App will be rejected with the reason "Please upload the latest version of the binary application package"). +- React Native bundle packages are different for different platforms, so you must create different applications to distinguish them when using code-push-server (e.g., CodePushDemo-ios and CodePushDemo-android). +- React-native-code-push only updates resource files and does not update Java and Objective C. Therefore, when upgrading npm dependency package versions, if the dependency package uses native implementations, you must change the application version number (modify CFBundleShortVersionString in Info.plist for iOS, modify versionName in build.gradle for Android), then recompile the app and publish it to the app store. +- It is recommended to use the code-push release-react command to publish applications, as this command combines packaging and publishing commands (e.g., code-push release-react CodePushDemo-ios ios -d Production). +- Every time you submit a new version to the App Store, you should also publish an initial version to code-push-server based on that submission version. (This is because code-push-server will compare each subsequent version with the initial version to generate patch versions.) ### shell login ```shell -$ code-push login http://api.code-push.com #登录 +$ code-push login http://api.code-push.com #login ``` ### [web](http://www.code-push.com) -访问:http://www.code-push.com +Visit: http://www.code-push.com ### client eg. diff --git a/docker/README.md b/docker/README.md index d1fb6da1..6658ee85 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,74 +1,74 @@ -# docker 部署 code-push-server +# Deploy code-push-server with Docker ->该文档用于描述docker部署code-push-server,实例包含三个部分 +>This document describes how to deploy code-push-server using Docker, the instance includes three parts -- code-push-server部分 - - 更新包默认采用`local`存储(即存储在本地机器上)。使用docker volume存储方式,容器销毁不会导致数据丢失,除非人为删除volume。 - - 内部使用pm2 cluster模式管理进程,默认开启进程数为cpu数,可以根据自己机器配置设置docker-compose.yml文件中deploy参数。 - - docker-compose.yml只提供了应用的一部分参数设置,如需要设置其他配置,可以修改文件config.js。 -- mysql部分 - - 数据使用docker volume存储方式,容器销毁不会导致数据丢失,除非人为删除volume。 - - 应用请勿使用root用户,为了安全可以创建权限相对较小的权限供code-push-server使用,只需要给予`select,update,insert`权限即可。初始化数据库需要使用root或有建表权限用户 -- redis部分 - - `tryLoginTimes` 登录错误次数限制 - - `updateCheckCache` 提升应用性能 - - `rolloutClientUniqueIdCache` 灰度发布 +- code-push-server part + - Update packages use `local` storage by default (stored on the local machine). Using docker volume storage method, container destruction won't cause data loss unless the volume is manually deleted. + - Uses pm2 cluster mode internally to manage processes, default process count is equal to CPU count, you can configure the deploy parameters in docker-compose.yml file according to your machine configuration. + - docker-compose.yml only provides some application parameter settings, if you need to set other configurations, you can modify the config.js file. +- mysql part + - Data uses docker volume storage method, container destruction won't cause data loss unless the volume is manually deleted. + - Applications should not use root user, for security you can create a user with relatively small permissions for code-push-server to use, only `select,update,insert` permissions are needed. Initializing the database requires root or a user with table creation permissions +- redis part + - `tryLoginTimes` login error count limit + - `updateCheckCache` improves application performance + - `rolloutClientUniqueIdCache` gray release -## 安装docker +## Install Docker -参考docker官方安装教程 +Refer to Docker's official installation guide -- [>>mac点这里](https://docs.docker.com/docker-for-mac/install/) -- [>>windows点这里](https://docs.docker.com/docker-for-windows/install/) -- [>>linux点这里](https://docs.docker.com/install/linux/docker-ce/ubuntu/) +- [>>Click here for Mac](https://docs.docker.com/docker-for-mac/install/) +- [>>Click here for Windows](https://docs.docker.com/docker-for-windows/install/) +- [>>Click here for Linux](https://docs.docker.com/install/linux/docker-ce/ubuntu/) -`$ docker info` 能成功输出相关信息,则安装成功,才能继续下面步骤 +`$ docker info` should output relevant information successfully, then the installation is successful and you can proceed with the following steps -## 启动swarm +## Start Swarm ```shell $ sudo docker swarm init ``` -## 获取代码 +## Get Code ```shell $ git clone https://github.com/lisong/code-push-server.git $ cd code-push-server/docker ``` -## 修改配置文件 +## Modify Configuration File ```shell $ vim docker-compose.yml ``` -*将`DOWNLOAD_URL`中`YOU_MACHINE_IP`替换成本机外网ip或者域名* +*Replace `YOU_MACHINE_IP` in `DOWNLOAD_URL` with your machine's external IP or domain* -*将`MYSQL_HOST`中`YOU_MACHINE_IP`替换成本机内网ip* +*Replace `YOU_MACHINE_IP` in `MYSQL_HOST` with your machine's internal IP* -*将`REDIS_HOST`中`YOU_MACHINE_IP`替换成本机内网ip* +*Replace `YOU_MACHINE_IP` in `REDIS_HOST` with your machine's internal IP* -## jwt.tokenSecret修改 +## Modify jwt.tokenSecret -> code-push-server 验证登录验证方式使用的json web token加密方式,该对称加密算法是公开的,所以修改config.js中tokenSecret值很重要。 +> code-push-server uses JSON web token encryption method for login verification, this symmetric encryption algorithm is public, so modifying the tokenSecret value in config.js is very important. -*非常重要!非常重要! 非常重要!* +*Very important! Very important! Very important!* -> 可以打开连接`https://www.grc.com/passwords.htm`获取 `63 random alpha-numeric characters`类型的随机生成数作为密钥 +> You can open the link `https://www.grc.com/passwords.htm` to get a random number of type `63 random alpha-numeric characters` as the key -## 部署 +## Deploy ```shell $ sudo docker stack deploy -c docker-compose.yml code-push-server ``` -> 如果网速不佳,需要漫长而耐心的等待。。。去和妹子聊会天吧^_^ +> If the network speed is poor, you'll need to wait patiently... go chat with your friends meanwhile ^_^ -## 查看进展 +## Check Progress ```shell $ sudo docker service ls @@ -77,13 +77,13 @@ $ sudo docker service ps code-push-server_redis $ sudo docker service ps code-push-server_server ``` -> 确认`CURRENT STATE` 为 `Running about ...`, 则已经部署完成 +> Confirm that `CURRENT STATE` is `Running about ...`, then deployment is complete -## 访问接口简单验证 +## Simple API Access Verification `$ curl -I http://YOUR_CODE_PUSH_SERVER_IP:3000/` -返回`200 OK` +Returns `200 OK` ```http HTTP/1.1 200 OK @@ -100,19 +100,19 @@ Date: Sat, 25 Aug 2018 15:45:46 GMT Connection: keep-alive ``` -## 浏览器登录 +## Browser Login -> 默认用户名:admin 密码:123456 记得要修改默认密码哦 -> 如果登录连续输错密码超过一定次数,会限定无法再登录. 需要清空redis缓存 +> Default username: admin password: 123456 Remember to change the default password +> If you enter the wrong password too many times in a row, you will be locked out. You need to clear the redis cache ```shell -$ redis-cli -p6388 # 进入redis +$ redis-cli -p6388 # enter redis > flushall > quit ``` -## 查看服务日志 +## View Service Logs ```shell $ sudo docker service logs code-push-server_server @@ -120,16 +120,16 @@ $ sudo docker service logs code-push-server_db $ sudo docker service logs code-push-server_redis ``` -## 查看存储 `docker volume ls` +## View Storage `docker volume ls` -DRIVER | VOLUME NAME | 描述 +DRIVER | VOLUME NAME | Description ------ | ----- | ------- -local | code-push-server_data-mysql | 数据库存储数据目录 -local | code-push-server_data-storage | 存储打包文件目录 -local | code-push-server_data-tmp | 用于计算更新包差异文件临时目录 -local | code-push-server_data-redis | redis落地数据 +local | code-push-server_data-mysql | Database storage data directory +local | code-push-server_data-storage | Storage package files directory +local | code-push-server_data-tmp | Temporary directory for calculating update package differences +local | code-push-server_data-redis | Redis persistent data -## 销毁退出应用 +## Remove and Exit Application ```bash $ sudo docker stack rm code-push-server diff --git a/docs/react-native-code-push.md b/docs/react-native-code-push.md index 0b70bf37..ace88234 100644 --- a/docs/react-native-code-push.md +++ b/docs/react-native-code-push.md @@ -1,71 +1,71 @@ -# `react-native` 如何使用 `code-push` 热更新 +# How to Use `code-push` Hot Updates with `react-native` -## 使用前须知 +## Prerequisites - - Q: “苹果应用商店和android应用商店允不允许使用热更新?” - A: “都允许。” + - Q: "Do Apple App Store and Android App Store allow hot updates?" + A: "Yes, both allow it." - > 苹果允许使用热更新[Apple's developer agreement](https://developer.apple.com/programs/ios/information/iOS_Program_Information_4_3_15.pdf), 但是规定不能弹框提示用户更新,影响用户体验。 - > Google Play也允许热更新,但必须弹框告知用户更新。在中国的android市场发布时,都必须关闭更新弹框,否则会在审核应用时以“请上传最新版本的二进制应用包”驳回应用。 + > Apple allows hot updates according to [Apple's developer agreement](https://developer.apple.com/programs/ios/information/iOS_Program_Information_4_3_15.pdf), but it requires silent updates without dialog prompts to maintain user experience. + > Google Play also allows hot updates but requires a dialog to inform users about updates. When publishing to Chinese Android markets, update dialogs must be disabled, otherwise the app will be rejected with the reason "Please upload the latest version of the binary application package". - - Q: “react-native 开发环境更新模式是否可以直接用在生产环境下?” - A: “不能。” + - Q: "Can React Native development environment update mode be used directly in production?" + A: "No." - - Q: “code-push使用复杂么?” - A: “不复杂。很多网上的文章说复杂,是因为作者没有仔细理解官方文档,而且认为踩坑了。” + - Q: "Is code-push complicated to use?" + A: "No, it's not complicated. Many online articles say it's complex because the authors haven't carefully read the official documentation and think they've encountered issues." - - Q: “为什么推荐code-push?” - A: ”非常好。除了满足基本更新功能外,还有统计,hash计算容错和补丁更新功能。微软的项目,大公司技术有保障,而且开源。近几年微软在拥抱开源方面,让大家也是刮目相看。“ + - Q: "Why is code-push recommended?" + A: "It's excellent. Besides meeting basic update functionality, it also includes statistics, hash calculation error tolerance, and patch update features. It's a Microsoft project, so the technology is reliable, and it's open source. In recent years, Microsoft's embrace of open source has been impressive." -## 安装依赖包 +## Install Dependencies -#### 1. [react-native-cli](https://github.com/facebook/react-native) react-native命令行工具,安装后可以在终端使用`react-native`命令 +#### 1. [react-native-cli](https://github.com/facebook/react-native) React Native command line tool, after installation you can use the `react-native` command in terminal ```shell $ npm install react-native-cli@latest -g ``` -#### 2. [code-push-cli](https://github.com/Microsoft/code-push) 连接微软云端,管理发布更新版本命令行工具,安装后可以在终端使用`code-push`命令 +#### 2. [code-push-cli](https://github.com/Microsoft/code-push) Command line tool to connect to Microsoft cloud and manage release updates, after installation you can use the `code-push` command in terminal ```shell $ npm install code-push-cli@latest -g ``` -#### 3. [react-native-code-push](https://github.com/Microsoft/react-native-code-push) 集成到react-native项目,按照以下步骤安装并修改配置既可集成 +#### 3. [react-native-code-push](https://github.com/Microsoft/react-native-code-push) Integrate into React Native project, follow these steps to install and modify configuration ```shell -$ react-native init CodePushDemo #初始化一个react-native项目 +$ react-native init CodePushDemo #Initialize a React Native project $ cd CodePushDemo -$ npm install --save react-native-code-push@latest #安装react-native-code-push -$ react-native link react-native-code-push #连接到项目中,提示输入配置可以先行忽略 +$ npm install --save react-native-code-push@latest #Install react-native-code-push +$ react-native link react-native-code-push #Link to project, you can ignore configuration prompts for now ``` -#### 4. [code-push-server](https://github.com/lisong/code-push-server) 微软云服务在中国太慢,可以用它搭建自己的服务端。 +#### 4. [code-push-server](https://github.com/lisong/code-push-server) Microsoft cloud service is slow in China, you can use this to build your own server. - [docker](https://github.com/lisong/code-push-server/blob/master/docker/README.md) (recommend) - [manual operation](https://github.com/lisong/code-push-server/blob/master/docs/README.md) -## 创建服务端应用 +## Create Server Applications -基于code-push-server服务 +Based on code-push-server ```shell -$ code-push login http://YOUR_CODE_PUSH_SERVER_IP:3000 #浏览器中登录获取token,用户名:admin, 密码:123456 -$ code-push app add CodePushDemoiOS ios react-native #创建iOS版, 获取Production DeploymentKey -$ code-push app add CodePushDemoAndroid android react-native #创建android版,获取获取Production DeploymentKey +$ code-push login http://YOUR_CODE_PUSH_SERVER_IP:3000 #Login in browser to get token, username:admin, password:123456 +$ code-push app add CodePushDemoiOS ios react-native #Create iOS version, get Production DeploymentKey +$ code-push app add CodePushDemoAndroid android react-native #Create Android version, get Production DeploymentKey ``` -## 配置CodePushDemo react-native项目 +## Configure CodePushDemo React Native Project -#### iOS 配置 +#### iOS Configuration -编辑`Info.plist`文件,添加`CodePushDeploymentKey`和`CodePushServerURL` +Edit the `Info.plist` file, add `CodePushDeploymentKey` and `CodePushServerURL` -1. `CodePushDeploymentKey`值设置为CodePushDemo-ios的Production DeploymentKey值。 +1. Set `CodePushDeploymentKey` value to the Production DeploymentKey value of CodePushDemo-ios. -2. `CodePushServerURL`值设置为code-push-server服务地址 http://YOUR_CODE_PUSH_SERVER_IP:3000/ 不在同一台机器的时候,请将YOUR_CODE_PUSH_SERVER_IP改成外网ip或者域名地址。 +2. Set `CodePushServerURL` value to the code-push-server service address http://YOUR_CODE_PUSH_SERVER_IP:3000/ When not on the same machine, please change YOUR_CODE_PUSH_SERVER_IP to the external IP or domain address. -3. 将默认版本号1.0改成三位1.0.0 +3. Change the default version number from 1.0 to three digits 1.0.0 ```xml ... @@ -76,15 +76,15 @@ $ code-push app add CodePushDemoAndroid android react-native #创建android版 ... ``` -#### android 配置 +#### Android Configuration -编辑`MainApplication.java` +Edit `MainApplication.java` -1. `YourKey`替换成CodePushDemo-android的Production DeploymentKey值 +1. Replace `YourKey` with the Production DeploymentKey value of CodePushDemo-android -2. `YourCodePushServerUrl`值设置为code-push-server服务地址 http://YOUR_CODE_PUSH_SERVER_IP:3000/ 不在同一台机器的时候,请将YOUR_CODE_PUSH_SERVER_IP改成外网ip或者域名地址。 +2. Set `YourCodePushServerUrl` value to the code-push-server service address http://YOUR_CODE_PUSH_SERVER_IP:3000/ When not on the same machine, please change YOUR_CODE_PUSH_SERVER_IP to the external IP or domain address. -3. 将默认版本号1.0改成三位1.0.0 +3. Change the default version number from 1.0 to three digits 1.0.0 ```java @Override @@ -101,10 +101,10 @@ protected List getPackages() { } ``` -## 添加更新检查 +## Add Update Check -可以参考[code-push-demo-app](https://github.com/lisong/code-push-demo-app/) -可以在入口componentDidMount添加 +You can refer to [code-push-demo-app](https://github.com/lisong/code-push-demo-app/) +Add this in the entry componentDidMount: ```javascript CodePush.sync({ @@ -113,13 +113,13 @@ CodePush.sync({ }); ``` -不要忘记头部引入 +Don't forget to import at the top: ```javascript import CodePush from "react-native-code-push" ``` -## 运行CodePushDemo react-native项目 +## Run CodePushDemo React Native Project #### iOS @@ -127,32 +127,32 @@ import CodePush from "react-native-code-push" $ cd /path/to/CodePushDemo $ open ios/CodePushDemo.xcodeproj ``` -在Xcode中打开菜单 Product > Scheme > Edit Scheme... > Run 选项中Build Configuration修改成Release, 然后运行编译 +In Xcode, open menu Product > Scheme > Edit Scheme... > Run option, change Build Configuration to Release, then run and compile -### android +### Android ```shell $ cd /path/to/CodePushDemo $ cd android $ ./gradlew assembleRelease -$ cd app/build/outputs/apk #将打好的包app-release.apk安装到您的手机上 +$ cd app/build/outputs/apk #Install the generated app-release.apk on your phone ``` -## 发布更新到服务上 +## Publish Updates to Server -iOS和android要分开发布,所以创建了`CodePushDemo-ios`和`CodePushDemo-android`应用 +iOS and Android need to be published separately, so we created `CodePushDemo-ios` and `CodePushDemo-android` applications ```shell $ cd /path/to/CodePushDemo -$ code-push release-react CodePushDemo-ios ios -d Production #iOS版 -$ code-push release-react CodePushDemo-android android -d Production #android版 +$ code-push release-react CodePushDemo-ios ios -d Production #iOS version +$ code-push release-react CodePushDemo-android android -d Production #Android version ``` -## 例子 +## Examples [code-push-demo-app](https://github.com/lisong/code-push-demo-app) -### 更多信息参考[code-push-server](https://github.com/lisong/code-push-server) +### For more information, refer to [code-push-server](https://github.com/lisong/code-push-server)