Skip to content

Commit 30223ba

Browse files
main Added CLI workflow.
1 parent d21be21 commit 30223ba

File tree

4 files changed

+47
-38
lines changed

4 files changed

+47
-38
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Dependency directories
2-
./node_modules
2+
node_modules
3+
*.log

LTresults.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env node
2+
3+
const ltClient = require("@lambdatest/node-rest-client");
4+
const fetchSession = async (options) => {
5+
// read credentials from env
6+
7+
if (!process.env.LT_ACCESS_KEY || !process.env.LT_USERNAME) {
8+
console.log("Access and username is required");
9+
throw new Error("User name and Access is required parameter");
10+
}
11+
12+
// read build name from env
13+
if (!process.env.LT_BUILD) {
14+
console.log(" Please set Build name to env");
15+
throw new Error("Build name is required");
16+
}
17+
18+
const autoClient = ltClient.AutomationClient({
19+
username: process.env.LT_USERNAME,
20+
accessKey: process.env.LT_ACCESS_KEY,
21+
});
22+
23+
if (!options) {
24+
// using default options
25+
console.log("Setting default configurations");
26+
options = {
27+
buildLimt: 20,
28+
buildName: process.env.LT_BUILD,
29+
sessionParams: {
30+
limit: 10000,
31+
},
32+
};
33+
}
34+
const data = await autoClient.getSessionsOfBuild(options);
35+
console.log(JSON.stringify(data));
36+
return;
37+
};
38+
39+
fetchSession();
40+
module.exports = fetchSession;

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "1.0.0",
44
"description": "This plugin fetches session details based on build name",
55
"main": "LTresults.js",
6+
"bin": {
7+
"fetch-LT-sessions": "./index.js"
8+
},
69
"scripts": {
710
"test": "echo \"Error: no test specified\" && exit 1"
811
},
@@ -20,7 +23,8 @@
2023
"lambdatest",
2124
"automation",
2225
"browser",
23-
"testing"
26+
"testing",
27+
"cli"
2428
],
2529
"dependencies": {
2630
"@lambdatest/node-rest-client": "^1.0.4"

0 commit comments

Comments
 (0)