1.0.0 • Published 3 years ago

protoc3 v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

背景

  • 使用诉求。在前后端开发协作中,将用于协议编写的proto文档转换为ts的类型定义文件。
  • 使用痛点。公司内网或者并未翻墙的开发者,github存在无法访问或者访问速度很差的情况,https://www.npmjs.com/package/protoc,原有的protoc包大概率出现安装失败的情况。

改进点

  • 将支持的protoc版本从3.11.2升级到3.18.1
  • 使用本地包来代替从指定的github下载地址下载,避免网络问题导致安装失败。
  • 修复现有包对后续版本支持的问题。现有的包在对压缩包遍历时,只能支持单节点目录,假定所有的包里面只有bin目录,对于多目录压缩后的包,出现定位执行文件失败。

支持PB版本

  • 3.18.1

支持操作系统平台

  • darwin
  • linux
  • windows(在git bash下运行sh)

示例

var protoc = require("protoc");
 
protoc.library(["path/to/file.proto", "path/to/file2.proto"], function(err, files) {
  if (err) return console.error(err);
  // Handle the JavaScript Vinyl files.
  // These files can be used in Google Closure Compiler,
  // but they require the files in
  // https://github.com/google/protobuf/tree/master/js
  // ...
});