1:codePush 命令
npm install -g code-push-cli
code-push -v
code-push login 登陆
code-push loout 注销
code-push access-key ls 列出登陆的token
code-push access-key rm <accessKeyName> 删除某个 access-key
code-push app add <appName> <os> <platform> 在账号里面添加一个新的app
code-push app remove 或者 rm 在账号里移除一个app
code-push app rename 重命名一个存在app
code-push app list 或则 ls 列出账号下面的所有app
code-push app transfer 把app的所有权转移到另外一个账号
code-push register //当注册成功后,CodePush会给我们一个key,
我们直接复制这个key,然后在终端中将这个key填写进去即可
应用添加成功后就会返回对应的production 和 Staging 两个key,production代表生产版的热更新部署,Staging代表开发版的热更新部署
2:deployment 命令
code-push deployment <command>
命令:
add Add a new deployment to an app
clear Clear the release history associated with a deployment
remove Remove a deployment from an app
rm Remove a deployment from an app
rename Rename an existing deployment
list List the deployments associated with an app
ls List the deployments associated with an app
history Display the release history for a deployment
h Display the release history for a deployment
3:集成CodePush SDK
进入项目根目录(具有Android,ios,和package.json文件为项目根目录)
npm install --save react-native-code-push
react-native link
4:发布更新
code-push release-react <appName> <platform> [options]
选项:
--bundleName, -b Name of the generated JS bundle file. If unspecified, the standard bundle name will be used, depending on the specified platform: "main.jsbundle" (iOS), "index.android.bundle" (Android) or "index.windows.bundle" (Windows) [字符串] [默认值: null]
--deploymentName, -d Deployment to release the update to [字符串] [默认值: "Staging",分为"Staging","Production"]
--description, --des Description of the changes made to the app with this release [字符串] [默认值: null,描述,备注]
--development, --dev Specifies whether to generate a dev or release build [布尔] [默认值: false]
--disabled, -x Specifies whether this release should be immediately downloadable [布尔] [默认值: false]
--entryFile, -e Path to the app's entry Javascript file. If omitted, "index.<platform>.js" and then "index.js" will be used (if they exist) [字符串] [默认值: null]
--gradleFile, -g Path to the gradle file which specifies the binary version you want to target this release at (android only). [默认值: null]
--mandatory, -m Specifies whether this release should be considered mandatory [布尔] [默认值: false,强制更新]
--noDuplicateReleaseError When this flag is set, releasing a package that is identical to the latest release will produce a warning instead of an error [布尔] [默认值: false]
--plistFile, -p Path to the plist file which specifies the binary version you want to target this release at (iOS only). [默认值: null]
--plistFilePrefix, --pre Prefix to append to the file name when attempting to find your app's Info.plist file (iOS only). [默认值: null]
--rollout, -r Percentage of users this release should be immediately available to [字符串] [默认值: "100%"]
--privateKeyPath, -k Specifies the location of a RSA private key to sign the release with [字符串] [默认值: false]
--sourcemapOutput, -s Path to where the sourcemap for the resulting bundle should be written. If omitted, a sourcemap will not be generated. [字符串] [默认值: null]
--targetBinaryVersion, -t Semver expression that specifies the binary app version(s) this release is targeting (e.g. 1.1.0, ~1.2.3). If omitted, the release will target the exact version specified in the "Info.plist" (iOS), "build.gradle" (Android) or "Package.appxmanifest" (Windows) files. [字符串] [默认值: null]
--outputDir, -o Path to where the bundle and sourcemap should be written. If omitted, a bundle and sourcemap will not be written. [字符串] [默认值: null]
--config, -c Path to the React Native CLI configuration file [字符串] [默认值: null]
-v, --version 显示版本号 [布尔]
mkdir bundles //在当前目录中新建文件夹bundles
react-native bundle --platform android --entry-file index.js --bundle-output ./bundles/index.android.bundle --dev false
code-push release <appName> <updateContentsPath> <targetBinaryVersion> [options]
code-push release AndroidRNCodePushDemo ./bundles/index.android.bundle 1.0.0 --deploymentName Staging --description "1:测试第一次codePush" --mandatory true
5:接入流程
安装 CodePush CLI
注册 CodePush账号
在CodePush服务器注册App
RN代码中集成CodePush
原生应用中配置CodePush
生成bundle
上传bundle
6:appcenter账号
appcenter login
npm i appcenter-cli 更新appcenter客户端
After registering, you are automatically logged-in with the CLI, so until you explicitly log out, you don't need to login again from the same machine.
appcenter profile list 展示登录的appcenter账号信息
appcenter logout 退出登录appcenter
appcenter tokens list
appcenter tokens delete <machineName(ID)>
appcenter tokens create -d "Azure DevOps Integration"
appcenter login --token <accessToken>
appcenter apps list
appcenter apps set-current <ownerName>/<appName>
appcenter codepush deployment list -a <ownerName>/<appName>
appcenter codepush deployment list
appcenter apps get-current
appcenter codepush deployment list -a Yieron/iOSRNCodePushDemo --displayKeys
codePush与Pushy起冲突,一个应用集成一个热更新就行。
具体参考以下两篇文章:
CodePush热更新详细接入教程 作者光强_上海
react-native热更新之CodePush详细介绍及使用方法
作者clf_programing
特别感谢两位的文章!
网友评论