Giter Club home page Giter Club logo

nx-buf's Introduction

nx-buf

An Nx plugin for performing codegen from Protobuf/gRPC projects using Buf.

Installation

To install this plugin, run the following command:

npm install @clsx524/nx-buf

And add it to the list of plugins in nx.json:

{
  // ...
  "plugins": [
    // ...
    "@clsx524/nx-buf"
  ]
}

Features

This plugin assumes that you have a separate Nx project in your workspace that contains your .proto files, as well as buf.yaml and buf.gen.yaml in that project root.

Linting

To enable linting a buf project, use the @clsx524/nx-buf:lint executor in that project's project.json:

{
  // ...
  "targets": {
    "lint": {
      "executor": "@clsx524/nx-buf:lint"
    }
  }
}

Codegen

To generate source files from a buf project into another project, use the @clsx524/nx-buf:generate executor in the destination project:

{
  // ...
  "targets": {
    "proto-gen": {
      "executor": "@clsx524/nx-buf:generate",
      "outputs": ["{projectRoot}/{options.copyTo}"],
      "options": {
        "srcProject": "proto",
        "copyFrom": ["gen/*"],
        "copyTo": "src/gen",
        "options": "--include-imports"
      }
    },
    "build": {
      "dependsOn": ["proto-gen"],
      // ...
    }
  }
}

The options are as follows:

  • srcProject: the project from where to grab the generated sources after running buf generate.
  • copyFrom: a list of glob patterns to copy from that project, relative to its root.
  • copyTo: the destination folder, relative to the target project.
  • options: (optional) additional command-line arguments to pass to buf generate.

Dependency graph

This plugin will automatically establish a dependency between any project that contain a @clsx524/nx-buf:generate target and the respective project specified in options.srcProject.

nx-buf's People

Contributors

rliang avatar clsx524 avatar workstream-vercel-share-account avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.