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的所有權(quán)轉(zhuǎn)移到另外一個賬號
code-push register //當(dāng)注冊成功后就缆,CodePush會給我們一個key,
我們直接復(fù)制這個key,然后在終端中將這個key填寫進(jìn)去即可
應(yīng)用添加成功后就會返回對應(yīng)的production 和 Staging 兩個key,production代表生產(chǎn)版的熱更新部署终畅,Staging代表開發(fā)版的熱更新部署
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
進(jìn)入項目根目錄(具有Android絮识,ios挪圾,和package.json文件為項目根目錄)
npm install --save react-native-code-push
react-native link
4:發(fā)布更新
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) [字符串] [默認(rèn)值: null]
--deploymentName, -d Deployment to release the update to [字符串] [默認(rèn)值: "Staging",分為"Staging","Production"]
--description, --des Description of the changes made to the app with this release [字符串] [默認(rèn)值: null靠益,描述,備注]
--development, --dev Specifies whether to generate a dev or release build [布爾] [默認(rèn)值: false]
--disabled, -x Specifies whether this release should be immediately downloadable [布爾] [默認(rèn)值: 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) [字符串] [默認(rèn)值: null]
--gradleFile, -g Path to the gradle file which specifies the binary version you want to target this release at (android only). [默認(rèn)值: null]
--mandatory, -m Specifies whether this release should be considered mandatory [布爾] [默認(rèn)值: 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 [布爾] [默認(rèn)值: false]
--plistFile, -p Path to the plist file which specifies the binary version you want to target this release at (iOS only). [默認(rèn)值: null]
--plistFilePrefix, --pre Prefix to append to the file name when attempting to find your app's Info.plist file (iOS only). [默認(rèn)值: null]
--rollout, -r Percentage of users this release should be immediately available to [字符串] [默認(rèn)值: "100%"]
--privateKeyPath, -k Specifies the location of a RSA private key to sign the release with [字符串] [默認(rèn)值: false]
--sourcemapOutput, -s Path to where the sourcemap for the resulting bundle should be written. If omitted, a sourcemap will not be generated. [字符串] [默認(rèn)值: 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. [字符串] [默認(rèn)值: null]
--outputDir, -o Path to where the bundle and sourcemap should be written. If omitted, a bundle and sourcemap will not be written. [字符串] [默認(rèn)值: null]
--config, -c Path to the React Native CLI configuration file [字符串] [默認(rèn)值: null]
-v, --version 顯示版本號 [布爾]
mkdir bundles //在當(dāng)前目錄中新建文件夾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服務(wù)器注冊App
RN代碼中集成CodePush
原生應(yīng)用中配置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
7:范圍表達(dá)式
1.2.3 僅僅只有1.2.3的版本
*所有版本
1.2.x 主要版本1街图,次要版本2的任何修補程序版本
1.2.3 - 1.2.7 1.2.3版本到1.2.7版本
=1.2.3 <1.2.7 大于等于1.2.3版本小于1.2.7的版本
~1.2.3 大于等于1.2.3版本小于1.3.0的版本
^1.2.3 大于等于1.2.3版本小于2.0.0的版本
codePush與Pushy起沖突,一個應(yīng)用集成一個熱更新就行耘擂。
具體參考以下三篇文章:
CodePush熱更新詳細(xì)接入教程 作者光強_上海
react-native熱更新之CodePush詳細(xì)介紹及使用方法
作者clf_programing
code-push常用命令 作者九卿
特別感謝三位的文章胆剧!
微軟官網(wǎng)鏈接:Releasing CodePush updates using the App Center CLI