2.0.1 • Published 6 years ago

protogenjs v2.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

protogenjs

Circle CI Status npm

Utility for generating interfaces from *.proto schemes.

Eliminates hardcode paths to files and folders.

Recursively reads the paths to the schemes in the specified directory and generates the correct *.js and *.d.ts files.

A configuration file is required for operation (specified by the argument --config).

Sample configuration file:

{
    "srcPaths": ["./test/proto/**/*.proto"],
    "distDir": "./test/dist",
    "commonFiles": ["./test/common/**/*.proto"],
    "isolateModule": true
}

Description of parameters:

  • srcPaths - an array of paths where you need to look for *.proto schemes (supports glob syntax).
  • distDir - the directory in which you want to put the final *.js and *.d.ts files.
  • commonFiles - an array of paths to *.proto general purpose schemes that need to be included in all other *.proto schemes (supports glob syntax).
  • isolateModule - if it is set to true, then a directory with the name of the module will be created in the distDir directory.

Using

After installation, the utility will be available in 2 versions - in npm scripts and through the console indicating the full path.

Using the npm script:

// package.json
"scripts": {
    "generate": "protogenjs --config protobuf.json"
}
user@ubuntu$ npm run generate
user@ubuntu$ yarn run generate

Or directly from the terminal:

user@ubuntu$ $(npm bin)/protogenjs --help
Usage examples:
    protogenjs -h[--help]                  Print this message
    protogenjs -p[--progress]              Show progress
    protogenjs -c[--config] protobuf.json  Run with config file
Config file example:
{
    "srcPaths": ["./test/proto/**/*.proto"],
    "distDir": "./test/dist",
    "commonFiles": [
        "./test/common/**/*.proto"
    ],
    "isolateModule": true
}
user@ubuntu$ $(npm bin)/protogenjs --config protobuf.json