codepush支持多bundle更新重构

2020-01-02  本文已影响0人  gy先生

codepush实现原理

code-push.png

梳理下关键节点

原生与RN混合开发codepush存在的问题

重构方案

基于以上存在的问题,要对现有的codepush结构进行调整,首先就是要支持多个不同bundle同时更新,需要业务层自行传入关键字来区分需要更新哪个bundle;再者对codepush更新后的bundle存放路径需要进行关键字分组,方便按组清理和回滚;

CodePush({ bundle: "bundleName" });
//由业务测根据配置项返回deploymentKey
- (NSString *)getDeploymentKey:(NSString *)bundleName;
+ (NSString *)getPackageFolderPath:(NSString *)deploymentKey packageHash:(NSString *)packageHash
{
    return [[self getDeploymentFilePath:deploymentKey] stringByAppendingPathComponent:packageHash];
}
+ (NSString *)getDeploymentFilePath:(NSString *)deploymentKey
{
    return [[self getCodePushPath] stringByAppendingPathComponent:deploymentKey];;
}

当然,codepush重构的改造量还是比较多的,这些属于冰山一角,获取deploymentKey几乎贯穿整个事务;js初始的时候只传入bundleName,同名bundleName在不同的工程项目中配置的deploymentKey是不同的,需要原生业务代码提供;不同deploymentKey也需要独立缓存最新包信息,便于更新后获取并加载等等;

feature

上一篇 下一篇

猜你喜欢

热点阅读