react-helper-jad

react 发布工具


Keywords
react, build, git, cdn
License
ISC
Install
npm install react-helper-jad@1.0.3

Documentation

react-helper

  • 支持CDN上传打包文件。
  • 支持GIT上传打包文件。
使用说明
  1. 安装 npm install react-helper-jad -g

  2. 初始化配置文件

  3. 默认配置文件 执行 react-helper create 在根目录生成 github.helper.json 文件

  4. 自定义生成某一配置文件 执行 ng-helper create -t TYPE TYPE值请参考 TYPE类型

  5. 如不需要使用 七牛CDNGit 移除相关配置文件即可

  6. 拉取base仓库

    react-helper init

    1. 配置base仓库地址

      默认使用jpush ad内部项目仓库,可使用 -u 拉取自定义仓库地址

    2. 配置项目目录名称

      使用 -n 自定义项目名称

    3. 配置项目地址

      使用 -p 自定义项目路径,支持相对路径,改参数不推荐使用

  7. 打包发布(完整流程)

  8. 默认打包发布命令 执行 react-helper publish 默认使用 production 配置项

打包工具会注入一个 *REACT_APP_ENV* 变量,变量值默认为 *production*
  1. 自定义打包发布命令 执行 ng-helper publish -e ENV 使用 通过 process.env.REACT_APP_ENV 来获取 ENV 的值

  2. 手动发布

    发布分为build、push、upload三个功能,手动发布请遵循 build—>push—>upload 流程

    1. build模块

      react-helper build 支持 -e、-a、-m、-s参数

    2. push模块

      react-helper push 支持 -e、-a、-m、-s、-o参数

    3. upload模块

      react-helper push 支持 -e参数

TYPE类型
命令 文件配置 备注
react-helper create github.helper.json Git配置项
react-helper create -t c cdn.helper.json CDN配置项
react-helper create -t g github .helper.json Git配置项
react-helper publish -e l 默认为production 设置环境变量
react-helper publish -a l true,false 默认为false 自动打tag并升级版本号
react-helper publish -o l true,false 默认为true 自动打开发布仓库地址
react-helper publish -m l version,commit 默认为version 提交信息类型
react-helper publish -s l *true,false 默认为false 控制台是否显示提交信息
配置说明
  1. CDN配置项--cdn.helper.json
{
  "dev": {
    "url": "http://xxxxxxxx/", //资源地址 url+"dirname/v/"+file
    "dirname": "ng-helper-dev", //可删除该选项
    "ak": "xxxxxxxx",
    "sk": "xxxxxxxx",
    "bk": "xxxxxxxx",
    "v": "0.0.1", //可删除该选项
    "zone": "Zone_z0", //Zone_z0、Zone_z1、Zone_z2、Zone_na0、Zone_as0 参考七牛node sdk下的zone.js文件,可删除该选项
    "ignore": [ // 以下类型文件不会被上传到CDN,可删除该选项
      "*.html"
    ]
  },
  "production": {
    "url": "http://xxxxxxxx/",
    "dirname": "ng-helper-prod",
    "ak": "xxxxxxxx",
    "sk": "xxxxxxxx",
    "bk": "xxxxxxxx",
    "v": "0.0.1",
    "zone": "Zone_z0",
    "ignore": [
      "*.html"
    ]
  }
}
  1. Git配置项--github.helper.json
{
  "dev": {
    "remote": "xxxxxxxxx",
    "branch": "dev",
    "dirname": "dist", //git仓库下哪一目录,可删除该选项
    "ignore": [ // 以下类型文件不会被提交到发布仓库,可删除该选项
      "*.json",
      "*.css",
      "*.js",
      "*.jpg",
      "*.svg"
    ]
  },
  "production": {
    "remote": "xxxxxxxxx",
    "branch": "master",
    "dirname": "dist", //git仓库下哪一目录
    "ignore": [ // 以下类型文件不会被提交到发布仓库
      "*.json",
      "*.css",
      "*.js",
      "*.jpg",
      "*.svg"
    ]
  }
}