{"id":13740966,"url":"https://github.com/konsumer/node-protoc-plugin","last_synced_at":"2025-09-02T21:33:32.264Z","repository":{"id":57147975,"uuid":"83018231","full_name":"konsumer/node-protoc-plugin","owner":"konsumer","description":"Create protoc code-generation plugins easily in nodejs","archived":false,"fork":false,"pushed_at":"2017-04-20T00:08:06.000Z","size":294,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T13:39:46.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Protocol Buffer","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konsumer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-24T08:16:34.000Z","updated_at":"2024-09-13T02:39:47.000Z","dependencies_parsed_at":"2022-09-06T17:01:32.527Z","dependency_job_id":null,"html_url":"https://github.com/konsumer/node-protoc-plugin","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/konsumer/node-protoc-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnode-protoc-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnode-protoc-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnode-protoc-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnode-protoc-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/node-protoc-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fnode-protoc-plugin/sbom","scorecard":{"id":567160,"data":{"date":"2025-08-11","repo":{"name":"github.com/konsumer/node-protoc-plugin","commit":"331e33f49565be967007f3d817e99a5a94fb8a30"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T15:17:23.620Z","repository_id":57147975,"created_at":"2025-08-20T15:17:23.620Z","updated_at":"2025-08-20T15:17:23.620Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273355648,"owners_count":25090825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:00:54.056Z","updated_at":"2025-09-02T21:33:32.215Z","avatar_url":"https://github.com/konsumer.png","language":"Protocol Buffer","funding_links":[],"categories":["Language-Specific"],"sub_categories":["Node.js"],"readme":"# [node-protoc-plugin](https://www.npmjs.com/package/protoc-plugin)\n\nCreate protoc code-generation plugins easily in nodejs\n\n\n## installation\n\n`npm i -S protoc-plugin`\n\n\n## usage\n\nYou can checkout the code in the `example/` dir, but here is a quick example:\n\n```js\n#! /usr/bin/env node\nconst protocPlugin = require('protoc-plugin')\n\nprotocPlugin(protos =\u003e {\n  // do stuff here with protos\n  // return array like [{name: 'filename', content: 'CONTENTS'}]\n})\n```\n\nMake sure not to output anything to `stdout` (for example with `console.log`) because protoc uses `stdout`. I use `console.error` to output stuff to the user.\n\nSince it's a promise, you can `throw` or just return `Promise.reject('reason')`, and you can do async stuff with promises.\n\nOnce you have made your plugin, save it as `protoc-gen-NAME`, give it executable permissions, then run it like this:\n\n```sh\nprotoc --plugin=protoc-gen-NAME --NAME_out=generated yourfile.proto\n```\n\nIf you put it in your path, you don't need the `--plugin=protoc-gen-NAME` part.\n\n\u003e **PRO TIP** - use [npm's `bin`](https://docs.npmjs.com/files/package.json#bin) in your package.json to get your plugin script installed, cross-platform, in the user's path.\n\n## `findCommentByPath`\n\nThere is a utility included for finding comments in various places in the protobuf file. It's a lil obtuse, but you can look in [the spec](https://github.com/google/protobuf/blob/master/src/google/protobuf/descriptor.proto#L720-L799) for more info.\n\nHere are some `locationList` addresses I use a lot in protoc plugins:\n\n```\n * [4, m] - message comments\n * [4, m, 2, f] - field comments in message\n * [6, s] - service comments\n * [6, s, 2, r] - rpc comments in service\n```\n\nwhere:\n\n* `m` - the method count in the proto, from index 0\n* `f` - the field-count in the method, from index 0\n* `s` - the service definition in the proto, from index 0\n* `r` - the RPC definition in the service, from index 0\n\nlike this:\n\n```proto\n// [4, 0] is right here \nmessage MyMessage {\n  // [4, 0, 2, 0] is right here\n  int32 field1 = 1;\n}\n\n// [6, 0] is right here\nservice MyService {\n  // [6, 0, 2, 0] is here!\n  rpc (MyMessage) returns (MyMessage);\n}\n```\n\nThere are more addresses, but you will have to look at the [the spec](https://github.com/google/protobuf/blob/master/src/google/protobuf/descriptor.proto#L720-L799) to figure it out.\n\n### usage\n\n```js\nconst protocPlugin = require('protoc-plugin')\nconst findCommentByPath = protocPlugin.findCommentByPath\n\n// output comments for services \u0026 messages to stderr\nprotocPlugin(protos =\u003e {\n  protos.forEach(proto =\u003e {\n    proto.serviceList.forEach((service, s) =\u003e {\n      console.error('SERVICE', service.name, findCommentByPath([6, s], proto.sourceCodeInfo.locationList))\n      service.methodList.forEach((rpc, r) =\u003e {\n        console.error('RPC', rpc.name, findCommentByPath([6, s, 2, r], proto.sourceCodeInfo.locationList))\n      })\n    })\n    proto.messageList.forEach((message, m) =\u003e {\n      console.error('MESSAGE', message.name, findCommentByPath([4, m], proto.sourceCodeInfo.locationList))\n      message.fieldList.forEach((field, f) =\u003e {\n        console.error('FIELD', field.name, findCommentByPath([4, m, 2, f], proto.sourceCodeInfo.locationList))\n      })\n    })\n  })\n  \n  // no files written\n  return []\n})\n\n```\n\n\n## advanced usage\n\nIf you need more from the incoming stdin `CodeGeneratorRequest` have a look at `example/protoc-gen-extendedlogger`.\n\n### extensions\n\nI am currently including `google/api/annotations` proto file, so gRPC-annotions will work out of the box (for example see `proto/helloworld.proto`) For any other extensions, you will need to generate the `google-protobuf` representation, and require it before parsing. You can easily generate them with a command like this:\n\n```sh\nprotoc --js_out=import_style=commonjs,binary:YOURDIR/ -I PROTODIR/ PROTODIR/YOURFILE.proto\n```\n\nthen require like this:\n\n```js\nrequire('./NAMESPACE_pb')\n```\n\nYou can see how I have done this with [`google/api/annotations_pb` in `index.js`](https://github.com/konsumer/node-protoc-plugin/blob/master/src/index.js#L6).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnode-protoc-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Fnode-protoc-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fnode-protoc-plugin/lists"}