jsprotobuf-generater

0.1.0 • Public • Published

jsprotobuf-generater

A tool to download protobuf file from origin git repo and generate JavaScript protobuf code.

  • download protocol buffers files from remote git repos
  • generate JavaScript Protobuf code using protoc

使用方式

  1. yarn add --dev jsprotobuf-generater
  2. package.json中,scripts中配置如下:
  {
    ...
    "scripts": {
      ...
      "gpc": "gpc"
    }
  }
  1. 运行yarn gpc -i并依据提示进行相关操作

gpc-config.json

{
  "root": "xx", // 远程protobuf文件存放在本地的目录
  "output": "src/xx", // JavaScript protobuf 文件生成目录
  "url": "direct:https://gitee.com/xx/xx.git#main", // 远程仓库的地址支持gitee/github/gitlab等
  "sourcePath": "cherry/src/main/protobuf", // 需要生成javascript protobuf文件的源目录,
  "clientWrapper": { // 如果需要生成默认导出client,则需要配置此参数
    "name": "xx", // 默认导出名
    "path": "src/utils/fileName" // clientWrapper.path fileName可不传文件扩展名
  }
}

注意:url 的书写规则可以参考dowload-git-repo

命令

Usage: gpc [<param>]

  <param>
    将要运行的名称,例如 gpc -i/--init

支持的命令如下:

命令 说明 备注
-i/--init 初始化并拉取远程 git repos,生成 javascript protobuf code download,generate
-g/--generate 在存在本地 protobuf 的文件下,直接生成 JavaScript protobuf 文件 generate
-c/--clients 生成所有 client 的默认导出文件

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i jsprotobuf-generater

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

28.4 kB

Total Files

19

Last publish

Collaborators

  • limoer