diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f872351..2fe09d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,7 +49,6 @@ jobs: # npx force-resolutions : in case of Permission denied: run it locally to fix package-lock.json run: | echo "install" - pnpm run preinstall pnpm install echo "show outdated (if any)" pnpm outdated --depth=3 || echo "you must think about update your dependencies :)" diff --git a/README.md b/README.md index 4f24fcc..a4a5b2f 100644 --- a/README.md +++ b/README.md @@ -328,12 +328,7 @@ For security reason, since [#102](https://github.com/boly38/node-mongotools/issu You're not a dev ? just submit an issue (bug, improvements, questions). Or else: * Clone * Install deps -* Then mocha tests -``` -git clone https://github.com/boly38/node-mongotools.git -pnpm install -pnpm run test -``` +* Then mocha tests (cf. [README](./tests/README.md)) * you could also fork, feature branch, then submit a pull request. ### Services or activated bots diff --git a/lib/MTDropbox.js b/lib/MTDropbox.js index 60d4c81..442e582 100644 --- a/lib/MTDropbox.js +++ b/lib/MTDropbox.js @@ -22,9 +22,8 @@ export default class MTDropbox { }) .catch(filesListError => { MUST_LOG_DEBUG && console.log('filesListError', filesListError) - const {status} = filesListError; - if (status === 409) { - reject(new Error(`Dropbox path '${path}' dont exist`)); + if (isPathNotFoundError(filesListError)) { + resolve([]); return; } reject(new Error( @@ -230,8 +229,13 @@ function getDropbox(options) { }) } +function isPathNotFoundError(filesListError) { + const {status, error} = filesListError; + return (status === 409 && error?.error_summary?.includes("not_found")); +} + function dropboxErrorResponseToSummary(dropboxResponseError) { const {status, error} = dropboxResponseError - const error_summary = error?.error_summary /* deprecated */ || error; + const error_summary = error?.error_summary || error; return `[status:${status}] ${error_summary}`; } \ No newline at end of file diff --git a/package.json b/package.json index 0efe39e..be6c0bf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "scripts": { "lint": "eslint .", "audit": "npm audit --omit=dev", - "preinstall": "npx force-resolutions", "test-requirement": "echo You must do: source ./env/initEnv.test.sh", "test": "echo test&& mocha --bail --unhandled-rejections=strict tests/*.test.js --timeout 50000", "test21": "echo beta test with nodejs 21&& node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info --test tests", @@ -39,12 +38,7 @@ ], "copyright": { "title": "node-mongotools", - "years": [ - 2020, - 2021, - 2022, - 2023 - ], + "years": [2020,2021,2022,2023,2024,2025], "author": "Brice Vandeputte" }, "dependencies": { @@ -55,7 +49,7 @@ "devDependencies": { "@eslint/js": "^9.35.0", "@stylistic/eslint-plugin": "^5.3.1", - "@types/node": "^24.5.1", + "@types/node": "^24.5.2", "chai": "^6.0.1", "chai-string": "^1.6.0", "eslint": "^9.35.0", @@ -66,14 +60,20 @@ "json5": "^2.2.3", "mocha": "^11.7.2", "mongoose": "^8.18.1", - "npm-force-resolutions": "^0.0.10", "nyc": "^17.1.0" }, "pnpm": { "overrides": { - "form-data": "^4.0.4" + "form-data": "^4.0.4", + "chai-string>chai": "^6.0.1", + "glob": "^9.3.5", + "rimraf": "^3.0.2" } }, + "doc": { + "npm-force-resolutions": "needed by GHA", + "rimraf": "need to move from nyc to c8" + }, "jshintConfig": { "esversion": 6 }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 443e406..ad5bd21 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,9 @@ settings: overrides: form-data: ^4.0.4 + chai-string>chai: ^6.0.1 + glob: ^9.3.5 + rimraf: ^3.0.2 importers: @@ -19,7 +22,7 @@ importers: version: 10.34.0(@types/node-fetch@2.6.13) dropbox-refresh-token: specifier: ^0.0.5 - version: 0.0.5(@types/node@24.5.1) + version: 0.0.5(@types/node@24.5.2) devDependencies: '@eslint/js': specifier: ^9.35.0 @@ -28,8 +31,8 @@ importers: specifier: ^5.3.1 version: 5.3.1(eslint@9.35.0) '@types/node': - specifier: ^24.5.1 - version: 24.5.1 + specifier: ^24.5.2 + version: 24.5.2 chai: specifier: ^6.0.1 version: 6.0.1 @@ -60,9 +63,6 @@ importers: mongoose: specifier: ^8.18.1 version: 8.18.1 - npm-force-resolutions: - specifier: ^0.0.10 - version: 0.0.10 nyc: specifier: ^17.1.0 version: 17.1.0 @@ -203,10 +203,6 @@ packages: resolution: {integrity: sha512-lGPVU3yO9ZNqA7vTYz26jny41lE7yoQansmqdMLBEfqaGsmdg7V3W9mK9Pvb5IL4EVZ9GnSDGMO/cJXud5dMaw==} engines: {node: '>=18'} - '@isaacs/cliui@8.0.2': - resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} - engines: {node: '>=12'} - '@istanbuljs/load-nyc-config@1.1.0': resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} engines: {node: '>=8'} @@ -234,10 +230,6 @@ packages: '@mongodb-js/saslprep@1.3.0': resolution: {integrity: sha512-zlayKCsIjYb7/IdfqxorK5+xUMyi4vOKcFy10wKJYc63NSdKI8mNME+uJqfatkPmOSMMUiojrL58IePKBm3gvQ==} - '@pkgjs/parseargs@0.11.0': - resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} - engines: {node: '>=14'} - '@stylistic/eslint-plugin@5.3.1': resolution: {integrity: sha512-Ykums1VYonM0TgkD0VteVq9mrlO2FhF48MDJnPyv3MktIB2ydtuhlO0AfWm7xnW1kyf5bjOqA6xc7JjviuVTxg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -253,8 +245,8 @@ packages: '@types/node-fetch@2.6.13': resolution: {integrity: sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==} - '@types/node@24.5.1': - resolution: {integrity: sha512-/SQdmUP2xa+1rdx7VwB9yPq8PaKej8TD5cQ+XfKDPWWC+VDJU4rvVVagXqKUzhKjtFoNA8rXDJAkCxQPAe00+Q==} + '@types/node@24.5.2': + resolution: {integrity: sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ==} '@types/webidl-conversions@7.0.3': resolution: {integrity: sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==} @@ -291,18 +283,10 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - ansi-regex@6.2.2: - resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} - engines: {node: '>=12'} - ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} - ansi-styles@6.2.3: - resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==} - engines: {node: '>=12'} - append-transform@2.0.0: resolution: {integrity: sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==} engines: {node: '>=8'} @@ -325,8 +309,8 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - baseline-browser-mapping@2.8.4: - resolution: {integrity: sha512-L+YvJwGAgwJBV1p6ffpSTa2KRc69EeeYGYjRVWKs0GKrK+LON0GC0gV+rKSNtALEDvMDqkvCFq9r1r94/Gjwxw==} + baseline-browser-mapping@2.8.6: + resolution: {integrity: sha512-wrH5NNqren/QMtKUEEJf7z86YjfqW/2uw3IL3/xpqZUC95SSVIFXYQeeGjL6FT/X68IROu6RMehZQS5foy2BXw==} hasBin: true bl@4.1.0: @@ -350,9 +334,6 @@ packages: resolution: {integrity: sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==} engines: {node: '>=16.20.1'} - buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} @@ -382,7 +363,7 @@ packages: chai-string@1.6.0: resolution: {integrity: sha512-sXV7whDmpax+8H++YaZelgin7aur1LGf9ZhjZa3ojETFJ0uPVuS4XEXuIagpZ/c8uVOtsSh4MwOjy5CBLjJSXA==} peerDependencies: - chai: ^4.1.2 + chai: ^6.0.1 chai@6.0.1: resolution: {integrity: sha512-/JOoU2//6p5vCXh00FpNgtlw0LjvhGttaWc+y7wpW9yjBm3ys0dI8tSKZxIOgNruz5J0RleccatSIC3uxEZP0g==} @@ -509,18 +490,12 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} - eastasianwidth@0.2.0: - resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - - electron-to-chromium@1.5.220: - resolution: {integrity: sha512-TWXijEwR1ggr4BdAKrb1nMNqYLTx1/4aD1fkeZU+FVJGTKu53/T7UyHKXlqEX3Ub02csyHePbHmkvnrjcaYzMA==} + electron-to-chromium@1.5.222: + resolution: {integrity: sha512-gA7psSwSwQRE60CEoLz6JBCQPIxNeuzB2nL8vE03GK/OHxlvykbLyeiumQy1iH5C2f3YbRAZpGCMT12a/9ih9w==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - emoji-regex@9.2.2: - resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -707,13 +682,9 @@ packages: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} - glob@10.4.5: - resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} - hasBin: true - - glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported + glob@9.3.5: + resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==} + engines: {node: '>=16 || 14 >=14.17'} globals@14.0.0: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} @@ -784,10 +755,6 @@ packages: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} - inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. - inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -865,9 +832,6 @@ packages: resolution: {integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==} engines: {node: '>=8'} - jackspeak@3.4.3: - resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -887,9 +851,6 @@ packages: json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} - json-format@1.0.1: - resolution: {integrity: sha512-MoKIg/lBeQALqjYnqEanikfo3zBKRwclpXJexdF0FUniYAAN2ypEIXBEtpQb+9BkLFtDK1fyTLAsnGlyGfLGxw==} - json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -966,10 +927,18 @@ packages: minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@8.0.4: + resolution: {integrity: sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==} + engines: {node: '>=16 || 14 >=14.17'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} + minipass@4.2.8: + resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==} + engines: {node: '>=8'} + minipass@7.1.2: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} @@ -1047,18 +1016,11 @@ packages: node-releases@2.0.21: resolution: {integrity: sha512-5b0pgg78U3hwXkCM8Z9b2FJdPZlr9Psr9V2gQPESdGHqbntyFJKFW4r5TeWGFzafGY3hzs1JC62VEQMbl1JFkw==} - npm-force-resolutions@0.0.10: - resolution: {integrity: sha512-Jscex+xIU6tw3VsyrwxM1TeT+dd9Fd3UOMAjy6J1TMpuYeEqg4LQZnATQO5vjPrsARm3und6zc6Dii/GUyRE5A==} - hasBin: true - nyc@17.1.0: resolution: {integrity: sha512-U42vQ4czpKa0QdI1hu950XuNhYqgoM+ZF1HT+VuUHL9hPfDPVvNQyltmMqdE9bUHMVa+8yNbc3QKTj8zQhlVxQ==} engines: {node: '>=18'} hasBin: true - once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - onetime@5.1.2: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} @@ -1099,9 +1061,6 @@ packages: resolution: {integrity: sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==} engines: {node: '>=8'} - package-json-from-dist@1.0.1: - resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==} - parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -1110,10 +1069,6 @@ packages: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} - path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -1242,9 +1197,6 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} - source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -1263,10 +1215,6 @@ packages: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} - string-width@5.1.2: - resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} - engines: {node: '>=12'} - string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} @@ -1274,10 +1222,6 @@ packages: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} - strip-ansi@7.1.2: - resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==} - engines: {node: '>=12'} - strip-bom@4.0.0: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} @@ -1386,20 +1330,9 @@ packages: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} - wrap-ansi@8.1.0: - resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} - engines: {node: '>=12'} - - wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - write-file-atomic@3.0.3: resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==} - xmlhttprequest@1.8.0: - resolution: {integrity: sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==} - engines: {node: '>=0.4.0'} - y18n@4.0.3: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} @@ -1598,24 +1531,15 @@ snapshots: '@humanwhocodes/retry@0.4.3': {} - '@inquirer/external-editor@1.0.2(@types/node@24.5.1)': + '@inquirer/external-editor@1.0.2(@types/node@24.5.2)': dependencies: chardet: 2.1.0 iconv-lite: 0.7.0 optionalDependencies: - '@types/node': 24.5.1 + '@types/node': 24.5.2 '@inquirer/figures@1.0.13': {} - '@isaacs/cliui@8.0.2': - dependencies: - string-width: 5.1.2 - string-width-cjs: string-width@4.2.3 - strip-ansi: 7.1.2 - strip-ansi-cjs: strip-ansi@6.0.1 - wrap-ansi: 8.1.0 - wrap-ansi-cjs: wrap-ansi@7.0.0 - '@istanbuljs/load-nyc-config@1.1.0': dependencies: camelcase: 5.3.1 @@ -1649,9 +1573,6 @@ snapshots: dependencies: sparse-bitfield: 3.0.3 - '@pkgjs/parseargs@0.11.0': - optional: true - '@stylistic/eslint-plugin@5.3.1(eslint@9.35.0)': dependencies: '@eslint-community/eslint-utils': 4.9.0(eslint@9.35.0) @@ -1668,10 +1589,10 @@ snapshots: '@types/node-fetch@2.6.13': dependencies: - '@types/node': 24.5.1 + '@types/node': 24.5.2 form-data: 4.0.4 - '@types/node@24.5.1': + '@types/node@24.5.2': dependencies: undici-types: 7.12.0 @@ -1707,14 +1628,10 @@ snapshots: ansi-regex@5.0.1: {} - ansi-regex@6.2.2: {} - ansi-styles@4.3.0: dependencies: color-convert: 2.0.1 - ansi-styles@6.2.3: {} - append-transform@2.0.0: dependencies: default-require-extensions: 3.0.1 @@ -1733,7 +1650,7 @@ snapshots: base64-js@1.5.1: {} - baseline-browser-mapping@2.8.4: {} + baseline-browser-mapping@2.8.6: {} bl@4.1.0: dependencies: @@ -1754,16 +1671,14 @@ snapshots: browserslist@4.26.2: dependencies: - baseline-browser-mapping: 2.8.4 + baseline-browser-mapping: 2.8.6 caniuse-lite: 1.0.30001743 - electron-to-chromium: 1.5.220 + electron-to-chromium: 1.5.222 node-releases: 2.0.21 update-browserslist-db: 1.1.3(browserslist@4.26.2) bson@6.10.4: {} - buffer-from@1.1.2: {} - buffer@5.7.1: dependencies: base64-js: 1.5.1 @@ -1886,10 +1801,10 @@ snapshots: diff@7.0.0: {} - dropbox-refresh-token@0.0.5(@types/node@24.5.1): + dropbox-refresh-token@0.0.5(@types/node@24.5.2): dependencies: cross-fetch: 4.1.0 - inquirer: 9.3.8(@types/node@24.5.1) + inquirer: 9.3.8(@types/node@24.5.2) yesno: 0.4.0 transitivePeerDependencies: - '@types/node' @@ -1908,14 +1823,10 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - eastasianwidth@0.2.0: {} - - electron-to-chromium@1.5.220: {} + electron-to-chromium@1.5.222: {} emoji-regex@8.0.0: {} - emoji-regex@9.2.2: {} - es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -2127,23 +2038,12 @@ snapshots: dependencies: is-glob: 4.0.3 - glob@10.4.5: - dependencies: - foreground-child: 3.3.1 - jackspeak: 3.4.3 - minimatch: 9.0.5 - minipass: 7.1.2 - package-json-from-dist: 1.0.1 - path-scurry: 1.11.1 - - glob@7.2.3: + glob@9.3.5: dependencies: fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 + minimatch: 8.0.4 + minipass: 4.2.8 + path-scurry: 1.11.1 globals@14.0.0: {} @@ -2193,16 +2093,11 @@ snapshots: indent-string@4.0.0: {} - inflight@1.0.6: - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - inherits@2.0.4: {} - inquirer@9.3.8(@types/node@24.5.1): + inquirer@9.3.8(@types/node@24.5.2): dependencies: - '@inquirer/external-editor': 1.0.2(@types/node@24.5.1) + '@inquirer/external-editor': 1.0.2(@types/node@24.5.2) '@inquirer/figures': 1.0.13 ansi-escapes: 4.3.2 cli-width: 4.1.0 @@ -2287,12 +2182,6 @@ snapshots: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 - jackspeak@3.4.3: - dependencies: - '@isaacs/cliui': 8.0.2 - optionalDependencies: - '@pkgjs/parseargs': 0.11.0 - js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -2308,8 +2197,6 @@ snapshots: json-buffer@3.0.1: {} - json-format@1.0.1: {} - json-schema-traverse@0.4.1: {} json-stable-stringify-without-jsonify@1.0.1: {} @@ -2374,10 +2261,16 @@ snapshots: dependencies: brace-expansion: 1.1.12 + minimatch@8.0.4: + dependencies: + brace-expansion: 2.0.2 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.2 + minipass@4.2.8: {} + minipass@7.1.2: {} mocha@11.7.2: @@ -2388,7 +2281,7 @@ snapshots: diff: 7.0.0 escape-string-regexp: 4.0.0 find-up: 5.0.0 - glob: 10.4.5 + glob: 9.3.5 he: 1.2.0 js-yaml: 4.1.0 log-symbols: 4.1.0 @@ -2457,12 +2350,6 @@ snapshots: node-releases@2.0.21: {} - npm-force-resolutions@0.0.10: - dependencies: - json-format: 1.0.1 - source-map-support: 0.5.21 - xmlhttprequest: 1.8.0 - nyc@17.1.0: dependencies: '@istanbuljs/load-nyc-config': 1.1.0 @@ -2474,7 +2361,7 @@ snapshots: find-up: 4.1.0 foreground-child: 3.3.1 get-package-type: 0.1.0 - glob: 7.2.3 + glob: 9.3.5 istanbul-lib-coverage: 3.2.2 istanbul-lib-hook: 3.0.0 istanbul-lib-instrument: 6.0.3 @@ -2495,10 +2382,6 @@ snapshots: transitivePeerDependencies: - supports-color - once@1.4.0: - dependencies: - wrappy: 1.0.2 - onetime@5.1.2: dependencies: mimic-fn: 2.1.0 @@ -2553,16 +2436,12 @@ snapshots: lodash.flattendeep: 4.4.0 release-zalgo: 1.0.0 - package-json-from-dist@1.0.1: {} - parent-module@1.0.1: dependencies: callsites: 3.1.0 path-exists@4.0.0: {} - path-is-absolute@1.0.1: {} - path-key@3.1.1: {} path-parse@1.0.7: {} @@ -2627,7 +2506,7 @@ snapshots: rimraf@3.0.2: dependencies: - glob: 7.2.3 + glob: 9.3.5 run-async@3.0.0: {} @@ -2661,11 +2540,6 @@ snapshots: signal-exit@4.1.0: {} - source-map-support@0.5.21: - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - source-map@0.6.1: {} sparse-bitfield@3.0.3: @@ -2689,12 +2563,6 @@ snapshots: is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - string-width@5.1.2: - dependencies: - eastasianwidth: 0.2.0 - emoji-regex: 9.2.2 - strip-ansi: 7.1.2 - string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 @@ -2703,10 +2571,6 @@ snapshots: dependencies: ansi-regex: 5.0.1 - strip-ansi@7.1.2: - dependencies: - ansi-regex: 6.2.2 - strip-bom@4.0.0: {} strip-json-comments@3.1.1: {} @@ -2724,7 +2588,7 @@ snapshots: test-exclude@6.0.0: dependencies: '@istanbuljs/schema': 0.1.3 - glob: 7.2.3 + glob: 9.3.5 minimatch: 3.1.2 tr46@0.0.3: {} @@ -2803,14 +2667,6 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - wrap-ansi@8.1.0: - dependencies: - ansi-styles: 6.2.3 - string-width: 5.1.2 - strip-ansi: 7.1.2 - - wrappy@1.0.2: {} - write-file-atomic@3.0.3: dependencies: imurmurhash: 0.1.4 @@ -2818,8 +2674,6 @@ snapshots: signal-exit: 3.0.7 typedarray-to-buffer: 3.1.5 - xmlhttprequest@1.8.0: {} - y18n@4.0.3: {} y18n@5.0.8: {} diff --git a/tests/README.md b/tests/README.md index c7e8555..923fcd0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,23 +1,46 @@ # node-mongotools tests +# TL;DR + +```bash +git clone https://github.com/boly38/node-mongotools.git +# setup env +pnpm install +pnpm test +``` + ## Requirements - a `localhost` mongodb instance running - `mongodump` and `mongorestore` binaries - setup done ## Setup (first time) + +Add dependencies +```bash +pnpm install +``` + Copy and source env/initEnv - cp ./env initEnv.template.sh initEnv.dontpush.sh - . ./env/initEnv.dontpush.sh +```bash +cp ./env initEnv.template.sh initEnv.dontpush.sh +. ./env/initEnv.dontpush.sh +``` Update MT_MONGO_PORT, and if required MT_MONGO_USER, MT_MONGO_PWD -In order to run unit test: - . ./env/initEnv.test.sh +In order to run unit tests: +```bash +. ./env/initEnv.test.sh +``` + +## Setup (first time) -If you would like to play dropbox test, you may setup MT_DROPBOX_TOKEN too. +If you would like to play dropbox test, then you must set MT_DROPBOX_TOKEN too. ## Run tests - npm run test \ No newline at end of file +````bash +pnpm test +```` \ No newline at end of file diff --git a/tests/mongo-tools.test.js b/tests/mongo-tools.test.js index b1a1edc..b1e2007 100644 --- a/tests/mongo-tools.test.js +++ b/tests/mongo-tools.test.js @@ -53,7 +53,7 @@ function logSuccess(success) { console.info(`OK ${JSON.stringify(success, null, 4)}`); } -describe("Mongo Tools", function () { +describe("🧪🧩 Mongo Tools", function () { before(async () => { console.info("Mongo Tools :: before"); @@ -76,7 +76,23 @@ describe("Mongo Tools", function () { // DEBUG // console.log("MTOptions", mtOptions); }); - it("should not dump with invalid parameter", done => { + it("🧪 should list backups for an unknown directory return []", done => { + mt.list(new MTOptions({ + uri: testDbUri, + path: testBackupSubDirectory, + dropboxToken: null, + showCommand: true + })) + .then(listResult => { + logSuccess(listResult); + expect(listResult.filesystem).to.be.empty; + expect(listResult.path).to.be.eql(testBackupSubDirectory); + done(); + }) + .catch(_expectNoError); + }); + + it("🧪 should not dump with invalid parameter", done => { mtOptions.numParallelCollections = "Error because I'm not an integer ^^"; mt.mongodump(mtOptions) .then(result => expect.fail("expect error but got", result)) @@ -88,7 +104,7 @@ describe("Mongo Tools", function () { }); - it("should dump database locally", done => { + it("🧪 should dump database locally", done => { mt.mongodump(mtOptions) .then(dumpResult => { logSuccess(dumpResult); @@ -101,7 +117,7 @@ describe("Mongo Tools", function () { .catch(_expectNoError); }); - it("should dump database from uri", done => { + it("🧪 should dump database from uri", done => { mt.mongodump(new MTOptions({ uri: testDbUri, path: testBackupDirectory, @@ -120,7 +136,7 @@ describe("Mongo Tools", function () { .catch(_expectNoError); }); - it("should restore database", done => { + it("🧪 should restore database", done => { dropDatabase(testDbUri, `local:${testPort} db:${testDbName}`) .then(() => { mtOptions.dumpFile = lastDumpFile; @@ -141,19 +157,20 @@ describe("Mongo Tools", function () { .catch(_expectNoError); }); - it("should list backup", done => { + it("🧪 should list backups", done => { mt.list(mtOptions) .then(listResult => { logSuccess(listResult); - expect(listResult.filesystem).to.have.lengthOf(nbBackupExpected); + expect(listResult.filesystem).to.have.lengthOf(nbBackupExpected + 1); expect(listResult.filesystem).to.include(lastDumpFile) + expect(listResult.filesystem).to.include(testBackupSubDirectory) listResult.path.should.be.eql(testBackupDirectory); done(); }) .catch(_expectNoError); }); - it("should list backup from unexisting dir", done => { + it("🧪 should list backups from unexisting dir", done => { // given removed target subDirectory if (fs.existsSync(testBackupSubDirectory)) { fs.rmdirSync(testBackupSubDirectory, {recursive: true}); @@ -182,7 +199,7 @@ describe("Mongo Tools", function () { fs.rmdirSync(testBackupSubDirectory, {recursive: true}); }); - it("should dry rotate backups", done => { + it("🧪 should dry rotate backups", done => { mt.rotation({ path: testBackupDirectory, dropboxToken: null, @@ -200,7 +217,7 @@ describe("Mongo Tools", function () { .catch(_expectNoError); }); - it("should rotate backups", done => { + it("🧪 should rotate backups", done => { mt.rotation({ path: testBackupDirectory, dropboxToken: null, @@ -219,7 +236,7 @@ describe("Mongo Tools", function () { }); - it("should rotate no backups", done => { + it("🧪 should rotate no backups", done => { mt.rotation({ path: testBackupDirectory, dropboxToken: null, @@ -242,7 +259,7 @@ describe("Mongo Tools", function () { if (testDbToken !== null || testDbAppKey != null) { let nbDropBoxBackup = 0; let withDropboxMtTestOptions = null; - describe("Mongo Tools with Dropbox", function () { + describe("🧪🧩 Mongo Tools with Dropbox", function () { before(async () => { console.info("Mongo Tools with Dropbox :: before"); @@ -258,7 +275,9 @@ if (testDbToken !== null || testDbAppKey != null) { }); }) - it("should dump database on dropbox", done => { + // ℹ️ for now there is no remote cleanup so no way to test list of unexisting remote backup dir + + it("🧪 should dump database on dropbox", done => { mt.mongodump(withDropboxMtTestOptions) .then(dumpResult => { logSuccess(dumpResult); @@ -271,7 +290,7 @@ if (testDbToken !== null || testDbAppKey != null) { .catch(_expectNoError); }); - it("should list include dropbox backup", done => { + it("🧪 should list include dropbox backups", done => { mt.list(withDropboxMtTestOptions) .then(listResult => { logSuccess(listResult); @@ -285,7 +304,7 @@ if (testDbToken !== null || testDbAppKey != null) { .catch(_expectNoError); }); - it("should restore database from dropbox", done => { + it("🧪 should restore database from dropbox", done => { dropDatabase(testDbUri, `local:${testPort} db:${testDbName}`) .then(() => { withDropboxMtTestOptions.dumpFile = "/" + lastDumpFile; @@ -306,7 +325,7 @@ if (testDbToken !== null || testDbAppKey != null) { .catch(_expectNoError); }); - it("should rotation remove dropbox backup too", done => { + it("🧪 should rotation remove dropbox backup too", done => { mt.rotation({ path: testBackupDirectory, rotationWindowsDays: 0, diff --git a/tests/mongo-wrapper-unit.test.js b/tests/mongo-wrapper-unit.test.js index b9e7fc3..a87207b 100644 --- a/tests/mongo-wrapper-unit.test.js +++ b/tests/mongo-wrapper-unit.test.js @@ -17,9 +17,9 @@ const testDbUri = `mongodb://${testDbAuth}127.0.0.1:${testFixedPort}/${testDbNam const wrapper = new MTWrapper(); -describe("MTWrapper unit tests", function () { +describe("🧪🧩 MTWrapper unit tests", function () { - it("should wrap dump commandConnectFromOptions db user basic", async function () { + it("🧪 should wrap dump commandConnectFromOptions db user basic", async function () { const mtOptions = new MTOptions({ db: testDbName, port: testFixedPort, @@ -33,7 +33,7 @@ describe("MTWrapper unit tests", function () { command.should.be.eql("--beginning --host 127.0.0.1 --port 17017 --username myUser --password myPass --authenticationDatabase admin --db myDbForTest"); }); - it("should wrap dump commandConnectFromOptions uri ssl", async function () { + it("🧪 should wrap dump commandConnectFromOptions uri ssl", async function () { const mtOptions = new MTOptions({ uri: testDbUri, username:"myUser", @@ -54,7 +54,7 @@ describe("MTWrapper unit tests", function () { + "--sslCRLFile /tmp/pem/sslCRLFile --sslFIPSMode --tlsInsecure"); }); - it("should wrap restore commandConnectFromOptions db user basic", async function () { + it("🧪 should wrap restore commandConnectFromOptions db user basic", async function () { const mtOptions = new MTOptions({ db: testDbName, port: testFixedPort, @@ -68,7 +68,7 @@ describe("MTWrapper unit tests", function () { command.should.be.eql("--beginning --host 127.0.0.1 --port 17017 --username myUser --password myPass --authenticationDatabase admin --nsInclude myDbForTest.*"); }); - it("should wrap restore commandConnectFromOptions db user basic source and target dbs", async function () { + it("🧪 should wrap restore commandConnectFromOptions db user basic source and target dbs", async function () { const mtOptions = new MTOptions({ db: null, dbFrom: testSourceDbName, @@ -84,7 +84,7 @@ describe("MTWrapper unit tests", function () { command.should.be.eql("--beginning --host 127.0.0.1 --port 17017 --username myUser --password myPass --authenticationDatabase admin --nsFrom mySourceDbForTest.* --nsTo myTargetDbForTest.*"); }); - it("should wrap restore commandConnectFromOptions uri ssl", async function () { + it("🧪 should wrap restore commandConnectFromOptions uri ssl", async function () { const mtOptions = new MTOptions({ uri: testDbUri, ssl: "1",