From e71755d99ea9e20c70001074107fdb0f0a77dc11 Mon Sep 17 00:00:00 2001 From: ruleeeer Date: Sat, 29 Jan 2022 11:18:08 +0800 Subject: [PATCH 1/5] Migrate to eslint --- .eslintrc.js | 14 + .file-headerrc | 18 + .licenserc.yaml | 2 + package-lock.json | 875 ++++++++++++++++++++++++++++++++++++++++------ package.json | 17 +- tslint.json | 14 - 6 files changed, 817 insertions(+), 123 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .file-headerrc delete mode 100644 tslint.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..f9b716c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + extends: ["eslint:recommended", "plugin:prettier/recommended"], + plugins: ["header"], + parser: "@typescript-eslint/parser", + parserOptions: { + sourceType: "module" + }, + rules: { + "header/header": [2, ".file-headerrc"] + }, + env: { + node: true + } +}; diff --git a/.file-headerrc b/.file-headerrc new file mode 100644 index 0000000..e996f71 --- /dev/null +++ b/.file-headerrc @@ -0,0 +1,18 @@ +/*! + * + * 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. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + */ diff --git a/.licenserc.yaml b/.licenserc.yaml index 05c024d..81961c3 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -33,5 +33,7 @@ header: - '.prettierrc' - 'lib' - '.husky' + - '.file-headerrc' + - '.eslintrc.js' comment: on-failure diff --git a/package-lock.json b/package-lock.json index 85543c3..b583d14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -484,6 +484,76 @@ "kuler": "^2.0.0" } }, + "@eslint/eslintrc": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.2.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "globals": { + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", + "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + } + } + }, "@grpc/grpc-js": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.4.4.tgz", @@ -505,6 +575,40 @@ "yargs": "^16.1.1" } }, + "@humanwhocodes/config-array": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", + "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + }, + "dependencies": { + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -733,6 +837,32 @@ "tar": "^6.1.11" } }, + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, "@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -1099,6 +1229,93 @@ "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", "dev": true }, + "@typescript-eslint/parser": { + "version": "5.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.10.1.tgz", + "integrity": "sha512-GReo3tjNBwR5RnRO0K2wDIDN31cM3MmDtgyQ85oAxAmC5K3j/g85IjP+cDfcqDsDDBf1HNKQAD0WqOYL8jXqUA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.10.1", + "@typescript-eslint/types": "5.10.1", + "@typescript-eslint/typescript-estree": "5.10.1", + "debug": "^4.3.2" + }, + "dependencies": { + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.10.1.tgz", + "integrity": "sha512-Lyvi559Gvpn94k7+ElXNMEnXu/iundV5uFmCUNnftbFrUbAJ1WBoaGgkbOBm07jVZa682oaBU37ao/NGGX4ZDg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.10.1", + "@typescript-eslint/visitor-keys": "5.10.1" + } + }, + "@typescript-eslint/types": { + "version": "5.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.10.1.tgz", + "integrity": "sha512-ZvxQ2QMy49bIIBpTqFiOenucqUyjTQ0WNLhBM6X1fh1NNlYAC6Kxsx8bRTY3jdYsYg44a0Z/uEgQkohbR0H87Q==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.10.1.tgz", + "integrity": "sha512-PwIGnH7jIueXv4opcwEbVGDATjGPO1dx9RkUl5LlHDSe+FXxPwFL5W/qYd5/NHr7f6lo/vvTrAzd0KlQtRusJQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.10.1", + "@typescript-eslint/visitor-keys": "5.10.1", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "dependencies": { + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.10.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.10.1.tgz", + "integrity": "sha512-NjQ0Xinhy9IL979tpoTRuLKxMc0zJC7QVSdeerXs2/QvOy2yRkzX5dRb10X5woNUdJgU8G3nYRDlI33sq1K4YQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.10.1", + "eslint-visitor-keys": "^3.0.0" + } + }, "abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", @@ -1145,6 +1362,12 @@ } } }, + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true + }, "acorn-walk": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", @@ -1187,6 +1410,18 @@ "indent-string": "^4.0.0" } }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "amqplib": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.7.1.tgz", @@ -1343,6 +1578,12 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", "dev": true }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1755,12 +1996,6 @@ "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "byline": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz", @@ -2037,12 +2272,6 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -2359,6 +2588,15 @@ "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==", "dev": true }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, "docker-compose": { "version": "0.23.13", "resolved": "https://registry.npmjs.org/docker-compose/-/docker-compose-0.23.13.tgz", @@ -2427,6 +2665,15 @@ } } }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "domexception": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", @@ -2540,12 +2787,279 @@ "source-map": "~0.6.1" } }, + "eslint": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.8.0.tgz", + "integrity": "sha512-H3KXAzQGBH1plhYS3okDix2ZthuYJlQQEGE5k0IKuEqUSiyu4AmxxlJ2MtTYeJ3xB4jDhcYCwGOg2TXYdnDXlQ==", + "dev": true, + "requires": { + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.0", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.2.0", + "espree": "^9.3.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^6.0.1", + "globals": "^13.6.0", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "regexpp": "^3.2.0", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "globals": { + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", + "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "eslint-config-prettier": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz", + "integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==", + "dev": true + }, + "eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true + }, + "eslint-plugin-prettier": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", + "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-scope": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.2.0.tgz", + "integrity": "sha512-IOzT0X126zn7ALX0dwFiUQEdsfzrm4+ISsQS8nukaJXwEyYKRSnEIIDULYg1mCtGp7UUXgfGl7BIolXREQK+XQ==", + "dev": true + }, + "espree": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.0.tgz", + "integrity": "sha512-d/5nCsb0JcqsSEeQzFZ8DH1RmxPcglRWh24EFTlUEmCKoehXGdpsx0RkHDubqUI8LSAIKMQp4r9SzQ3n+sm4HQ==", + "dev": true, + "requires": { + "acorn": "^8.7.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^3.1.0" + }, + "dependencies": { + "acorn": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "dev": true + } + } + }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + } + }, "estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", @@ -2780,6 +3294,42 @@ } } }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "fast-glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", + "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2792,6 +3342,15 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fastq": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "fb-watchman": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", @@ -2806,6 +3365,15 @@ "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.1.tgz", "integrity": "sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q==" }, + "file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "requires": { + "flat-cache": "^3.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2840,6 +3408,22 @@ "path-exists": "^4.0.0" } }, + "flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "requires": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + } + }, + "flatted": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", + "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "dev": true + }, "fn.name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", @@ -2923,6 +3507,12 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.0.tgz", @@ -3001,12 +3591,35 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, + "globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + } + }, "google-protobuf": { "version": "3.19.1", "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.19.1.tgz", @@ -3262,6 +3875,30 @@ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true }, + "ignore": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + } + } + }, "import-local": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.3.tgz", @@ -3442,6 +4079,12 @@ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -3453,6 +4096,15 @@ "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -4319,6 +4971,18 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json5": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", @@ -4594,6 +5258,12 @@ "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", "dev": true }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "log-update": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", @@ -4727,6 +5397,12 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", @@ -5383,6 +6059,15 @@ "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -5443,6 +6128,12 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", "dev": true }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, "pg": { "version": "8.7.1", "resolved": "https://registry.npmjs.org/pg/-/pg-8.7.1.tgz", @@ -5574,11 +6265,20 @@ "dev": true }, "prettier": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.0.tgz", - "integrity": "sha512-FM/zAKgWTxj40rH03VxzIPdXmj39SwSjwG0heUcNFwI+EMZJnY93yAiKXM3dObIKAM5TA88werc8T/EwhB45eg==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", + "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-format": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz", @@ -5676,6 +6376,12 @@ "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", "dev": true }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true + }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -5778,6 +6484,12 @@ "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==", "dev": true }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -5866,6 +6578,12 @@ "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rfdc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", @@ -5887,6 +6605,15 @@ "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "requires": { + "queue-microtask": "^1.2.2" + } + }, "rxjs": { "version": "7.5.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.2.tgz", @@ -6627,6 +7354,12 @@ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6774,6 +7507,12 @@ "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "throat": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", @@ -6932,95 +7671,10 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, - "tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.13.0", - "tsutils": "^2.29.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } - } - }, - "tslint-config-prettier": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", - "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", - "dev": true - }, "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -7157,6 +7811,15 @@ } } }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -7195,6 +7858,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" }, + "v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true + }, "v8-to-istanbul": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.1.2.tgz", diff --git a/package.json b/package.json index 19d8111..33e0172 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,12 @@ "main": "lib/index.js", "typings": "lib/index.d.ts", "scripts": { - "prepare": "npm run generate-source & husky install", + "postinstall": "husky install", + "prepare": "npm run generate-source", "generate-source": "scripts/protoc.sh", "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", + "lint": "eslint src/**/*.ts", + "lint:fix": "eslint --fix src/**/*.ts", "lint-staged": "lint-staged", "test": "DEBUG=testcontainers* jest", "format": "prettier --write \"src/**/*.ts\"", @@ -46,8 +48,13 @@ "@types/node": "^14.0.11", "@types/semver": "^7.2.0", "@types/uuid": "^8.0.0", + "@typescript-eslint/parser": "^5.10.1", "amqplib": "^0.7.0", "axios": "^0.21.0", + "eslint": "^8.8.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-header": "^3.1.1", + "eslint-plugin-prettier": "^4.0.0", "express": "^4.17.1", "grpc-tools": "^1.11.1", "grpc_tools_node_protoc_ts": "^5.3.0", @@ -60,13 +67,11 @@ "mysql": "^2.18.1", "mysql2": "^2.2.5", "pg": "^8.5.1", - "prettier": "^2.0.5", + "prettier": "^2.5.1", "testcontainers": "^6.2.0", "ts-jest": "^26.4.4", "ts-node": "^8.10.2", "tsconfig-paths": "^3.9.0", - "tslint": "^6.1.2", - "tslint-config-prettier": "^1.18.0", "typescript": "^3.9.5", "wait-for-expect": "^3.0.2" }, @@ -80,7 +85,7 @@ }, "lint-staged": { "*.ts": [ - "tslint -p", + "eslint", "prettier --write" ] } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index b404359..0000000 --- a/tslint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": [ - "tslint:recommended", - "tslint-config-prettier" - ], - "rules": { - "file-header": [ - true, - { - "default": "\nLicensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements. See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the \"License\"); you may not use this file except in compliance with\nthe License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" - } - ] - } -} From 4909557bb3a403e0e26151581655e518aa31aa1a Mon Sep 17 00:00:00 2001 From: ruleeeer Date: Sun, 30 Jan 2022 19:59:55 +0800 Subject: [PATCH 2/5] SkyWakingEventEmitter rename to SkyWalkingEventEmitterImpl --- src/lib/EventEmitter.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/EventEmitter.ts b/src/lib/EventEmitter.ts index c801979..4523e2a 100644 --- a/src/lib/EventEmitter.ts +++ b/src/lib/EventEmitter.ts @@ -27,7 +27,6 @@ declare interface SkyWalkingEventEmitter { on(event: 'segments-sent', listener: () => void): this; } -class SkyWalkingEventEmitter extends EventEmitter { -} +class SkyWalkingEventEmitterImpl extends EventEmitter {} -export const emitter: SkyWalkingEventEmitter = new SkyWalkingEventEmitter(); +export const emitter: SkyWalkingEventEmitterImpl = new SkyWalkingEventEmitterImpl(); From 3f4ad11b610f65e0d196632cbd9ca729cf4f3405 Mon Sep 17 00:00:00 2001 From: ruleeeer Date: Sun, 30 Jan 2022 20:00:36 +0800 Subject: [PATCH 3/5] Change eslint configuration --- .eslintrc.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index f9b716c..d6defff 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,14 @@ module.exports = { sourceType: "module" }, rules: { - "header/header": [2, ".file-headerrc"] + "header/header": ["error", ".file-headerrc"], + "no-useless-escape": "off", + "no-unused-vars": [ + "error", + // we are only using this rule to check for unused arguments since TS + // catches unused variables but not args. + { varsIgnorePattern: ".*", args: "none" } + ] }, env: { node: true From c1003e3931d84ad0a353e20d4bb4026a46deb8c8 Mon Sep 17 00:00:00 2001 From: ruleeeer Date: Sun, 30 Jan 2022 21:07:51 +0800 Subject: [PATCH 4/5] Eslint and prettier format code --- src/azure/AzureHttpTriggerPlugin.ts | 25 ++--- src/config/AgentConfig.ts | 59 ++++++++--- src/core/PluginInstaller.ts | 54 +++++----- src/core/SwPlugin.ts | 49 +++++---- src/logging/index.ts | 13 +-- src/plugins/AMQPLibPlugin.ts | 36 ++++--- src/plugins/AxiosPlugin.ts | 23 ++--- src/plugins/ExpressPlugin.ts | 18 ++-- src/plugins/HttpPlugin.ts | 61 ++++++------ src/plugins/IORedisPlugin.ts | 64 ++++++------ src/plugins/MongoDBPlugin.ts | 149 ++++++++++++++++------------ src/plugins/MongoosePlugin.ts | 27 ++--- src/plugins/MySQL2Plugin.ts | 12 +-- src/plugins/MySQLPlugin.ts | 16 +-- src/plugins/PgPlugin.ts | 37 +++---- src/trace/Component.ts | 2 +- 16 files changed, 335 insertions(+), 310 deletions(-) diff --git a/src/azure/AzureHttpTriggerPlugin.ts b/src/azure/AzureHttpTriggerPlugin.ts index 0e3bdb7..3310608 100644 --- a/src/azure/AzureHttpTriggerPlugin.ts +++ b/src/azure/AzureHttpTriggerPlugin.ts @@ -28,14 +28,14 @@ import { ignoreHttpMethodCheck } from '../config/AgentConfig'; class AzureHttpTriggerPlugin { wrap(func: any) { - return function(this: any, context: any) { + return function (this: any, context: any) { let outRet = true; let outName: any; for (const def of context.bindingDefinitions || []) { if (def.type === 'http' && def.directioun === 'out') { outName = def.name; - outRet = outName === '$return' + outRet = outName === '$return'; } } @@ -66,8 +66,7 @@ class AzureHttpTriggerPlugin { if (status) { span.tag(Tag.httpStatusCode(status)); - if (status >= 400) - span.errored = true; + if (status >= 400) span.errored = true; } span.stop(); @@ -78,15 +77,12 @@ class AzureHttpTriggerPlugin { const done = context.done; let did = false; - context.done = function(err: any, _ret: any) { + context.done = function (err: any, _ret: any) { if (!did) { - if (err) - span.error(err); + if (err) span.error(err); - if (arguments.length >= 2) - arguments[1] = stop(_ret); - else - stop(); + if (arguments.length >= 2) arguments[1] = stop(_ret); + else stop(); did = true; } @@ -98,7 +94,6 @@ class AzureHttpTriggerPlugin { try { ret = func.apply(this, arguments); - } catch (err) { span.error(err); stop(); @@ -106,10 +101,10 @@ class AzureHttpTriggerPlugin { throw err; } - if (ret && typeof ret.then === 'function') { // generic Promise check + if (ret && typeof ret.then === 'function') { + // generic Promise check ret = ret.then( (_ret: any) => { - return stop(_ret); }, @@ -118,7 +113,7 @@ class AzureHttpTriggerPlugin { stop(); return Promise.reject(err); - } + }, ); } diff --git a/src/config/AgentConfig.ts b/src/config/AgentConfig.ts index 6a267cb..34bee6e 100644 --- a/src/config/AgentConfig.ts +++ b/src/config/AgentConfig.ts @@ -42,21 +42,51 @@ export type AgentConfig = { }; export function finalizeConfig(config: AgentConfig): void { - const escapeRegExp = (s: string) => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); + const escapeRegExp = (s: string) => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); - config.reDisablePlugins = RegExp(`^(?:${config.disablePlugins!.split(',').map((s) => escapeRegExp(s.trim())).join('|')})$`, 'i'); + config.reDisablePlugins = RegExp( + `^(?:${config + .disablePlugins!.split(',') + .map((s) => escapeRegExp(s.trim())) + .join('|')})$`, + 'i', + ); - const ignoreSuffix =`^.+(?:${config.ignoreSuffix!.split(',').map((s) => escapeRegExp(s.trim())).join('|')})$`; - const ignorePath = '^(?:' + config.traceIgnorePath!.split(',').map( - (s1) => s1.trim().split('**').map( - (s2) => s2.split('*').map( - (s3) => s3.split('?').map(escapeRegExp).join('[^/]') // replaces "?" - ).join('[^/]*') // replaces "*" - ).join('(?:(?:[^/]+/)*[^/]+)?') // replaces "**" - ).join('|') + ')$'; // replaces "," + const ignoreSuffix = `^.+(?:${config + .ignoreSuffix!.split(',') + .map((s) => escapeRegExp(s.trim())) + .join('|')})$`; + const ignorePath = + '^(?:' + + config + .traceIgnorePath!.split(',') + .map( + (s1) => + s1 + .trim() + .split('**') + .map( + (s2) => + s2 + .split('*') + .map( + (s3) => s3.split('?').map(escapeRegExp).join('[^/]'), // replaces "?" + ) + .join('[^/]*'), // replaces "*" + ) + .join('(?:(?:[^/]+/)*[^/]+)?'), // replaces "**" + ) + .join('|') + + ')$'; // replaces "," config.reIgnoreOperation = RegExp(`${ignoreSuffix}|${ignorePath}`); - config.reHttpIgnoreMethod = RegExp(`^(?:${config.httpIgnoreMethod!.split(',').map((s) => s.trim()).join('|')})$`, 'i'); + config.reHttpIgnoreMethod = RegExp( + `^(?:${config + .httpIgnoreMethod!.split(',') + .map((s) => s.trim()) + .join('|')})$`, + 'i', + ); } const _config = { @@ -69,8 +99,9 @@ const _config = { collectorAddress: process.env.SW_AGENT_COLLECTOR_BACKEND_SERVICES || '127.0.0.1:11800', secure: process.env.SW_AGENT_SECURE?.toLowerCase() === 'true', authorization: process.env.SW_AGENT_AUTHENTICATION, - maxBufferSize: Number.isSafeInteger(process.env.SW_AGENT_MAX_BUFFER_SIZE) ? - Number.parseInt(process.env.SW_AGENT_MAX_BUFFER_SIZE as string, 10) : 1000, + maxBufferSize: Number.isSafeInteger(process.env.SW_AGENT_MAX_BUFFER_SIZE) + ? Number.parseInt(process.env.SW_AGENT_MAX_BUFFER_SIZE as string, 10) + : 1000, coldEndpoint: process.env.SW_COLD_ENDPOINT?.toLowerCase() === 'true', disablePlugins: process.env.SW_AGENT_DISABLE_PLUGINS || '', ignoreSuffix: process.env.SW_IGNORE_SUFFIX ?? '.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg', @@ -80,7 +111,7 @@ const _config = { sqlParametersMaxLength: Math.trunc(Math.max(0, Number(process.env.SW_SQL_PARAMETERS_MAX_LENGTH))) || 512, mongoTraceParameters: (process.env.SW_MONGO_TRACE_PARAMETERS || '').toLowerCase() === 'true', mongoParametersMaxLength: Math.trunc(Math.max(0, Number(process.env.SW_MONGO_PARAMETERS_MAX_LENGTH))) || 512, - reDisablePlugins: RegExp(''), // temporary placeholder so Typescript doesn't throw a fit + reDisablePlugins: RegExp(''), // temporary placeholder so Typescript doesn't throw a fit reIgnoreOperation: RegExp(''), reHttpIgnoreMethod: RegExp(''), }; diff --git a/src/core/PluginInstaller.ts b/src/core/PluginInstaller.ts index 10d4bc6..f6f285f 100644 --- a/src/core/PluginInstaller.ts +++ b/src/core/PluginInstaller.ts @@ -32,7 +32,8 @@ while (topModule.parent) { topModule = topModule.parent; - if (filename.endsWith('/skywalking-nodejs/lib/index.js')) // stop at the appropriate level in case app is being run by some other framework + if (filename.endsWith('/skywalking-nodejs/lib/index.js')) + // stop at the appropriate level in case app is being run by some other framework break; } @@ -55,7 +56,8 @@ export default class PluginInstaller { isSupported: true, }; } - } catch { // module not found + } catch { + // module not found return { version: 'not found,', isSupported: false, @@ -82,35 +84,35 @@ export default class PluginInstaller { install(): void { fs.readdirSync(this.pluginDir) - .filter((file) => !(file.endsWith('.d.ts') || file.endsWith('.js.map'))) - .forEach((file) => { - if (file.replace(/(?:Plugin)?\.js$/i, '').match(config.reDisablePlugins)) { - logger.info(`Plugin ${file} not installed because it is disabled`); - return; - } + .filter((file) => !(file.endsWith('.d.ts') || file.endsWith('.js.map'))) + .forEach((file) => { + if (file.replace(/(?:Plugin)?\.js$/i, '').match(config.reDisablePlugins)) { + logger.info(`Plugin ${file} not installed because it is disabled`); + return; + } - let plugin; - const pluginFile = path.join(this.pluginDir, file); + let plugin; + const pluginFile = path.join(this.pluginDir, file); - try { - plugin = this.require(pluginFile).default as SwPlugin; - const { isSupported, version } = this.checkModuleVersion(plugin); + try { + plugin = this.require(pluginFile).default as SwPlugin; + const { isSupported, version } = this.checkModuleVersion(plugin); - if (!isSupported) { - logger.info(`Plugin ${plugin.module} ${version} doesn't satisfy the supported version ${plugin.versions}`); - return; - } + if (!isSupported) { + logger.info(`Plugin ${plugin.module} ${version} doesn't satisfy the supported version ${plugin.versions}`); + return; + } - logger.info(`Installing plugin ${plugin.module} ${plugin.versions}`); + logger.info(`Installing plugin ${plugin.module} ${plugin.versions}`); - plugin.install(this); - } catch (e) { - if (plugin) { - logger.error(`Error installing plugin ${plugin.module} ${plugin.versions}`); - } else { - logger.error(`Error processing plugin ${pluginFile}`); + plugin.install(this); + } catch (e) { + if (plugin) { + logger.error(`Error installing plugin ${plugin.module} ${plugin.versions}`); + } else { + logger.error(`Error processing plugin ${pluginFile}`); + } } - } - }); + }); } } diff --git a/src/core/SwPlugin.ts b/src/core/SwPlugin.ts index 4bb220c..d369097 100644 --- a/src/core/SwPlugin.ts +++ b/src/core/SwPlugin.ts @@ -27,44 +27,43 @@ export default interface SwPlugin { install(installer: PluginInstaller): void; } -export const wrapEmit = (span: Span, ee: any, doError: boolean = true, stop: any = NaN) => { // stop = NaN because NaN !== NaN +export const wrapEmit = (span: Span, ee: any, doError: boolean = true, stop: any = NaN) => { + // stop = NaN because NaN !== NaN const stopIsFunc = typeof stop === 'function'; const _emit = ee.emit; - Object.defineProperty(ee, 'emit', {configurable: true, writable: true, value: (function(this: any): any { - const event = arguments[0]; + Object.defineProperty(ee, 'emit', { + configurable: true, + writable: true, + value: function (this: any): any { + const event = arguments[0]; - span.resync(); + span.resync(); - try { - if (doError && event === 'error') - span.error(arguments[1]); + try { + if (doError && event === 'error') span.error(arguments[1]); - return _emit.apply(this, arguments); + return _emit.apply(this, arguments); + } catch (err) { + span.error(err); - } catch (err) { - span.error(err); - - throw err; - - } finally { - if (stopIsFunc ? stop(event) : event === stop) - span.stop(); - else - span.async(); - } - })}); + throw err; + } finally { + if (stopIsFunc ? stop(event) : event === stop) span.stop(); + else span.async(); + } + }, + }); }; export const wrapCallback = (span: Span, callback: any, idxError: any = false) => { - return function(this: any) { - if (idxError !== false && arguments[idxError]) - span.error(arguments[idxError]); + return function (this: any) { + if (idxError !== false && arguments[idxError]) span.error(arguments[idxError]); span.stop(); return callback.apply(this, arguments); - } + }; }; export const wrapPromise = (span: Span, promise: any) => { @@ -80,6 +79,6 @@ export const wrapPromise = (span: Span, promise: any) => { span.stop(); return Promise.reject(err); - } + }, ); }; diff --git a/src/logging/index.ts b/src/logging/index.ts index 68c0302..6ae1240 100644 --- a/src/logging/index.ts +++ b/src/logging/index.ts @@ -59,16 +59,17 @@ export function createLogger(name: string): LoggerLevelAware { _isInfoEnabled, }); - const nop = (): void => { /* a cookie for the linter */ }; + const nop = (): void => { + /* a cookie for the linter */ + }; - if (loggerLevel < logger.levels.debug) // we do this because logger still seems to stringify anything sent to it even if it is below the logging level, costing performance + if (loggerLevel < logger.levels.debug) + // we do this because logger still seems to stringify anything sent to it even if it is below the logging level, costing performance (logger as any).debug = nop; - if (loggerLevel < logger.levels.info) - (logger as any).info = nop; + if (loggerLevel < logger.levels.info) (logger as any).info = nop; - if (loggerLevel < logger.levels.warn) - (logger as any).warn = nop; + if (loggerLevel < logger.levels.warn) (logger as any).warn = nop; return logger as LoggerLevelAware; } diff --git a/src/plugins/AMQPLibPlugin.ts b/src/plugins/AMQPLibPlugin.ts index fe91742..f7f6842 100644 --- a/src/plugins/AMQPLibPlugin.ts +++ b/src/plugins/AMQPLibPlugin.ts @@ -30,7 +30,7 @@ class AMQPLibPlugin implements SwPlugin { readonly versions = '*'; install(installer: PluginInstaller): void { - const {BaseChannel} = installer.require('amqplib/lib/channel'); + const { BaseChannel } = installer.require('amqplib/lib/channel'); this.interceptProducer(BaseChannel); this.interceptConsumer(BaseChannel); @@ -39,11 +39,14 @@ class AMQPLibPlugin implements SwPlugin { interceptProducer(BaseChannel: any): void { const _sendMessage = BaseChannel.prototype.sendMessage; - BaseChannel.prototype.sendMessage = function(fields: any, properties: any, content: any) { + BaseChannel.prototype.sendMessage = function (fields: any, properties: any, content: any) { const topic = fields.exchange || ''; const queue = fields.routingKey || ''; const peer = `${this.connection.stream.remoteAddress}:${this.connection.stream.remotePort}`; - const span = ContextManager.current.newExitSpan('RabbitMQ/' + topic + '/' + queue + '/Producer', Component.RABBITMQ_PRODUCER); + const span = ContextManager.current.newExitSpan( + 'RabbitMQ/' + topic + '/' + queue + '/Producer', + Component.RABBITMQ_PRODUCER, + ); span.start(); @@ -58,31 +61,28 @@ class AMQPLibPlugin implements SwPlugin { span.tag(Tag.mqBroker((this.connection.stream.constructor.name === 'Socket' ? 'amqp://' : 'amqps://') + peer)); - if (topic) - span.tag(Tag.mqTopic(topic)); + if (topic) span.tag(Tag.mqTopic(topic)); - if (queue) - span.tag(Tag.mqQueue(queue)); + if (queue) span.tag(Tag.mqQueue(queue)); const ret = _sendMessage.call(this, fields, properties, content); span.stop(); return ret; - } catch (e) { span.error(e); span.stop(); throw e; } - } + }; } interceptConsumer(BaseChannel: any): void { const _dispatchMessage = BaseChannel.prototype.dispatchMessage; - BaseChannel.prototype.dispatchMessage = function(fields: any, message: any) { + BaseChannel.prototype.dispatchMessage = function (fields: any, message: any) { const topic = message?.fields?.exchange || ''; const queue = message?.fields?.routingKey || ''; const carrier = ContextCarrier.from(message?.properties?.headers || {}); @@ -95,30 +95,28 @@ class AMQPLibPlugin implements SwPlugin { span.layer = SpanLayer.MQ; span.peer = `${this.connection.stream.remoteAddress}:${this.connection.stream.remotePort}`; - span.tag(Tag.mqBroker((this.connection.stream.constructor.name === 'Socket' ? 'amqp://' : 'amqps://') + span.peer)); + span.tag( + Tag.mqBroker((this.connection.stream.constructor.name === 'Socket' ? 'amqp://' : 'amqps://') + span.peer), + ); - if (topic) - span.tag(Tag.mqTopic(topic)); + if (topic) span.tag(Tag.mqTopic(topic)); - if (queue) - span.tag(Tag.mqQueue(queue)); + if (queue) span.tag(Tag.mqQueue(queue)); - if (message === null) - span.log('Cancel', true); + if (message === null) span.log('Cancel', true); const ret = _dispatchMessage.call(this, fields, message); span.stop(); return ret; - } catch (e) { span.error(e); span.stop(); throw e; } - } + }; } } diff --git a/src/plugins/AxiosPlugin.ts b/src/plugins/AxiosPlugin.ts index 9727f75..63b3e85 100644 --- a/src/plugins/AxiosPlugin.ts +++ b/src/plugins/AxiosPlugin.ts @@ -39,13 +39,11 @@ class AxiosPlugin implements SwPlugin { const Axios = installer.require('axios/lib/core/Axios'); const _request = Axios.prototype.request; - Axios.prototype.request = function(url?: any, config?: any) { - if (typeof url === 'string') - config = config ? {...config, url} : {url}; - else - config = url ? {...url} : {}; + Axios.prototype.request = function (url?: any, config?: any) { + if (typeof url === 'string') config = config ? { ...config, url } : { url }; + else config = url ? { ...url } : {}; - const {origin, host, pathname: operation} = new URL(config.url, config.baseURL); // TODO: this may throw invalid URL + const { origin, host, pathname: operation } = new URL(config.url, config.baseURL); // TODO: this may throw invalid URL const method = (config.method || 'GET').toUpperCase(); const span = ignoreHttpMethodCheck(method) ? DummySpan.create() @@ -54,7 +52,7 @@ class AxiosPlugin implements SwPlugin { span.start(); try { - config.headers = config.headers ? {...config.headers} : {}; + config.headers = config.headers ? { ...config.headers } : {}; span.component = Component.AXIOS; span.layer = SpanLayer.HTTP; @@ -63,19 +61,17 @@ class AxiosPlugin implements SwPlugin { span.tag(Tag.httpURL(origin + operation)); span.tag(Tag.httpMethod(method)); - span.inject().items.forEach((item) => config.headers[item.key] = item.value); + span.inject().items.forEach((item) => (config.headers[item.key] = item.value)); const copyStatus = (response: any) => { if (response) { if (response.status) { span.tag(Tag.httpStatusCode(response.status)); - if (response.status >= 400) - span.errored = true; + if (response.status >= 400) span.errored = true; } - if (response.statusText) - span.tag(Tag.httpStatusMsg(response.statusText)); + if (response.statusText) span.tag(Tag.httpStatusMsg(response.statusText)); } }; @@ -93,13 +89,12 @@ class AxiosPlugin implements SwPlugin { span.stop(); return Promise.reject(err); - } + }, ); span.async(); return ret; - } catch (err) { span.error(err); span.stop(); diff --git a/src/plugins/ExpressPlugin.ts b/src/plugins/ExpressPlugin.ts index d9b25f0..23de86c 100644 --- a/src/plugins/ExpressPlugin.ts +++ b/src/plugins/ExpressPlugin.ts @@ -40,7 +40,7 @@ class ExpressPlugin implements SwPlugin { const router = installer.require('express/lib/router'); const _handle = router.handle; - router.handle = function(req: IncomingMessage, res: ServerResponse, next: any) { + router.handle = function (req: IncomingMessage, res: ServerResponse, next: any) { const carrier = ContextCarrier.from((req as any).headers || {}); const operation = (req.url || '/').replace(/\?.*/g, ''); const span = ignoreHttpMethodCheck(req.method ?? 'GET') @@ -49,18 +49,24 @@ class ExpressPlugin implements SwPlugin { span.component = Component.EXPRESS; - if (span.depth) // if we inherited from http then just change component ID and let http do the work + if (span.depth) + // if we inherited from http then just change component ID and let http do the work return _handle.apply(this, arguments); - return HttpPlugin.wrapHttpResponse(span, req, res, () => { // http plugin disabled, we use its mechanism anyway + return HttpPlugin.wrapHttpResponse(span, req, res, () => { + // http plugin disabled, we use its mechanism anyway try { return _handle.call(this, req, res, (err: Error) => { span.error(err); next.call(this, err); }); - - } finally { // req.protocol is only possibly available after call to _handle() - span.tag(Tag.httpURL(((req as any).protocol ? (req as any).protocol + '://' : '') + (req.headers.host || '') + req.url)); + } finally { + // req.protocol is only possibly available after call to _handle() + span.tag( + Tag.httpURL( + ((req as any).protocol ? (req as any).protocol + '://' : '') + (req.headers.host || '') + req.url, + ), + ); } }); }; diff --git a/src/plugins/HttpPlugin.ts b/src/plugins/HttpPlugin.ts index a4eba60..56e1606 100644 --- a/src/plugins/HttpPlugin.ts +++ b/src/plugins/HttpPlugin.ts @@ -17,7 +17,7 @@ * */ -import SwPlugin, {wrapEmit} from '../core/SwPlugin'; +import SwPlugin, { wrapEmit } from '../core/SwPlugin'; import { URL } from 'url'; import { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'http'; import ContextManager from '../trace/context/ContextManager'; @@ -44,7 +44,7 @@ class HttpPlugin implements SwPlugin { } private interceptClientRequest(module: any, protocol: string) { - const _request = module.request; // BUG! this doesn't work with "import {request} from http", but haven't found an alternative yet + const _request = module.request; // BUG! this doesn't work with "import {request} from http", but haven't found an alternative yet module.request = function () { const url: URL | string | RequestOptions = arguments[0]; @@ -53,11 +53,11 @@ class HttpPlugin implements SwPlugin { url instanceof URL ? url : typeof url === 'string' - ? new URL(url) // TODO: this may throw invalid URL + ? new URL(url) // TODO: this may throw invalid URL : { - host: (url.host || url.hostname || 'unknown') + ':' + (url.port || 80), - pathname: url.path || '/', - }; + host: (url.host || url.hostname || 'unknown') + ':' + (url.port || 80), + pathname: url.path || '/', + }; const operation = pathname.replace(/\?.*$/g, ''); const method = arguments[url instanceof URL || typeof url === 'string' ? 1 : 0]?.method || 'GET'; @@ -65,7 +65,8 @@ class HttpPlugin implements SwPlugin { ? DummySpan.create() : ContextManager.current.newExitSpan(operation, Component.HTTP); - if (span.depth) // if we inherited from a higher level plugin then do nothing, higher level should do all the work and we don't duplicate here + if (span.depth) + // if we inherited from a higher level plugin then do nothing, higher level should do all the work and we don't duplicate here return _request.apply(this, arguments); span.start(); @@ -81,39 +82,34 @@ class HttpPlugin implements SwPlugin { const copyStatusAndWrapEmit = (res: any) => { span.tag(Tag.httpStatusCode(res.statusCode)); - if (res.statusCode && res.statusCode >= 400) - span.errored = true; + if (res.statusCode && res.statusCode >= 400) span.errored = true; - if (res.statusMessage) - span.tag(Tag.httpStatusMsg(res.statusMessage)); + if (res.statusMessage) span.tag(Tag.httpStatusMsg(res.statusMessage)); - wrapEmit(span, res, false); + wrapEmit(span, res, false); }; - const responseCB = function(this: any, res: any) { // may wrap callback instead of event because it procs first + const responseCB = function (this: any, res: any) { + // may wrap callback instead of event because it procs first span.resync(); copyStatusAndWrapEmit(res); try { - if (callback) - return callback.apply(this, arguments); - + if (callback) return callback.apply(this, arguments); } catch (err) { span.error(err); throw err; - } finally { span.async(); } }; const idxCallback = typeof arguments[2] === 'function' ? 2 : typeof arguments[1] === 'function' ? 1 : 0; - const callback = arguments[idxCallback]; + const callback = arguments[idxCallback]; - if (idxCallback) - arguments[idxCallback] = responseCB; + if (idxCallback) arguments[idxCallback] = responseCB; const req: ClientRequest = _request.apply(this, arguments); @@ -122,15 +118,13 @@ class HttpPlugin implements SwPlugin { wrapEmit(span, req, true, 'close'); req.on('timeout', () => span.log('Timeout', true)); - req.on('abort', () => span.log('Abort', span.errored = true)); + req.on('abort', () => span.log('Abort', (span.errored = true))); - if (!idxCallback) - req.on('response', copyStatusAndWrapEmit); + if (!idxCallback) req.on('response', copyStatusAndWrapEmit); span.async(); return req; - } catch (err) { span.error(err); span.stop(); @@ -142,9 +136,13 @@ class HttpPlugin implements SwPlugin { private interceptServerRequest(module: any, protocol: string) { const plugin = this; - const _addListener = module.Server.prototype.addListener; // TODO? full event protocol support not currently implemented (prependListener(), removeListener(), etc...) + const _addListener = module.Server.prototype.addListener; // TODO? full event protocol support not currently implemented (prependListener(), removeListener(), etc...) - module.Server.prototype.addListener = module.Server.prototype.on = function (event: any, handler: any, ...addArgs: any[]) { + module.Server.prototype.addListener = module.Server.prototype.on = function ( + event: any, + handler: any, + ...addArgs: any[] + ) { return _addListener.call(this, event, event === 'request' ? _sw_request : handler, ...addArgs); function _sw_request(this: any, req: IncomingMessage, res: ServerResponse, ...reqArgs: any[]) { @@ -169,8 +167,8 @@ class HttpPlugin implements SwPlugin { try { span.layer = SpanLayer.HTTP; span.peer = - (typeof req.headers['x-forwarded-for'] === 'string' && req.headers['x-forwarded-for'].split(',').shift()) - || (req.connection.remoteFamily === 'IPv6' + (typeof req.headers['x-forwarded-for'] === 'string' && req.headers['x-forwarded-for'].split(',').shift()) || + (req.connection.remoteFamily === 'IPv6' ? `[${req.connection.remoteAddress}]:${req.connection.remotePort}` : `${req.connection.remoteAddress}:${req.connection.remotePort}`); @@ -183,11 +181,9 @@ class HttpPlugin implements SwPlugin { if (emittedEvent === stopEvent) { span.tag(Tag.httpStatusCode(res.statusCode)); - if (res.statusCode && res.statusCode >= 400) - span.errored = true; + if (res.statusCode && res.statusCode >= 400) span.errored = true; - if (res.statusMessage) - span.tag(Tag.httpStatusMsg(res.statusMessage)); + if (res.statusMessage) span.tag(Tag.httpStatusMsg(res.statusMessage)); return true; } @@ -204,7 +200,6 @@ class HttpPlugin implements SwPlugin { span.async(); return ret; - } catch (err) { span.error(err); span.stop(); diff --git a/src/plugins/IORedisPlugin.ts b/src/plugins/IORedisPlugin.ts index 626606c..d4d2c76 100644 --- a/src/plugins/IORedisPlugin.ts +++ b/src/plugins/IORedisPlugin.ts @@ -25,46 +25,44 @@ import { Component } from '../trace/Component'; import ContextManager from '../trace/context/ContextManager'; class IORedisPlugin implements SwPlugin { - readonly module = 'ioredis'; - readonly versions = '*'; + readonly module = 'ioredis'; + readonly versions = '*'; - install(installer: PluginInstaller): void { - const Redis = installer.require('ioredis'); + install(installer: PluginInstaller): void { + const Redis = installer.require('ioredis'); - this.interceptOperation(Redis, 'sendCommand'); - } + this.interceptOperation(Redis, 'sendCommand'); + } - interceptOperation(Cls: any, operation: string): void { - const _original = Cls.prototype[operation]; + interceptOperation(Cls: any, operation: string): void { + const _original = Cls.prototype[operation]; - if (!_original) - return; + if (!_original) return; - Cls.prototype[operation] = function (...args: any[]) { - const command = args[0]; - const host = `${this.options.host}:${this.options.port}`; - const span = ContextManager.current.newExitSpan(`redis/${command?.name}`, Component.REDIS); + Cls.prototype[operation] = function (...args: any[]) { + const command = args[0]; + const host = `${this.options.host}:${this.options.port}`; + const span = ContextManager.current.newExitSpan(`redis/${command?.name}`, Component.REDIS); - span.start(); - span.component = Component.REDIS; - span.layer = SpanLayer.CACHE; - span.peer = host; - span.tag(Tag.dbType('Redis')); - span.tag(Tag.dbInstance(`${this.condition.select}`)); + span.start(); + span.component = Component.REDIS; + span.layer = SpanLayer.CACHE; + span.peer = host; + span.tag(Tag.dbType('Redis')); + span.tag(Tag.dbInstance(`${this.condition.select}`)); - try { - const ret = wrapPromise(span, _original.apply(this, args)); - span.async(); - return ret; + try { + const ret = wrapPromise(span, _original.apply(this, args)); + span.async(); + return ret; + } catch (err) { + span.error(err); + span.stop(); - } catch (err) { - span.error(err); - span.stop(); - - throw err; - } - } - } + throw err; + } + }; + } } -export default new IORedisPlugin(); \ No newline at end of file +export default new IORedisPlugin(); diff --git a/src/plugins/MongoDBPlugin.ts b/src/plugins/MongoDBPlugin.ts index c1f70b5..8d022fc 100644 --- a/src/plugins/MongoDBPlugin.ts +++ b/src/plugins/MongoDBPlugin.ts @@ -17,7 +17,7 @@ * */ -import SwPlugin, {wrapEmit, wrapPromise} from '../core/SwPlugin'; +import SwPlugin, { wrapEmit, wrapPromise } from '../core/SwPlugin'; import ContextManager from '../trace/context/ContextManager'; import { Component } from '../trace/Component'; import Tag from '../Tag'; @@ -34,8 +34,7 @@ class MongoDBPlugin implements SwPlugin { Db: any; hookCursorMaybe(span: any, cursor: any): boolean { - if (!(cursor instanceof this.Cursor)) - return false; + if (!(cursor instanceof this.Cursor)) return false; wrapEmit(span, cursor, true, 'close'); @@ -43,37 +42,33 @@ class MongoDBPlugin implements SwPlugin { } install(installer: PluginInstaller): void { - const plugin = this; + const plugin = this; this.Collection = installer.require('mongodb/lib/collection'); - this.Cursor = installer.require('mongodb/lib/cursor'); - this.Db = installer.require('mongodb/lib/db'); + this.Cursor = installer.require('mongodb/lib/cursor'); + this.Db = installer.require('mongodb/lib/db'); const wrapCallbackWithCursorMaybe = (span: any, args: any[], idx: number): boolean => { - const callback = args.length > idx && typeof args[idx = args.length - 1] === 'function' ? args[idx] : null; + const callback = args.length > idx && typeof args[(idx = args.length - 1)] === 'function' ? args[idx] : null; - if (!callback) - return false; + if (!callback) return false; - args[idx] = function(this: any) { // arguments = [error: any, result: any] - span.mongodbInCall = false; // we do this because some operations may call callback immediately which would not create a new span for any operations in that callback (db.collection()) + args[idx] = function (this: any) { + // arguments = [error: any, result: any] + span.mongodbInCall = false; // we do this because some operations may call callback immediately which would not create a new span for any operations in that callback (db.collection()) - if (arguments[0]) - span.error(arguments[0]); + if (arguments[0]) span.error(arguments[0]); - if (arguments[0] || !plugin.hookCursorMaybe(span, arguments[1])) - span.stop(); + if (arguments[0] || !plugin.hookCursorMaybe(span, arguments[1])) span.stop(); return callback.apply(this, arguments); - } + }; return true; }; const stringify = (params: any) => { - if (params === undefined) - return ''; - else if (typeof params === 'function') - return `${params}`; + if (params === undefined) return ''; + else if (typeof params === 'function') return `${params}`; let str = JSON.stringify(params); @@ -81,53 +76,66 @@ class MongoDBPlugin implements SwPlugin { str = str.slice(0, agentConfig.mongoParametersMaxLength) + ' ...'; return str; - } + }; - const collInsertFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [doc(s), options, callback] + const collInsertFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [doc(s), options, callback] span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}()`)); - if (agentConfig.mongoTraceParameters) - span.tag(Tag.dbMongoParameters(stringify(args[0]))); + if (agentConfig.mongoTraceParameters) span.tag(Tag.dbMongoParameters(stringify(args[0]))); return wrapCallbackWithCursorMaybe(span, args, 1); }; - const collDeleteFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [filter, options, callback] + const collDeleteFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [filter, options, callback] span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${stringify(args[0])})`)); return wrapCallbackWithCursorMaybe(span, args, 1); }; - const collUpdateFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [filter, update, options, callback] + const collUpdateFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [filter, update, options, callback] span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${stringify(args[0])})`)); - if (agentConfig.mongoTraceParameters) - span.tag(Tag.dbMongoParameters(stringify(args[1]))); + if (agentConfig.mongoTraceParameters) span.tag(Tag.dbMongoParameters(stringify(args[1]))); return wrapCallbackWithCursorMaybe(span, args, 2); }; - const collFindOneFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [query, options, callback] - span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${typeof args[0] !== 'function' ? stringify(args[0]) : ''})`)); + const collFindOneFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [query, options, callback] + span.tag( + Tag.dbStatement( + `${this.s.namespace.collection}.${operation}(${typeof args[0] !== 'function' ? stringify(args[0]) : ''})`, + ), + ); return wrapCallbackWithCursorMaybe(span, args, 0); }; - const collFindAndRemoveFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [query, sort, options, callback] - span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${stringify(args[0])}${typeof args[1] !== 'function' && args[1] !== undefined ? ', ' + stringify(args[1]) : ''})`)); + const collFindAndRemoveFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [query, sort, options, callback] + span.tag( + Tag.dbStatement( + `${this.s.namespace.collection}.${operation}(${stringify(args[0])}${ + typeof args[1] !== 'function' && args[1] !== undefined ? ', ' + stringify(args[1]) : '' + })`, + ), + ); return wrapCallbackWithCursorMaybe(span, args, 1); }; - const collFindAndModifyFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [query, sort, doc, options, callback] + const collFindAndModifyFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [query, sort, doc, options, callback] let params = stringify(args[0]); if (typeof args[1] !== 'function' && args[1] !== undefined) { params += ', ' + stringify(args[1]); if (typeof args[2] !== 'function' && args[2] !== undefined) { - if (agentConfig.mongoTraceParameters) - span.tag(Tag.dbMongoParameters(stringify(args[2]))); + if (agentConfig.mongoTraceParameters) span.tag(Tag.dbMongoParameters(stringify(args[2]))); } } @@ -136,44 +144,59 @@ class MongoDBPlugin implements SwPlugin { return wrapCallbackWithCursorMaybe(span, args, 1); }; - const collMapReduceFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [map, reduce, options, callback] - span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${stringify(args[0])}, ${stringify(args[1])})`)); + const collMapReduceFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [map, reduce, options, callback] + span.tag( + Tag.dbStatement(`${this.s.namespace.collection}.${operation}(${stringify(args[0])}, ${stringify(args[1])})`), + ); return wrapCallbackWithCursorMaybe(span, args, 2); }; - const collDropFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [options, callback] + const collDropFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [options, callback] span.tag(Tag.dbStatement(`${this.s.namespace.collection}.${operation}()`)); return wrapCallbackWithCursorMaybe(span, args, 0); }; - const dbAddUserFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [username, password, options, callback] + const dbAddUserFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [username, password, options, callback] span.tag(Tag.dbStatement(`${operation}(${stringify(args[0])})`)); return wrapCallbackWithCursorMaybe(span, args, 2); }; - const dbRemoveUserFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [username, options, callback] + const dbRemoveUserFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [username, options, callback] span.tag(Tag.dbStatement(`${operation}(${stringify(args[0])})`)); return wrapCallbackWithCursorMaybe(span, args, 1); }; - const dbRenameCollectionFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [fromCollection, toCollection, options, callback] + const dbRenameCollectionFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [fromCollection, toCollection, options, callback] span.tag(Tag.dbStatement(`${operation}(${stringify(args[0])}, ${stringify(args[1])})`)); return wrapCallbackWithCursorMaybe(span, args, 2); }; - const dbCollectionsFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [options, callback] + const dbCollectionsFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [options, callback] span.tag(Tag.dbStatement(`${operation}()`)); return wrapCallbackWithCursorMaybe(span, args, 0); }; - const dbEvalFunc = function(this: any, operation: string, span: any, args: any[]): boolean { // args = [code, parameters, options, callback] - span.tag(Tag.dbStatement(`${operation}(${stringify(args[0])}${typeof args[1] !== 'function' && args[1] !== undefined ? ', ' + stringify(args[1]) : ''})`)); + const dbEvalFunc = function (this: any, operation: string, span: any, args: any[]): boolean { + // args = [code, parameters, options, callback] + span.tag( + Tag.dbStatement( + `${operation}(${stringify(args[0])}${ + typeof args[1] !== 'function' && args[1] !== undefined ? ', ' + stringify(args[1]) : '' + })`, + ), + ); return wrapCallbackWithCursorMaybe(span, args, 1); }; @@ -191,7 +214,7 @@ class MongoDBPlugin implements SwPlugin { this.interceptOperation(this.Collection, 'updateOne', collUpdateFunc); this.interceptOperation(this.Collection, 'updateMany', collUpdateFunc); this.interceptOperation(this.Collection, 'replaceOne', collUpdateFunc); - this.interceptOperation(this.Collection, 'find', collFindOneFunc); // cursor + this.interceptOperation(this.Collection, 'find', collFindOneFunc); // cursor this.interceptOperation(this.Collection, 'findOne', collFindOneFunc); this.interceptOperation(this.Collection, 'findOneAndDelete', collDeleteFunc); this.interceptOperation(this.Collection, 'findOneAndReplace', collUpdateFunc); @@ -201,7 +224,7 @@ class MongoDBPlugin implements SwPlugin { this.interceptOperation(this.Collection, 'bulkWrite', collInsertFunc); this.interceptOperation(this.Collection, 'mapReduce', collMapReduceFunc); - this.interceptOperation(this.Collection, 'aggregate', collDeleteFunc); // cursor + this.interceptOperation(this.Collection, 'aggregate', collDeleteFunc); // cursor this.interceptOperation(this.Collection, 'distinct', collFindAndRemoveFunc); this.interceptOperation(this.Collection, 'count', collFindOneFunc); this.interceptOperation(this.Collection, 'estimatedDocumentCount', collDropFunc); @@ -218,7 +241,7 @@ class MongoDBPlugin implements SwPlugin { this.interceptOperation(this.Collection, 'indexes', collDropFunc); this.interceptOperation(this.Collection, 'indexExists', collDeleteFunc); this.interceptOperation(this.Collection, 'indexInformation', collDropFunc); - this.interceptOperation(this.Collection, 'listIndexes', collDropFunc); // cursor + this.interceptOperation(this.Collection, 'listIndexes', collDropFunc); // cursor this.interceptOperation(this.Collection, 'stats', collDropFunc); this.interceptOperation(this.Collection, 'rename', collDeleteFunc); @@ -226,7 +249,7 @@ class MongoDBPlugin implements SwPlugin { this.interceptOperation(this.Collection, 'options', collDropFunc); this.interceptOperation(this.Collection, 'isCapped', collDropFunc); - this.interceptOperation(this.Db, 'aggregate', dbAddUserFunc); // cursor + this.interceptOperation(this.Db, 'aggregate', dbAddUserFunc); // cursor this.interceptOperation(this.Db, 'addUser', dbAddUserFunc); this.interceptOperation(this.Db, 'removeUser', dbRemoveUserFunc); @@ -236,7 +259,7 @@ class MongoDBPlugin implements SwPlugin { this.interceptOperation(this.Db, 'renameCollection', dbRenameCollectionFunc); this.interceptOperation(this.Db, 'dropCollection', dbRemoveUserFunc); this.interceptOperation(this.Db, 'collections', dbCollectionsFunc); - this.interceptOperation(this.Db, 'listCollections', dbAddUserFunc); // cursor + this.interceptOperation(this.Db, 'listCollections', dbAddUserFunc); // cursor this.interceptOperation(this.Db, 'createIndex', dbRenameCollectionFunc); this.interceptOperation(this.Db, 'ensureIndex', dbRenameCollectionFunc); @@ -268,35 +291,38 @@ class MongoDBPlugin implements SwPlugin { } interceptOperation(Cls: any, operation: string, operationFunc: any): void { - const plugin = this; + const plugin = this; const _original = Cls.prototype[operation]; - if (!_original) - return; + if (!_original) return; - Cls.prototype[operation] = function(...args: any[]) { + Cls.prototype[operation] = function (...args: any[]) { let span = ContextManager.currentSpan; // XXX: mongodb calls back into itself at this level in several places, for this reason we just do a normal call // if this is detected instead of opening a new span. This should not affect secondary db calls being recorded // from a cursor since this span is kept async until the cursor is closed, at which point it is stoppped. - if ((span as any)?.mongodbInCall) // mongodb has called into itself internally + if ((span as any)?.mongodbInCall) + // mongodb has called into itself internally return _original.apply(this, args); let host = '???'; try { const db = this instanceof plugin.Collection ? this.s.db : this; - host = db.serverConfig.s.options.servers.map((s: any) => `${s.host}:${s.port}`).join(','); // will this work for non-NativeTopology? - } catch { /* nop */ } + host = db.serverConfig.s.options.servers.map((s: any) => `${s.host}:${s.port}`).join(','); // will this work for non-NativeTopology? + } catch { + /* nop */ + } span = ContextManager.current.newExitSpan('MongoDB/' + operation, Component.MONGODB); span.start(); try { - if (span.component === Component.UNKNOWN) // in case mongoose sitting on top + if (span.component === Component.UNKNOWN) + // in case mongoose sitting on top span.component = Component.MONGODB; span.layer = SpanLayer.DATABASE; @@ -314,11 +340,11 @@ class MongoDBPlugin implements SwPlugin { if (!hasCB) { if (plugin.hookCursorMaybe(span, ret)) { // NOOP - - } else if (ret && typeof ret.then === 'function') { // generic Promise check + } else if (ret && typeof ret.then === 'function') { + // generic Promise check ret = wrapPromise(span, ret); - - } else { // no callback passed in and no Promise or Cursor returned, play it safe + } else { + // no callback passed in and no Promise or Cursor returned, play it safe span.stop(); return ret; @@ -328,7 +354,6 @@ class MongoDBPlugin implements SwPlugin { span.async(); return ret; - } catch (e) { span.error(e); span.stop(); diff --git a/src/plugins/MongoosePlugin.ts b/src/plugins/MongoosePlugin.ts index 0b2f458..52aa349 100644 --- a/src/plugins/MongoosePlugin.ts +++ b/src/plugins/MongoosePlugin.ts @@ -17,7 +17,7 @@ * */ -import SwPlugin, {wrapCallback, wrapPromise} from '../core/SwPlugin'; +import SwPlugin, { wrapCallback, wrapPromise } from '../core/SwPlugin'; import ContextManager from '../trace/context/ContextManager'; import { Component } from '../trace/Component'; import Tag from '../Tag'; @@ -30,7 +30,7 @@ class MongoosePlugin implements SwPlugin { mongodbEnabled?: boolean; install(installer: PluginInstaller): void { - const {Model} = installer.require('mongoose'); + const { Model } = installer.require('mongoose'); this.interceptOperation(Model, 'aggregate'); this.interceptOperation(Model, 'bulkWrite'); @@ -88,13 +88,13 @@ class MongoosePlugin implements SwPlugin { interceptOperation(Container: any, operation: string): void { const _original = Container[operation]; - if (!_original) - return; + if (!_original) return; - Container[operation] = function() { + Container[operation] = function () { let span = ContextManager.currentSpan; - if ((span as any)?.mongooseInCall) // mongoose has called into itself internally + if ((span as any)?.mongooseInCall) + // mongoose has called into itself internally return _original.apply(this, arguments); const host = `${this.db.host}:${this.db.port}`; @@ -104,7 +104,7 @@ class MongoosePlugin implements SwPlugin { try { span.component = Component.MONGOOSE; - span.layer = SpanLayer.DATABASE; // mongodb may not actually be called so we set these here in case + span.layer = SpanLayer.DATABASE; // mongodb may not actually be called so we set these here in case span.peer = host; span.tag(Tag.dbType('MongoDB')); @@ -115,22 +115,24 @@ class MongoosePlugin implements SwPlugin { if (hasCB) { const wrappedCallback = wrapCallback(span, arguments[arguments.length - 1], 0); - arguments[arguments.length - 1] = function() { // in case of immediate synchronous callback from mongoose + arguments[arguments.length - 1] = function () { + // in case of immediate synchronous callback from mongoose (span as any).mongooseInCall = false; wrappedCallback.apply(this, arguments as any); }; } - (span as any).mongooseInCall = true; // if mongoose calls into itself while executing this operation then ignore it + (span as any).mongooseInCall = true; // if mongoose calls into itself while executing this operation then ignore it let ret = _original.apply(this, arguments); (span as any).mongooseInCall = false; if (!hasCB) { - if (ret && typeof ret.then === 'function') { // generic Promise check + if (ret && typeof ret.then === 'function') { + // generic Promise check ret = wrapPromise(span, ret); - - } else { // no callback passed in and no Promise or Cursor returned, play it safe + } else { + // no callback passed in and no Promise or Cursor returned, play it safe span.stop(); return ret; @@ -140,7 +142,6 @@ class MongoosePlugin implements SwPlugin { span.async(); return ret; - } catch (err) { span.error(err); span.stop(); diff --git a/src/plugins/MySQL2Plugin.ts b/src/plugins/MySQL2Plugin.ts index 4488c96..e1497ba 100644 --- a/src/plugins/MySQL2Plugin.ts +++ b/src/plugins/MySQL2Plugin.ts @@ -55,14 +55,12 @@ class MySQL2Plugin implements SwPlugin { if (typeof sql === 'function') { sql = wrapCallback(span, sql, 0); - } else if (typeof sql === 'object') { _sql = sql.sql; if (typeof values === 'function') { values = wrapCallback(span, values, 0); _values = sql.values; - } else if (values !== undefined) { _values = values; @@ -71,17 +69,14 @@ class MySQL2Plugin implements SwPlugin { } else { streaming = true; } - } else { streaming = true; } - } else { _sql = sql; if (typeof values === 'function') { values = wrapCallback(span, values, 0); - } else if (values !== undefined) { _values = values; @@ -90,7 +85,6 @@ class MySQL2Plugin implements SwPlugin { } else { streaming = true; } - } else { streaming = true; } @@ -99,7 +93,7 @@ class MySQL2Plugin implements SwPlugin { span.tag(Tag.dbStatement(`${_sql}`)); if (agentConfig.sqlTraceParameters && _values) { - let vals = _values.map((v: any) => v === undefined ? 'undefined' : JSON.stringify(v)).join(', '); + let vals = _values.map((v: any) => (v === undefined ? 'undefined' : JSON.stringify(v))).join(', '); if (vals.length > agentConfig.sqlParametersMaxLength) vals = vals.slice(0, agentConfig.sqlParametersMaxLength) + ' ...'; @@ -109,9 +103,7 @@ class MySQL2Plugin implements SwPlugin { query = _query.call(this, sql, values, cb); - if (streaming) - wrapEmit(span, query, true, 'end'); - + if (streaming) wrapEmit(span, query, true, 'end'); } catch (e) { span.error(e); span.stop(); diff --git a/src/plugins/MySQLPlugin.ts b/src/plugins/MySQLPlugin.ts index caf0352..1e08033 100644 --- a/src/plugins/MySQLPlugin.ts +++ b/src/plugins/MySQLPlugin.ts @@ -17,7 +17,7 @@ * */ -import SwPlugin, {wrapEmit, wrapCallback} from '../core/SwPlugin'; +import SwPlugin, { wrapEmit, wrapCallback } from '../core/SwPlugin'; import ContextManager from '../trace/context/ContextManager'; import { Component } from '../trace/Component'; import Tag from '../Tag'; @@ -33,7 +33,7 @@ class MySQLPlugin implements SwPlugin { const Connection = installer.require('mysql/lib/Connection'); const _query = Connection.prototype.query; - Connection.prototype.query = function(sql: any, values: any, cb: any) { + Connection.prototype.query = function (sql: any, values: any, cb: any) { let query: any; const host = `${this.config.host}:${this.config.port}`; @@ -55,14 +55,12 @@ class MySQLPlugin implements SwPlugin { if (typeof sql === 'function') { sql = wrapCallback(span, sql, 0); - } else if (typeof sql === 'object') { _sql = sql.sql; if (typeof values === 'function') { values = wrapCallback(span, values, 0); _values = sql.values; - } else if (values !== undefined) { _values = values; @@ -71,17 +69,14 @@ class MySQLPlugin implements SwPlugin { } else { streaming = true; } - } else { streaming = true; } - } else { _sql = sql; if (typeof values === 'function') { values = wrapCallback(span, values, 0); - } else if (values !== undefined) { _values = values; @@ -90,7 +85,6 @@ class MySQLPlugin implements SwPlugin { } else { streaming = true; } - } else { streaming = true; } @@ -99,7 +93,7 @@ class MySQLPlugin implements SwPlugin { span.tag(Tag.dbStatement(`${_sql}`)); if (agentConfig.sqlTraceParameters && _values) { - let vals = _values.map((v: any) => v === undefined ? 'undefined' : JSON.stringify(v)).join(', '); + let vals = _values.map((v: any) => (v === undefined ? 'undefined' : JSON.stringify(v))).join(', '); if (vals.length > agentConfig.sqlParametersMaxLength) vals = vals.slice(0, agentConfig.sqlParametersMaxLength) + ' ...'; @@ -109,9 +103,7 @@ class MySQLPlugin implements SwPlugin { query = _query.call(this, sql, values, cb); - if (streaming) - wrapEmit(span, query, true, 'end'); - + if (streaming) wrapEmit(span, query, true, 'end'); } catch (e) { span.error(e); span.stop(); diff --git a/src/plugins/PgPlugin.ts b/src/plugins/PgPlugin.ts index ad266d0..3addc39 100644 --- a/src/plugins/PgPlugin.ts +++ b/src/plugins/PgPlugin.ts @@ -17,7 +17,7 @@ * */ -import SwPlugin, {wrapEmit, wrapCallback, wrapPromise} from '../core/SwPlugin'; +import SwPlugin, { wrapEmit, wrapCallback, wrapPromise } from '../core/SwPlugin'; import ContextManager from '../trace/context/ContextManager'; import { Component } from '../trace/Component'; import Tag from '../Tag'; @@ -36,11 +36,13 @@ class MySQLPlugin implements SwPlugin { try { Cursor = installer.require('pg-cursor'); - } catch { /* Linter food */ } + } catch { + /* Linter food */ + } const _query = Client.prototype.query; - Client.prototype.query = function(config: any, values: any, callback: any) { + Client.prototype.query = function (config: any, values: any, callback: any) { let query: any; const host = `${this.host}:${this.port}`; @@ -59,46 +61,39 @@ class MySQLPlugin implements SwPlugin { let _sql: any; let _values: any; - if (typeof config === 'string') - _sql = config; - + if (typeof config === 'string') _sql = config; else if (config !== null && config !== undefined) { - _sql = config.text; + _sql = config.text; _values = config.values; - if (typeof config.callback === 'function') - config.callback = wrapCallback(span, config.callback, 0); + if (typeof config.callback === 'function') config.callback = wrapCallback(span, config.callback, 0); } - if (typeof values === 'function') - values = wrapCallback(span, values, 0); - else if (_values !== undefined) - _values = values; + if (typeof values === 'function') values = wrapCallback(span, values, 0); + else if (_values !== undefined) _values = values; - if (typeof callback === 'function') - callback = wrapCallback(span, callback, 0); + if (typeof callback === 'function') callback = wrapCallback(span, callback, 0); span.tag(Tag.dbStatement(`${_sql}`)); if (agentConfig.sqlTraceParameters && _values) { - let vals = _values.map((v: any) => v === undefined ? 'undefined' : JSON.stringify(v)).join(', '); + let vals = _values.map((v: any) => (v === undefined ? 'undefined' : JSON.stringify(v))).join(', '); if (vals.length > agentConfig.sqlParametersMaxLength) vals = vals.slice(0, agentConfig.sqlParametersMaxLength) + ' ...'; - span.tag(Tag.dbSqlParameters(`[${vals}]`)); + span.tag(Tag.dbSqlParameters(`[${vals}]`)); } query = _query.call(this, config, values, callback); if (query) { - if (Cursor && query instanceof Cursor) - wrapEmit(span, query, true, 'end'); - else if (typeof query.then === 'function') // generic Promise check + if (Cursor && query instanceof Cursor) wrapEmit(span, query, true, 'end'); + else if (typeof query.then === 'function') + // generic Promise check query = wrapPromise(span, query); // else we assume there was a callback } - } catch (e) { span.error(e); span.stop(); diff --git a/src/trace/Component.ts b/src/trace/Component.ts index a4bd44f..6b45f17 100644 --- a/src/trace/Component.ts +++ b/src/trace/Component.ts @@ -32,5 +32,5 @@ export class Component { static readonly AXIOS = new Component(4005); static readonly MONGOOSE = new Component(4006); - constructor(public readonly id: number) { } + constructor(public readonly id: number) {} } From 8a5fc1cb015650b359ed064f83f8d236867b592c Mon Sep 17 00:00:00 2001 From: ruleeeer Date: Mon, 31 Jan 2022 17:53:52 +0800 Subject: [PATCH 5/5] Modify Github Action to pass the test --- .github/workflows/build.yaml | 11 +++++++++-- .github/workflows/test.yaml | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6df12d3..0dd5071 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - node-version: [ 10, 12, 14 ] + node-version: [ 10, 12, 14, 16 ] steps: - uses: actions/checkout@v2 with: @@ -47,8 +47,15 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Build + - name: Build On Node@12 And Above(Current:Node@${{matrix.node-version}}) + if: matrix.node-version >= 12 run: | npm i npm run lint npm run build + + - name: Build On Node@10 + if: matrix.node-version == 10 + run: | + npm i + npm run build diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cf53de9..1169706 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -49,12 +49,19 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Test + - name: Test On Node@12 And Above(Current:Node@${{matrix.node-version}}) + if: matrix.node-version >= 12 run: | npm i npm run lint npm run test + - name: Test On Node@10 + if: matrix.node-version == 10 + run: | + npm i + npm run test + TestLib: runs-on: ubuntu-18.04 timeout-minutes: 30