diff --git a/package-lock.json b/package-lock.json index d5d4459a9a..fd5154aeab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10177,7 +10177,8 @@ "node_modules/@types/dateformat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@types/dateformat/-/dateformat-5.0.2.tgz", - "integrity": "sha512-M95hNBMa/hnwErH+a+VOD/sYgTmo15OTYTM2Hr52/e0OdOuY+Crag+kd3/ioZrhg0WGbl9Sm3hR7UU+MH6rfOw==" + "integrity": "sha512-M95hNBMa/hnwErH+a+VOD/sYgTmo15OTYTM2Hr52/e0OdOuY+Crag+kd3/ioZrhg0WGbl9Sm3hR7UU+MH6rfOw==", + "dev": true }, "node_modules/@types/debug": { "version": "4.1.7", @@ -20593,6 +20594,7 @@ "version": "3.6.1", "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.6.1.tgz", "integrity": "sha512-hT9yh/tiinkmirKrlv4KWOjztdoZo1mx9Qh4KvWqC7isoXwdUY3PNWUxceF4/qO9R6riA2C29jdTOeQOIROjgw==", + "dev": true, "engines": { "node": ">=6" } @@ -32105,14 +32107,6 @@ "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, - "node_modules/rimraf": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", - "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=", - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/rndm": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz", @@ -36362,7 +36356,8 @@ "node_modules/w3c-keyname": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", - "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "dev": true }, "node_modules/w3c-xmlserializer": { "version": "3.0.0", @@ -39814,7 +39809,6 @@ "@node-oauth/oauth2-server": "^5.1.0", "@node-saml/passport-saml": "^4.0.4", "@overleaf/access-token-encryptor": "*", - "@overleaf/dictionaries": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", "@overleaf/fetch-utils": "*", "@overleaf/logger": "*", "@overleaf/metrics": "*", @@ -39824,7 +39818,6 @@ "@overleaf/redis-wrapper": "*", "@overleaf/settings": "*", "@slack/webhook": "^7.0.2", - "@types/dateformat": "^5.0.2", "@xmldom/xmldom": "^0.7.13", "accepts": "^1.3.7", "ajv": "^8.12.0", @@ -39844,7 +39837,6 @@ "contentful": "^10.8.5", "cookie": "^0.2.3", "cookie-parser": "1.4.6", - "core-js": "^3.38.1", "crc-32": "^1.2.2", "csurf": "^1.11.0", "csv": "^6.2.5", @@ -39857,8 +39849,6 @@ "express-bearer-token": "^2.4.0", "express-http-proxy": "^1.6.0", "express-session": "^1.17.1", - "fs-extra": "^4.0.2", - "fuse.js": "^3.0.0", "globby": "^5.0.0", "helmet": "^6.0.1", "i18next": "^23.10.0", @@ -39901,16 +39891,13 @@ "referer-parser": "github:overleaf/nodejs-referer-parser#8b8b103762d05b7be4cfa2f810e1d408be67d7bb", "request": "^2.88.2", "requestretry": "^7.1.0", - "rimraf": "2.2.6", "sanitize-html": "^2.8.1", "tough-cookie": "^4.0.0", "tsscmp": "^1.0.6", "uid-safe": "^2.1.5", "utf-8-validate": "^5.0.2", - "uuid": "^9.0.1", "valid-data-url": "^2.0.0", "valid-url": "^1.0.9", - "w3c-keyname": "^2.2.8", "xml-crypto": "^2.1.2", "xml2js": "^0.6.2", "xregexp": "^4.3.0", @@ -39949,6 +39936,7 @@ "@opentelemetry/sdk-trace-web": "^1.15.2", "@opentelemetry/semantic-conventions": "^1.15.2", "@overleaf/codemirror-tree-view": "^0.1.3", + "@overleaf/dictionaries": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", "@overleaf/ranges-tracker": "*", "@overleaf/stream-utils": "*", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11", @@ -39976,6 +39964,7 @@ "@types/bootstrap": "^5.2.10", "@types/bootstrap-5": "npm:@types/bootstrap@^5.2.10", "@types/chai": "^4.3.0", + "@types/dateformat": "^5.0.2", "@types/diff": "^5.0.9", "@types/dompurify": "^3.0.5", "@types/events": "^3.0.0", @@ -40022,6 +40011,7 @@ "classnames": "^2.2.6", "cookie-signature": "^1.2.1", "copy-webpack-plugin": "^11.0.0", + "core-js": "^3.38.1", "css-loader": "^6.8.1", "css-minimizer-webpack-plugin": "^5.0.1", "cypress": "13.13.2", @@ -40043,6 +40033,7 @@ "fake-indexeddb": "^6.0.0", "fetch-mock": "^9.10.2", "formik": "^2.2.9", + "fuse.js": "^3.0.0", "glob": "^7.1.6", "handlebars": "^4.7.8", "handlebars-loader": "^1.7.3", @@ -40101,6 +40092,8 @@ "to-string-loader": "^1.2.0", "tty-browserify": "^0.0.1", "typescript": "^5.0.4", + "uuid": "^9.0.1", + "w3c-keyname": "^2.2.8", "webpack": "^5.93.0", "webpack-assets-manifest": "^5.2.1", "webpack-cli": "^5.1.4", @@ -40295,7 +40288,8 @@ "services/web/node_modules/@overleaf/dictionaries": { "version": "0.0.3", "resolved": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", - "integrity": "sha512-/VJRrwY62Va2M4K5BE5UMruJHgKPGp0SGQkY/nrrQpBbHhMuTVoRtXkR+hcOfi1Iu6SO0vcwiK+L7xzs+fZmXQ==" + "integrity": "sha512-/VJRrwY62Va2M4K5BE5UMruJHgKPGp0SGQkY/nrrQpBbHhMuTVoRtXkR+hcOfi1Iu6SO0vcwiK+L7xzs+fZmXQ==", + "dev": true }, "services/web/node_modules/@sentry/browser": { "version": "7.46.0", @@ -41737,6 +41731,7 @@ "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", + "dev": true, "hasInstallScript": true, "funding": { "type": "opencollective", @@ -41889,16 +41884,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "services/web/node_modules/fs-extra": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "services/web/node_modules/fs-monkey": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.6.tgz", @@ -42039,14 +42024,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, - "services/web/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "services/web/node_modules/lolex": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", @@ -42575,14 +42552,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "services/web/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "engines": { - "node": ">= 4.0.0" - } - }, "services/web/node_modules/url": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/url/-/url-0.11.4.tgz", @@ -49550,7 +49519,6 @@ "fake-indexeddb": "^6.0.0", "fetch-mock": "^9.10.2", "formik": "^2.2.9", - "fs-extra": "^4.0.2", "fuse.js": "^3.0.0", "glob": "^7.1.6", "globby": "^5.0.0", @@ -49636,7 +49604,6 @@ "request": "^2.88.2", "requestretry": "^7.1.0", "resolve-url-loader": "^5.0.0", - "rimraf": "2.2.6", "samlp": "^7.0.2", "sandboxed-module": "overleaf/node-sandboxed-module#cafa2d60f17ce75cc023e6f296eb8de79d92d35d", "sanitize-html": "^2.8.1", @@ -49812,7 +49779,8 @@ }, "@overleaf/dictionaries": { "version": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", - "integrity": "sha512-/VJRrwY62Va2M4K5BE5UMruJHgKPGp0SGQkY/nrrQpBbHhMuTVoRtXkR+hcOfi1Iu6SO0vcwiK+L7xzs+fZmXQ==" + "integrity": "sha512-/VJRrwY62Va2M4K5BE5UMruJHgKPGp0SGQkY/nrrQpBbHhMuTVoRtXkR+hcOfi1Iu6SO0vcwiK+L7xzs+fZmXQ==", + "dev": true }, "@sentry/browser": { "version": "7.46.0", @@ -50830,7 +50798,8 @@ "core-js": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", - "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==" + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", + "dev": true }, "csv": { "version": "6.2.5", @@ -50945,16 +50914,6 @@ "signal-exit": "^4.0.1" } }, - "fs-extra": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "fs-monkey": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.6.tgz", @@ -51051,14 +51010,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "^4.1.6" - } - }, "lolex": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", @@ -51447,11 +51398,6 @@ "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", "dev": true }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - }, "url": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/url/-/url-0.11.4.tgz", @@ -53078,7 +53024,8 @@ "@types/dateformat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@types/dateformat/-/dateformat-5.0.2.tgz", - "integrity": "sha512-M95hNBMa/hnwErH+a+VOD/sYgTmo15OTYTM2Hr52/e0OdOuY+Crag+kd3/ioZrhg0WGbl9Sm3hR7UU+MH6rfOw==" + "integrity": "sha512-M95hNBMa/hnwErH+a+VOD/sYgTmo15OTYTM2Hr52/e0OdOuY+Crag+kd3/ioZrhg0WGbl9Sm3hR7UU+MH6rfOw==", + "dev": true }, "@types/debug": { "version": "4.1.7", @@ -60998,7 +60945,8 @@ "fuse.js": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.6.1.tgz", - "integrity": "sha512-hT9yh/tiinkmirKrlv4KWOjztdoZo1mx9Qh4KvWqC7isoXwdUY3PNWUxceF4/qO9R6riA2C29jdTOeQOIROjgw==" + "integrity": "sha512-hT9yh/tiinkmirKrlv4KWOjztdoZo1mx9Qh4KvWqC7isoXwdUY3PNWUxceF4/qO9R6riA2C29jdTOeQOIROjgw==", + "dev": true }, "gauge": { "version": "3.0.2", @@ -70286,11 +70234,6 @@ "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, - "rimraf": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", - "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=" - }, "rndm": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz", @@ -73478,7 +73421,8 @@ "w3c-keyname": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", - "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "dev": true }, "w3c-xmlserializer": { "version": "3.0.0", diff --git a/services/web/app/src/Features/Uploads/ArchiveManager.js b/services/web/app/src/Features/Uploads/ArchiveManager.js index 8e81d3364c..fc81fdb4b3 100644 --- a/services/web/app/src/Features/Uploads/ArchiveManager.js +++ b/services/web/app/src/Features/Uploads/ArchiveManager.js @@ -17,7 +17,6 @@ const OError = require('@overleaf/o-error') const metrics = require('@overleaf/metrics') const fs = require('fs') const Path = require('path') -const fse = require('fs-extra') const yauzl = require('yauzl') const Settings = require('@overleaf/settings') const { @@ -122,7 +121,7 @@ const ArchiveManager = { return callback(err) } - return fse.ensureDir(Path.dirname(destFile), function (err) { + fs.mkdir(Path.dirname(destFile), { recursive: true }, function (err) { if (err != null) { return errorHandler(err) } diff --git a/services/web/app/src/Features/Uploads/ProjectUploadManager.js b/services/web/app/src/Features/Uploads/ProjectUploadManager.js index b96f5bd850..6cd095f134 100644 --- a/services/web/app/src/Features/Uploads/ProjectUploadManager.js +++ b/services/web/app/src/Features/Uploads/ProjectUploadManager.js @@ -1,5 +1,5 @@ const Path = require('path') -const fs = require('fs-extra') +const fs = require('fs') const { callbackify } = require('util') const ArchiveManager = require('./ArchiveManager') const { Doc } = require('../../models/Doc') @@ -59,7 +59,7 @@ async function createProjectFromZipArchive(ownerId, defaultName, zipPath) { ) throw err } - await fs.remove(contentsPath) + await fs.promises.rm(contentsPath, { recursive: true, force: true }) return project } @@ -92,7 +92,7 @@ async function createProjectFromZipArchiveWithName( ) throw err } - await fs.remove(contentsPath) + await fs.promises.rm(contentsPath, { recursive: true, force: true }) return project } diff --git a/services/web/package.json b/services/web/package.json index 6ef7a00289..49abbdc29f 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -76,7 +76,6 @@ "@node-oauth/oauth2-server": "^5.1.0", "@node-saml/passport-saml": "^4.0.4", "@overleaf/access-token-encryptor": "*", - "@overleaf/dictionaries": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", "@overleaf/fetch-utils": "*", "@overleaf/logger": "*", "@overleaf/metrics": "*", @@ -86,7 +85,6 @@ "@overleaf/redis-wrapper": "*", "@overleaf/settings": "*", "@slack/webhook": "^7.0.2", - "@types/dateformat": "^5.0.2", "@xmldom/xmldom": "^0.7.13", "accepts": "^1.3.7", "ajv": "^8.12.0", @@ -106,7 +104,6 @@ "contentful": "^10.8.5", "cookie": "^0.2.3", "cookie-parser": "1.4.6", - "core-js": "^3.38.1", "crc-32": "^1.2.2", "csurf": "^1.11.0", "csv": "^6.2.5", @@ -119,8 +116,6 @@ "express-bearer-token": "^2.4.0", "express-http-proxy": "^1.6.0", "express-session": "^1.17.1", - "fs-extra": "^4.0.2", - "fuse.js": "^3.0.0", "globby": "^5.0.0", "helmet": "^6.0.1", "i18next": "^23.10.0", @@ -163,16 +158,13 @@ "referer-parser": "github:overleaf/nodejs-referer-parser#8b8b103762d05b7be4cfa2f810e1d408be67d7bb", "request": "^2.88.2", "requestretry": "^7.1.0", - "rimraf": "2.2.6", "sanitize-html": "^2.8.1", "tough-cookie": "^4.0.0", "tsscmp": "^1.0.6", "uid-safe": "^2.1.5", "utf-8-validate": "^5.0.2", - "uuid": "^9.0.1", "valid-data-url": "^2.0.0", "valid-url": "^1.0.9", - "w3c-keyname": "^2.2.8", "xml-crypto": "^2.1.2", "xml2js": "^0.6.2", "xregexp": "^4.3.0", @@ -211,6 +203,7 @@ "@opentelemetry/sdk-trace-web": "^1.15.2", "@opentelemetry/semantic-conventions": "^1.15.2", "@overleaf/codemirror-tree-view": "^0.1.3", + "@overleaf/dictionaries": "https://github.com/overleaf/dictionaries/archive/refs/tags/v0.0.3.tar.gz", "@overleaf/ranges-tracker": "*", "@overleaf/stream-utils": "*", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11", @@ -238,7 +231,9 @@ "@types/bootstrap": "^5.2.10", "@types/bootstrap-5": "npm:@types/bootstrap@^5.2.10", "@types/chai": "^4.3.0", + "@types/dateformat": "^5.0.2", "@types/diff": "^5.0.9", + "uuid": "^9.0.1", "@types/dompurify": "^3.0.5", "@types/events": "^3.0.0", "@types/express": "^4.17.13", @@ -284,6 +279,7 @@ "classnames": "^2.2.6", "cookie-signature": "^1.2.1", "copy-webpack-plugin": "^11.0.0", + "core-js": "^3.38.1", "css-loader": "^6.8.1", "css-minimizer-webpack-plugin": "^5.0.1", "cypress": "13.13.2", @@ -305,6 +301,7 @@ "fake-indexeddb": "^6.0.0", "fetch-mock": "^9.10.2", "formik": "^2.2.9", + "fuse.js": "^3.0.0", "glob": "^7.1.6", "handlebars": "^4.7.8", "handlebars-loader": "^1.7.3", @@ -363,6 +360,7 @@ "to-string-loader": "^1.2.0", "tty-browserify": "^0.0.1", "typescript": "^5.0.4", + "w3c-keyname": "^2.2.8", "webpack": "^5.93.0", "webpack-assets-manifest": "^5.2.1", "webpack-cli": "^5.1.4", diff --git a/services/web/scripts/ukamf/check-idp-metadata.js b/services/web/scripts/ukamf/check-idp-metadata.js index d72bb834bb..6c5bd6b05d 100644 --- a/services/web/scripts/ukamf/check-idp-metadata.js +++ b/services/web/scripts/ukamf/check-idp-metadata.js @@ -7,7 +7,7 @@ import { Certificate } from '@fidm/x509' import _ from 'lodash' import moment from 'moment' -import fs from 'fs-extra' +import fs from 'fs' import xml2js from 'xml2js' function checkCertDates(signingKey) { @@ -45,7 +45,7 @@ async function main() { console.log('Checking SAML metadata') - const data = await fs.readFile(file, 'utf8') + const data = await fs.promises.readFile(file, 'utf8') const parser = new xml2js.Parser() const xml = await parser.parseStringPromise(data) diff --git a/services/web/scripts/ukamf/ukamf-db.js b/services/web/scripts/ukamf/ukamf-db.js index 6c50878762..347ffb5fe0 100644 --- a/services/web/scripts/ukamf/ukamf-db.js +++ b/services/web/scripts/ukamf/ukamf-db.js @@ -1,4 +1,4 @@ -import fs from 'fs-extra' +import fs from 'fs' import xml2js from 'xml2js' import UKAMFEntity from './ukamf-entity.js' @@ -8,7 +8,7 @@ class UKAMFDB { } async init() { - const data = await fs.readFile(this.file, 'utf8') + const data = await fs.promises.readFile(this.file, 'utf8') const parser = new xml2js.Parser() const xml = await parser.parseStringPromise(data) diff --git a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js index 7e4c32da51..12696cf9a0 100644 --- a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js +++ b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js @@ -44,8 +44,7 @@ describe('ArchiveManager', function () { open: sinon.stub().callsArgWith(2, null, this.zipfile), }), '@overleaf/metrics': this.metrics, - fs: (this.fs = {}), - 'fs-extra': (this.fse = {}), + fs: (this.fs = { mkdir: sinon.stub().yields() }), './ArchiveErrors': ArchiveErrors, }, }) @@ -70,7 +69,6 @@ describe('ArchiveManager', function () { .callsArgWith(1, null, this.readStream) this.writeStream = new events.EventEmitter() this.fs.createWriteStream = sinon.stub().returns(this.writeStream) - this.fse.ensureDir = sinon.stub().callsArg(1) this.ArchiveManager.extractZipArchive( this.source, this.destination, @@ -101,7 +99,6 @@ describe('ArchiveManager', function () { .callsArgWith(1, null, this.readStream) this.writeStream = new events.EventEmitter() this.fs.createWriteStream = sinon.stub().returns(this.writeStream) - this.fse.ensureDir = sinon.stub().callsArg(1) this.ArchiveManager.extractZipArchive( this.source, this.destination, @@ -267,7 +264,6 @@ describe('ArchiveManager', function () { this.zipfile.openReadStream = sinon .stub() .callsArgWith(1, null, this.readStream) - this.fse.ensureDir = sinon.stub().callsArg(1) this.ArchiveManager.extractZipArchive( this.source, this.destination, @@ -291,10 +287,12 @@ describe('ArchiveManager', function () { }) it('should treat the backslashes as a directory separator when creating the directory', function () { - this.fse.ensureDir.should.be.calledWith(`${this.destination}/wombat`) - return this.fse.ensureDir.should.be.calledWith( - `${this.destination}/potato` - ) + this.fs.mkdir.should.be.calledWith(`${this.destination}/wombat`, { + recursive: true, + }) + this.fs.mkdir.should.be.calledWith(`${this.destination}/potato`, { + recursive: true, + }) }) it('should treat the backslashes as a directory separator when creating the file', function () { @@ -367,7 +365,6 @@ describe('ArchiveManager', function () { .callsArgWith(1, null, this.readStream) this.writeStream = new events.EventEmitter() this.fs.createWriteStream = sinon.stub().returns(this.writeStream) - this.fse.ensureDir = sinon.stub().callsArg(1) this.ArchiveManager.extractZipArchive( this.source, this.destination, @@ -405,7 +402,6 @@ describe('ArchiveManager', function () { .callsArgWith(1, null, this.readStream) this.writeStream = new events.EventEmitter() this.fs.createWriteStream = sinon.stub().returns(this.writeStream) - this.fse.ensureDir = sinon.stub().callsArg(1) this.ArchiveManager.extractZipArchive( this.source, this.destination, diff --git a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js index 493f242c9c..e996259095 100644 --- a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js +++ b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js @@ -62,7 +62,9 @@ describe('ProjectUploadManager', function () { ] this.fs = { - remove: sinon.stub().resolves(), + promises: { + rm: sinon.stub().resolves(), + }, } this.ArchiveManager = { promises: { @@ -146,7 +148,7 @@ describe('ProjectUploadManager', function () { this.ProjectUploadManager = SandboxedModule.require(MODULE_PATH, { requires: { - 'fs-extra': this.fs, + fs: this.fs, './ArchiveManager': this.ArchiveManager, '../../models/Doc': { Doc: this.Doc }, '../Docstore/DocstoreManager': this.DocstoreManager, @@ -230,7 +232,10 @@ describe('ProjectUploadManager', function () { }) it('should remove the destination directory afterwards', function () { - this.fs.remove.should.have.been.calledWith(this.extractedZipPath) + this.fs.promises.rm.should.have.been.calledWith(this.extractedZipPath, { + recursive: true, + force: true, + }) }) }) @@ -311,7 +316,10 @@ describe('ProjectUploadManager', function () { }) it('should remove the destination directory afterwards', function () { - this.fs.remove.should.have.been.calledWith(this.extractedZipPath) + this.fs.promises.rm.should.have.been.calledWith(this.extractedZipPath, { + recursive: true, + force: true, + }) }) describe('when initializing the folder structure fails', function () {