Skip to content

Commit 4012ae5

Browse files
Merge pull request #97 from LambdaTest/dev
Release 2.1.8
2 parents fc3a312 + b570e38 commit 4012ae5

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
lines changed

commands/utils/archive.js

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function archive_project(lt_config) {
3838

3939
archive.on("error", function (err) {
4040
console.log("ERROR", err);
41-
throw err;
41+
reject(err);
42+
//throw err;
4243
});
4344

4445
// pipe archive data to the file
@@ -68,9 +69,65 @@ function archive_project(lt_config) {
6869
console.log("Ignoring files: ", ignore_files);
6970
archive.glob(
7071
"**/*",
71-
{ cwd: process.cwd(), ignore: ignore_files },
72+
{ cwd: process.cwd(), ignore: ignore_files, dot: true },
7273
{ prefix: "project/" }
7374
);
75+
//OverRide NPM Dependencies
76+
if (lt_config.run_settings.npm_dependencies) {
77+
console.log("Overriding NPM Dependencies");
78+
let rawdata = fs.readFileSync("package.json");
79+
80+
let package = JSON.parse(rawdata);
81+
package.dependencies = lt_config.run_settings.npm_dependencies;
82+
package.devDependencies = {};
83+
archive.append(
84+
JSON.stringify(package, null, 4),
85+
{
86+
name: "project/package.json",
87+
cwd: process.cwd(),
88+
ignore: ignore_files,
89+
},
90+
{ prefix: "project/" }
91+
);
92+
}
93+
if (
94+
lt_config.run_settings.dep_tokens &&
95+
lt_config.run_settings.dep_tokens.length > 0
96+
) {
97+
if (fs.existsSync(".npmrc")) {
98+
let raw_data = fs.readFileSync(".npmrc", "utf8");
99+
let replace_map = {};
100+
for (let i = 0; i < lt_config.run_settings.dep_tokens.length; i++) {
101+
if (process.env[lt_config.run_settings.dep_tokens[i]]) {
102+
//Used for creating regular expression by escaping the $ and {}
103+
replace_map[
104+
"\\$\\{" + lt_config.run_settings.dep_tokens[i] + "\\}"
105+
] = process.env[lt_config.run_settings.dep_tokens[i]];
106+
//User for String replacement
107+
replace_map["${" + lt_config.run_settings.dep_tokens[i] + "}"] =
108+
process.env[lt_config.run_settings.dep_tokens[i]];
109+
} else {
110+
reject("Dep Tokens are not in environment");
111+
return;
112+
}
113+
}
114+
var re = new RegExp(Object.keys(replace_map).join("|"), "gi");
115+
raw_data = raw_data.replace(re, function (matched) {
116+
return replace_map[matched];
117+
});
118+
archive.append(
119+
raw_data,
120+
{
121+
name: "project/.npmrc",
122+
cwd: process.cwd(),
123+
ignore: ignore_files,
124+
},
125+
{ prefix: "project/" }
126+
);
127+
} else {
128+
reject("Dep Tokens are passed but .npmrc does not exist");
129+
}
130+
}
74131

75132
archive.finalize();
76133
});

commands/utils/batch/batch_runner.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ function run_test(payload, env = "prod") {
5252
if (parseInt(build_id) == 0) {
5353
reject("Some Error occured on Lambdatest Server");
5454
} else {
55+
//Write session_id to a file
56+
data = { build_id: build_id, session_id: session_id };
57+
fs.writeFileSync(
58+
"lambdatest_run.json",
59+
JSON.stringify(data, null, 3)
60+
);
5561
console.log(
5662
`Uploaded tests successfully `,
5763
responseData["value"]["message"]

commands/utils/default_config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ module.exports = {
2525
network: false,
2626
headless: false,
2727
reporter_config_file: "",
28+
npm_dependencies: {
29+
cypress: "9.0.0",
30+
},
2831
},
2932
tunnel_settings: {
3033
tunnel: false,

commands/utils/validate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ module.exports = validate_config = function (lt_config) {
7878
let rawdata = fs.readFileSync("package.json");
7979
try {
8080
let package = JSON.parse(rawdata);
81+
//Override npm_dependencies
82+
if (lt_config.run_settings.npm_dependencies) {
83+
package.dependencies = lt_config.run_settings.npm_dependencies;
84+
package.devDependencies = {};
85+
}
8186
let cypress_flag = false;
8287
if (package.hasOwnProperty("dependencies")) {
8388
for (const [key, value] of Object.entries(package["dependencies"])) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambdatest-cypress-cli",
3-
"version": "2.1.7",
3+
"version": "2.1.8",
44
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
55
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
66
"author": "LambdaTest <keys@lambdatest.com>",

0 commit comments

Comments
 (0)