This program makes developer easily to sync and generate code in any language based on proto
from git remote repo or defined in local directory through configuration yaml file
brew tap louishuyng/sync-rpc-proto && brew install sync-proto
First you need to define protodep.yaml
file. See instruction below
- Running with
protodep.yaml
defined in current directory that script execution
sync-proto
- Running with
yaml file
defined in other directory that script execution
sync-proto -f other_dirctory/custom.yaml
- Running with mode
local
(the default mode isremote
)
sync-proto -m local
source: grpc-proto-repo
branch: main
outpb: app/grpc/pb
outdir: app/grpc/rpc_pb
token_key: GH_PROTO_REPO_TOKEN
dependencies:
- auth/jwt
- user/login_signup
command: python -m grpc_tools.protoc -I./$outpb --python_out=./$outdir --grpc_python_out=./$outdir $dependency.proto
source
The github remote url that including your proto files
branch
The branch you want to download proto and sync (for best practice branch
can be use to separate environment)
outpb
The directory proto will be downloaded from source
outdir
The directory code will be generate based on proto after running script
token_key
The github token key set in (.env
file or set as environment variable
) get based on this instruction
dependencies
The list proto you want to sync from source
-
In remote git we have folder like below
├── auth │ ├── jwt.proto ├── user │ ├── login_signup.proto
-
Then if we want to sync jwt proto and login_signup.proto we can define the array value like below in configuration file
dependencies: - auth/jwt - user/login_signup
command
The command to generate a code it be differently in each language.
In command script we can use $outpb
$outdir
and $dependency
to reflect with the key already defined in configuration file.
Based on above configuration we will replace the value like below:
$outpb
=>app/grpc/pb
$outpb
=>app/grpc/pb
$dependency
=>auth/jwt
anduser/login_signup
in each iteration
- We can ignore keys
source
,branch
andtoken_key
- Remove
command
and addlanguage
key to detect context running script
For support, email [email protected]