Giter VIP home page Giter VIP logo

shivam010 / protocol-buffer-to-typescript-plugin Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 2.0 58 KB

Protocol Buffer to TypeScript Plugin is the extension of the Protocol Compiler to compile the proto files into corresponding TypeScript code

License: MIT License

Batchfile 1.51% Python 95.79% Shell 2.70%
google-protobuf typescript protocol-buffers python-plugin google-protocol-buffers google angular

protocol-buffer-to-typescript-plugin's Introduction

Build Status

Protocol Buffer to TypeScript Plugin

Protocol Buffer is copyright with Google Inc. https://developers.google.com/protocol-buffers/

Protocol Buffer to TypeScript Plugin is the extension of the Protocol Compiler to compile the proto files into corresponding TypeScript code.

Overview

Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. You can find protobuf's documentation on the Google Developers site.

This repository contains the TypeScript extension that implements Protocol Buffers functionality in TypeScript.

Consider file test.proto,

    syntax = "proto3";

    package test;

    message Msg{
    string name = 1;
    }

Compiling the file into TypeScript code,

    import { Observable } from 'rxjs';

    export interface Msg {
        name: string;
    }

Installations

  1. Make sure you have Python 2.x. If in doubt, run:

    $ python -V
    
  2. If you don't have the protocol compiler, protoc installed, install a binary distribution of protoc, and the simplest way to install it is to download a pre-built binary.

     $ protoc --version
    
  3. Download or clone the Python Protocol Buffers runtime library

  4. Build and run the tests:

    $ python setup.py build
    $ python setup.py test
    
  5. And Install:

    $ python setup.py install
    
  6. Now, clone our plugin and you are all done.

Setup and Run

For Windows

  1. Set the interpreter to the plugin by adding your Python 2.x path 'C:\Python27\python.exe' in the begining of the tsPlugin.py file #!C:\Python27\python.exe

  2. Now, edit the runPlugin.bat file to make the python file executable.

  3. Now, generate your TypeScript code using,

    $ protoc -I <Project_Path> -I <Proto_File_Directory_Path> <Proto_Files_Path> --plugin=protoc-gen-custom=<Executable_File_Path> --custom_out=<Output_Directory_Path>
    

    Like:

    $ pwd
    ..\protobuf-to-typescript
    $ protoc -I . -I examples\test examples\test\test.proto --plugin=protoc-gen-custom=runPlugin.bat --custom_out=examples\output`
    

Fow Linux

  1. Set the interpreter to the plugin by adding your Python 2.x path '/usr/bin/env python' in the begining of the tsPlugin.py file #!/usr/bin/env python

  2. Now, generate your TypeScript code using,

    $ protoc -I <Project_Path> -I <Proto_File_Directory_Path> <Proto_Files_Path> --plugin=protoc-gen-custom=<Plugin_Path> --custom_out=<Output_Directory_Path>
    

    Like:

    $ protoc -I . -I examples\test examples/test/test.proto --plugin=protoc-gen-custom=tsPlugin.py --custom_out=examples/output
    

    or

    Use the generator.sh script to compile all the proto files in a directory

Contributing

Changes and improvements are more than welcome! Feel free to fork and open a pull request. And Please make your changes in a specific branch and request to pull into master! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.

License

Protocol Buffer to TypeScript Plugin is licensed under the MIT license.

protocol-buffer-to-typescript-plugin's People

Contributors

shivam010 avatar zerosh010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shivtelo sbv3597

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.