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
commit fa3a2f507d26b2f021d10948a7d995061a6f404b Author: kezhenxu94 <kezhenx...@163.com> AuthorDate: Tue Jun 23 15:55:54 2020 +0800 Put src into individual module to allow importing from package.json --- package.json | 3 +-- scripts/protoc.sh | 2 -- src/core/PluginInstaller.ts | 13 +++++++------ tsconfig.json => src/tsconfig.json | 16 ++++++++++++---- tsconfig.json | 23 +++++++---------------- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index af44970..99293e3 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,11 @@ "scripts": { "prepare": "npm run generate-source", "generate-source": "scripts/protoc.sh", - "build": "tsc", + "build": "tsc --build src", "lint": "tslint -p tsconfig.json", "fix-lint": "tslint --fix -p tsconfig.json", "test": "echo \"Error: no test specified\" && exit 1", "format": "prettier --write \"src/**/*.ts\"", - "dev": "node --experimental-worker node_modules/ts-node/dist/bin -r tsconfig-paths/register test/dev-test.ts", "clean": "(rm -rf src/proto || true) && (rm -rf src/proto || true)" }, "files": [ diff --git a/scripts/protoc.sh b/scripts/protoc.sh index ec20c72..47ae6bc 100755 --- a/scripts/protoc.sh +++ b/scripts/protoc.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -set -x - ROOT_DIR="$(dirname "$0")"/.. (rm -rf src/proto || true) && (mkdir -p src/proto || true) && (rm -rf src/proto || true) && (mkdir -p src/proto || true) diff --git a/src/core/PluginInstaller.ts b/src/core/PluginInstaller.ts index ea7cf66..301849b 100644 --- a/src/core/PluginInstaller.ts +++ b/src/core/PluginInstaller.ts @@ -32,12 +32,13 @@ class PluginInstaller { } install(): void { - const files = fs.readdirSync(this.pluginDir); - files.forEach(file => { - const plugin = require(path.join(this.pluginDir, file)).default as SwPlugin; - logger.info(`Installing plugin ${plugin.module} ${plugin.versions}`); - plugin.install(); - }); + fs.readdirSync(this.pluginDir) + .filter((file) => !file.endsWith('.d.ts')) + .forEach((file) => { + const plugin = require(path.join(this.pluginDir, file)).default as SwPlugin; + logger.info(`Installing plugin ${plugin.module} ${plugin.versions}`); + plugin.install(); + }); } } diff --git a/tsconfig.json b/src/tsconfig.json similarity index 63% copy from tsconfig.json copy to src/tsconfig.json index 9c2237e..fe65fba 100644 --- a/tsconfig.json +++ b/src/tsconfig.json @@ -1,19 +1,27 @@ { "compilerOptions": { "target": "es5", - "module": "esnext", + "module": "commonjs", "strict": true, "importHelpers": true, "moduleResolution": "node", "experimentalDecorators": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "outDir": "./lib", + "outDir": "../lib", + "rootDir": ".", + "baseUrl": ".", "resolveJsonModule": true, - "declaration": true + "declaration": true, + "allowJs": true }, + "references": [ + { + "path": ".." + } + ], "include": [ - "src/**/*" + "**/*" ], "exclude": [ "node_modules", diff --git a/tsconfig.json b/tsconfig.json index 9c2237e..0afd6e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,13 @@ { "compilerOptions": { - "target": "es5", - "module": "esnext", - "strict": true, - "importHelpers": true, - "moduleResolution": "node", - "experimentalDecorators": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "./lib", + "module": "commonjs", + "rootDir": ".", + "baseUrl": ".", + "outDir": ".", "resolveJsonModule": true, - "declaration": true + "composite": true }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "**/__tests__/*" + "files": [ + "package.json" ] }