From 2f3b7af8d29de2a06893b8202d3e49688b23b51c Mon Sep 17 00:00:00 2001 From: Potapov Dmitriy Date: Sun, 17 Sep 2023 21:42:19 +0300 Subject: [PATCH] chore/update code format, remove one place package usage (#845) --- .github/dependabot.yml | 14 ++++---- lib/check-paths-existence.js | 22 +++++------- lib/compute-download-urls.js | 4 +-- lib/compute-fs-paths.js | 8 ++--- lib/get-selenium-status-url.js | 22 +++++++----- package-lock.json | 63 +++------------------------------- package.json | 1 - 7 files changed, 38 insertions(+), 96 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5c8290b4..6080484f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,8 +8,6 @@ updates: open-pull-requests-limit: 10 versioning-strategy: increase-if-necessary ignore: - - dependency-name: "fs-extra" - update-types: ["version-update:semver-major"] - dependency-name: "got" update-types: ["version-update:semver-major"] - dependency-name: "mocha" @@ -25,14 +23,14 @@ updates: - dependency-name: "eslint-plugin-prettier" update-types: ["version-update:semver-major"] - dependency-name: "eslint" - update-types: ["version-update:semver-major"] + update-types: ["version-update:semver-major"] - dependency-name: "execa" - update-types: ["version-update:semver-major"] + update-types: ["version-update:semver-major"] - dependency-name: "find-process" - update-types: ["version-update:semver-major"] + update-types: ["version-update:semver-major"] - dependency-name: "fkill" - update-types: ["version-update:semver-major"] + update-types: ["version-update:semver-major"] - dependency-name: "prettier" - update-types: ["version-update:semver-major"] + update-types: ["version-update:semver-major"] + - diff --git a/lib/check-paths-existence.js b/lib/check-paths-existence.js index 79e911c7..6612d3e0 100644 --- a/lib/check-paths-existence.js +++ b/lib/check-paths-existence.js @@ -1,17 +1,13 @@ -module.exports = checkPathsExistence; +const fs = require('fs'); -const fse = require('fs-extra'); +const checkPathsExistence = (paths) => { + const pathValues = Object.values(paths); -async function checkPathsExistence(paths) { - const pathValues = Object.keys(paths).map((key) => { - return paths[key]; + pathValues.forEach((path) => { + if (!fs.existsSync(path)) { + throw new Error('Missing ' + path); + } }); +}; - return Promise.all( - pathValues.map(async (path) => { - if (!(await fse.pathExists(path))) { - throw new Error('Missing ' + path); - } - }) - ); -} +module.exports = checkPathsExistence; diff --git a/lib/compute-download-urls.js b/lib/compute-download-urls.js index 691607b6..543ebea7 100644 --- a/lib/compute-download-urls.js +++ b/lib/compute-download-urls.js @@ -1,5 +1,3 @@ -module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium }; - const got = require('got'); const util = require('util'); const { isSelenium4 } = require('./isSelenium4'); @@ -343,3 +341,5 @@ async function getPackageInfo(version, arh, channel, baseUrl) { return { latestVersion, url }; } + +module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium }; diff --git a/lib/compute-fs-paths.js b/lib/compute-fs-paths.js index c6073388..4b209002 100644 --- a/lib/compute-fs-paths.js +++ b/lib/compute-fs-paths.js @@ -1,5 +1,3 @@ -module.exports = computeFsPaths; - const path = require('path'); const { getLastChromedriverVersionFromMajor, getLatestChromium } = require('./compute-download-urls'); const { validateMajorVersionPrefix } = require('./validation'); @@ -7,7 +5,7 @@ const { detectBrowserPlatformCustom } = require('./platformDetection'); const basePath = path.join(__dirname, '..', '.selenium'); -async function computeFsPaths(options) { +const computeFsPaths = async (options) => { let fsPaths = {}; const opts = Object.assign({}, options); opts.basePath = opts.basePath || basePath; @@ -104,4 +102,6 @@ async function computeFsPaths(options) { }, fsPaths); return fsPaths; -} +}; + +module.exports = computeFsPaths; diff --git a/lib/get-selenium-status-url.js b/lib/get-selenium-status-url.js index 7f1d04b2..4891a1cd 100644 --- a/lib/get-selenium-status-url.js +++ b/lib/get-selenium-status-url.js @@ -7,17 +7,15 @@ const PROCESS_TYPES = { GRID_NODE: 2, DISTRIBUTOR_NODE: 3, }; -exports.PROCESS_TYPES = PROCESS_TYPES; -function parseRole(role) { +const parseRole = (role) => { if (!role || role === 'standalone') return PROCESS_TYPES.STANDALONE; if (role === 'hub') return PROCESS_TYPES.GRID_HUB; if (role === 'node') return PROCESS_TYPES.GRID_NODE; if (role === 'distributor') return PROCESS_TYPES.DISTRIBUTOR_NODE; - return undefined; -} +}; -function getDefaultPort(processType) { +const getDefaultPort = (processType) => { switch (processType) { case PROCESS_TYPES.STANDALONE: case PROCESS_TYPES.GRID_HUB: @@ -25,9 +23,9 @@ function getDefaultPort(processType) { case PROCESS_TYPES.GRID_NODE: return 5555; } -} +}; -exports.getRunningProcessType = function (seleniumArgs) { +const getRunningProcessType = (seleniumArgs) => { const roleArg = Math.max( seleniumArgs.indexOf('hub'), seleniumArgs.indexOf('node'), @@ -44,7 +42,7 @@ exports.getRunningProcessType = function (seleniumArgs) { * @param {object} opts * @returns {URL} */ -exports.getSeleniumStatusUrl = function (seleniumArgs, opts) { +const getSeleniumStatusUrl = (seleniumArgs, opts) => { const nodeConfigArg = seleniumArgs.indexOf('-nodeConfig'); // args prefix differs for selenium3 and selenium4 @@ -58,7 +56,7 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) { let host = 'localhost'; let port; let config; - let processType = this.getRunningProcessType(seleniumArgs); + let processType = getRunningProcessType(seleniumArgs); // If node config path is pass via -nodeConfig, we have to take settings from there, // and override them with possible command line options, as later ones have higher priority @@ -109,3 +107,9 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) { statusURI.port = port || getDefaultPort(processType); return statusURI; }; + +module.exports = { + getSeleniumStatusUrl, + getRunningProcessType, + PROCESS_TYPES, +}; diff --git a/package-lock.json b/package-lock.json index 0d671e3c..816b5f67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "execa": "^5.1.1", "find-process": "^1.4.7", "fkill": "^7.2.1", - "fs-extra": "^10.0.0", "got": "^11.8.2", "is-port-reachable": "^3.0.0", "lodash.mapvalues": "^4.6.0", @@ -2794,19 +2793,6 @@ "node": ">=0.4.x" } }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -3307,7 +3293,8 @@ "node_modules/graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true }, "node_modules/graphemer": { "version": "1.4.0", @@ -4427,17 +4414,6 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/keyv": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", @@ -8361,14 +8337,6 @@ "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==", "dev": true }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -11159,16 +11127,6 @@ "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", "dev": true }, - "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -11579,7 +11537,8 @@ "graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true }, "graphemer": { "version": "1.4.0", @@ -12352,15 +12311,6 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, "keyv": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", @@ -15372,11 +15322,6 @@ "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==", "dev": true }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index ff3ea323..75a5e9e5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "execa": "^5.1.1", "find-process": "^1.4.7", "fkill": "^7.2.1", - "fs-extra": "^10.0.0", "got": "^11.8.2", "is-port-reachable": "^3.0.0", "lodash.mapvalues": "^4.6.0",