This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-nodejs.git
The following commit(s) were added to refs/heads/master by this push:
new aa7013f bugfix: fix tsc error of dist lib (#24)
aa7013f is described below
commit aa7013f43d0dc29eccd83c555b6f2b2f3f4f1d9a
Author: Zhenxu Ke <[email protected]>
AuthorDate: Fri Jan 15 21:53:55 2021 +0800
bugfix: fix tsc error of dist lib (#24)
---
.github/workflows/test.yaml | 15 ++++++++++++-
package.json | 2 +-
scripts/protoc.sh | 17 +++++++-------
src/trace/context/CarrierItem.ts | 7 +++---
scripts/protoc.sh => tests/build/Dockerfile | 26 +++++++---------------
.../context/CarrierItem.ts => tests/build/main.ts | 9 ++++----
tests/build/package.json | 16 +++++++++++++
tests/build/tsconfig.json | 14 ++++++++++++
8 files changed, 71 insertions(+), 35 deletions(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index f210af9..9d48727 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -24,7 +24,7 @@ on:
- master
jobs:
- Build:
+ TestPlugins:
runs-on: ubuntu-18.04
timeout-minutes: 30
strategy:
@@ -54,3 +54,16 @@ jobs:
npm i
npm run lint
npm run test
+
+ TestLib:
+ runs-on: ubuntu-18.04
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+
+ - name: Test Dist Lib
+ run: |
+ docker build . -f tests/build/Dockerfile -t skywalking-nodejs:${{
github.sha }}
+ docker run --rm skywalking-nodejs:${{ github.sha }}
diff --git a/package.json b/package.json
index 4409c2b..f6c9d31 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"scripts": {
"prepare": "npm run generate-source",
"generate-source": "scripts/protoc.sh",
- "build": "tsc --build src",
+ "build": "npm run clean && npm run prepare && tsc --build src &&
OUT_DIR=lib/proto/ scripts/protoc.sh",
"lint": "tslint -p src/tsconfig.json src/**/*.ts",
"test": "DEBUG=testcontainers* jest",
"format": "prettier --write \"src/**/*.ts\"",
diff --git a/scripts/protoc.sh b/scripts/protoc.sh
index 8e7679d..992d6c6 100755
--- a/scripts/protoc.sh
+++ b/scripts/protoc.sh
@@ -16,24 +16,25 @@
# limitations under the License.
#
-ROOT_DIR="$(dirname "$0")"/..
+ROOT_DIR=$(cd "$(dirname "$0")"/..; pwd)
+OUT_DIR="$ROOT_DIR"/${OUT_DIR:-src/proto/}
-(rm -rf src/proto || true) && (mkdir -p src/proto || true) && (rm -rf
src/proto || true) && (mkdir -p src/proto || true)
+mkdir -p $OUT_DIR || true
cd "${ROOT_DIR}"/protocol || exit
-PROTOC_GEN_TS_PATH="../${ROOT_DIR}/node_modules/.bin/protoc-gen-ts"
-PROTOC_PLUGIN="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc_plugin"
-PROTOC="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc"
+PROTOC_GEN_TS_PATH="${ROOT_DIR}/node_modules/.bin/protoc-gen-ts"
+PROTOC_PLUGIN="${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc_plugin"
+PROTOC="${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc"
${PROTOC} \
- --js_out=import_style=commonjs,binary:../src/proto/ \
- --grpc_out=../src/proto/ \
+ --js_out=import_style=commonjs,binary:$OUT_DIR \
+ --grpc_out=$OUT_DIR \
--plugin=protoc-gen-grpc="${PROTOC_PLUGIN}" \
**/*.proto
${PROTOC} \
--plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \
- --ts_out=../src/proto/ \
+ --ts_out=$OUT_DIR \
**/*.proto
diff --git a/src/trace/context/CarrierItem.ts b/src/trace/context/CarrierItem.ts
index 99b2fa2..b26ae5a 100644
--- a/src/trace/context/CarrierItem.ts
+++ b/src/trace/context/CarrierItem.ts
@@ -17,8 +17,9 @@
*
*/
-export class CarrierItem {
- value!: string;
+export abstract class CarrierItem {
+ abstract get value(): string;
+ abstract set value(val: string);
- constructor(public key: string) {}
+ protected constructor(public key: string) {}
}
diff --git a/scripts/protoc.sh b/tests/build/Dockerfile
old mode 100755
new mode 100644
similarity index 52%
copy from scripts/protoc.sh
copy to tests/build/Dockerfile
index 8e7679d..7c0722f
--- a/scripts/protoc.sh
+++ b/tests/build/Dockerfile
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
@@ -14,26 +12,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
-ROOT_DIR="$(dirname "$0")"/..
+FROM node:12
-(rm -rf src/proto || true) && (mkdir -p src/proto || true) && (rm -rf
src/proto || true) && (mkdir -p src/proto || true)
+WORKDIR /app
-cd "${ROOT_DIR}"/protocol || exit
+ADD . /app
-PROTOC_GEN_TS_PATH="../${ROOT_DIR}/node_modules/.bin/protoc-gen-ts"
-PROTOC_PLUGIN="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc_plugin"
-PROTOC="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc"
+RUN npm install request && npm install && npm run build
-${PROTOC} \
- --js_out=import_style=commonjs,binary:../src/proto/ \
- --grpc_out=../src/proto/ \
- --plugin=protoc-gen-grpc="${PROTOC_PLUGIN}" \
- **/*.proto
+ADD tests/build/main.ts /test/main.ts
+ADD tests/build/package.json /test/package.json
-${PROTOC} \
- --plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \
- --ts_out=../src/proto/ \
- **/*.proto
+WORKDIR /test
+RUN npm install && npm install /app && npm run build
diff --git a/src/trace/context/CarrierItem.ts b/tests/build/main.ts
similarity index 88%
copy from src/trace/context/CarrierItem.ts
copy to tests/build/main.ts
index 99b2fa2..af97cc8 100644
--- a/src/trace/context/CarrierItem.ts
+++ b/tests/build/main.ts
@@ -17,8 +17,9 @@
*
*/
-export class CarrierItem {
- value!: string;
+import agent from 'skywalking-backend-js';
- constructor(public key: string) {}
-}
+agent.start({
+ serviceName: 'server',
+ maxBufferSize: 1000,
+});
diff --git a/tests/build/package.json b/tests/build/package.json
new file mode 100644
index 0000000..e11b67f
--- /dev/null
+++ b/tests/build/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "test",
+ "version": "1.0.0",
+ "scripts": {
+ "build": "tsc main.ts"
+ },
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "tslib": "^2.1.0"
+ },
+ "devDependencies": {
+ "@types/node": "^14.14.21",
+ "typescript": "^4.1.3"
+ }
+}
diff --git a/tests/build/tsconfig.json b/tests/build/tsconfig.json
new file mode 100644
index 0000000..0a402e8
--- /dev/null
+++ b/tests/build/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "rootDir": ".",
+ "baseUrl": ".",
+ "outDir": ".",
+ "resolveJsonModule": true,
+ "composite": true,
+ "esModuleInterop": true
+ },
+ "files": [
+ "package.json"
+ ]
+}