From 1731de9db722dea5701ffe3e06cf544403483903 Mon Sep 17 00:00:00 2001 From: asad_h Date: Thu, 9 Mar 2023 11:28:40 +0530 Subject: [PATCH 1/3] support npm install traffic via tunnel --- commands/utils/constants.js | 11 +++++------ commands/utils/set_args.js | 9 +++++++++ commands/utils/validate.js | 14 ++++++++++++++ index.js | 5 +++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/commands/utils/constants.js b/commands/utils/constants.js index 3549f5a..531c8f1 100644 --- a/commands/utils/constants.js +++ b/commands/utils/constants.js @@ -27,16 +27,15 @@ module.exports = { "https://api.lambdatest.com/automation/api/v1/cypress/artefacts/test/", }, beta: { - INTEGRATION_BASE_URL: - "https://api-cypress-v2-dev.lambdatestinternal.com/liis", + INTEGRATION_BASE_URL: "https://api-envi-dev.lambdatestinternal.com/liis", BUILD_BASE_URL: - "https://api-cypress-v2-dev.lambdatestinternal.com/automation/api/v1/builds/", + "https://api-envi-dev.lambdatestinternal.com/automation/api/v1/builds/", BUILD_STOP_URL: - "https://api-cypress-v2-dev.lambdatestinternal.com/api/v1/test/stop?sessionId=", + "https://api-envi-dev.lambdatestinternal.com/api/v1/test/stop?sessionId=", SESSION_URL: - "https://api-cypress-v2-dev.lambdatestinternal.com/automation/api/v1/sessions?limit=200&session_id=", + "https://api-envi-dev.lambdatestinternal.com/automation/api/v1/sessions?limit=200&session_id=", REPORT_URL: - "https://api-cypress-v2-dev.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/", + "https://api-envi-dev.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/", }, stage: { INTEGRATION_BASE_URL: "https://stage-api.lambdatestinternal.com/liis", diff --git a/commands/utils/set_args.js b/commands/utils/set_args.js index de5d707..4afcdc7 100644 --- a/commands/utils/set_args.js +++ b/commands/utils/set_args.js @@ -416,6 +416,15 @@ function sync_args_from_cmd(args) { lt_config["run_settings"]["dedicated_proxy"] = false; } + //Allow npm install via tunnel, to install private dependencies which are behind VPN + if ("npm_via_tunnel" in args) { + lt_config["run_settings"]["npm_via_tunnel"] = true + ? args["npm_via_tunnel"] == "true" + : false; + } else if (!lt_config["run_settings"]["npm_via_tunnel"]) { + lt_config["run_settings"]["npm_via_tunnel"] = false; + } + //get specs from current directory if specs are not passed in config or cli if ( (lt_config["run_settings"]["specs"] == undefined || diff --git a/commands/utils/validate.js b/commands/utils/validate.js index 9043618..6274ec9 100644 --- a/commands/utils/validate.js +++ b/commands/utils/validate.js @@ -385,6 +385,20 @@ module.exports = validate_config = function (lt_config, validation_configs) { reject("Error!! Tunnel and Dedicated Proxy can not be passed in same run") } + //validate if npm_via_tunnel field contains expected value + if ("npm_via_tunnel" in lt_config["run_settings"]) { + if (!(typeof lt_config["run_settings"]["npm_via_tunnel"] === "boolean")) { + reject("Error!! boolean value is expected in npm_via_tunnel key"); + } + } + + //validate that if npm_via_tunnel is set, tunnel must be set to true + if (lt_config["run_settings"]["npm_via_tunnel"]==true && lt_config["tunnel_settings"]["tunnel"] ==false){ + reject("Error!! Installing npm packages behind private VPN is supported only with tunnel. Please pass tunnel as true.") + }else{ + console.log("Warning!! Using the flag `npm_via_tunnel` may result in higher build duration.") + } + if(lt_config) resolve(cypress_version); }); diff --git a/index.js b/index.js index ee1ccae..59e54e2 100644 --- a/index.js +++ b/index.js @@ -184,6 +184,11 @@ const argv = require("yargs") alias: "dedicated_proxy", describe: "dedicated proxy", type: "bool", + }) + .option("npm_tun", { + alias: "npm_via_tunnel", + describe: "Install npm packages which are behind private VPN. Disclaimer:This will increase the build duration of your tests.", + type: "bool", }); }, function (argv) { From e5de429cf05fdc49caa29c7e9146eec62a9dc62f Mon Sep 17 00:00:00 2001 From: asad_h Date: Thu, 9 Mar 2023 16:46:41 +0530 Subject: [PATCH 2/3] fix: validation error for the flag --- commands/utils/validate.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/commands/utils/validate.js b/commands/utils/validate.js index 6274ec9..6930b1c 100644 --- a/commands/utils/validate.js +++ b/commands/utils/validate.js @@ -393,10 +393,13 @@ module.exports = validate_config = function (lt_config, validation_configs) { } //validate that if npm_via_tunnel is set, tunnel must be set to true - if (lt_config["run_settings"]["npm_via_tunnel"]==true && lt_config["tunnel_settings"]["tunnel"] ==false){ - reject("Error!! Installing npm packages behind private VPN is supported only with tunnel. Please pass tunnel as true.") - }else{ - console.log("Warning!! Using the flag `npm_via_tunnel` may result in higher build duration.") + if (lt_config["run_settings"]["npm_via_tunnel"]==true) + { + if (lt_config["tunnel_settings"]["tunnel"] ==false){ + reject("Error!! Installing npm packages behind private VPN is supported only with tunnel. Please pass tunnel as true."); + }else{ + console.log("Warning!! Using the flag `npm_via_tunnel` may result in higher build duration."); + } } if(lt_config) From 1b88b9ead91f96fc75af85704e753710b8129d8c Mon Sep 17 00:00:00 2001 From: asad_h Date: Fri, 10 Mar 2023 15:06:48 +0530 Subject: [PATCH 3/3] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d877de9..9fbf14e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lambdatest-cypress-cli", - "version": "3.0.10", + "version": "3.0.11", "description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.", "homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli", "author": "LambdaTest ",