jsprotobuf-generater
v0.1.0
Published
A tool to download protobuf file from origin git repo and generate JavaScript protobuf code.
Downloads
8
Maintainers
Readme
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
使用方式
yarn add --dev jsprotobuf-generater
- 在
package.json
中,scripts
中配置如下:
{
...
"scripts": {
...
"gpc": "gpc"
}
}
- 运行
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 的默认导出文件 | |