@lambdatest/smartui-cli 4.1.21 → 4.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +106 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,9 +22,28 @@ var spawn = require('cross-spawn');
|
|
|
22
22
|
var NodeCache = require('node-cache');
|
|
23
23
|
var uuid = require('uuid');
|
|
24
24
|
var sharp = require('sharp');
|
|
25
|
+
var http = require('http');
|
|
25
26
|
|
|
26
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
28
|
|
|
29
|
+
function _interopNamespace(e) {
|
|
30
|
+
if (e && e.__esModule) return e;
|
|
31
|
+
var n = Object.create(null);
|
|
32
|
+
if (e) {
|
|
33
|
+
Object.keys(e).forEach(function (k) {
|
|
34
|
+
if (k !== 'default') {
|
|
35
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
36
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return e[k]; }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
n.default = e;
|
|
44
|
+
return Object.freeze(n);
|
|
45
|
+
}
|
|
46
|
+
|
|
28
47
|
var which__default = /*#__PURE__*/_interopDefault(which);
|
|
29
48
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
30
49
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
@@ -35,10 +54,11 @@ var addErrors__default = /*#__PURE__*/_interopDefault(addErrors);
|
|
|
35
54
|
var stringify__default = /*#__PURE__*/_interopDefault(stringify);
|
|
36
55
|
var FormData__default = /*#__PURE__*/_interopDefault(FormData);
|
|
37
56
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
38
|
-
var
|
|
57
|
+
var https__namespace = /*#__PURE__*/_interopNamespace(https);
|
|
39
58
|
var spawn__default = /*#__PURE__*/_interopDefault(spawn);
|
|
40
59
|
var NodeCache__default = /*#__PURE__*/_interopDefault(NodeCache);
|
|
41
60
|
var sharp__default = /*#__PURE__*/_interopDefault(sharp);
|
|
61
|
+
var http__namespace = /*#__PURE__*/_interopNamespace(http);
|
|
42
62
|
|
|
43
63
|
var __defProp = Object.defineProperty;
|
|
44
64
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -1903,7 +1923,7 @@ var authExec_default = (ctx) => {
|
|
|
1903
1923
|
};
|
|
1904
1924
|
|
|
1905
1925
|
// package.json
|
|
1906
|
-
var version = "4.1.
|
|
1926
|
+
var version = "4.1.22";
|
|
1907
1927
|
var package_default = {
|
|
1908
1928
|
name: "@lambdatest/smartui-cli",
|
|
1909
1929
|
version,
|
|
@@ -1980,7 +2000,7 @@ var httpClient = class {
|
|
|
1980
2000
|
} : false
|
|
1981
2001
|
};
|
|
1982
2002
|
if (SMARTUI_API_SKIP_CERTIFICATES) {
|
|
1983
|
-
axiosConfig.httpsAgent = new
|
|
2003
|
+
axiosConfig.httpsAgent = new https__namespace.default.Agent({
|
|
1984
2004
|
rejectUnauthorized: false
|
|
1985
2005
|
});
|
|
1986
2006
|
}
|
|
@@ -2646,10 +2666,10 @@ var ctx_default = (options) => {
|
|
|
2646
2666
|
mergeByBuild: false
|
|
2647
2667
|
};
|
|
2648
2668
|
};
|
|
2649
|
-
function executeCommand(
|
|
2669
|
+
function executeCommand(command10) {
|
|
2650
2670
|
let dst = process.cwd();
|
|
2651
2671
|
try {
|
|
2652
|
-
return child_process.execSync(
|
|
2672
|
+
return child_process.execSync(command10, {
|
|
2653
2673
|
cwd: dst,
|
|
2654
2674
|
stdio: ["ignore"],
|
|
2655
2675
|
encoding: "utf-8"
|
|
@@ -2694,8 +2714,8 @@ var git_default = (ctx) => {
|
|
|
2694
2714
|
} else {
|
|
2695
2715
|
const splitCharacter = "<##>";
|
|
2696
2716
|
const prettyFormat = ["%h", "%H", "%s", "%f", "%b", "%at", "%ct", "%an", "%ae", "%cn", "%ce", "%N", ""];
|
|
2697
|
-
const
|
|
2698
|
-
let res = executeCommand(
|
|
2717
|
+
const command10 = 'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) + '" && git rev-parse --abbrev-ref HEAD && git tag --contains HEAD';
|
|
2718
|
+
let res = executeCommand(command10).split(splitCharacter);
|
|
2699
2719
|
var branchAndTags = res[res.length - 1].split("\n").filter((n) => n);
|
|
2700
2720
|
var branch = ctx.env.CURRENT_BRANCH || branchAndTags[0];
|
|
2701
2721
|
branchAndTags.slice(1);
|
|
@@ -4025,15 +4045,15 @@ var startTunnel_default = (ctx) => {
|
|
|
4025
4045
|
|
|
4026
4046
|
// src/commander/exec.ts
|
|
4027
4047
|
var command = new commander.Command();
|
|
4028
|
-
command.name("exec").description("Run test commands around SmartUI").argument("<command...>", "Command supplied for running tests").option("-P, --port <number>", "Port number for the server").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--scheduled <string>", "Specify the schedule ID").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(execCommand, _,
|
|
4048
|
+
command.name("exec").description("Run test commands around SmartUI").argument("<command...>", "Command supplied for running tests").option("-P, --port <number>", "Port number for the server").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--scheduled <string>", "Specify the schedule ID").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(execCommand, _, command10) {
|
|
4029
4049
|
return __async(this, null, function* () {
|
|
4030
4050
|
var _a;
|
|
4031
|
-
const options =
|
|
4051
|
+
const options = command10.optsWithGlobals();
|
|
4032
4052
|
if (options.buildName === "") {
|
|
4033
4053
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4034
4054
|
process.exit(1);
|
|
4035
4055
|
}
|
|
4036
|
-
let ctx = ctx_default(
|
|
4056
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
4037
4057
|
if (!which__default.default.sync(execCommand[0], { nothrow: true })) {
|
|
4038
4058
|
ctx.log.error(`Error: Command not found "${execCommand[0]}"`);
|
|
4039
4059
|
return;
|
|
@@ -4649,15 +4669,15 @@ var captureScreenshots_default = (ctx) => {
|
|
|
4649
4669
|
|
|
4650
4670
|
// src/commander/capture.ts
|
|
4651
4671
|
var command2 = new commander.Command();
|
|
4652
|
-
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("-C, --parallel [number]", "Specify the number of instances per browser", parseInt).option("-F, --force", "forcefully apply the specified parallel instances per browser").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--scheduled <string>", "Specify the schedule ID").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(file, _,
|
|
4672
|
+
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("-C, --parallel [number]", "Specify the number of instances per browser", parseInt).option("-F, --force", "forcefully apply the specified parallel instances per browser").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--scheduled <string>", "Specify the schedule ID").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(file, _, command10) {
|
|
4653
4673
|
return __async(this, null, function* () {
|
|
4654
4674
|
var _a, _b;
|
|
4655
|
-
const options =
|
|
4675
|
+
const options = command10.optsWithGlobals();
|
|
4656
4676
|
if (options.buildName === "") {
|
|
4657
4677
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4658
4678
|
process.exit(1);
|
|
4659
4679
|
}
|
|
4660
|
-
let ctx = ctx_default(
|
|
4680
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
4661
4681
|
ctx.isSnapshotCaptured = true;
|
|
4662
4682
|
if (!fs5__default.default.existsSync(file)) {
|
|
4663
4683
|
ctx.log.error(`Web Static Config file ${file} not found.`);
|
|
@@ -4745,14 +4765,14 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
4745
4765
|
return val.split(",").map((ext) => ext.trim().toLowerCase());
|
|
4746
4766
|
}).option("-E, --removeExtensions", "Strips file extensions from snapshot names").option("-i, --ignoreDir <patterns>", "Comma-separated list of directories to ignore", (val) => {
|
|
4747
4767
|
return val.split(",").map((pattern) => pattern.trim());
|
|
4748
|
-
}).option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(directory, _,
|
|
4768
|
+
}).option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(directory, _, command10) {
|
|
4749
4769
|
return __async(this, null, function* () {
|
|
4750
|
-
const options =
|
|
4770
|
+
const options = command10.optsWithGlobals();
|
|
4751
4771
|
if (options.buildName === "") {
|
|
4752
4772
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4753
4773
|
process.exit(1);
|
|
4754
4774
|
}
|
|
4755
|
-
let ctx = ctx_default(
|
|
4775
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
4756
4776
|
ctx.isSnapshotCaptured = true;
|
|
4757
4777
|
if (!fs5__default.default.existsSync(directory)) {
|
|
4758
4778
|
console.log(`Error: The provided directory ${directory} not found.`);
|
|
@@ -5030,10 +5050,10 @@ var uploadAppFigma_default2 = (ctx) => {
|
|
|
5030
5050
|
var uploadFigma = new commander.Command();
|
|
5031
5051
|
var uploadWebFigmaCommand = new commander.Command();
|
|
5032
5052
|
var uploadAppFigmaCommand = new commander.Command();
|
|
5033
|
-
uploadFigma.name("upload-figma").description("Capture screenshots of static sites").argument("<file>", "figma design config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").action(function(file, _,
|
|
5053
|
+
uploadFigma.name("upload-figma").description("Capture screenshots of static sites").argument("<file>", "figma design config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").action(function(file, _, command10) {
|
|
5034
5054
|
return __async(this, null, function* () {
|
|
5035
5055
|
var _a, _b;
|
|
5036
|
-
let ctx = ctx_default(
|
|
5056
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
5037
5057
|
ctx.isSnapshotCaptured = true;
|
|
5038
5058
|
if (!fs5__default.default.existsSync(file)) {
|
|
5039
5059
|
console.log(`Error: Figma Config file ${file} not found.`);
|
|
@@ -5072,10 +5092,10 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
|
|
|
5072
5092
|
}
|
|
5073
5093
|
});
|
|
5074
5094
|
});
|
|
5075
|
-
uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screenshots into CLI build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _,
|
|
5095
|
+
uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screenshots into CLI build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command10) {
|
|
5076
5096
|
return __async(this, null, function* () {
|
|
5077
5097
|
var _a;
|
|
5078
|
-
let ctx = ctx_default(
|
|
5098
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
5079
5099
|
if (!fs5__default.default.existsSync(file)) {
|
|
5080
5100
|
console.log(`Error: figma-web config file ${file} not found.`);
|
|
5081
5101
|
return;
|
|
@@ -5125,10 +5145,10 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screen
|
|
|
5125
5145
|
}
|
|
5126
5146
|
});
|
|
5127
5147
|
});
|
|
5128
|
-
uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screenshots into App Build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _,
|
|
5148
|
+
uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screenshots into App Build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command10) {
|
|
5129
5149
|
return __async(this, null, function* () {
|
|
5130
5150
|
var _a;
|
|
5131
|
-
let ctx = ctx_default(
|
|
5151
|
+
let ctx = ctx_default(command10.optsWithGlobals());
|
|
5132
5152
|
if (!fs5__default.default.existsSync(file)) {
|
|
5133
5153
|
console.log(`Error: figma-app config file ${file} not found.`);
|
|
5134
5154
|
return;
|
|
@@ -5504,10 +5524,73 @@ var mergeBuild_default = command8;
|
|
|
5504
5524
|
var program = new commander.Command();
|
|
5505
5525
|
program.name("merge").description("Merge a source branch into the target branch").addCommand(mergeBranch_default).addCommand(mergeBuild_default);
|
|
5506
5526
|
var merge_default = program;
|
|
5527
|
+
function getSmartUIServerAddress3() {
|
|
5528
|
+
const serverAddress = process.env.SMARTUI_SERVER_ADDRESS || "http://localhost:49152";
|
|
5529
|
+
return serverAddress;
|
|
5530
|
+
}
|
|
5531
|
+
function makeHttpRequest(url, timeout) {
|
|
5532
|
+
return new Promise((resolve, reject) => {
|
|
5533
|
+
const urlObj = new URL(url);
|
|
5534
|
+
const isHttps = urlObj.protocol === "https:";
|
|
5535
|
+
const client = isHttps ? https__namespace : http__namespace;
|
|
5536
|
+
const req = client.request(url, { timeout }, (res) => {
|
|
5537
|
+
let data = "";
|
|
5538
|
+
res.on("data", (chunk) => {
|
|
5539
|
+
data += chunk;
|
|
5540
|
+
});
|
|
5541
|
+
res.on("end", () => {
|
|
5542
|
+
let parsedData;
|
|
5543
|
+
try {
|
|
5544
|
+
parsedData = JSON.parse(data);
|
|
5545
|
+
} catch (e) {
|
|
5546
|
+
parsedData = data;
|
|
5547
|
+
}
|
|
5548
|
+
resolve({
|
|
5549
|
+
status: res.statusCode || 0,
|
|
5550
|
+
data: parsedData
|
|
5551
|
+
});
|
|
5552
|
+
});
|
|
5553
|
+
});
|
|
5554
|
+
req.on("error", (error) => {
|
|
5555
|
+
reject(error);
|
|
5556
|
+
});
|
|
5557
|
+
req.on("timeout", () => {
|
|
5558
|
+
req.destroy();
|
|
5559
|
+
const timeoutError = new Error("Request timeout");
|
|
5560
|
+
timeoutError.code = "ECONNABORTED";
|
|
5561
|
+
reject(timeoutError);
|
|
5562
|
+
});
|
|
5563
|
+
req.end();
|
|
5564
|
+
});
|
|
5565
|
+
}
|
|
5566
|
+
var command9 = new commander.Command();
|
|
5567
|
+
command9.name("exec:pingTest").description("Ping the SmartUI server to check if it is running using default http client").action(function() {
|
|
5568
|
+
return __async(this, null, function* () {
|
|
5569
|
+
try {
|
|
5570
|
+
console.log(chalk__default.default.yellow("Pinging server using default http client..."));
|
|
5571
|
+
const serverAddress = getSmartUIServerAddress3();
|
|
5572
|
+
console.log(chalk__default.default.yellow(`Pinging server at ${serverAddress} from terminal using default http client...`));
|
|
5573
|
+
const response = yield makeHttpRequest(`${serverAddress}/ping`, 15e3);
|
|
5574
|
+
if (response.status === 200) {
|
|
5575
|
+
console.log(chalk__default.default.green("SmartUI Server is running"));
|
|
5576
|
+
console.log(chalk__default.default.green(`Response: ${JSON.stringify(response.data)}`));
|
|
5577
|
+
} else {
|
|
5578
|
+
console.log(chalk__default.default.red("Failed to reach the server"));
|
|
5579
|
+
}
|
|
5580
|
+
} catch (error) {
|
|
5581
|
+
if (error.code === "ECONNABORTED") {
|
|
5582
|
+
console.error(chalk__default.default.red("Error: SmartUI server did not respond in 15 seconds"));
|
|
5583
|
+
} else {
|
|
5584
|
+
console.error(chalk__default.default.red("SmartUI server is not running"));
|
|
5585
|
+
}
|
|
5586
|
+
}
|
|
5587
|
+
});
|
|
5588
|
+
});
|
|
5589
|
+
var pingTest_default = command9;
|
|
5507
5590
|
|
|
5508
5591
|
// src/commander/commander.ts
|
|
5509
5592
|
var program2 = new commander.Command();
|
|
5510
|
-
program2.name("smartui").description("CLI to help you run your SmartUI tests on LambdaTest platform").version(`v${version}`).option("-c --config <filepath>", "Config file path").option("--markBaseline", "Mark this build baseline").option("--baselineBranch <string>", "Mark this build baseline").option("--baselineBuild <string>", "Mark this build baseline").option("--githubURL <string>", "GitHub URL including commitId").addCommand(exec_default2).addCommand(capture_default).addCommand(configWeb).addCommand(configStatic).addCommand(upload_default).addCommand(server_default2).addCommand(stopServer_default).addCommand(merge_default).addCommand(ping_default).addCommand(configFigma).addCommand(uploadFigma).addCommand(configWebFigma).addCommand(configAppFigma).addCommand(uploadWebFigmaCommand).addCommand(uploadAppFigmaCommand);
|
|
5593
|
+
program2.name("smartui").description("CLI to help you run your SmartUI tests on LambdaTest platform").version(`v${version}`).option("-c --config <filepath>", "Config file path").option("--markBaseline", "Mark this build baseline").option("--baselineBranch <string>", "Mark this build baseline").option("--baselineBuild <string>", "Mark this build baseline").option("--githubURL <string>", "GitHub URL including commitId").addCommand(exec_default2).addCommand(capture_default).addCommand(configWeb).addCommand(configStatic).addCommand(upload_default).addCommand(server_default2).addCommand(stopServer_default).addCommand(merge_default).addCommand(ping_default).addCommand(configFigma).addCommand(uploadFigma).addCommand(configWebFigma).addCommand(configAppFigma).addCommand(uploadWebFigmaCommand).addCommand(uploadAppFigmaCommand).addCommand(pingTest_default);
|
|
5511
5594
|
var commander_default = program2;
|
|
5512
5595
|
(function() {
|
|
5513
5596
|
return __async(this, null, function* () {
|