Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2ac2d55
Update README.md
ji-podhead Mar 11, 2024
69e6fc0
Update README.md
ji-podhead Mar 11, 2024
9396088
added other languages
ji-podhead Mar 11, 2024
e4ac4fd
other languages
ji-podhead Mar 11, 2024
4349d43
my changes
ji-podhead Mar 11, 2024
07b214b
made my package out of it
ji-podhead Mar 11, 2024
4847577
Update index.js
ji-podhead Mar 11, 2024
b169c67
Update README.md
ji-podhead Mar 11, 2024
722a8ee
Create npm-publish.yml
ji-podhead Mar 11, 2024
e8204c0
Create npm-publish-github-packages.yml
ji-podhead Mar 11, 2024
df05025
Update package.json
ji-podhead Mar 11, 2024
04ac375
changed package
ji-podhead Mar 11, 2024
bba6813
Update package.json
ji-podhead Mar 11, 2024
2e3181c
a
ji-podhead Mar 11, 2024
d0eca1c
Update README.md
ji-podhead Mar 11, 2024
7e50b9a
Update README.md
ji-podhead Mar 11, 2024
bc8ba0e
added second publish option
ji-podhead Mar 11, 2024
42d48c5
Merge branch 'master' of https://github.com/ji-podhead/protoc-helper
ji-podhead Mar 11, 2024
3f6ce7d
Update README.md
ji-podhead Mar 12, 2024
3e3bf23
Update README.md
ji-podhead Mar 12, 2024
9703c46
Update README.md
ji-podhead Mar 12, 2024
659fa82
Update .npmrc copy
ji-podhead Mar 12, 2024
3bacb16
Update README.md
ji-podhead Mar 14, 2024
d135413
Update README.md
ji-podhead Mar 14, 2024
94cdcf9
added Typescript
ji-podhead Mar 14, 2024
de0771a
Update README.md
ji-podhead Mar 14, 2024
cbf6452
Update README.md
ji-podhead Mar 14, 2024
1246f72
Merge branch 'master' of https://github.com/ji-podhead/protoc-helper
ji-podhead Mar 14, 2024
1f62eb6
Update README.md
ji-podhead Mar 14, 2024
23905db
Update README.md
ji-podhead Mar 14, 2024
610413b
Update README.md
ji-podhead Mar 14, 2024
f957651
Update README.md
ji-podhead Mar 14, 2024
553421d
a
ji-podhead Mar 14, 2024
ec93d01
a
ji-podhead Mar 14, 2024
283254b
Update README.md
ji-podhead Mar 14, 2024
53ceb43
Update README.md
ji-podhead Mar 14, 2024
707af1a
Update README.md
ji-podhead Mar 14, 2024
9705015
Update README.md
ji-podhead Mar 14, 2024
105d4f3
Update README.md
ji-podhead Mar 14, 2024
3ebd3de
Update README.md
ji-podhead Mar 15, 2024
268c47b
Update README.md
ji-podhead Mar 15, 2024
8d6274d
Update README.md
ji-podhead Mar 16, 2024
f92db0a
Update README.md
ji-podhead Mar 16, 2024
211276a
better description
ji-podhead Mar 16, 2024
0a47f80
Merge branch 'master' of https://github.com/ji-podhead/protoc-helper
ji-podhead Mar 16, 2024
455a296
Update README.md
ji-podhead Mar 16, 2024
8f745d9
Update README.md
ji-podhead Mar 16, 2024
912980e
added versionbadge
ji-podhead Mar 16, 2024
17327c1
added version badge
ji-podhead Mar 16, 2024
c1c937c
changed typo
ji-podhead Mar 16, 2024
8e04862
Update README.md
ji-podhead Mar 17, 2024
f432b93
Update README.md
ji-podhead Mar 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
20 changes: 20 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish to npm

on:
push:
branches:
- main # Ersetzen Sie 'main' durch den Namen Ihrer Hauptbranch, falls anders

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14' # Ersetzen Sie '14' durch die gewünschte Node.js-Version
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
157 changes: 132 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,141 @@
# Protocol Buffers for Node
A wrapper in Node for the compiled protoc from https://github.com/protocolbuffers/protobuf.

