@lambdatest/smartui-cli 4.1.15 → 4.1.17
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 +49 -9
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var addErrors = require('ajv-errors');
|
|
|
13
13
|
var test = require('@playwright/test');
|
|
14
14
|
var util = require('util');
|
|
15
15
|
var winston = require('winston');
|
|
16
|
+
var stringify = require('json-stringify-safe');
|
|
16
17
|
var FormData = require('form-data');
|
|
17
18
|
var axios = require('axios');
|
|
18
19
|
var https = require('https');
|
|
@@ -31,6 +32,7 @@ var fastify__default = /*#__PURE__*/_interopDefault(fastify);
|
|
|
31
32
|
var fs5__default = /*#__PURE__*/_interopDefault(fs5);
|
|
32
33
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
33
34
|
var addErrors__default = /*#__PURE__*/_interopDefault(addErrors);
|
|
35
|
+
var stringify__default = /*#__PURE__*/_interopDefault(stringify);
|
|
34
36
|
var FormData__default = /*#__PURE__*/_interopDefault(FormData);
|
|
35
37
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
36
38
|
var https__default = /*#__PURE__*/_interopDefault(https);
|
|
@@ -737,6 +739,18 @@ var ConfigSchema = {
|
|
|
737
739
|
userAgent: {
|
|
738
740
|
type: "string",
|
|
739
741
|
errorMessage: "User Agent value must be a valid string"
|
|
742
|
+
},
|
|
743
|
+
requestHeaders: {
|
|
744
|
+
type: "array",
|
|
745
|
+
items: {
|
|
746
|
+
type: "object",
|
|
747
|
+
minProperties: 1,
|
|
748
|
+
additionalProperties: { type: "string" }
|
|
749
|
+
},
|
|
750
|
+
uniqueItems: true,
|
|
751
|
+
errorMessage: {
|
|
752
|
+
uniqueItems: "Invalid config; duplicates in requestHeaders"
|
|
753
|
+
}
|
|
740
754
|
}
|
|
741
755
|
},
|
|
742
756
|
anyOf: [
|
|
@@ -1655,6 +1669,9 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
1655
1669
|
console.log(`Failed to fetch capabilities for sessionId ${sessionId}: ${error.message}`);
|
|
1656
1670
|
}
|
|
1657
1671
|
}
|
|
1672
|
+
if (capsBuildId && capsBuildId !== "") {
|
|
1673
|
+
process.env.SMARTUI_BUILD_ID = capsBuildId;
|
|
1674
|
+
}
|
|
1658
1675
|
}
|
|
1659
1676
|
ctx.testType = testType;
|
|
1660
1677
|
(_c = ctx.snapshotQueue) == null ? void 0 : _c.enqueue(snapshot);
|
|
@@ -1777,7 +1794,7 @@ var logger = winston.createLogger({
|
|
|
1777
1794
|
winston.format.timestamp(),
|
|
1778
1795
|
winston.format.printf((info) => {
|
|
1779
1796
|
let contextString = Object.values(logContext).join(" | ");
|
|
1780
|
-
let message = typeof info.message === "object" ?
|
|
1797
|
+
let message = typeof info.message === "object" ? stringify__default.default(info.message) : info.message.trim();
|
|
1781
1798
|
switch (info.level) {
|
|
1782
1799
|
case "warn":
|
|
1783
1800
|
message = chalk__default.default.yellow(message);
|
|
@@ -1856,7 +1873,7 @@ var authExec_default = (ctx) => {
|
|
|
1856
1873
|
};
|
|
1857
1874
|
|
|
1858
1875
|
// package.json
|
|
1859
|
-
var version = "4.1.
|
|
1876
|
+
var version = "4.1.17";
|
|
1860
1877
|
var package_default = {
|
|
1861
1878
|
name: "@lambdatest/smartui-cli",
|
|
1862
1879
|
version,
|
|
@@ -1882,14 +1899,15 @@ var package_default = {
|
|
|
1882
1899
|
author: "LambdaTest <keys@lambdatest.com>",
|
|
1883
1900
|
license: "MIT",
|
|
1884
1901
|
dependencies: {
|
|
1902
|
+
"@lambdatest/node-tunnel": "^4.0.9",
|
|
1885
1903
|
"@playwright/browser-chromium": "^1.47.2",
|
|
1886
1904
|
"@playwright/browser-firefox": "^1.47.2",
|
|
1887
1905
|
"@playwright/browser-webkit": "^1.47.2",
|
|
1888
1906
|
"@playwright/test": "^1.47.2",
|
|
1889
1907
|
"@types/cross-spawn": "^6.0.4",
|
|
1908
|
+
"@types/json-stringify-safe": "^5.0.3",
|
|
1890
1909
|
"@types/node": "^20.8.9",
|
|
1891
1910
|
"@types/which": "^3.0.2",
|
|
1892
|
-
"@lambdatest/node-tunnel": "^4.0.9",
|
|
1893
1911
|
ajv: "^8.12.0",
|
|
1894
1912
|
"ajv-errors": "^3.0.0",
|
|
1895
1913
|
axios: "^1.6.0",
|
|
@@ -1898,6 +1916,7 @@ var package_default = {
|
|
|
1898
1916
|
"cross-spawn": "^7.0.3",
|
|
1899
1917
|
fastify: "^4.24.3",
|
|
1900
1918
|
"form-data": "^4.0.0",
|
|
1919
|
+
"json-stringify-safe": "^5.0.1",
|
|
1901
1920
|
listr2: "^7.0.1",
|
|
1902
1921
|
"node-cache": "^5.1.2",
|
|
1903
1922
|
sharp: "^0.33.4",
|
|
@@ -2451,7 +2470,6 @@ var ctx_default = (options) => {
|
|
|
2451
2470
|
try {
|
|
2452
2471
|
if (options.config) {
|
|
2453
2472
|
config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
|
|
2454
|
-
logger_default.debug(`Config file ${options.config} loaded: ${JSON.stringify(config, null, 2)}`);
|
|
2455
2473
|
if ((_a = config.web) == null ? void 0 : _a.resolutions) {
|
|
2456
2474
|
config.web.viewports = config.web.resolutions;
|
|
2457
2475
|
delete config.web.resolutions;
|
|
@@ -2531,7 +2549,8 @@ var ctx_default = (options) => {
|
|
|
2531
2549
|
ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
|
|
2532
2550
|
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
|
|
2533
2551
|
tunnel: tunnelObj,
|
|
2534
|
-
userAgent: config.userAgent || ""
|
|
2552
|
+
userAgent: config.userAgent || "",
|
|
2553
|
+
requestHeaders: config.requestHeaders || {}
|
|
2535
2554
|
},
|
|
2536
2555
|
uploadFilePath: "",
|
|
2537
2556
|
webStaticConfig: [],
|
|
@@ -2567,7 +2586,8 @@ var ctx_default = (options) => {
|
|
|
2567
2586
|
fetchResults: fetchResultObj,
|
|
2568
2587
|
fetchResultsFileName: fetchResultsFileObj,
|
|
2569
2588
|
baselineBranch: options.baselineBranch || "",
|
|
2570
|
-
baselineBuild: options.baselineBuild || ""
|
|
2589
|
+
baselineBuild: options.baselineBuild || "",
|
|
2590
|
+
githubURL: options.githubURL || ""
|
|
2571
2591
|
},
|
|
2572
2592
|
cliVersion: version,
|
|
2573
2593
|
totalSnapshots: -1,
|
|
@@ -2615,6 +2635,10 @@ var git_default = (ctx) => {
|
|
|
2615
2635
|
ctx.env.SMART_GIT = false;
|
|
2616
2636
|
}
|
|
2617
2637
|
}
|
|
2638
|
+
let githubURL;
|
|
2639
|
+
if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
|
|
2640
|
+
githubURL = ctx.options.githubURL;
|
|
2641
|
+
}
|
|
2618
2642
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
2619
2643
|
let gitInfo = JSON.parse(fs5__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
2620
2644
|
if (ctx.options.markBaseline) {
|
|
@@ -2626,7 +2650,7 @@ var git_default = (ctx) => {
|
|
|
2626
2650
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
2627
2651
|
commitMessage: gitInfo.commit_body || "",
|
|
2628
2652
|
commitAuthor: gitInfo.commit_author || "",
|
|
2629
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
2653
|
+
githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
2630
2654
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2631
2655
|
};
|
|
2632
2656
|
} else {
|
|
@@ -2646,7 +2670,7 @@ var git_default = (ctx) => {
|
|
|
2646
2670
|
commitId: res[0] || "",
|
|
2647
2671
|
commitMessage: res[2] || "",
|
|
2648
2672
|
commitAuthor: res[7] || "",
|
|
2649
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
2673
|
+
githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
2650
2674
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2651
2675
|
};
|
|
2652
2676
|
}
|
|
@@ -2664,6 +2688,9 @@ var getGitInfo_default = (ctx) => {
|
|
|
2664
2688
|
try {
|
|
2665
2689
|
ctx2.git = git_default(ctx2);
|
|
2666
2690
|
task.output = chalk__default.default.gray(`branch: ${ctx2.git.branch}, commit: ${ctx2.git.commitId}, author: ${ctx2.git.commitAuthor}`);
|
|
2691
|
+
if (ctx2.git.githubURL && ctx2.git.githubURL !== "") {
|
|
2692
|
+
task.output += chalk__default.default.gray(`, githubURL: ${ctx2.git.githubURL}`);
|
|
2693
|
+
}
|
|
2667
2694
|
task.title = "Fetched git information";
|
|
2668
2695
|
} catch (error) {
|
|
2669
2696
|
ctx2.log.debug(error);
|
|
@@ -2931,6 +2958,9 @@ function prepareSnapshot(snapshot, ctx) {
|
|
|
2931
2958
|
if (ctx.config.basicAuthorization) {
|
|
2932
2959
|
processedOptions.basicAuthorization = ctx.config.basicAuthorization;
|
|
2933
2960
|
}
|
|
2961
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
2962
|
+
processedOptions.requestHeaders = ctx.config.requestHeaders;
|
|
2963
|
+
}
|
|
2934
2964
|
ctx.config.allowedHostnames.push(new URL(snapshot.url).hostname);
|
|
2935
2965
|
processedOptions.allowedHostnames = ctx.config.allowedHostnames;
|
|
2936
2966
|
processedOptions.skipCapturedCookies = ctx.env.SMARTUI_DO_NOT_USE_CAPTURED_COOKIES;
|
|
@@ -3076,6 +3106,9 @@ function processSnapshot(snapshot, ctx) {
|
|
|
3076
3106
|
browsers: {}
|
|
3077
3107
|
};
|
|
3078
3108
|
let processedOptions = {};
|
|
3109
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
3110
|
+
processedOptions.requestHeaders = ctx.config.requestHeaders;
|
|
3111
|
+
}
|
|
3079
3112
|
let globalViewport = "";
|
|
3080
3113
|
let globalBrowser = constants_default.CHROME;
|
|
3081
3114
|
let launchOptions = {
|
|
@@ -3150,6 +3183,13 @@ function processSnapshot(snapshot, ctx) {
|
|
|
3150
3183
|
let token = Buffer.from(`${ctx.config.basicAuthorization.username}:${ctx.config.basicAuthorization.password}`).toString("base64");
|
|
3151
3184
|
requestOptions.headers.Authorization = `Basic ${token}`;
|
|
3152
3185
|
}
|
|
3186
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
3187
|
+
ctx.config.requestHeaders.forEach((headerObj) => {
|
|
3188
|
+
Object.entries(headerObj).forEach(([key, value]) => {
|
|
3189
|
+
requestOptions.headers[key] = value;
|
|
3190
|
+
});
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3153
3193
|
let response, body;
|
|
3154
3194
|
if (requestUrl === snapshot.url) {
|
|
3155
3195
|
response = {
|
|
@@ -5427,7 +5467,7 @@ var merge_default = program;
|
|
|
5427
5467
|
|
|
5428
5468
|
// src/commander/commander.ts
|
|
5429
5469
|
var program2 = new commander.Command();
|
|
5430
|
-
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").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);
|
|
5470
|
+
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);
|
|
5431
5471
|
var commander_default = program2;
|
|
5432
5472
|
(function() {
|
|
5433
5473
|
return __async(this, null, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambdatest/smartui-cli",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.17",
|
|
4
4
|
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*"
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
"author": "LambdaTest <keys@lambdatest.com>",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@lambdatest/node-tunnel": "^4.0.9",
|
|
20
21
|
"@playwright/browser-chromium": "^1.47.2",
|
|
21
22
|
"@playwright/browser-firefox": "^1.47.2",
|
|
22
23
|
"@playwright/browser-webkit": "^1.47.2",
|
|
23
24
|
"@playwright/test": "^1.47.2",
|
|
24
25
|
"@types/cross-spawn": "^6.0.4",
|
|
26
|
+
"@types/json-stringify-safe": "^5.0.3",
|
|
25
27
|
"@types/node": "^20.8.9",
|
|
26
28
|
"@types/which": "^3.0.2",
|
|
27
|
-
"@lambdatest/node-tunnel": "^4.0.9",
|
|
28
29
|
"ajv": "^8.12.0",
|
|
29
30
|
"ajv-errors": "^3.0.0",
|
|
30
31
|
"axios": "^1.6.0",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"cross-spawn": "^7.0.3",
|
|
34
35
|
"fastify": "^4.24.3",
|
|
35
36
|
"form-data": "^4.0.0",
|
|
37
|
+
"json-stringify-safe": "^5.0.1",
|
|
36
38
|
"listr2": "^7.0.1",
|
|
37
39
|
"node-cache": "^5.1.2",
|
|
38
40
|
"sharp": "^0.33.4",
|