diff --git a/en/react-native-code-push.md b/en/react-native-code-push.md index 049575e0c61590accb52242a56f795ade56f9080..e7c2714ca3effec193ae64dc495c0cb90f7e9d90 100644 --- a/en/react-native-code-push.md +++ b/en/react-native-code-push.md @@ -15,6 +15,14 @@ > [!TIP] [Github address](https://github.com/react-native-oh-library/react-native-code-push) +The repository for this third-party library has been migrated to Gitcode, and it now supports direct download from npm. The new package name is: `@react-native-ohos/react-native-code-push`. The specific version relationships are as follows: + +| Version | Package Name | Repository | Release |Supported RN Version | +| ------------------------------ | ---------------- | ------------------- | ------------------- | -------------------- | +| <= 8.2.2-0.0.10@deprecated |@react-native-oh-tpl/react-native-code-push|[Github](https://github.com/react-native-oh-library/react-native-code-push/releases) | [Github Releases](https://github.com/react-native-oh-library/react-native-code-push/releases) | 0.72 | +| 8.2.3 | @react-native-ohos/react-native-code-push|[GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.72 | +| 9.0.2 | @react-native-ohos/react-native-code-push|[GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.77 | + ## Pre-preparation ### code-push-cli @@ -34,7 +42,27 @@ code-push app list //List all apps under the account. code-push app add harmony react-native // Creating an Application code-push release "< version number > "--description "" -m //Packet sending command. Add -m to forcibly update the version. The asterisk (*) indicates all versions, for example, code-push release CodePush_Local ./bundle.harmony.js "*" --description "v1.0.0 Test Update" ``` +``` +Execute the following commands in the project directory: + +code-push login // Prerequisite: Server must be started (public network accessible) +This will open a webpage. Enter account and password (default account: admin, password: 123456) +Click "Get token" +Copy the token to the command line window +Prompt shows login successful + +# Ensure the bundle file has minor modifications +echo "// Force update for 1.0.0 pending fix - $(date)" >> ./bundles/bundle.harmony.js + +Modify the characters in "// Force update for 1.0.0 pending fix - $(date)" as needed + +# Publish a mandatory update for version 1.0.0 +code-push release MyApp-Harmony ./bundles/bundle.harmony.js 1.0.0 -d Staging --description "Force fix for issues" --mandatory + +# Publish a non-mandatory update for version 1.0.0 +code-push release MyApp-Harmony ./bundles/bundle.harmony.js 1.0.0 -d Staging --description "Non-mandatory fix for issues" +``` ### code-push-server 1. Clone the [code-push-server](https://github.com/react-native-oh-library/code-push-server) to the local host. @@ -43,16 +71,84 @@ code-push release "< version number > "--descripti 4. Modifying the `code-push-server/src/core/config.ts` Configuration File 5. Run the `npm run dev` command in the code-push-server directory to generate the `bin` directory. 6. Run the `npm run start` command in the code-push-server directory to start the service. +``` +Install MySQL +# Ubuntu/Debian +sudo apt update +sudo apt install mysql-server +# Start service +sudo systemctl start mysql +sudo mysql_secure_installation +# Follow the prompts to set up: +# 1. Set root password +# 2. Remove anonymous users +# 3. Disallow remote root login +# 4. Remove test database +# 5. Reload privilege tables +First enter y/yes for all + +# First log in to MySQL (no password required) +sudo mysql +# Execute in MySQL command line: +ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password'; +FLUSH PRIVILEGES; +EXIT; + +# Now log in with password +mysql -u root -p +Enter password +EXIT; + +# Edit configuration file +sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf +# Find bind-address and modify +# bind-address = 0.0.0.0 +# Allow all IP access +# Ctrl+S to save and exit automatically +# Restart MySQL + +sudo systemctl restart mysql + +Install Redis +sudo apt update +sudo apt install redis-server -y + +# Start and enable service +sudo systemctl start redis-server +# Test +redis-cli ping +Should reply PONG +# Edit Redis configuration file +sudo nano /etc/redis/redis.conf + +# Find and modify the following lines: +# bind 0.0.0.0 # If remote access is needed +# protected-mode no # If bind is set to 0.0.0.0, need to turn off protected mode +# Ctrl+S to save and exit automatically +# Restart Redis +sudo systemctl restart redis-server +``` -## Installation and Usage - -Please refer to the Releases page of the third-party library for the corresponding version information +``` +Modify document sections +In the code-push-server directory, modify code-push-server/src/core/config.ts <127.0.0.1> Change to server address + +In code-push-server/src/db.ts, for example: + .example( + '$0 init --dbname codepush --dbhost localhost (replace with server address) --dbuser root --dbpassword (replace with database password) --dbport 3306 --force', + 'Initialize code-push-server database', + ) +In this file, replace all occurrences of 'localhost' with server address + +Create bin directory (might prompt that database codepush is not created) +npm run dev (prompts that database codepush doesn't exist) Ctrl+C to force exit +Execute +npm run init Success returns "success" and creates database codepush +Execute +npm run dev +``` -| Third-party Library Version | Release Information | Supported RN Version | -| ---------- | ------------------------------------------------------------ | ---------- | -| <= 8.2.2-0.0.10@deprecated | [@react-native-oh-tpl/react-native-code-push Releases(deprecated)](https://github.com/react-native-oh-library/react-native-code-push/releases) | 0.72 | -| 8.2.3 | [@react-native-ohos/react-native-code-push Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.72 | -| 9.0.2 | [@react-native-ohos/react-native-code-push Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.77 | +## Installation and Usage For older versions not published on npm, please refer to the [Installation Guide](/en/tgz-usage-en.md) to install the tgz package. diff --git a/zh-cn/react-native-code-push.md b/zh-cn/react-native-code-push.md index 81ea5b7d614b08194480764b662e6845d67d8fbc..7a9de0d4672d7101ee692fd9a87b0e46565bf682 100644 --- a/zh-cn/react-native-code-push.md +++ b/zh-cn/react-native-code-push.md @@ -16,6 +16,14 @@ > [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-code-push) +该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-code-push`,具体版本所属关系如下: + +| Version | Package Name | Repository | Release |Supported RN Version | +| ------------------------------ | ---------------- | ------------------- | ------------------- | -------------------- | +| <= 8.2.2-0.0.10@deprecated |@react-native-oh-tpl/react-native-code-push|[Github](https://github.com/react-native-oh-library/react-native-code-push/releases) | [Github Releases](https://github.com/react-native-oh-library/react-native-code-push/releases) | 0.72 | +| 8.2.3 | @react-native-ohos/react-native-code-push|[GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.72 | +| 9.0.2 | @react-native-ohos/react-native-code-push|[GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.77 | + ## 前期准备 ### code-push-cli @@ -34,10 +42,33 @@ code-push login <服务器地址> code-push app list //列出账号下面的所有app code-push app add harmony react-native //创建应用 code-push release "<版本号>" --description "" -m //发包命令,加-m是强制更新, * 代表所有版本,例如:code-push release CodePush_Local ./bundle.harmony.js "*" --description "v1.0.0 测试更新" +``` +``` +在工程目录下执行如下 + +code-push login <服务器地址> //前提为先启动服务器(公网) +会拉起网页 输入账户和密码 账户默认为admin 密码123456 +点击获取token +复制token到命令行窗口 +提示登录成功 + +# 确保 bundle 文件有微小修改 +echo "// Force update for 1.0.0 pending fix - $(date)" >> ./bundles/bundle.harmony.js + +"// Force update for 1.0.0 pending fix - $(date)"修改这里的字符即可 + +# 发布针对 1.0.0 的强制更新 +code-push release MyApp-Harmony ./bundles/bundle.harmony.js 1.0.0 -d Staging --description "强制解决问题" --mandatory + +# 发布针对 1.0.0 的非强制更新 +code-push release MyApp-Harmony ./bundles/bundle.harmony.js 1.0.0 -d Staging --description "非强制解决问题" + ``` ### code-push-server +#### 推荐在服务器搭建 + 1. 克隆 [code-push-server](https://github.com/react-native-oh-library/code-push-server) 到本地 2. 在 code-push-server 目录下执行 `npm install` 4. 安装 mysql、redis @@ -45,15 +76,83 @@ code-push release "<版本号>" --description " 改为服务器地址 + +code-push-server/src/db.ts 例如 .example( + '$0 init --dbname codepush --dbhost localhost(替换为服务器地址) --dbuser root --dbpassword (替换为数据库密码) --dbport 3306 --force', + '初始化code-push-server数据库', + ) +在该文件中出现 localhost 字符 统一修改为服务器地址 + +创建bin目录(可能会提示数据库codepush未创建) +npm run dev (提示没有数据库codepush)Ctrl+C 强制退出 +执行 +npm run init 成功返回 success 创建数据库codepush +执行 +npm run dev +``` -| 三方库版本 | 发布信息 | 支持RN版本 | -|--------| ------------------------------------------------------------ | ---------- | -| <= 8.2.2-0.0.10@deprecated | [@react-native-oh-tpl/react-native-code-push Releases(deprecated)](https://github.com/react-native-oh-library/react-native-code-push/releases) | 0.72 | -| 8.2.3 | [@react-native-ohos/react-native-code-push Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.72 | -| 9.0.2 | [@react-native-ohos/react-native-code-push Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-code-push/releases) | 0.77 | +## 安装与使用 对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。