forked from gitpod-io/gitpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[supervisor] Provide TypeScript clients for gRPC, gRPC-web and REST
- Loading branch information
Christian Weichel
committed
Sep 24, 2020
1 parent
9cb4125
commit 282346e
Showing
38 changed files
with
330 additions
and
7,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
packages: | ||
- name: proto | ||
type: generic | ||
srcs: | ||
- "*.proto" | ||
config: | ||
commands: | ||
- ["git", "clone", "https://github.com/grpc-ecosystem/grpc-gateway"] | ||
- ["mv", "grpc-gateway/third_party", "third_party"] | ||
- ["rm", "-r", "grpc-gateway"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,6 @@ PROTOC_INCLUDE="-I. -I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_ | |
|
||
GO111MODULE=on go get github.com/golang/protobuf/[email protected] | ||
GO111MODULE=off go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway | ||
GO111MODULE=off go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
protoc $PROTOC_INCLUDE --go_out=plugins=grpc:go *.proto | ||
protoc $PROTOC_INCLUDE --grpc-gateway_out=allow_colon_final_segments=true,logtostderr=true,paths=source_relative:go *.proto | ||
|
||
# GO111MODULE=on go get github.com/golang/mock/mockgen@latest | ||
# cd go | ||
# # source mode does not always work for gRPC: see https://github.com/golang/mock/pull/163 | ||
# mockgen -package mock github.com/gitpod-io/gitpod/ws-manager/api WorkspaceManagerClient,WorkspaceManager_SubscribeClient > mock/mock.go | ||
# cd .. | ||
|
||
# generate typescript client | ||
cd typescript | ||
export PATH=$PWD/../../../node_modules/.bin:$PATH | ||
protoc $PROTOC_INCLUDE --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` --js_out=import_style=commonjs,binary:src --grpc_out=grpc_js:src -I.. ../*.proto | ||
protoc $PROTOC_INCLUDE --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=grpc_js:src -I.. ../*.proto | ||
|
||
## HACK: we don't care for the API annotations in the generated Javascript/Typescript code. | ||
## Rather than trying to make the dependencies work, we just remove the respective code. | ||
sed -i '/google_api_annotations_pb/d' src/*.js | ||
|
||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@gitpod/supervisor-api-grpc", | ||
"version": "0.1.5", | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"prepare": "mkdir -p src; protoc -I ${PROTOLOC:-$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway}/third_party/googleapis -I /usr/lib/protoc/include --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` --js_out=import_style=commonjs,binary:src --grpc_out=grpc_js:src -I${PROTOLOC:-..} ${PROTOLOC:-..}/*.proto && protoc -I ${PROTOLOC:-$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway}/third_party/googleapis -I /usr/lib/protoc/include --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=grpc_js:src -I${PROTOLOC:-..} ${PROTOLOC:-..}/*.proto && sed -i '/google_api_annotations_pb/d' src/*.js", | ||
"build": "mkdir -p lib; tsc && cp -f src/*.js src/*d.ts lib" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"dependencies": { | ||
"@grpc/grpc-js": "^1.1.5", | ||
"google-protobuf": "^3.8.0-rc.1" | ||
}, | ||
"devDependencies": { | ||
"@types/google-protobuf": "^3.2.7", | ||
"grpc-tools": "^1.7.2", | ||
"grpc_tools_node_protoc_ts": "^2.5.0", | ||
"typescript-formatter": "^7.2.2" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*_pb.*ts | ||
*_pb.*js | ||
*_pb_service.*js | ||
*_pb_service.*ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
packages: | ||
- name: lib | ||
type: yarn | ||
srcs: | ||
- package.json | ||
deps: | ||
- components/supervisor-api:proto | ||
env: | ||
- PROTOLOC=components-supervisor-api--proto | ||
config: | ||
packaging: library | ||
dontTest: true | ||
commands: | ||
build: ["yarn", "build"] | ||
yarnLock: ${coreYarnLockBase}/../yarn.lock | ||
tsconfig: tsconfig.json | ||
- name: publish | ||
type: generic | ||
deps: | ||
- :lib | ||
- components/gitpod-protocol:scripts | ||
argdeps: | ||
- version | ||
config: | ||
commands: | ||
- ["node", "components-gitpod-protocol--scripts/publish.js", "${version}", "components-supervisor-api-typescript-grpcweb--lib/package"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@gitpod/supervisor-api-grpcweb", | ||
"version": "0.1.5", | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"prepare": "mkdir -p src; protoc -I ${PROTOLOC:-$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway}/third_party/googleapis -I /usr/lib/protoc/include --plugin=\"protoc-gen-ts=`which protoc-gen-ts`\" --js_out=\"import_style=commonjs,binary:src\" --ts_out=\"service=grpc-web:src\" -I${PROTOLOC:-..} ${PROTOLOC:-..}/*.proto", | ||
"build": "mkdir -p lib; tsc && cp -f src/*.js src/*d.ts lib", | ||
"full-build": "yarn prepare && yarn build" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"ts-protoc-gen": "^0.13.0" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
components/supervisor-api/typescript-grpcweb/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"experimentalDecorators": true, | ||
"outDir": "lib", | ||
"lib": [ | ||
"es6", | ||
"esnext.asynciterable" | ||
], | ||
"strict": true, | ||
"noEmitOnError": false, | ||
"noUnusedLocals": true, | ||
"emitDecoratorMetadata": true, | ||
"strictPropertyInitialization": false, | ||
"downlevelIteration": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"target": "es5", | ||
"jsx": "react", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
packages: | ||
- name: lib | ||
type: yarn | ||
srcs: | ||
- package.json | ||
deps: | ||
- components/supervisor-api:proto | ||
env: | ||
- PROTOLOC=components-supervisor-api--proto | ||
config: | ||
packaging: library | ||
dontTest: true | ||
commands: | ||
build: ["yarn", "build"] | ||
yarnLock: ${coreYarnLockBase}/../yarn.lock | ||
tsconfig: tsconfig.json | ||
- name: publish | ||
type: generic | ||
deps: | ||
- :lib | ||
- components/gitpod-protocol:scripts | ||
argdeps: | ||
- version | ||
config: | ||
commands: | ||
- ["node", "components-gitpod-protocol--scripts/publish.js", "${version}", "components-supervisor-api-typescript-rest--lib/package"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@gitpod/supervisor-api-rest", | ||
"version": "0.1.5", | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"build": "mkdir -p lib; protoc -I ${PROTOLOC:-$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway}/third_party/googleapis -I /usr/lib/protoc/include --swagger_out=logtostderr=true:. -I${PROTOLOC:-..} ${PROTOLOC:-..}/*.proto && mv *.swagger.json lib && for f in $(ls lib/*.swagger.json); do yarn dtsgen -o ${f%.swagger.json}.dt.ts $f; done" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"dtsgenerator": "^3.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"experimentalDecorators": true, | ||
"outDir": "lib", | ||
"lib": [ | ||
"es6", | ||
"esnext.asynciterable" | ||
], | ||
"strict": true, | ||
"noEmitOnError": false, | ||
"noUnusedLocals": true, | ||
"emitDecoratorMetadata": true, | ||
"strictPropertyInitialization": false, | ||
"downlevelIteration": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"target": "es5", | ||
"jsx": "react", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
components/supervisor-api/typescript/src/backup_grpc_pb.d.ts
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
components/supervisor-api/typescript/src/backup_grpc_pb.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.