# protoc-gen

> Protocol Buffers Compiler (protoc) plugin for Node.js

Latest version **0.0.4** (published 2019-05-23) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install protoc-gen
pnpm add protoc-gen
yarn add protoc-gen
bun add protoc-gen
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2019-05-23 |
| First published | 2019-04-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 3 |
| Author | Suvitruf |
| Maintainers | suvitruf |
| Keywords | protobuf, protoc, proto3 |

## Links

- npm: https://www.npmjs.com/package/protoc-gen
- Repository: https://github.com/Suvitruf/protoc-gen
- Homepage: https://github.com/Suvitruf/protoc-gen#readme
- Issues: https://github.com/Suvitruf/protoc-gen/issues
- npm.io page: https://npm.io/package/protoc-gen

## Dependencies (4)

- [unzip](https://npm.io/package/unzip.md) ^0.1.11
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [request](https://npm.io/package/request.md) ^2.88.0
- [google-protobuf](https://npm.io/package/google-protobuf.md) ^3.7.1

## Recent versions

- 0.0.4 (latest) — 2019-05-23
- 0.0.3 — 2019-04-12
- 0.0.2 — 2019-04-12
- 0.0.1 — 2019-04-12

## README

[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![NPM](https://img.shields.io/npm/v/protoc-gen.svg)](https://www.npmjs.com/package/protoc-gen)

# Protocol Buffers Compiler (protoc) for Node.js 
A wrapper in Node for the compiled protoc from [https://github.com/google/protobuf](https://github.com/google/protobuf).

# Disclaimer
It was really annoying to download protoc binary each time, so I've written this module for myself. But feel free to use :D


# Version
It's currently using Protocol Buffers `v3.7.1` (`proto3`).

# Platforms
Windows, Linux and OSX in x86_64 and x86_32.

# Examples

## From nodejs srcipt

If your directory looks like:
  
    project
    │   [...] 
    │
    └───models
    │   │   base.proto
    │   │
    │   └───nested
    │       │   base_nested.proto
    │       │ 
    │       └───nested2
    │       │    base_nested_2.proto

### Not Recursive

```JavaScript
const path = require('path');
const protoc = require('protoc-gen');


protoc.protoc({inputPath: path.join('models'), recursive: false, destinationPath: path.join('out')})
    .catch(err => {
        console.log(err);
    });
```

It will look:

    project
    │   [...] 
    │
    └───models
    │   │   base.proto
    │   │
    │   └───nested
    │       │   base_nested.proto
    │       │ 
    │       └───nested2
    │       │    base_nested_2.proto
    │   
    └───out
        │   base_pb.js

### Recursive

```JavaScript
const path = require('path');
const protoc = require('protoc-gen');


protoc.protoc({inputPath: path.join('models'), recursive: true, destinationPath: path.join('out')})
    .catch(err => {
        console.log(err);
    });
```

It will look:

    project
    │   [...] 
    │
    └───models
    │   │   base.proto
    │   │
    │   └───nested
    │       │   base_nested.proto
    │       │ 
    │       └───nested2
    │       │    base_nested_2.proto
    │   
    └───out
        │   base_pb.js
        │
        └───nested
            │    base_nested_pb.js
            │ 
            └───nested2
            │    base_nested_2_pb.js

### File list

```JavaScript
const path = require('path');
const protoc = require('protoc-gen');


protoc.protoc({inputPath: path.join('models'), inputFiles: ['base.proto'], destinationPath: path.join('out')})
    .catch(err => {
        console.log(err);
    });
```

    project
    │   [...] 
    │
    └───models
    │   │   base.proto
    │   │
    │   └───nested
    │       │   base_nested.proto
    │       │ 
    │       └───nested2
    │       │    base_nested_2.proto
    │   
    └───out
        │   base_pb.js


## From cli

`npm explore protoc-gen -- npm run gen -- --input_path ../../models --dest_path ../../out --r`

Result:

    project
    │   [...] 
    │
    └───models
    │   │   base.proto
    │   │
    │   └───nested
    │       │   base_nested.proto
    │       │ 
    │       └───nested2
    │       │    base_nested_2.proto
    │   
    └───out
        │   base_pb.js
        │
        └───nested
            │    base_nested_pb.js
            │ 
            └───nested2
            │    base_nested_2_pb.js

### Arguments
|    Argument          |  Alias          | Description                                  |
|----------------------|-----------------|----------------------------------------------|
| `--recursive`        | `--r`           | Will check all nested directories            | 
| `--input_path`       |  `--inp_path`   | Root directory where  .proto files located   |   
| `--input_files`      |  `--inp_files`  | Exact  .proto files list                     |   
| `--destination_path` |  `--dest_path`  | Root directory where put generated .js files |

---
_Source: https://npm.io/package/protoc-gen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
