Skip to content

Commit 77cc4bf

Browse files
authored
Merge pull request #232 from asad9711/CYP-626
support npm install traffic via tunnel
2 parents 8b49930 + 1827cde commit 77cc4bf

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

commands/run.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module.exports = function (args) {
6666
set_args
6767
.sync_args_from_cmd(args)
6868
.then(function (lt_config) {
69+
console.log("lt_config -> ", lt_config);
6970
//validate the config options
7071
validate(lt_config, resp)
7172
.then(function (cypressVersion) {

commands/utils/set_args.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,15 @@ function sync_args_from_cmd(args) {
425425
lt_config["run_settings"]["dedicated_proxy"] = false;
426426
}
427427

428+
//Allow npm install via tunnel, to install private dependencies which are behind VPN
429+
if ("npm_via_tunnel" in args) {
430+
lt_config["run_settings"]["npm_via_tunnel"] = true
431+
? args["npm_via_tunnel"] == "true"
432+
: false;
433+
} else if (!lt_config["run_settings"]["npm_via_tunnel"]) {
434+
lt_config["run_settings"]["npm_via_tunnel"] = false;
435+
}
436+
428437
//get specs from current directory if specs are not passed in config or cli
429438
if (
430439
(lt_config["run_settings"]["specs"] == undefined ||

commands/utils/validate.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,20 @@ module.exports = validate_config = function (lt_config, validation_configs) {
385385
reject("Error!! Tunnel and Dedicated Proxy can not be passed in same run")
386386
}
387387

388+
//validate if npm_via_tunnel field contains expected value
389+
if ("npm_via_tunnel" in lt_config["run_settings"]) {
390+
if (!(typeof lt_config["run_settings"]["npm_via_tunnel"] === "boolean")) {
391+
reject("Error!! boolean value is expected in npm_via_tunnel key");
392+
}
393+
}
394+
395+
//validate that if npm_via_tunnel is set, tunnel must be set to true
396+
if (lt_config["run_settings"]["npm_via_tunnel"]==true && lt_config["run_settings"]["tunnel"] ==false){
397+
reject("Error!! Installing npm packages behind private VPN is supported only with tunnel. Please pass tunnel as true.")
398+
}else{
399+
console.log("Warning!! Using the flag `npm_via_tunnel` may result in higher build duration.")
400+
}
401+
388402
if(lt_config)
389403
resolve(cypress_version);
390404
});

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ const argv = require("yargs")
182182
alias: "dedicated_proxy",
183183
describe: "dedicated proxy",
184184
type: "bool",
185+
})
186+
.option("npm_tun", {
187+
alias: "npm_via_tunnel",
188+
describe: "Install npm packages which are behind private VPN. Disclaimer:This will increase the build duration of your tests.",
189+
type: "bool",
185190
});
186191
},
187192
function (argv) {

0 commit comments

Comments
 (0)