From acf6f0d2ae2920e3636eb528182707c0d8184bb6 Mon Sep 17 00:00:00 2001 From: Shailee Mehta Date: Mon, 15 Mar 2021 22:24:56 +0530 Subject: [PATCH] 29 removing shell dependencies. Simplyfiying ip parsing method --- frontend/package.json | 1 - frontend/src/boot/axios.js | 20 +++++++++--------- frontend/src/boot/env-parser.js | 10 +++++++-- frontend/yarn.lock | 36 --------------------------------- 4 files changed, 17 insertions(+), 50 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 5900799..03b36d6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,7 +29,6 @@ "moment-timezone": "0.5.32", "plotly.js": "^1.55.2", "quasar": "^1.0.0", - "shelljs": "0.8.4", "vue-i18n": "^8.20.0", "webpack": "^5.23.0", "xlsx": "0.16.7" diff --git a/frontend/src/boot/axios.js b/frontend/src/boot/axios.js index 3571bfd..5350616 100644 --- a/frontend/src/boot/axios.js +++ b/frontend/src/boot/axios.js @@ -7,20 +7,18 @@ const axiosInstance = axios.create({ baseURL: process.env.BASE_URL }); const _appendSubdomain = (domain, subdomain) => { - const ip = domain.split("://")[1] - ? domain.split("://")[1].split(":") - ? domain.split("://")[1].split(":")[0] - : null - : null; + // Get the hostname (including port) + const hostname = domain.split("://")[1]; - //skip adding sub-domain to ip - if ( - /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( - ip - ) - ) { + // a domain name contains at least one letter + const hostnameIsDomain = hostname.match(/[a-z]/i); + + // skip adding sub-domain to IP + if (!hostnameIsDomain) { return domain; } + + // If localhost is in domain if (domain.indexOf("localhost") > -1) { return domain; } diff --git a/frontend/src/boot/env-parser.js b/frontend/src/boot/env-parser.js index d3c8e42..e504f40 100644 --- a/frontend/src/boot/env-parser.js +++ b/frontend/src/boot/env-parser.js @@ -1,6 +1,12 @@ const DotEnv = require("dotenv"); -var shell = require("shelljs"); -var is3000On = shell.exec("lsof -t -i :3000 -s TCP:LISTEN").stdout; +const execSync = require("child_process").execSync; +let is3000On = false; + +try { + is3000On = execSync("lsof -t -i :3000 -s TCP:LISTEN").toString(); +} catch (e) { + // not running throws error +} module.exports = function() { if (!!is3000On) { diff --git a/frontend/yarn.lock b/frontend/yarn.lock index b16e36d..aeee95a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -7399,11 +7399,6 @@ internal-ip@^4.3.0: default-gateway "^4.2.0" ipaddr.js "^1.9.0" -interpret@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" - integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== - interval-tree-1d@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/interval-tree-1d/-/interval-tree-1d-1.0.3.tgz#8fdbde02b6b2c7dbdead636bcbed8e08710d85c1" @@ -7558,13 +7553,6 @@ is-color-stop@^1.0.0: rgb-regex "^1.0.1" rgba-regex "^1.0.0" -is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== - dependencies: - has "^1.0.3" - is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -10795,13 +10783,6 @@ readdirp@~3.4.0: dependencies: picomatch "^2.2.1" -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q= - dependencies: - resolve "^1.1.6" - recursive-readdir@^2.1.0: version "2.2.2" resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.2.tgz#9946fb3274e1628de6e36b2f6714953b4845094f" @@ -11115,14 +11096,6 @@ resolve@^1.0.0, resolve@^1.1.5, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13. dependencies: path-parse "^1.0.6" -resolve@^1.1.6: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - responselike@1.0.2, responselike@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" @@ -11664,15 +11637,6 @@ shell-quote@^1.6.1: resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2" integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg== -shelljs@0.8.4: - version "0.8.4" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2" - integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ== - dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"