{"name":"protobufjs-cli","version":"2.2.0","author":{"name":"Daniel Wirtz","email":"dcode+protobufjs@dcode.io"},"license":"BSD-3-Clause","_id":"protobufjs-cli@2.2.0","maintainers":[{"name":"dcode","email":"dcode+npm@dcode.io"},{"name":"fenster","email":"npm@fenster.name"},{"name":"google-wombot","email":"node-team-npm+wombot@google.com"}],"homepage":"https://github.com/protobufjs/protobuf.js#readme","bugs":{"url":"https://github.com/protobufjs/protobuf.js/issues"},"bin":{"pbjs":"bin/pbjs","pbts":"bin/pbts","protoc-gen-pbjs":"bin/protoc-gen-pbjs"},"dist":{"shasum":"7b0fe72ca26dd9e454674871097a09377df2156a","tarball":"http://registry-npm.ywwl.com/protobufjs-cli/download/protobufjs-cli-2.2.0.tgz","fileCount":34,"integrity":"sha512-vpGt6STprj8FFm5x5w0mOrIISgtmoMKZt0X74N7Lyd0VWNHX6pDPp0iF0MEegSnwkeErh0wdFfIQfbhcgUaBdw==","signatures":[{"sig":"MEUCIA7+c2FrL8mndhiwETV8XDCTiwahGyRf6B47ivyNdjjZAiEAvPeXLxdNyoDTKy60GVPRnlPk4TraXLKeyis5x4MKmfs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/protobufjs-cli@2.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":141454,"size":35892,"noattachment":false,"key":"/protobufjs-cli/-/protobufjs-cli-2.2.0.tgz"},"main":"index.js","type":"commonjs","types":"index.d.ts","engines":{"node":">=12.0.0"},"gitHead":"f8d5f3fe7104fade45407341228f0f0bb623e76d","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f8f428c0-1e63-4584-bdfb-b85f76ff1924"}},"repository":{"url":"git+https://github.com/protobufjs/protobuf.js.git","type":"git"},"_npmVersion":"11.14.1","description":"Translates between file formats and generates static code as well as TypeScript definitions.","directories":{},"_nodeVersion":"24.14.1","dependencies":{"tmp":"^0.2.1","glob":"^8.0.0","chalk":"^4.0.0","jsdoc":"^4.0.0","espree":"^9.0.0","semver":"^7.1.2","minimist":"^1.2.8","escodegen":"^1.13.0","uglify-js":"^3.7.7","estraverse":"^5.1.0"},"_hasShrinkwrap":false,"devDependencies":{"protobufjs":"file:.."},"peerDependencies":{"protobufjs":">=8.1.0 <9"},"_npmOperationalInternal":{"tmp":"tmp/protobufjs-cli_2.2.0_1778355484478_0.795652866785411","host":"s3://npm-registry-packages-npm-production"},"readme":"# protobufjs-cli\n\n[![npm](https://img.shields.io/npm/v/protobufjs-cli.svg)](https://www.npmjs.com/package/protobufjs-cli)\n\nCommand line add-on for [protobuf.js](https://github.com/protobufjs/protobuf.js). Generates static code, reflection bundles, and TypeScript definitions.\n\n```sh\nnpm install --save-dev protobufjs-cli\n```\n\n## pbjs for JavaScript\n\n```sh\nnpx pbjs --help\n```\n\n```\nTranslates between file formats and generates static code.\n\n  -t, --target     Specifies the target format. Also accepts a path to require a custom target.\n\n                   json          JSON bundle\n                   json-module   JSON bundle as a module\n                   proto2        Protocol Buffers, Version 2\n                   proto3        Protocol Buffers, Version 3\n                   static        Static code without reflection (non-functional on its own)\n                   static-module Static code without reflection as a module\n\n  -p, --path       Adds a directory to the include path.\n\n  --filter         Path to a JSON file listing messages and their dependencies to keep.\n                   Example: {\"messageNames\":[\"mypackage.Message\",\"Message2\"]}\n\n  -o, --out        Saves to a file instead of writing to stdout.\n\n  -d, --dts        Also saves a .d.ts file next to --out for static-module and json-module.\n\n  --sparse         Exports only those types referenced from a main file (experimental).\n\n  Module targets only:\n\n  -w, --wrap       Specifies the wrapper to use. Also accepts a path to require a custom wrapper.\n\n                   default   Default wrapper supporting both CommonJS and AMD\n                   commonjs  CommonJS wrapper\n                   amd       AMD wrapper\n                   esm       ESM wrapper (implies --es6)\n                   closure   A closure adding to protobuf.roots where protobuf is a global\n\n  --dependency     Specifies which version of protobuf to require. Accepts any valid module id\n\n  -r, --root       Specifies an alternative protobuf.roots name.\n\n  -l, --lint       Linter configuration. Defaults to protobuf.js-compatible rules:\n\n                   eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars, default-case, jsdoc/require-param\n\n  --es6            Enables ES6 syntax (const/let instead of var)\n\n  Proto sources only:\n\n  --keep-case      Keeps field casing instead of converting to camel case.\n  --alt-comment    Turns on an alternate comment parsing mode that preserves more comments.\n\n  Static targets only:\n\n  --no-create      Does not generate create functions used for reflection compatibility.\n  --no-encode      Does not generate encode functions.\n  --no-decode      Does not generate decode functions.\n  --no-verify      Does not generate verify functions.\n  --no-convert     Does not generate convert functions like from/toObject\n  --no-delimited   Does not generate delimited encode/decode functions.\n  --no-typeurl     Does not generate getTypeUrl function.\n  --no-beautify    Does not beautify generated code.\n  --no-comments    Does not output any JSDoc comments.\n  --no-service     Does not output service classes.\n\n  --force-long     Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.\n  --force-number   Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.\n  --force-message  Enforces the use of message instances instead of plain objects.\n\n  --null-defaults  Default value for optional fields is null instead of zero value.\n  --null-semantics Make nullable fields match protobuf semantics (overrides --null-defaults).\n\nusage: pbjs [options] file1.proto file2.json ...  (or pipe)  other | pbjs [options] -\n```\n\n## pbts for TypeScript\n\n```sh\nnpx pbts --help\n```\n\n```\nGenerates TypeScript definitions from annotated JavaScript files.\n\n  -o, --out       Saves to a file instead of writing to stdout.\n\n  -g, --global    Name of the global object in browser environments, if any.\n\n  -i, --import    Comma delimited list of imports, optionally as localName=path.\n\n  --no-constructor Emits private constructors for reflection-backed declarations.\n\n  --no-comments   Does not output any JSDoc comments.\n\n  Internal flags:\n\n  -n, --name      Wraps everything in a module of the specified name.\n\n  -m, --main      Whether building a standalone file without any imports.\n\nusage: pbts [options] file1.js file2.js ...  (or)  other | pbts [options] -\n```\n\n## Common commands\n\nGenerate static code and a matching declaration file:\n\n```sh\nnpx pbjs -t static-module -w commonjs -o compiled.js --dts file1.proto file2.proto\n```\n\nGenerate a reflection bundle and a matching declaration file:\n\n```sh\nnpx pbjs -t json-module -w commonjs -o bundle.js --dts file1.proto file2.proto\n```\n\nNote that declarations generated for JSON modules describe reflection-backed message types. Use `MyMessage.create(...)` instead of constructors.\n\nFor nested reflected properties like `MyMessage.MyEnum`, type, service and enum names must start with an uppercase letter. Otherwise, use reflection lookups such as `root.lookupType(...)`.\n\n## protoc plugin\n\nThe CLI also provides `protoc-gen-pbjs` for projects that already use `protoc` but prefer protobuf.js code generation.\n\nThe plugin is an aggregate generator: each invocation writes one JavaScript module and, with `dts`, one matching declaration file.\n\n```sh\nprotoc \\\n  --plugin=protoc-gen-pbjs=./node_modules/.bin/protoc-gen-pbjs \\\n  --pbjs_out=gen \\\n  --pbjs_opt=dts \\\n  proto/awesome.proto\n```\n\nBy default, the plugin emits `index.js` with `target=static-module` and `wrap=esm`. Use `file=PATH` to choose the aggregate output file, `target=json-module` for a JSON module, `wrap=commonjs` for CommonJS output, and `keep-case` to preserve descriptor field names.\n\nOther `pbjs` code generation options can be passed as usual, for example `root=NAME`, `dependency=ID`, `lint=CONFIG`, `no-create`, `force-long`, or `null-semantics`. See the `pbjs` help output above for the full option set.\n\n## Command line API\n\nBoth utilities can be used programmatically by providing command line arguments and a callback to their respective `main` functions:\n\n```js\nconst { pbjs, pbts } = require(\"protobufjs-cli\");\n\npbjs.main([\"--target\", \"json-module\", \"path/to/myproto.proto\"], function(err, output) {\n  if (err) throw err;\n  // do something with output\n});\n```\n\n## Additional documentation\n\nSee the [protobuf.js README](https://github.com/protobufjs/protobuf.js) for runtime variants, usage examples, and additional documentation.\n","publish_time":1778355484622,"_cnpm_publish_time":1778355484622,"dist-tags":{"experimental":"2.0.4-experimental","latest":"2.7.1","latest-1":"1.3.3"}}