-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No service server interface created #38
Comments
I guess the // package:
// file: audit.proto
/* tslint:disable */
import * as grpc from "grpc";
import * as audit_pb from "./audit_pb";
interface IAuditServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
createAuditSource: IAuditServiceService_ICreateAuditSource;
}
interface IAuditServiceService_ICreateAuditSource extends grpc.MethodDefinition<audit_pb.CreateAuditSourceRequest, audit_pb.CreateAuditSourceResponse> {
path: string; // "/.AuditService/CreateAuditSource"
requestStream: boolean; // false
responseStream: boolean; // false
requestSerialize: grpc.serialize<audit_pb.CreateAuditSourceRequest>;
requestDeserialize: grpc.deserialize<audit_pb.CreateAuditSourceRequest>;
responseSerialize: grpc.serialize<audit_pb.CreateAuditSourceResponse>;
responseDeserialize: grpc.deserialize<audit_pb.CreateAuditSourceResponse>;
}
export const AuditServiceService: IAuditServiceService;
export interface IAuditServiceServer {
createAuditSource: grpc.handleUnaryCall<audit_pb.CreateAuditSourceRequest, audit_pb.CreateAuditSourceResponse>;
}
export interface IAuditServiceClient {
createAuditSource(request: audit_pb.CreateAuditSourceRequest, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
createAuditSource(request: audit_pb.CreateAuditSourceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
createAuditSource(request: audit_pb.CreateAuditSourceRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
}
export class AuditServiceClient extends grpc.Client implements IAuditServiceClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public createAuditSource(request: audit_pb.CreateAuditSourceRequest, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
public createAuditSource(request: audit_pb.CreateAuditSourceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
public createAuditSource(request: audit_pb.CreateAuditSourceRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: audit_pb.CreateAuditSourceResponse) => void): grpc.ClientUnaryCall;
} |
@agreatfool It only seems to be generating the |
I saw you use Try grpc_tools_node_protoc \
--plugin=protoc-gen-ts=../bin/protoc-gen-ts \
--ts_out=${PROTO_DEST} \
-I ./proto \
proto/*.proto |
@agreatfool This is the command I'm using:
It's not generating any |
Sample bash command you given:
=> try this:
protoc => grpc_tools_node_protoc |
I believe these commands are the same. Now I am getting the |
It looks the files are generating now that I'm using |
Cool~ |
Very odd... now it's not working again. I'm also having some trouble compiling
It works in one project, but not a project that's essentially a clone. I tried installing my dependencies with a clean {
"name": "[redacted]",
"version": "0.0.1",
"private": true,
"scripts": {
"compile": "./bin/compile.sh"
},
"dependencies": {
"typescript": "^3.3.3"
},
"devDependencies": {
"@types/google-protobuf": "^3.2.7",
"@types/node": "^11.9.4",
"google-protobuf": "^3.6.0",
"grpc": "^1.9.0",
"grpc-tools": "^1.6.6",
"grpc_tools_node_protoc_ts": "^2.5.0",
"nodemon": "^1.18.10",
"protobufjs": "^6.8.8",
"ts-node": "^8.0.2",
"ts-protoc-gen": "^0.9.0"
}
} |
That's a bit hard to help. I think you could clone Figure out issues by isolation. |
I've been trying to isolate the issue by using the Here is my FROM node:11
ADD run.sh /
RUN chmod +x /run.sh
ENTRYPOINT ["/run.sh"] And the #!/bin/bash
git clone https://github.com/agreatfool/grpc_tools_node_protoc_ts.git /tmp/grpc
cd /tmp/grpc/examples
npm i -g node-pre-gyp && npm i -g grpc-tools@1.6.6 && npm i && npm run build I wasn't able to install the dependencies properly on any version of Node 8-11. Could this be because of the older version of grpc-tools that's being used? This is the error output consistent for all versions:
|
Several issues: npm permission Read more: grpc/grpc-node#604 grpc missing typescript missing try this: FROM node:8.4.0
RUN apt-get update && \
apt-get -y install git unzip build-essential autoconf libtool
RUN git clone https://github.com/google/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && \
make && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf
RUN git clone https://github.com/agreatfool/grpc_tools_node_protoc_ts.git grpc_protoc && \
cd grpc_protoc && \
npm i -g grpc-tools@1.6.6 --unsafe-perm && \
npm i -g typescript --unsafe-perm && \
npm i --unsafe-perm && \
./bash/build.sh |
Dockerfile: FROM node:8.4.0
RUN apt-get update && \
apt-get -y install git unzip build-essential autoconf libtool
RUN git clone https://github.com/google/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && \
make -j8 && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf
RUN git clone https://github.com/agreatfool/grpc_tools_node_protoc_ts.git grpc_protoc && \
cd grpc_protoc/examples && \
npm i -g grpc-tools@1.6.6 typescript@3.3 --unsafe-perm && \
npm i --unsafe-perm ts-protoc-gen && \
npm i --unsafe-perm && \
./bash/build.sh Error Output
|
I did some research and found the reason. I just separated the building process into three parts: First FROM node:8.4.0
RUN apt-get update && \
apt-get -y install git unzip build-essential autoconf libtool
RUN git clone https://github.com/google/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && \
make -j8 && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf $ docker build -t node_protobuf:0.1 .
...
make[1]: Leaving directory '/protobuf/src'
Removing intermediate container fc421c4bc68c
---> 4fefe33499e4
Successfully built 4fefe33499e4
Successfully tagged node_protobuf:0.1 Second FROM node_protobuf:0.1
RUN git clone https://github.com/agreatfool/grpc_tools_node_protoc_ts.git grpc_protoc && \
cd grpc_protoc/examples && \
npm i -g grpc-tools@1.6.6 --unsafe-perm && \
npm i -g --unsafe-perm typescript@3.3 && \
npm i --unsafe-perm $ docker build -t node_protoc_built:0.1 .
...
npm WARN example@1.0.0 No repository field.
added 211 packages in 451.898s
npm info ok
Removing intermediate container b3bcff295074
---> 29f2fa49da4b
Successfully built 29f2fa49da4b
Successfully tagged node_protoc_built:0.1 Third $ docker run --name protoc --rm -i -t node_protoc_built:0.1 /bin/bash
root@25806b55bea6:/# ls
bin boot dev etc grpc_protoc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@e3cf4ba4661b:/# cd grpc_protoc
root@e3cf4ba4661b:/# ls
LICENSE README.md bash bin build examples package-lock.json package.json src tsconfig.json tslint.json As you can see, there is no node_modules in code directory. Thus, tsc failed. |
I didn't notice you have changed the dir to 'examples', so please ignore previous comment. |
I got the issue: Since the tsc plugin command used in grpc_tools_node_protoc \
--plugin=protoc-gen-ts=../bin/protoc-gen -ts \
--ts_out=${PROTO_DEST} \
-I ./proto \
proto/*.proto Notice: And the outside plugin main npm packages not installed, so error encountered. Update: FROM node:8.4.0
RUN apt-get update && \
apt-get -y install git unzip build-essential autoconf libtool
RUN git clone https://github.com/google/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && \
make -j8 && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf
RUN git clone https://github.com/agreatfool/grpc_tools_node_protoc_ts.git grpc_protoc && \
cd grpc_protoc && \
npm i -g grpc-tools@1.6.6 --unsafe-perm && \
npm i -g --unsafe-perm typescript@3.3 && \
npm i --unsafe-perm && \
cd ./examples && \
npm i --unsafe-perm && \
./bash/build.sh I did't test the combined Dockerfile (I just tested with separated piece), you could have a try. |
@agreatfool Well I'm glad we could get a baseline docker image to work. But I'm still having issues when I install it on a fresh Linux host (I've given up on Windows at this point). I was able to run a docker image running Node 11, so I'm not sure where these issues are coming from now:
|
OK, when I use tsconfig.json: {
"compilerOptions": {
"strict": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitThis": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"target": "es2016",
"lib": [
"es5",
"es6",
"es7",
"esnext"
],
"rootDir": "lib/",
"outDir": "dist/",
"declaration": true,
"declarationDir": "dist/"
},
"exclude": [
"dist/",
"lib/**/*.d.ts"
]
} package.json: {
"private": true,
"index": "./dist/index.js",
"types": "./dist/index.ts",
"scripts": {
"compile": "./bin/compile.sh",
"postinstall": "tsc -p ."
},
"dependencies": {
"@grpc/grpc-js": "^0.3.5",
"google-protobuf": "~3.5.0",
"grpc_tools_node_protoc_ts": "^2.5.0",
"protobufjs": "^6.8.8"
},
"devDependencies": {
"@types/google-protobuf": "^3.2.7",
"@types/node": "^11.9.4",
"grpc-tools": "^1.6.6",
"shx": "^0.3.2",
"ts-node": "^8.0.2",
"typescript": "^3.3.3"
}
} tsc error:
I'll investigate more and see if I can figure out what the permissions issue is, and how we can update the readme to make this easier for new users. |
So funny enough, getting a new PC solved this issue for me. I think it may have something to do with working on the project in both Windows and Linux (WSL) and directory case sensitivity. It does not work on Windows, but I'm able to quickly switch to bash, remove node_modules and reinstall it in Linux, and then run the compiler script. bin/compile.sh #!/bin/bash
PROTO_SRC_DIR="./proto/"
PROTO_OUT_DIR="./lib/"
PROTO_FILES=$(find ${PROTO_SRC_DIR} -type f -name '*.proto' -printf ' %P')
bin_not_found() {
echo "Failed to find binary at: $1" >&2
exit 1
}
PROTO_GRPC_TS_BIN="./node_modules/.bin/grpc_tools_node_protoc"
PROTO_GRPC_TS_PLUGIN_BIN="./node_modules/.bin/grpc_tools_node_protoc_plugin"
PROTOC_GEN_TS_BIN="./node_modules/grpc_tools_node_protoc_ts/bin/protoc-gen-ts"
if ! [[ -x "$(command -v ${PROTO_GRPC_TS_BIN})" ]]; then bin_not_found "$PROTO_GRPC_TS_BIN"; fi
if ! [[ -x "$(command -v ${PROTO_GRPC_TS_PLUGIN_BIN})" ]]; then bin_not_found "$PROTO_GRPC_TS_PLUGIN_BIN"; fi
if ! [[ -x "$(command -v ${PROTOC_GEN_TS_BIN})" ]]; then bin_not_found "$PROTOC_GEN_TS_BIN"; fi
rm -r ${PROTO_OUT_DIR}/*
mkdir -p ${PROTO_OUT_DIR}
${PROTO_GRPC_TS_BIN} --grpc_out=${PROTO_OUT_DIR} \
--plugin="protoc-gen-grpc=${PROTO_GRPC_TS_PLUGIN_BIN}" \
-I ${PROTO_SRC_DIR} --js_out="import_style=commonjs,binary:${PROTO_OUT_DIR}" \
${PROTO_FILES}
${PROTO_GRPC_TS_BIN} \
--plugin="protoc-gen-ts=$PROTOC_GEN_TS_BIN" \
-I ${PROTO_SRC_DIR} --ts_out=${PROTO_OUT_DIR} \
${PROTO_FILES} package.json dependencies:
|
I have met the same problem. After some investigation, I've figured out that .bin/protoc-gen-ts was linked by two plugins: this one and the After uninstalling the other plugin, the problem solved. |
@yz-ark7 very useful information, thanks. |
I'm running the following commands, but my outputted
.d.ts
files have no server interface?Currently running:
protobuf definition:
output TS file:
The text was updated successfully, but these errors were encountered: