Add node.js gen scripts

This commit is contained in:
Nex
2020-03-14 21:48:59 +08:00
parent cfe8dd42e3
commit 45081f759e
7 changed files with 36 additions and 6 deletions

19
scripts/gen-go.bat Normal file
View File

@@ -0,0 +1,19 @@
@echo off
cd /d "%~dp0.."
set dir=.\gen\go
set exe=protoc
set gen=protoc-gen-go
if defined GOPATH set PATH=%PATH%;%GOPATH%\bin
where /q %exe% || echo missing %exe% && exit /B
where /q %gen% || echo missing %gen% && exit /B
if not exist %dir% mkdir %dir%
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/common.proto
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/error_details.proto
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/node.proto
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/ledger.proto
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/query.proto
echo all done

9
scripts/gen-go.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
cd "${0%/*}/.."
dir=gen/nodejs
mkdir -p $dir
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/common.proto
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/error_details.proto
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/node.proto
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/ledger.proto
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/query.proto

10
scripts/gen-node.js.sh Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
cd "${0%/*}/.."
dir=gen/nodejs
plugin=`which grpc_tools_node_protoc_plugin`
mkdir -p $dir
%exe% --js_out=import_style=commonjs,binary:%dir --grpc_out=%dir --plugin=protoc-gen-grpc=$plugin bdledger/api/common.proto
%exe% --js_out=import_style=commonjs,binary:%dir --grpc_out=%dir --plugin=protoc-gen-grpc=$plugin bdledger/api/error_details.proto
%exe% --js_out=import_style=commonjs,binary:%dir --grpc_out=%dir --plugin=protoc-gen-grpc=$plugin bdledger/api/node.proto
%exe% --js_out=import_style=commonjs,binary:%dir --grpc_out=%dir --plugin=protoc-gen-grpc=$plugin bdledger/api/ledger.proto
%exe% --js_out=import_style=commonjs,binary:%dir --grpc_out=%dir --plugin=protoc-gen-grpc=$plugin bdledger/api/query.proto

16
scripts/gen-nodejs.bat Normal file
View File

@@ -0,0 +1,16 @@
@echo off
cd /d "%~dp0.."
set dir=.\gen\nodejs
set exe=grpc_tools_node_protoc
for /f %%i in ('where grpc_tools_node_protoc_plugin') do set plugin=%%i
where /q %exe% || echo missing %exe% && exit /B
if not exist %dir% mkdir %dir%
call %exe% --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%plugin% bdledger/api/common.proto
call %exe% --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%plugin% bdledger/api/error_details.proto
call %exe% --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%plugin% bdledger/api/node.proto
call %exe% --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%plugin% bdledger/api/ledger.proto
call %exe% --js_out=import_style=commonjs,binary:%dir% --grpc_out=%dir% --plugin=protoc-gen-grpc=%plugin% bdledger/api/query.proto
echo all done

17
scripts/gen-web.bat Normal file
View File

@@ -0,0 +1,17 @@
@echo off
cd /d "%~dp0.."
set dir=.\gen\web
set exe=protoc
set gen=protoc-protoc-gen-grpc-web
where /q %exe% || echo missing %exe% && exit /B
where /q %gen% || echo missing %gen% && exit /B
if not exist %dir% mkdir %dir%
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/common.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/error_details.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/node.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/ledger.proto
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/query.proto
echo all done

9
scripts/gen-web.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
cd "${0%/*}/.."
dir=gen/web
mkdir -p $dir
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/common.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/error_details.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/node.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/ledger.proto
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/query.proto