断点变化
复制一个设置提示,包含安装步骤和该插件的完整 Markdown 指南。
本文档解释了如何在您的应用程序中处理破坏性更改的方法,使用版本化通道。这一方法允许您维护应用程序的不同版本,同时确保用户接收兼容的更新。
示例场景
标题为“示例场景”假设您有:
- 应用程序版本 1.2.3(旧版本)- 使用生产通道
- App 版本 2.0.0 (新版本,包含重大更改) - 使用 v2 通道
- 实时更新 1.2.4 (兼容 1.2.3)
- 实时更新 2.0.1 (兼容 2.0.0)
策略:总是使用 defaultChannel 为主要版本
策略:总是使用 defaultChannel 为主要版本推荐方法: 为每个主要版本设置一个 defaultChannel 。这样您就可以始终将更新推送到特定用户组,而不依赖动态通道分配。
// Version 1.x releasesdefaultChannel: 'v1'
// Version 2.x releasesdefaultChannel: 'v2'
// Version 3.x releases (future)defaultChannel: 'v3'1. 为新版本创建频道
Section titled “1. 为新版本创建频道”# Create channel for version 2.xnpx @capgo/cli channel create v22. 更新 Capacitor 配置为版本 2.0.0
标题:2. 更新 Capacitor 配置为版本 2.0.0在发布应用商店版本 2.0.0之前,请更新您的 Capacitor 配置:
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { appId: 'com.example.app', appName: 'Example App', plugins: { CapacitorUpdater: { // ... other options defaultChannel: 'v2' // All 2.0.0 users will use v2 channel } }};
export default config;3. 独立管理Code分支
Section titled “3. 独立管理Code分支”为保持应用程序版本之间的兼容性,创建独立的git分支:
# Create and maintain a branch for version 1.x updatesgit checkout -b v1-maintenancegit push origin v1-maintenance
# Your main branch continues with version 2.x developmentgit checkout main重要提示: 永远不要将JavaScript包推送到期望native code/APIs但实际上没有的旧应用程序。始终从适当的分支构建更新:
- v1-maintenance branch: 对1.x应用程序的更新(生产频道)
- main branch: 对2.x应用程序的更新(v2频道)
4. 将包上传到相应的频道
Section titled “4. 将打包文件上传到各个渠道”# For 1.x updates: Build from v1-maintenance branchgit checkout v1-maintenance# Make your 1.x compatible changes herenpx @capgo/cli bundle upload --channel production
# For 2.x updates: Build from main branchgit checkout main# Make your 2.x changes herenpx @capgo/cli bundle upload --channel v25. 启用自我分配
Section titled “5. 启用自我分配”# Allow apps to self-assign to v2 channelnpx @capgo/cli channel set v2 --self-assign6. 部署到 App Store
Section titled “6. 部署到 App Store”在 App Store 上部署版本 2.0.0。所有下载此版本的用户(新用户或升级的现有用户)都会自动使用 v2 通道,因为它在应用程序包中配置。
扩展到未来版本
标题:扩展到未来版本当您发布版本 3.0.0 时,带有更多破坏性更改:
# Create channel for version 3.xnpx @capgo/cli channel create v3// capacitor.config.ts for version 3.0.0const config: CapacitorConfig = { // ... plugins: { CapacitorUpdater: { defaultChannel: 'v3' // Version 3.x users } }};现在您可以推送任何版本的更新:
production渠道 → 版本 1.x 用户v2渠道 → 版本 2.x 用户v3channel → Version 3.x 用户
7. 清理(迁移后)
Section titled “7. 清理(迁移后)”一旦所有用户都迁移到版本 2.x(计时 3-4 个月):
- 移除
defaultChannel从您的 Capacitor 配置中 - 删除 v2 频道:
npx @capgo/cli channel delete v2- 删除 v1-maintenance Branch:
git branch -d v1-maintenancegit push origin --delete v1-maintenance在每个渠道中都要彻底测试更新之前始终进行部署
维护 1.x 版本更新
维护 1.x 版本更新要发送与 1.x 版本兼容的更新:
- 切换到 v1-maintenance branch:
git checkout v1-maintenance- 请在本地环境中进行修改并提交:
# Make 1.x compatible changesgit add .git commit -m "Fix for v1.x"git push origin v1-maintenance- 将应用程序构建并上传到生产环境:
npx @capgo/cli bundle upload --channel production继续从Breaking Changes
继续从Breaking ChangesIf you are using __CAPGO_KEEP_0__ to plan channel routing and staged rollout, connect it with __CAPGO_KEEP_1__ for the implementation detail in __CAPGO_KEEP_1__, __CAPGO_KEEP_1__ for the implementation detail in __CAPGO_KEEP_1__, __CAPGO_KEEP_1__ for the implementation detail in __CAPGO_KEEP_1__, __CAPGO_KEEP_2__ for the product workflow in __CAPGO_KEEP_2__, and __CAPGO_KEEP_3__ for the product workflow in __CAPGO_KEEP_3__ Breaking Changes 为了计划通道路由和阶段性发布,请连接 Channels 为了实现细节,请参阅 Channels 为了实现细节,请参阅 Channels 为了实现细节,请参阅 Beta Testing Solution 为了产品工作流程,请参阅 Version Targeting Solution 用于产品工作流程的版本目标解决方案。