From 5a2a53cfa256a32aa342d4dee48492118065e84a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 7 Feb 2023 21:20:10 +0100 Subject: [PATCH] fix(simulator): detect string emptyness properly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Close #390 Signed-off-by: Jérôme Benoit --- package-lock.json | 293 +++++++++--------- package.json | 9 +- src/charging-station/AuthorizedTagsCache.ts | 2 +- src/charging-station/ChargingStation.ts | 14 +- src/charging-station/ChargingStationUtils.ts | 8 +- src/charging-station/SharedLRUCache.ts | 2 +- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 10 +- src/charging-station/ocpp/OCPPServiceUtils.ts | 2 +- .../ui-server/UIHttpServer.ts | 2 +- .../ui-server/UIWebSocketServer.ts | 2 +- src/utils/FileUtils.ts | 6 +- src/utils/Logger.ts | 2 +- src/utils/Utils.ts | 9 +- test/utils/UtilsTest.ts | 22 +- ui/web/package-lock.json | 14 +- ui/web/package.json | 2 +- 16 files changed, 219 insertions(+), 180 deletions(-) diff --git a/package-lock.json b/package-lock.json index 882f5454..69d682bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,9 +20,10 @@ "http-status-codes": "^2.2.0", "just-clone": "^6.2.0", "just-merge": "^3.2.0", + "logform": "^2.5.1", "mnemonist": "^0.39.5", "moment": "^2.29.4", - "mongodb": "^5.0.0", + "mongodb": "^5.0.1", "poolifier": "^2.3.7", "proper-lockfile": "^4.1.2", "source-map-support": "^0.5.21", @@ -41,7 +42,7 @@ "@rollup/plugin-json": "^6.0.0", "@types/mocha": "^10.0.1", "@types/mochawesome": "^6.2.1", - "@types/node": "^18.11.19", + "@types/node": "^18.13.0", "@types/proper-lockfile": "^4.1.2", "@types/tar": "^6.1.3", "@types/ws": "^8.5.4", @@ -59,9 +60,9 @@ "eslint-plugin-n": "^15.6.1", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-tsdoc": "^0.2.17", - "expect": "^29.4.1", + "expect": "^29.4.2", "husky": "^8.0.3", - "lint-staged": "^13.1.0", + "lint-staged": "^13.1.1", "mocha": "^10.2.0", "mochawesome": "^7.1.3", "prettier": "^2.8.3", @@ -1042,21 +1043,21 @@ } }, "node_modules/@jest/expect-utils": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.1.tgz", - "integrity": "sha512-w6YJMn5DlzmxjO00i9wu2YSozUYRBhIoJ6nQwpMYcBMtiqMGJm1QBzOf6DDgRao8dbtpDoaqLg6iiQTvv0UHhQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.2.tgz", + "integrity": "sha512-Dd3ilDJpBnqa0GiPN7QrudVs0cczMMHtehSo2CSTjm3zdHx0RcpmhFNVEltuEFeqfLIyWKFI224FsMSQ/nsJQA==", "dev": true, "dependencies": { - "jest-get-type": "^29.2.0" + "jest-get-type": "^29.4.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/schemas": { - "version": "29.4.0", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz", - "integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.2.tgz", + "integrity": "sha512-ZrGzGfh31NtdVH8tn0mgJw4khQuNHiKqdzJAFbCaERbyCP9tHlxWuL/mnMu8P7e/+k4puWjI1NOzi/sFsjce/g==", "dev": true, "dependencies": { "@sinclair/typebox": "^0.25.16" @@ -1066,12 +1067,12 @@ } }, "node_modules/@jest/types": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz", - "integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.2.tgz", + "integrity": "sha512-CKlngyGP0fwlgC1BRUtPZSiWLBhyS9dKwKmyGxk8Z6M82LBEGB2aLQSg+U1MyLsU+M7UjnlLllBM2BLWKVm/Uw==", "dev": true, "dependencies": { - "@jest/schemas": "^29.4.0", + "@jest/schemas": "^29.4.2", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", @@ -2150,9 +2151,9 @@ } }, "node_modules/@types/node": { - "version": "18.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.19.tgz", - "integrity": "sha512-YUgMWAQBWLObABqrvx8qKO1enAvBUdjZOAWQ5grBAkp5LQv45jBvYKZ3oFS9iKRCQyFjqw6iuEa1vmFqtxYLZw==" + "version": "18.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", + "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==" }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -2224,6 +2225,11 @@ "minipass": "^3.3.5" } }, + "node_modules/@types/triple-beam": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz", + "integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g==" + }, "node_modules/@types/ua-parser-js": { "version": "0.7.36", "resolved": "https://registry.npmjs.org/@types/ua-parser-js/-/ua-parser-js-0.7.36.tgz", @@ -2260,9 +2266,9 @@ } }, "node_modules/@types/yargs": { - "version": "17.0.20", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.20.tgz", - "integrity": "sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A==", + "version": "17.0.22", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", + "integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==", "dev": true, "dependencies": { "@types/yargs-parser": "*" @@ -5424,9 +5430,9 @@ } }, "node_modules/diff-sequences": { - "version": "29.3.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.3.1.tgz", - "integrity": "sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.2.tgz", + "integrity": "sha512-R6P0Y6PrsH3n4hUXxL3nns0rbRk6Q33js3ygJBeEpbzLzgcNuJ61+u0RXasFpTKISw99TxUzFnumSnRLsjhLaw==", "dev": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -6644,16 +6650,16 @@ } }, "node_modules/expect": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.1.tgz", - "integrity": "sha512-OKrGESHOaMxK3b6zxIq9SOW8kEXztKff/Dvg88j4xIJxur1hspEbedVkR3GpHe5LO+WB2Qw7OWN0RMTdp6as5A==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.2.tgz", + "integrity": "sha512-+JHYg9O3hd3RlICG90OPVjRkPBoiUH7PxvDVMnRiaq1g6JUgZStX514erMl0v2Dc5SkfVbm7ztqbd6qHHPn+mQ==", "dev": true, "dependencies": { - "@jest/expect-utils": "^29.4.1", - "jest-get-type": "^29.2.0", - "jest-matcher-utils": "^29.4.1", - "jest-message-util": "^29.4.1", - "jest-util": "^29.4.1" + "@jest/expect-utils": "^29.4.2", + "jest-get-type": "^29.4.2", + "jest-matcher-utils": "^29.4.2", + "jest-message-util": "^29.4.2", + "jest-util": "^29.4.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -9036,57 +9042,57 @@ } }, "node_modules/jest-diff": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.1.tgz", - "integrity": "sha512-uazdl2g331iY56CEyfbNA0Ut7Mn2ulAG5vUaEHXycf1L6IPyuImIxSz4F0VYBKi7LYIuxOwTZzK3wh5jHzASMw==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.2.tgz", + "integrity": "sha512-EK8DSajVtnjx9sa1BkjZq3mqChm2Cd8rIzdXkQMA8e0wuXq53ypz6s5o5V8HRZkoEt2ywJ3eeNWFKWeYr8HK4g==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "diff-sequences": "^29.3.1", - "jest-get-type": "^29.2.0", - "pretty-format": "^29.4.1" + "diff-sequences": "^29.4.2", + "jest-get-type": "^29.4.2", + "pretty-format": "^29.4.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-get-type": { - "version": "29.2.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.2.0.tgz", - "integrity": "sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.2.tgz", + "integrity": "sha512-vERN30V5i2N6lqlFu4ljdTqQAgrkTFMC9xaIIfOPYBw04pufjXRty5RuXBiB1d72tGbURa/UgoiHB90ruOSivg==", "dev": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-matcher-utils": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.1.tgz", - "integrity": "sha512-k5h0u8V4nAEy6lSACepxL/rw78FLDkBnXhZVgFneVpnJONhb2DhZj/Gv4eNe+1XqQ5IhgUcqj745UwH0HJmMnA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.2.tgz", + "integrity": "sha512-EZaAQy2je6Uqkrm6frnxBIdaWtSYFoR8SVb2sNLAtldswlR/29JAgx+hy67llT3+hXBaLB0zAm5UfeqerioZyg==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^29.4.1", - "jest-get-type": "^29.2.0", - "pretty-format": "^29.4.1" + "jest-diff": "^29.4.2", + "jest-get-type": "^29.4.2", + "pretty-format": "^29.4.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-message-util": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.1.tgz", - "integrity": "sha512-H4/I0cXUaLeCw6FM+i4AwCnOwHRgitdaUFOdm49022YD5nfyr8C/DrbXOBEyJaj+w/y0gGJ57klssOaUiLLQGQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.2.tgz", + "integrity": "sha512-SElcuN4s6PNKpOEtTInjOAA8QvItu0iugkXqhYyguRvQoXapg5gN+9RQxLAkakChZA7Y26j6yUCsFWN+hlKD6g==", "dev": true, "dependencies": { "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.4.1", + "@jest/types": "^29.4.2", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.4.1", + "pretty-format": "^29.4.2", "slash": "^3.0.0", "stack-utils": "^2.0.3" }, @@ -9095,12 +9101,12 @@ } }, "node_modules/jest-util": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz", - "integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.2.tgz", + "integrity": "sha512-wKnm6XpJgzMUSRFB7YF48CuwdzuDIHenVuoIb1PLuJ6F+uErZsuDkU+EiExkChf6473XcawBrSfDSnXl+/YG4g==", "dev": true, "dependencies": { - "@jest/types": "^29.4.1", + "@jest/types": "^29.4.2", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -9460,9 +9466,9 @@ "dev": true }, "node_modules/lint-staged": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.0.tgz", - "integrity": "sha512-pn/sR8IrcF/T0vpWLilih8jmVouMlxqXxKuAojmbiGX5n/gDnz+abdPptlj0vYnbfE0SQNl3CY/HwtM0+yfOVQ==", + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.1.tgz", + "integrity": "sha512-LLJLO0Kdbcv2a+CvSF4p1M7jBZOajKSMpBUvyR8+bXccsqPER0/NxTFQSpNHjqwV9kM3tkHczYerTB5wI+bksQ==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", @@ -9870,11 +9876,12 @@ } }, "node_modules/logform": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.4.2.tgz", - "integrity": "sha512-W4c9himeAwXEdZ05dQNerhFz2XG80P9Oj0loPUMV23VC2it0orMHQhJm4hdnnor3rd1HsGf6a2lPwBM1zeXHGw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.5.1.tgz", + "integrity": "sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg==", "dependencies": { "@colors/colors": "1.5.0", + "@types/triple-beam": "^1.3.2", "fecha": "^4.2.0", "ms": "^2.1.1", "safe-stable-stringify": "^2.3.1", @@ -10841,9 +10848,9 @@ } }, "node_modules/mongodb": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.0.tgz", - "integrity": "sha512-WHmlbefKp/iAX2LlSZ56iKt4pRftib/dD3mDaji8R7IJcRoKPc5+/kSn3mIBxKPLVxcl73KdDKBLkQTxj1OjaA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz", + "integrity": "sha512-KpjtY+NWFmcic6UDYEdfn768ZTuKyv7CRaui7ZSd6q/0/o1AURMC7KygTUwB1Cl8V10Pe5NiP+Y2eBMCDs/ygQ==", "dependencies": { "bson": "^5.0.0", "mongodb-connection-string-url": "^2.6.0", @@ -12450,12 +12457,12 @@ } }, "node_modules/pretty-format": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.1.tgz", - "integrity": "sha512-dt/Z761JUVsrIKaY215o1xQJBGlSmTx/h4cSqXqjHLnU1+Kt+mavVE7UgqJJO5ukx5HjSswHfmXz4LjS2oIJfg==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz", + "integrity": "sha512-qKlHR8yFVCbcEWba0H0TOC8dnLlO4vPlyEjRPw31FZ2Rupy9nLa8ZLbYny8gWEl8CkEhJqAE6IzdNELTBVcBEg==", "dev": true, "dependencies": { - "@jest/schemas": "^29.4.0", + "@jest/schemas": "^29.4.2", "ansi-styles": "^5.0.0", "react-is": "^18.0.0" }, @@ -13208,9 +13215,9 @@ } }, "node_modules/release-it/node_modules/ansi-escapes/node_modules/type-fest": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.5.5.tgz", - "integrity": "sha512-Nudle2CLcCaf9/1bVQunwzX1/ZH4Z6mvP8hkWWZCbKrxtnN52QwD5Xn/mo68aofQhGU4be1GlEC6LQCTKGXkRw==", + "version": "3.5.6", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.5.6.tgz", + "integrity": "sha512-6bd2bflx8ed7c99tc6zSTIzHr1/QG29bQoK4Qh8MYGnlPbODUzGxklLShjwc/xWQQFHgIci+y5Arv7Rbb0LjXw==", "dev": true, "engines": { "node": ">=14.16" @@ -18280,30 +18287,30 @@ } }, "@jest/expect-utils": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.1.tgz", - "integrity": "sha512-w6YJMn5DlzmxjO00i9wu2YSozUYRBhIoJ6nQwpMYcBMtiqMGJm1QBzOf6DDgRao8dbtpDoaqLg6iiQTvv0UHhQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.2.tgz", + "integrity": "sha512-Dd3ilDJpBnqa0GiPN7QrudVs0cczMMHtehSo2CSTjm3zdHx0RcpmhFNVEltuEFeqfLIyWKFI224FsMSQ/nsJQA==", "dev": true, "requires": { - "jest-get-type": "^29.2.0" + "jest-get-type": "^29.4.2" } }, "@jest/schemas": { - "version": "29.4.0", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz", - "integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.2.tgz", + "integrity": "sha512-ZrGzGfh31NtdVH8tn0mgJw4khQuNHiKqdzJAFbCaERbyCP9tHlxWuL/mnMu8P7e/+k4puWjI1NOzi/sFsjce/g==", "dev": true, "requires": { "@sinclair/typebox": "^0.25.16" } }, "@jest/types": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz", - "integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.2.tgz", + "integrity": "sha512-CKlngyGP0fwlgC1BRUtPZSiWLBhyS9dKwKmyGxk8Z6M82LBEGB2aLQSg+U1MyLsU+M7UjnlLllBM2BLWKVm/Uw==", "dev": true, "requires": { - "@jest/schemas": "^29.4.0", + "@jest/schemas": "^29.4.2", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", @@ -19053,9 +19060,9 @@ } }, "@types/node": { - "version": "18.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.19.tgz", - "integrity": "sha512-YUgMWAQBWLObABqrvx8qKO1enAvBUdjZOAWQ5grBAkp5LQv45jBvYKZ3oFS9iKRCQyFjqw6iuEa1vmFqtxYLZw==" + "version": "18.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", + "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==" }, "@types/normalize-package-data": { "version": "2.4.1", @@ -19127,6 +19134,11 @@ "minipass": "^3.3.5" } }, + "@types/triple-beam": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz", + "integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g==" + }, "@types/ua-parser-js": { "version": "0.7.36", "resolved": "https://registry.npmjs.org/@types/ua-parser-js/-/ua-parser-js-0.7.36.tgz", @@ -19163,9 +19175,9 @@ } }, "@types/yargs": { - "version": "17.0.20", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.20.tgz", - "integrity": "sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A==", + "version": "17.0.22", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", + "integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -21668,9 +21680,9 @@ "dev": true }, "diff-sequences": { - "version": "29.3.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.3.1.tgz", - "integrity": "sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.2.tgz", + "integrity": "sha512-R6P0Y6PrsH3n4hUXxL3nns0rbRk6Q33js3ygJBeEpbzLzgcNuJ61+u0RXasFpTKISw99TxUzFnumSnRLsjhLaw==", "dev": true }, "diffie-hellman": { @@ -22645,16 +22657,16 @@ } }, "expect": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.1.tgz", - "integrity": "sha512-OKrGESHOaMxK3b6zxIq9SOW8kEXztKff/Dvg88j4xIJxur1hspEbedVkR3GpHe5LO+WB2Qw7OWN0RMTdp6as5A==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.2.tgz", + "integrity": "sha512-+JHYg9O3hd3RlICG90OPVjRkPBoiUH7PxvDVMnRiaq1g6JUgZStX514erMl0v2Dc5SkfVbm7ztqbd6qHHPn+mQ==", "dev": true, "requires": { - "@jest/expect-utils": "^29.4.1", - "jest-get-type": "^29.2.0", - "jest-matcher-utils": "^29.4.1", - "jest-message-util": "^29.4.1", - "jest-util": "^29.4.1" + "@jest/expect-utils": "^29.4.2", + "jest-get-type": "^29.4.2", + "jest-matcher-utils": "^29.4.2", + "jest-message-util": "^29.4.2", + "jest-util": "^29.4.2" } }, "ext": { @@ -24500,59 +24512,59 @@ } }, "jest-diff": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.1.tgz", - "integrity": "sha512-uazdl2g331iY56CEyfbNA0Ut7Mn2ulAG5vUaEHXycf1L6IPyuImIxSz4F0VYBKi7LYIuxOwTZzK3wh5jHzASMw==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.2.tgz", + "integrity": "sha512-EK8DSajVtnjx9sa1BkjZq3mqChm2Cd8rIzdXkQMA8e0wuXq53ypz6s5o5V8HRZkoEt2ywJ3eeNWFKWeYr8HK4g==", "dev": true, "requires": { "chalk": "^4.0.0", - "diff-sequences": "^29.3.1", - "jest-get-type": "^29.2.0", - "pretty-format": "^29.4.1" + "diff-sequences": "^29.4.2", + "jest-get-type": "^29.4.2", + "pretty-format": "^29.4.2" } }, "jest-get-type": { - "version": "29.2.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.2.0.tgz", - "integrity": "sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.2.tgz", + "integrity": "sha512-vERN30V5i2N6lqlFu4ljdTqQAgrkTFMC9xaIIfOPYBw04pufjXRty5RuXBiB1d72tGbURa/UgoiHB90ruOSivg==", "dev": true }, "jest-matcher-utils": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.1.tgz", - "integrity": "sha512-k5h0u8V4nAEy6lSACepxL/rw78FLDkBnXhZVgFneVpnJONhb2DhZj/Gv4eNe+1XqQ5IhgUcqj745UwH0HJmMnA==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.2.tgz", + "integrity": "sha512-EZaAQy2je6Uqkrm6frnxBIdaWtSYFoR8SVb2sNLAtldswlR/29JAgx+hy67llT3+hXBaLB0zAm5UfeqerioZyg==", "dev": true, "requires": { "chalk": "^4.0.0", - "jest-diff": "^29.4.1", - "jest-get-type": "^29.2.0", - "pretty-format": "^29.4.1" + "jest-diff": "^29.4.2", + "jest-get-type": "^29.4.2", + "pretty-format": "^29.4.2" } }, "jest-message-util": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.1.tgz", - "integrity": "sha512-H4/I0cXUaLeCw6FM+i4AwCnOwHRgitdaUFOdm49022YD5nfyr8C/DrbXOBEyJaj+w/y0gGJ57klssOaUiLLQGQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.2.tgz", + "integrity": "sha512-SElcuN4s6PNKpOEtTInjOAA8QvItu0iugkXqhYyguRvQoXapg5gN+9RQxLAkakChZA7Y26j6yUCsFWN+hlKD6g==", "dev": true, "requires": { "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.4.1", + "@jest/types": "^29.4.2", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.4.1", + "pretty-format": "^29.4.2", "slash": "^3.0.0", "stack-utils": "^2.0.3" } }, "jest-util": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz", - "integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.2.tgz", + "integrity": "sha512-wKnm6XpJgzMUSRFB7YF48CuwdzuDIHenVuoIb1PLuJ6F+uErZsuDkU+EiExkChf6473XcawBrSfDSnXl+/YG4g==", "dev": true, "requires": { - "@jest/types": "^29.4.1", + "@jest/types": "^29.4.2", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -24828,9 +24840,9 @@ "dev": true }, "lint-staged": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.0.tgz", - "integrity": "sha512-pn/sR8IrcF/T0vpWLilih8jmVouMlxqXxKuAojmbiGX5n/gDnz+abdPptlj0vYnbfE0SQNl3CY/HwtM0+yfOVQ==", + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.1.tgz", + "integrity": "sha512-LLJLO0Kdbcv2a+CvSF4p1M7jBZOajKSMpBUvyR8+bXccsqPER0/NxTFQSpNHjqwV9kM3tkHczYerTB5wI+bksQ==", "dev": true, "requires": { "cli-truncate": "^3.1.0", @@ -25152,11 +25164,12 @@ } }, "logform": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.4.2.tgz", - "integrity": "sha512-W4c9himeAwXEdZ05dQNerhFz2XG80P9Oj0loPUMV23VC2it0orMHQhJm4hdnnor3rd1HsGf6a2lPwBM1zeXHGw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.5.1.tgz", + "integrity": "sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg==", "requires": { "@colors/colors": "1.5.0", + "@types/triple-beam": "^1.3.2", "fecha": "^4.2.0", "ms": "^2.1.1", "safe-stable-stringify": "^2.3.1", @@ -25945,9 +25958,9 @@ } }, "mongodb": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.0.tgz", - "integrity": "sha512-WHmlbefKp/iAX2LlSZ56iKt4pRftib/dD3mDaji8R7IJcRoKPc5+/kSn3mIBxKPLVxcl73KdDKBLkQTxj1OjaA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.0.1.tgz", + "integrity": "sha512-KpjtY+NWFmcic6UDYEdfn768ZTuKyv7CRaui7ZSd6q/0/o1AURMC7KygTUwB1Cl8V10Pe5NiP+Y2eBMCDs/ygQ==", "requires": { "bson": "^5.0.0", "mongodb-connection-string-url": "^2.6.0", @@ -27136,12 +27149,12 @@ "dev": true }, "pretty-format": { - "version": "29.4.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.1.tgz", - "integrity": "sha512-dt/Z761JUVsrIKaY215o1xQJBGlSmTx/h4cSqXqjHLnU1+Kt+mavVE7UgqJJO5ukx5HjSswHfmXz4LjS2oIJfg==", + "version": "29.4.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz", + "integrity": "sha512-qKlHR8yFVCbcEWba0H0TOC8dnLlO4vPlyEjRPw31FZ2Rupy9nLa8ZLbYny8gWEl8CkEhJqAE6IzdNELTBVcBEg==", "dev": true, "requires": { - "@jest/schemas": "^29.4.0", + "@jest/schemas": "^29.4.2", "ansi-styles": "^5.0.0", "react-is": "^18.0.0" }, @@ -27751,9 +27764,9 @@ }, "dependencies": { "type-fest": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.5.5.tgz", - "integrity": "sha512-Nudle2CLcCaf9/1bVQunwzX1/ZH4Z6mvP8hkWWZCbKrxtnN52QwD5Xn/mo68aofQhGU4be1GlEC6LQCTKGXkRw==", + "version": "3.5.6", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.5.6.tgz", + "integrity": "sha512-6bd2bflx8ed7c99tc6zSTIzHr1/QG29bQoK4Qh8MYGnlPbODUzGxklLShjwc/xWQQFHgIci+y5Arv7Rbb0LjXw==", "dev": true } } diff --git a/package.json b/package.json index a98354ed..6e75c629 100644 --- a/package.json +++ b/package.json @@ -83,9 +83,10 @@ "http-status-codes": "^2.2.0", "just-clone": "^6.2.0", "just-merge": "^3.2.0", + "logform": "^2.5.1", "mnemonist": "^0.39.5", "moment": "^2.29.4", - "mongodb": "^5.0.0", + "mongodb": "^5.0.1", "poolifier": "^2.3.7", "proper-lockfile": "^4.1.2", "source-map-support": "^0.5.21", @@ -108,7 +109,7 @@ "@rollup/plugin-json": "^6.0.0", "@types/mocha": "^10.0.1", "@types/mochawesome": "^6.2.1", - "@types/node": "^18.11.19", + "@types/node": "^18.13.0", "@types/proper-lockfile": "^4.1.2", "@types/tar": "^6.1.3", "@types/ws": "^8.5.4", @@ -126,9 +127,9 @@ "eslint-plugin-n": "^15.6.1", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-tsdoc": "^0.2.17", - "expect": "^29.4.1", + "expect": "^29.4.2", "husky": "^8.0.3", - "lint-staged": "^13.1.0", + "lint-staged": "^13.1.1", "mocha": "^10.2.0", "mochawesome": "^7.1.3", "prettier": "^2.8.3", diff --git a/src/charging-station/AuthorizedTagsCache.ts b/src/charging-station/AuthorizedTagsCache.ts index fd085890..a3c8e5cd 100644 --- a/src/charging-station/AuthorizedTagsCache.ts +++ b/src/charging-station/AuthorizedTagsCache.ts @@ -35,7 +35,7 @@ export default class AuthorizedTagsCache { this.logPrefix(file), undefined, (event, filename) => { - if (!Utils.isEmptyString(filename) && event === 'change') { + if (Utils.isNotEmptyString(filename) && event === 'change') { try { logger.debug( `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload` diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 0de7ab93..65ea0873 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -161,7 +161,7 @@ export default class ChargingStation { public logPrefix = (): string => { return Utils.logPrefix( ` ${ - (!Utils.isEmptyString(this?.stationInfo?.chargingStationId) && + (Utils.isNotEmptyString(this?.stationInfo?.chargingStationId) && this?.stationInfo?.chargingStationId) ?? ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile()) ?? '' @@ -514,7 +514,7 @@ export default class ChargingStation { this.logPrefix(), undefined, (event, filename): void => { - if (!Utils.isEmptyString(filename) && event === 'change') { + if (Utils.isNotEmptyString(filename) && event === 'change') { try { logger.debug( `${this.logPrefix()} ${FileType.ChargingStationTemplate} ${ @@ -882,7 +882,7 @@ export default class ChargingStation { stationInfo.firmwareVersionPattern = stationTemplate?.firmwareVersionPattern ?? Constants.SEMVER_PATTERN; if ( - !Utils.isEmptyString(stationInfo.firmwareVersion) && + Utils.isNotEmptyString(stationInfo.firmwareVersion) && new RegExp(stationInfo.firmwareVersionPattern).test(stationInfo.firmwareVersion) === false ) { logger.warn( @@ -1037,8 +1037,8 @@ export default class ChargingStation { } if ( this.stationInfo.firmwareStatus === FirmwareStatus.Installing && - !Utils.isEmptyString(this.stationInfo.firmwareVersion) && - !Utils.isEmptyString(this.stationInfo.firmwareVersionPattern) + Utils.isNotEmptyString(this.stationInfo.firmwareVersion) && + Utils.isNotEmptyString(this.stationInfo.firmwareVersionPattern) ) { const patternGroup: number | undefined = this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ?? @@ -1102,7 +1102,7 @@ export default class ChargingStation { ); } if ( - !Utils.isEmptyString(this.stationInfo?.amperageLimitationOcppKey) && + Utils.isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) && !ChargingStationConfigurationUtils.getConfigurationKey( this, this.stationInfo.amperageLimitationOcppKey @@ -1767,7 +1767,7 @@ export default class ChargingStation { private getAmperageLimitation(): number | undefined { if ( - !Utils.isEmptyString(this.stationInfo?.amperageLimitationOcppKey) && + Utils.isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) && ChargingStationConfigurationUtils.getConfigurationKey( this, this.stationInfo.amperageLimitationOcppKey diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 534a3786..2d1adb5d 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -210,7 +210,7 @@ export class ChargingStationUtils { if (!Utils.isUndefined(template[key])) { logger.warn( `${logPrefix} Deprecated template key '${key}' usage in file '${templateFile}'${ - !Utils.isEmptyString(logMsgToAppend) && `. ${logMsgToAppend}` + Utils.isNotEmptyString(logMsgToAppend) && `. ${logMsgToAppend}` }` ); } @@ -269,13 +269,13 @@ export class ChargingStationUtils { }) : ''; stationInfo.chargePointSerialNumber = - !Utils.isEmptyString(stationTemplate?.chargePointSerialNumberPrefix) && + Utils.isNotEmptyString(stationTemplate?.chargePointSerialNumberPrefix) && `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`; stationInfo.chargeBoxSerialNumber = - !Utils.isEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) && + Utils.isNotEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) && `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`; stationInfo.meterSerialNumber = - !Utils.isEmptyString(stationTemplate?.meterSerialNumberPrefix) && + Utils.isNotEmptyString(stationTemplate?.meterSerialNumberPrefix) && `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`; } diff --git a/src/charging-station/SharedLRUCache.ts b/src/charging-station/SharedLRUCache.ts index 6b6df204..97ed4cd1 100644 --- a/src/charging-station/SharedLRUCache.ts +++ b/src/charging-station/SharedLRUCache.ts @@ -115,7 +115,7 @@ export default class SharedLRUCache { Utils.isNullOrUndefined(chargingStationConfiguration?.configurationHash) === false && Utils.isEmptyArray(chargingStationConfiguration?.configurationKey) === false && Utils.isEmptyObject(chargingStationConfiguration?.stationInfo) === false && - Utils.isEmptyString(chargingStationConfiguration?.configurationHash) === false + Utils.isNotEmptyString(chargingStationConfiguration?.configurationHash) === true ); } } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index fa3d8328..1340d8ac 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -749,7 +749,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if ( chargingStation.getLocalAuthListEnabled() === true && chargingStation.hasAuthorizedTags() === true && - !Utils.isEmptyString( + Utils.isNotEmptyString( chargingStation.authorizedTagsCache .getAuthorizedTags( ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo) @@ -1027,7 +1027,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer } if ( chargingStation.stationInfo?.firmwareUpgrade?.failureStatus && - !Utils.isEmptyString(chargingStation.stationInfo?.firmwareUpgrade?.failureStatus) + Utils.isNotEmptyString(chargingStation.stationInfo?.firmwareUpgrade?.failureStatus) ) { await chargingStation.ocppRequestService.requestHandler< OCPP16FirmwareStatusNotificationRequest, @@ -1095,9 +1095,9 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ftpClient = new Client(); const accessResponse = await ftpClient.access({ host: uri.host, - ...(!Utils.isEmptyString(uri.port) && { port: Utils.convertToInt(uri.port) }), - ...(!Utils.isEmptyString(uri.username) && { user: uri.username }), - ...(!Utils.isEmptyString(uri.password) && { password: uri.password }), + ...(Utils.isNotEmptyString(uri.port) && { port: Utils.convertToInt(uri.port) }), + ...(Utils.isNotEmptyString(uri.username) && { user: uri.username }), + ...(Utils.isNotEmptyString(uri.password) && { password: uri.password }), }); let uploadResponse: FTPResponse; if (accessResponse.code === 220) { diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 308f6b41..178e4be7 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -291,7 +291,7 @@ export class OCPPServiceUtils { methodName?: string ): string => { const logMsg = - !Utils.isEmptyString(moduleName) && !Utils.isEmptyString(methodName) + Utils.isNotEmptyString(moduleName) && Utils.isNotEmptyString(methodName) ? ` OCPP ${ocppVersion} | ${moduleName}.${methodName}:` : ` OCPP ${ocppVersion} |`; return Utils.logPrefix(logMsg); diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index f339dc3f..48dfadbd 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -63,7 +63,7 @@ export default class UIHttpServer extends AbstractUIServer { public logPrefix = (modName?: string, methodName?: string, prefixSuffix?: string): string => { const logMsgPrefix = prefixSuffix ? `UI HTTP Server ${prefixSuffix}` : 'UI HTTP Server'; const logMsg = - !Utils.isEmptyString(modName) && !Utils.isEmptyString(methodName) + Utils.isNotEmptyString(modName) && Utils.isNotEmptyString(methodName) ? ` ${logMsgPrefix} | ${modName}.${methodName}:` : ` ${logMsgPrefix} |`; return Utils.logPrefix(logMsg); diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index a8abad0b..9e8ad84b 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -150,7 +150,7 @@ export default class UIWebSocketServer extends AbstractUIServer { ? `UI WebSocket Server ${prefixSuffix}` : 'UI WebSocket Server'; const logMsg = - !Utils.isEmptyString(modName) && !Utils.isEmptyString(methodName) + Utils.isNotEmptyString(modName) && Utils.isNotEmptyString(methodName) ? ` ${logMsgPrefix} | ${modName}.${methodName}:` : ` ${logMsgPrefix} |`; return Utils.logPrefix(logMsg); diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index 8ef81680..ee8f053c 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -20,7 +20,7 @@ export default class FileUtils { logPrefix: string, refreshedVariable?: T, listener: fs.WatchListener = (event, filename) => { - if (!Utils.isEmptyString(filename) && event === 'change') { + if (Utils.isNotEmptyString(filename) && event === 'change') { try { logger.debug(`${logPrefix} ${fileType} file ${file} have changed, reload`); refreshedVariable && (refreshedVariable = JSON.parse(fs.readFileSync(file, 'utf8')) as T); @@ -32,7 +32,7 @@ export default class FileUtils { } } ): fs.FSWatcher | undefined { - if (!Utils.isEmptyString(file)) { + if (Utils.isNotEmptyString(file)) { try { return fs.watch(file, listener); } catch (error) { @@ -52,7 +52,7 @@ export default class FileUtils { logPrefix: string, params: HandleErrorParams = { throwError: true, consoleOut: false } ): void { - const prefix = !Utils.isEmptyString(logPrefix) ? `${logPrefix} ` : ''; + const prefix = Utils.isNotEmptyString(logPrefix) ? `${logPrefix} ` : ''; let logMsg: string; switch (error.code) { case 'ENOENT': diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 46897bb9..4b884638 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -1,5 +1,5 @@ import type { Format } from 'logform'; -import { Logger, createLogger, format, transport } from 'winston'; +import { type Logger, createLogger, format, type transport } from 'winston'; import TransportType from 'winston/lib/winston/transports'; import DailyRotateFile from 'winston-daily-rotate-file'; diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 81026720..43389155 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -193,7 +193,14 @@ export default class Utils { } public static isEmptyString(value: unknown): boolean { - return Utils.isString(value) && (value as string).trim().length === 0; + return ( + Utils.isNullOrUndefined(value) || + (Utils.isString(value) && (value as string).trim().length === 0) + ); + } + + public static isNotEmptyString(value: unknown): boolean { + return Utils.isString(value) && (value as string).trim().length > 0; } public static isUndefined(value: unknown): boolean { diff --git a/test/utils/UtilsTest.ts b/test/utils/UtilsTest.ts index 293c24d3..9d694308 100644 --- a/test/utils/UtilsTest.ts +++ b/test/utils/UtilsTest.ts @@ -167,8 +167,8 @@ describe('Utils test suite', () => { expect(Utils.isEmptyString('test')).toBe(false); expect(Utils.isEmptyString(' test')).toBe(false); expect(Utils.isEmptyString('test ')).toBe(false); - expect(Utils.isEmptyString(undefined)).toBe(false); - expect(Utils.isEmptyString(null)).toBe(false); + expect(Utils.isEmptyString(undefined)).toBe(true); + expect(Utils.isEmptyString(null)).toBe(true); expect(Utils.isEmptyString(0)).toBe(false); expect(Utils.isEmptyString({})).toBe(false); expect(Utils.isEmptyString([])).toBe(false); @@ -178,6 +178,24 @@ describe('Utils test suite', () => { expect(Utils.isEmptyString(new WeakSet())).toBe(false); }); + it('Verify isNotEmptyString()', () => { + expect(Utils.isNotEmptyString('')).toBe(false); + expect(Utils.isNotEmptyString(' ')).toBe(false); + expect(Utils.isNotEmptyString(' ')).toBe(false); + expect(Utils.isNotEmptyString('test')).toBe(true); + expect(Utils.isNotEmptyString(' test')).toBe(true); + expect(Utils.isNotEmptyString('test ')).toBe(true); + expect(Utils.isNotEmptyString(undefined)).toBe(false); + expect(Utils.isNotEmptyString(null)).toBe(false); + expect(Utils.isNotEmptyString(0)).toBe(false); + expect(Utils.isNotEmptyString({})).toBe(false); + expect(Utils.isNotEmptyString([])).toBe(false); + expect(Utils.isNotEmptyString(new Map())).toBe(false); + expect(Utils.isNotEmptyString(new Set())).toBe(false); + expect(Utils.isNotEmptyString(new WeakMap())).toBe(false); + expect(Utils.isNotEmptyString(new WeakSet())).toBe(false); + }); + it('Verify isUndefined()', () => { expect(Utils.isUndefined(undefined)).toBe(true); expect(Utils.isUndefined(null)).toBe(false); diff --git a/ui/web/package-lock.json b/ui/web/package-lock.json index f56c164b..54ab10fe 100644 --- a/ui/web/package-lock.json +++ b/ui/web/package-lock.json @@ -18,7 +18,7 @@ "devDependencies": { "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.19", + "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^5.51.0", "@typescript-eslint/parser": "^5.51.0", "@vue/cli": "~5.0.8", @@ -2863,9 +2863,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.19.tgz", - "integrity": "sha512-YUgMWAQBWLObABqrvx8qKO1enAvBUdjZOAWQ5grBAkp5LQv45jBvYKZ3oFS9iKRCQyFjqw6iuEa1vmFqtxYLZw==", + "version": "18.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", + "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -21006,9 +21006,9 @@ "dev": true }, "@types/node": { - "version": "18.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.19.tgz", - "integrity": "sha512-YUgMWAQBWLObABqrvx8qKO1enAvBUdjZOAWQ5grBAkp5LQv45jBvYKZ3oFS9iKRCQyFjqw6iuEa1vmFqtxYLZw==", + "version": "18.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", + "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==", "dev": true }, "@types/normalize-package-data": { diff --git a/ui/web/package.json b/ui/web/package.json index a66eae7a..746ef238 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.19", + "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^5.51.0", "@typescript-eslint/parser": "^5.51.0", "@vue/cli": "~5.0.8", -- 2.34.1