Skip to content

Commit 483ef25

Browse files
committed
Update examples. Fixes #18
1 parent 6787fe3 commit 483ef25

File tree

18 files changed

+4053
-4498
lines changed

18 files changed

+4053
-4498
lines changed

examples/gradle-ts-protoc-gen/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Install dependencies:
2020

2121
```sh
2222
npm install
23+
24+
# Apple M1 users should install for x64 due to grpc-tools not supporting arm64
25+
npm i --target_arch=x64
2326
```
2427

2528
Use Gradle & [`ts-protoc-gen`](https://www.npmjs.com/package/ts-protoc-gen) to generate the TypeScript files:

examples/gradle-ts-protoc-gen/build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11

22
plugins {
33
id 'java'
4-
id 'com.google.protobuf' version '0.8.13'
4+
id 'com.google.protobuf' version '0.8.16'
55
id 'com.github.jlouns.cpe' version '0.5.0'
66
}
77

8-
project.ext.set('protobufVersion', '3.12.0')
8+
project.ext.set('protobufVersion', '3.16.0')
99
project.ext.set('protocVersion', project.protobufVersion)
1010

1111
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
1212

1313
repositories {
14-
jcenter()
1514
mavenCentral()
1615
}
1716

@@ -25,7 +24,12 @@ sourceSets {
2524

2625
protobuf {
2726
protoc {
28-
artifact = "com.google.protobuf:protoc:${protocVersion}"
27+
if (osdetector.os == 'osx') {
28+
// Required for arm64 support on MacOS
29+
artifact = "com.google.protobuf:protoc:${protocVersion}:osx-x86_64"
30+
} else {
31+
artifact = "com.google.protobuf:protoc:${protocVersion}"
32+
}
2933
}
3034
plugins {
3135
grpc {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

examples/gradle-ts-protoc-gen/package-lock.json

Lines changed: 587 additions & 939 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/gradle-ts-protoc-gen/package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@
2222
"author": "",
2323
"license": "ISC",
2424
"dependencies": {
25-
"@grpc/grpc-js": "^1.2.2",
26-
"google-protobuf": "^3.14.0"
25+
"@grpc/grpc-js": "^1.3.1",
26+
"google-protobuf": "^3.17.0"
2727
},
2828
"devDependencies": {
2929
"@tsconfig/node12": "^1.0.7",
30-
"@types/google-protobuf": "^3.7.4",
31-
"@types/node": "^14.14.14",
32-
"@typescript-eslint/eslint-plugin": "^4.10.0",
33-
"@typescript-eslint/parser": "^4.10.0",
34-
"eslint": "^7.15.0",
35-
"eslint-config-prettier": "^7.0.0",
30+
"@types/google-protobuf": "^3.15.2",
31+
"@types/node": "^15.0.3",
32+
"@typescript-eslint/eslint-plugin": "^4.23.0",
33+
"@typescript-eslint/parser": "^4.23.0",
34+
"eslint": "^7.26.0",
35+
"eslint-config-prettier": "^8.3.0",
3636
"eslint-plugin-node": "^11.1.0",
37-
"eslint-plugin-prettier": "^3.3.0",
38-
"grpc-tools": "^1.10.0",
39-
"prettier": "^2.2.1",
40-
"ts-protoc-gen": "^0.14.0",
41-
"typescript": "^4.1.3"
37+
"eslint-plugin-prettier": "^3.4.0",
38+
"grpc-tools": "^1.11.1",
39+
"prettier": "^2.3.0",
40+
"ts-protoc-gen": "^0.15.0",
41+
"typescript": "^4.2.4"
4242
},
4343
"eslintConfig": {
4444
"ignorePatterns": [
@@ -57,7 +57,6 @@
5757
},
5858
"extends": [
5959
"plugin:@typescript-eslint/recommended",
60-
"prettier/@typescript-eslint",
6160
"plugin:prettier/recommended"
6261
]
6362
},

examples/gradle-ts-protoc-gen/proto/example_pb.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
/**
33
* @fileoverview
44
* @enhanceable
5+
* @suppress {missingRequire} reports error on implicit type usages.
56
* @suppress {messageConventions} JS Compiler reports an error if a variable or
67
* field starts with 'MSG_' and isn't a translatable message.
78
* @public
89
*/
910
// GENERATED CODE -- DO NOT EDIT!
11+
/* eslint-disable */
12+
// @ts-nocheck
1013

1114
var jspb = require('google-protobuf');
1215
var goog = jspb;

examples/grpc-proto-loader/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Install dependencies:
1919

2020
```sh
2121
npm install
22+
23+
# Apple M1 users should install for x64 due to grpc-tools not supporting arm64
24+
npm i --target_arch=x64
2225
```
2326

2427
Use [`@grpc/proto-loader`](https://www.npmjs.com/package/@grpc/proto-loader) to generate the TypeScript files:

examples/grpc-proto-loader/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { ServerMessage } from './proto/example_package/ServerMessage';
55

66
const host = '0.0.0.0:9090';
77
const packageDefinition = protoLoader.loadSync('./proto/example.proto');
8-
const proto = (grpc.loadPackageDefinition(
8+
const proto = grpc.loadPackageDefinition(
99
packageDefinition
10-
) as unknown) as ProtoGrpcType;
10+
) as unknown as ProtoGrpcType;
1111

1212
const client = new proto.example_package.Example(
1313
host,

0 commit comments

Comments
 (0)