## Version
It's currently using Protocol Buffers `v3.20.3`.
# protoc-helper
[![npm version](https://badge.fury.io/js/protoc-helper.svg)](https://badge.fury.io/js/protoc-helper)
[![NPM Downloads](https://img.shields.io/npm/dw/protoc-helper.svg)](https://www.npmjs.com/package/protoc-helper)
[![npm version](https://img.shields.io/badge/protoc_v26.0-binary-blue)](https://www.npmjs.com/package/protoc-helper)

## Platforms
Google only provides binary files for Windows, Linux and OSX in x86_64 and x86_32.
A multilanguage protoc protobuff generator for node. uses the protoc binary and supports multiple platforms and processors. forked from [node-protoc](https://github.com/YePpHa/node-protoc) to add additional languages.
. Please see [Protobuf Plugin Installation](https://github.com/ji-podhead/protoc-helper/tree/master?tab=readme-ov-file#protobuf-plugin-installation) to install the required plugins for your target language.

## Examples
There's currently no documentation. Hopefully this example will help.
## Install
- **local:** `npm i protoc-helper`
- **cli-tool:** `npx install protoch`
## How to use
- you can find a demoscript and the proto file in the scripts folder.
---

**CLI (via npx global install)**
```JavaScript
npx protoch <lang> <out_path> <proto_file> <proto_path>
npx protoc --go_out=<out_path> --proto_path=<proto_file_folder> <proto_file> // exchange --go_out is using another lamguage
```
---
**via Script** <br>
`without instance` (array not supported)
```JavaScript
createProtobuff( <lang> <output_path> <absolute_proto_file_path> )
createProtobuff( <lang> <output_path> <proto_file_folder> <proto_file>)

```
`using class instance`
```JavaScript
var protoc = require("protoc");

protoc.library(["path/to/file.proto", "path/to/file2.proto"], function(err, files) {
if (err) {
console.error(err);
return;
}

// 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

// ...
});
generator.generateProtobuf( <lang> <output_path> <proto_file> <proto_file_folder>)
```
`usings array` for multiple files

It's also possible to directly call the protoc binary file:
```JavaScript
generator.generateProtobuf([[ <lang> <output_path> <proto_file> <proto_file_folder>],[ <lang> <output_path> <proto_file> <proto_file_folder> ]])
```
npx protoc --help
---
### Arguments
**lang** The programming language for which the Protobuf file should be generated.
<br> **total_proto_file_path** The path to the Proto file that should be used as the source.
<br> **output_path** The path where the generated Protobuf file should be saved
<br> **proto_file** The name of the proto file including the extension.
<br> **proto_file_folder** A path to a folder that holds a proto file.

### Example
```JavaScript
const {ProtobuffGenerator,createProtobuff} = require("protoc-helper")
const generator = new ProtobuffGenerator()
const dir = String(__dirname)+"/"
generator.generateProtobuf([["go",dir,"helloworld.proto",dir],["python",dir,"helloworld.proto",dir]])
```


---

if you like this package, pls consider giving Jeppe’s and my repo a Star on github

---
## Protobuf Plugin Installation

### JavaScript/TypeScript
- **Repository**: [https://github.com/improbable-eng/ts-protoc-gen](https://github.com/improbable-eng/ts-protoc-gen)
- **Installation**: npm install ts-protoc-gen `already added to dependencies`
### Go
- **Repository**: [https://github.com/golang/protobuf](https://github.com/golang/protobuf)
- **Installation**: bash go get -u github.com/golang/protobuf/protoc-gen-go


### Java
- **Repository**: [https://github.com/google/protobuf-gradle-plugin](https://github.com/google/protobuf-gradle-plugin)
- **Installation**: gradle plugins { id 'com.google.protobuf' version '0.8.17' }


### Python
- **Repository**: [https://github.com/protocolbuffers/protobuf](https://github.com/protocolbuffers/protobuf)
- **Installation**:`may doesnt need plugin` see https://protobuf.dev/reference/python/python-generated/


### C#
- **Repository**: [https://github.com/protocolbuffers/protobuf](https://github.com/protocolbuffers/protobuf)
- **Installation**: powershell Install-Package Google.Protobuf.Tools `or it may doesnt need plugin`


### Ruby
- **Repository**: [https://github.com/localshred/protobuf](https://github.com/localshred/protobuf)
- **Installation**: doesnt need plugin, but might check out https://github.com/ruby-protobuf/protobuf


### Objective-C
- **Repository**: [[https://github.com/alexeyxo/protobuf-objc](https://github.com/protocolbuffers/protobuf](https://github.com/alexeyxo/protobuf-objc)
- **Installation**: may require cocoapod. see repo above


### PHP
- **Repository**: [https://github.com/protocolbuffers/protobuf](https://github.com/protocolbuffers/protobuf)
- **Installation**: doesnt need plugin


### Dart
- **Repository**: [https://github.com/dart-lang/protobuf](https://github.com/dart-lang/protobuf)
- **Installation**: bash dart pub global activate protoc_plugin


### Rust
- **Repository**: (https://github.com/neoeinstein/protoc-gen-prost](https://github.com/neoeinstein/protoc-gen-prost)
- **Installation**:*see repo


### Swift
- **Repository**: [https://github.com/apple/swift-protobuf](https://github.com/apple/swift-protobuf)
- **Installation**: swift // Add SwiftProtobuf as a dependency to your Xcode project


### Kotlin
- **Repository**: [https://github.com/grpc/grpc-kotlin/tree/master/compiler](https://github.com/grpc/grpc-kotlin/tree/master/compiler)
- **Installation**:Clone and build the plugin; it clone https://github.com/grpc/grpc-kotlin.git cd grpc-kotlin/compiler ./gradlew installDist


### Scala
- **Repository**: [https://github.com/scalapb/ScalaPB](https://github.com/scalapb/ScalaPB)
- **Installation**:Add ScalaPB as a dependency to your sbt project libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.1"



## NPX and additional args

you can use `npx protoc` or add your own arguments in the index.js:
```JavaScript
switch (language) {
case 'go':
// Example for Go --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative
command = `npx protoc --go_out=${outputPath} --proto_path=${proto_path} ${proto_file}`;
break;
case 'java':
// Example for Java
command = `npx protoc --java_out=${outputPath} --proto_path=${proto_path} ${proto_file}`;
break;
case 'python':
```
Loading