npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-egenie-codepush

v1.6.1

Published

衫数科技热更新组件

Downloads

104

Readme

react-native-egenie-codepush

衫数科技热更新组件

Installation

yarn add react-native-egenie-codepush

Android

cd android && ./gradlew sync

iOS

cd ios && pod install

Usage

Android

MainApplication.java 添加如下代码

public class MainApplication extends Application implements ReactApplication {
    private final ReactNativeHost mReactNativeHost =
      new ReactNativeHost(this) {
       ...
        @Nullable
        @Override
        protected String getBundleAssetName() {
          return "platform.android.bundle";
        }
       ...
      };
    ...
}

MainActivity.java 继承 CPReactActivity

public class MainActivity extends CPReactActivity {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  @Override
  protected String getMainComponentName() {
    return "CodepushExample";
  }
}

iOS

在 AppDelegate 中引入 CPReactController.h


#import "CPReactController.h"


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

#if DEBUG
  //本地调试代码
  ...
#else
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  CPReactController *rootViewController = [[CPReactController alloc]initWithLaunchOptions:launchOptions];
  rootViewController.downloadBundleBlock = ^{
    //开始下载bundle,需将覆盖顶层的试图移除,如RNSplashScreen
  };
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
#endif

return YES;
}

Extra

完成打包后 ios 需要将打包文件引入到工程
选中 Project->右键 Add Files to "Project"
将如下三个文件添加到工程
config.json
platform.ios.bundle
index.ios.bundle.zip

配置

在根目录新建 codepush.config.js 文件 配置如下

//需要调用真实接口
const getIterationList = () => {
  return ['mall-3.2.2', 'mall-3.2.1'];
};
//需要调用真实接口
const getIterationVersion = (it) => {
  return 8000;
};
module.exports = {
  /**
   * ios版本号
   */
  iosVersionName: '1.0',
  /**
   * ios构建号
   */
  iosVersionCode: 1,
  /**
   * ios工程名称
   */
  iosProjectName: 'CodepushExample',
  /**
   * android版本号
   */
  androidVersionName: '2.0',
  /**
   * android构建号
   */
  androidVersionCode: 1,
  /**
   *android和ios的发布版本号,用于区别程序版本
   */
  releaseVersion: '1.0.0',
  /**
   * 业务模块名称
   */
  moduleName: 'CodepushExample',
  /**
   * 业务模块入口
   */
  indexEntry: './index.tsx',
  /**
   * 基础模块入口
   */
  baseEntry: './base.js',
  /**
   * oss配置信息
   */
  ossOptions: {
    accessKeyId: '',
    accessKeySecret: '',
    bucket: '',
    region: '',
    timeout: 60 * 60 * 24,
  },
  /**
   * oss地址
   */
  ossUrl: 'https://test.oss-cn-hangzhou.aliyuncs.com',
  /**
   * oss热更新文件保存路径,如/app/app-test/codepush
   */
  ossPath: 'app/app-test/codepush',
  /**
   * 打包环境列表如['test','uat', 'release', 'release-reg']
   */
  envs: ['dev', 'test', 'uat', 'releasepre', 'release'],
  /**
   *获取迭代版本
   * @returns
   */
  getIterationList: getIterationList,

  /**
   *获取迭代版本号
   * @returns
   */
  getIterationVersion: getIterationVersion,

  /**
   * 加盐算法key
   */
  saltKey: '123456789',
};

配置环境文件

环境文件用于配置服务 url,随环境变化的数据等
在根目录新建环境文件
.env.dev
.env.test
.env.uat
.env.releasepre
.env.release. ...
以上环境需同 codepush.config.js 文件中的 envs 一致

内容示例如下.env.release

ENV=dev
API_URL=https://myapi.com
import { Config } from 'react-native-egenie-codepush';

console.log(Config.ENV);
console.log(Config.API_URL);

测试支持切换环境

import { CodePush } from 'react-native-egenie-codepush';
CodePush.changeEnv('uat');

打包脚本

环境切换 autoenv 命令

参数
--env 环境参数,需包含 codepush.config.js 中 envs
--allowWireShark true/false android 是否允许抓包,默认 false

yarn autoenv --env uat --allowWireShark true

打包 batch 命令

参数
--base true/false 是否需要基础包
--env dev/test/release 环境
--iteration select/mall-3.3.2 获取迭代号
--uposs true/false 是否上传到 oss
--allowWireShark true/false android 是否允许抓包,默认 false --force true/false 是否强制更新,默认 false

//uat
yarn batch --base true --env uat --iteration select --uposs true --allowWireShark true
//release
yarn batch --base false --env release --iteration select --uposs true --allowWireShark false

日志分析 log 命令

热更新插件每次热更会将 soucemap 文件一并上传到 oss
故分析脚本调整为从 oss 拉取,不用每次从 oss 手动下载
--path 异常路径,从异常日志中获取
--env release 环境,从异常日志中获取
--column 列,从异常日志中获取
--line 行,从异常日志中获取
--platform 系统 ios/android

yarn log --path app/app-pgms/codepush/release/1.3.0/10000 --env release --column 222 --line 222 --platform ios

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT