Skip to content

Commit

Permalink
support npm install traffic via tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
asad9711 committed Mar 9, 2023
1 parent 5ed78d0 commit 1731de9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
11 changes: 5 additions & 6 deletions commands/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions commands/utils/set_args.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
14 changes: 14 additions & 0 deletions commands/utils/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1731de9

Please sign in to comment.