Add node.js gen scripts
This commit is contained in:
parent
cfe8dd42e3
commit
45081f759e
@ -12,6 +12,10 @@
|
|||||||
go get -u google.golang.org/grpc
|
go get -u google.golang.org/grpc
|
||||||
go get -u github.com/golang/protobuf/protoc-gen-go
|
go get -u github.com/golang/protobuf/protoc-gen-go
|
||||||
```
|
```
|
||||||
|
- Node.js
|
||||||
|
```bash
|
||||||
|
npm install -g grpc-tools
|
||||||
|
```
|
||||||
- Web
|
- Web
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/grpc/grpc-web
|
git clone https://github.com/grpc/grpc-web
|
||||||
@ -27,4 +31,4 @@
|
|||||||
### 编译
|
### 编译
|
||||||
|
|
||||||
- 在本项目打开控制台,或者切换工作路径到本项目
|
- 在本项目打开控制台,或者切换工作路径到本项目
|
||||||
- 执行 `./gen-{{platform}}`
|
- 执行 `./scripts/gen-{{platform}}`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0.."
|
||||||
set dir=.\gen\go
|
set dir=.\gen\go
|
||||||
set exe=protoc
|
set exe=protoc
|
||||||
set gen=protoc-gen-go
|
set gen=protoc-gen-go
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cd "${0%/*}"
|
cd "${0%/*}/.."
|
||||||
dir=gen/go
|
dir=gen/nodejs
|
||||||
mkdir -p $dir
|
mkdir -p $dir
|
||||||
protoc -I . --go_out=plugins=grpc:$dir bdledger/api/common.proto
|
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/error_details.proto
|
10
scripts/gen-node.js.sh
Normal file
10
scripts/gen-node.js.sh
Normal 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
16
scripts/gen-nodejs.bat
Normal 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
|
@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0.."
|
||||||
set dir=.\gen\web
|
set dir=.\gen\web
|
||||||
set exe=protoc
|
set exe=protoc
|
||||||
set gen=protoc-protoc-gen-grpc-web
|
set gen=protoc-protoc-gen-grpc-web
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cd "${0%/*}"
|
cd "${0%/*}/.."
|
||||||
dir=gen/web
|
dir=gen/web
|
||||||
mkdir -p $dir
|
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/common.proto
|
Loading…
Reference in New Issue
Block a user