@lambdatest/smartui-cli 4.0.18 → 4.0.20
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 +108 -55
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -16,6 +16,7 @@ var axios = require('axios');
|
|
|
16
16
|
var child_process = require('child_process');
|
|
17
17
|
var spawn = require('cross-spawn');
|
|
18
18
|
var test = require('@playwright/test');
|
|
19
|
+
var uuid = require('uuid');
|
|
19
20
|
var sharp = require('sharp');
|
|
20
21
|
|
|
21
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -962,7 +963,7 @@ var validateFigmaDesignConfig = ajv.compile(FigmaDesignConfigSchema);
|
|
|
962
963
|
var validateWebFigmaConfig = ajv.compile(FigmaWebConfigSchema);
|
|
963
964
|
|
|
964
965
|
// src/lib/server.ts
|
|
965
|
-
var server_default = (ctx) => __async(
|
|
966
|
+
var server_default = (ctx) => __async(undefined, null, function* () {
|
|
966
967
|
const server = fastify__default.default({
|
|
967
968
|
logger: {
|
|
968
969
|
level: "debug",
|
|
@@ -980,7 +981,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
980
981
|
server.get("/domserializer", opts, (request, reply) => {
|
|
981
982
|
reply.code(200).send({ data: { dom: SMARTUI_DOM } });
|
|
982
983
|
});
|
|
983
|
-
server.post("/snapshot", opts, (request, reply) => __async(
|
|
984
|
+
server.post("/snapshot", opts, (request, reply) => __async(undefined, null, function* () {
|
|
984
985
|
var _a;
|
|
985
986
|
let replyCode;
|
|
986
987
|
let replyBody;
|
|
@@ -1083,7 +1084,7 @@ var logger_default = logger;
|
|
|
1083
1084
|
var startServer_default = (ctx) => {
|
|
1084
1085
|
return {
|
|
1085
1086
|
title: `Setting up SmartUI server`,
|
|
1086
|
-
task: (ctx2, task) => __async(
|
|
1087
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1087
1088
|
var _a;
|
|
1088
1089
|
updateLogContext({ task: "startServer" });
|
|
1089
1090
|
try {
|
|
@@ -1102,7 +1103,7 @@ var startServer_default = (ctx) => {
|
|
|
1102
1103
|
var auth_default = (ctx) => {
|
|
1103
1104
|
return {
|
|
1104
1105
|
title: `Authenticating with SmartUI`,
|
|
1105
|
-
task: (ctx2, task) => __async(
|
|
1106
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1106
1107
|
updateLogContext({ task: "auth" });
|
|
1107
1108
|
try {
|
|
1108
1109
|
const authResult = yield ctx2.client.auth(ctx2.log, ctx2.env);
|
|
@@ -1125,7 +1126,7 @@ var auth_default = (ctx) => {
|
|
|
1125
1126
|
};
|
|
1126
1127
|
|
|
1127
1128
|
// package.json
|
|
1128
|
-
var version = "4.0.
|
|
1129
|
+
var version = "4.0.20";
|
|
1129
1130
|
var package_default = {
|
|
1130
1131
|
name: "@lambdatest/smartui-cli",
|
|
1131
1132
|
version,
|
|
@@ -1168,6 +1169,7 @@ var package_default = {
|
|
|
1168
1169
|
listr2: "^7.0.1",
|
|
1169
1170
|
sharp: "^0.33.4",
|
|
1170
1171
|
tsup: "^7.2.0",
|
|
1172
|
+
uuid: "^11.0.3",
|
|
1171
1173
|
which: "^4.0.0",
|
|
1172
1174
|
winston: "^3.10.0"
|
|
1173
1175
|
},
|
|
@@ -1213,7 +1215,7 @@ var httpClient = class {
|
|
|
1213
1215
|
headers: error.response.headers,
|
|
1214
1216
|
body: error.response.data
|
|
1215
1217
|
})}`);
|
|
1216
|
-
throw new Error(((_a = error.response.data.error) == null ?
|
|
1218
|
+
throw new Error(((_a = error.response.data.error) == null ? undefined : _a.message) || error.response.data.message || error.response.data);
|
|
1217
1219
|
}
|
|
1218
1220
|
if (error.request) {
|
|
1219
1221
|
log2.debug(`http request failed: ${error.toJSON()}`);
|
|
@@ -1288,6 +1290,23 @@ var httpClient = class {
|
|
|
1288
1290
|
}
|
|
1289
1291
|
}, ctx.log);
|
|
1290
1292
|
}
|
|
1293
|
+
processSnapshot(ctx, snapshot, snapshotUuid) {
|
|
1294
|
+
return this.request({
|
|
1295
|
+
url: `/build/${ctx.build.id}/snapshot`,
|
|
1296
|
+
method: "POST",
|
|
1297
|
+
headers: { "Content-Type": "application/json" },
|
|
1298
|
+
data: {
|
|
1299
|
+
name: snapshot.name,
|
|
1300
|
+
url: snapshot.url,
|
|
1301
|
+
snapshotUuid,
|
|
1302
|
+
test: {
|
|
1303
|
+
type: ctx.testType,
|
|
1304
|
+
source: "cli"
|
|
1305
|
+
},
|
|
1306
|
+
async: false
|
|
1307
|
+
}
|
|
1308
|
+
}, ctx.log);
|
|
1309
|
+
}
|
|
1291
1310
|
uploadScreenshot({ id: buildId, name: buildName, baseline }, ssPath, ssName, browserName, viewport, log2) {
|
|
1292
1311
|
browserName = browserName === constants_default.SAFARI ? constants_default.WEBKIT : browserName;
|
|
1293
1312
|
const file = fs5__default.default.readFileSync(ssPath);
|
|
@@ -1356,6 +1375,18 @@ var httpClient = class {
|
|
|
1356
1375
|
}
|
|
1357
1376
|
}, ctx.log);
|
|
1358
1377
|
}
|
|
1378
|
+
getS3PresignedURLForSnapshotUpload(ctx, snapshotName, snapshotUuid) {
|
|
1379
|
+
return this.request({
|
|
1380
|
+
url: `/snapshotuploadurl`,
|
|
1381
|
+
method: "POST",
|
|
1382
|
+
headers: { "Content-Type": "application/json" },
|
|
1383
|
+
data: {
|
|
1384
|
+
buildId: ctx.build.id,
|
|
1385
|
+
snapshotName,
|
|
1386
|
+
snapshotUuid
|
|
1387
|
+
}
|
|
1388
|
+
}, ctx.log);
|
|
1389
|
+
}
|
|
1359
1390
|
uploadLogs(ctx, uploadURL) {
|
|
1360
1391
|
const fileStream = fs5__default.default.createReadStream(constants_default.LOG_FILE_PATH);
|
|
1361
1392
|
const { size } = fs5__default.default.statSync(constants_default.LOG_FILE_PATH);
|
|
@@ -1373,6 +1404,20 @@ var httpClient = class {
|
|
|
1373
1404
|
// prevent axios from limiting the content size
|
|
1374
1405
|
}, ctx.log);
|
|
1375
1406
|
}
|
|
1407
|
+
uploadSnapshotToS3(ctx, uploadURL, snapshot) {
|
|
1408
|
+
return this.request({
|
|
1409
|
+
url: uploadURL,
|
|
1410
|
+
method: "PUT",
|
|
1411
|
+
headers: {
|
|
1412
|
+
"Content-Type": "application/json"
|
|
1413
|
+
},
|
|
1414
|
+
data: snapshot,
|
|
1415
|
+
maxBodyLength: Infinity,
|
|
1416
|
+
// prevent axios from limiting the body size
|
|
1417
|
+
maxContentLength: Infinity
|
|
1418
|
+
// prevent axios from limiting the content size
|
|
1419
|
+
}, ctx.log);
|
|
1420
|
+
}
|
|
1376
1421
|
processWebFigma(requestBody, log2) {
|
|
1377
1422
|
return this.request({
|
|
1378
1423
|
url: "figma-web/upload",
|
|
@@ -1448,7 +1493,7 @@ var ctx_default = (options) => {
|
|
|
1448
1493
|
}
|
|
1449
1494
|
if (config.web) {
|
|
1450
1495
|
webConfig = { browsers: config.web.browsers, viewports: [] };
|
|
1451
|
-
for (let viewport of (_b = config.web) == null ?
|
|
1496
|
+
for (let viewport of (_b = config.web) == null ? undefined : _b.viewports)
|
|
1452
1497
|
webConfig.viewports.push({ width: viewport[0], height: viewport[1] || 0 });
|
|
1453
1498
|
}
|
|
1454
1499
|
if (config.mobile) {
|
|
@@ -1566,7 +1611,7 @@ var getGitInfo_default = (ctx) => {
|
|
|
1566
1611
|
skip: (ctx2) => {
|
|
1567
1612
|
return !isGitRepo() && !ctx2.env.SMARTUI_GIT_INFO_FILEPATH ? "[SKIPPED] Fetching git repo details; not a git repo" : "";
|
|
1568
1613
|
},
|
|
1569
|
-
task: (ctx2, task) => __async(
|
|
1614
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1570
1615
|
if (ctx2.env.CURRENT_BRANCH && ctx2.env.CURRENT_BRANCH.trim() === "") {
|
|
1571
1616
|
throw new Error("Error: The environment variable CURRENT_BRANCH cannot be empty.");
|
|
1572
1617
|
}
|
|
@@ -1586,7 +1631,7 @@ var getGitInfo_default = (ctx) => {
|
|
|
1586
1631
|
var createBuild_default = (ctx) => {
|
|
1587
1632
|
return {
|
|
1588
1633
|
title: `Creating SmartUI build`,
|
|
1589
|
-
task: (ctx2, task) => __async(
|
|
1634
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1590
1635
|
updateLogContext({ task: "createBuild" });
|
|
1591
1636
|
try {
|
|
1592
1637
|
let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name);
|
|
@@ -1594,7 +1639,8 @@ var createBuild_default = (ctx) => {
|
|
|
1594
1639
|
id: resp.data.buildId,
|
|
1595
1640
|
name: resp.data.buildName,
|
|
1596
1641
|
url: resp.data.buildURL,
|
|
1597
|
-
baseline: resp.data.baseline
|
|
1642
|
+
baseline: resp.data.baseline,
|
|
1643
|
+
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
1598
1644
|
};
|
|
1599
1645
|
task.output = chalk6__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
1600
1646
|
task.title = "SmartUI build created";
|
|
@@ -1643,7 +1689,7 @@ function launchBrowsers(ctx) {
|
|
|
1643
1689
|
return __async(this, null, function* () {
|
|
1644
1690
|
var _a;
|
|
1645
1691
|
let browsers = {};
|
|
1646
|
-
const isHeadless = ((_a = process.env.HEADLESS) == null ?
|
|
1692
|
+
const isHeadless = ((_a = process.env.HEADLESS) == null ? undefined : _a.toLowerCase()) === "false" ? false : true;
|
|
1647
1693
|
let launchOptions = { headless: isHeadless };
|
|
1648
1694
|
if (ctx.config.web) {
|
|
1649
1695
|
for (const browser of ctx.config.web.browsers) {
|
|
@@ -1658,6 +1704,7 @@ function launchBrowsers(ctx) {
|
|
|
1658
1704
|
browsers[constants_default.FIREFOX] = yield test.firefox.launch(launchOptions);
|
|
1659
1705
|
break;
|
|
1660
1706
|
case constants_default.EDGE:
|
|
1707
|
+
launchOptions.args = ["--headless=new"];
|
|
1661
1708
|
browsers[constants_default.EDGE] = yield test.chromium.launch(__spreadValues({ channel: constants_default.EDGE_CHANNEL }, launchOptions));
|
|
1662
1709
|
break;
|
|
1663
1710
|
}
|
|
@@ -1678,7 +1725,7 @@ function closeBrowsers(browsers) {
|
|
|
1678
1725
|
return __async(this, null, function* () {
|
|
1679
1726
|
var _a;
|
|
1680
1727
|
for (const browserName of Object.keys(browsers))
|
|
1681
|
-
yield (_a = browsers[browserName]) == null ?
|
|
1728
|
+
yield (_a = browsers[browserName]) == null ? undefined : _a.close();
|
|
1682
1729
|
});
|
|
1683
1730
|
}
|
|
1684
1731
|
function getWebRenderViewports(ctx) {
|
|
@@ -1727,7 +1774,7 @@ function getMobileRenderViewports(ctx) {
|
|
|
1727
1774
|
let os = constants_default.SUPPORTED_MOBILE_DEVICES[device].os;
|
|
1728
1775
|
let { width, height } = constants_default.SUPPORTED_MOBILE_DEVICES[device].viewport;
|
|
1729
1776
|
let portrait = ctx.config.mobile.orientation === constants_default.MOBILE_ORIENTATION_PORTRAIT ? true : false;
|
|
1730
|
-
(_a = mobileRenderViewports[os]) == null ?
|
|
1777
|
+
(_a = mobileRenderViewports[os]) == null ? undefined : _a.push({
|
|
1731
1778
|
viewport: { width: portrait ? width : height, height: portrait ? height : width },
|
|
1732
1779
|
viewportString: `${device} (${ctx.config.mobile.orientation})`,
|
|
1733
1780
|
fullPage: ctx.config.mobile.fullPage,
|
|
@@ -1750,12 +1797,12 @@ function getMobileRenderViewportsForOptions(options) {
|
|
|
1750
1797
|
let orientation = options.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT;
|
|
1751
1798
|
let portrait = orientation === constants_default.MOBILE_ORIENTATION_PORTRAIT;
|
|
1752
1799
|
let fullPage;
|
|
1753
|
-
if (options.mobile.fullPage ===
|
|
1800
|
+
if (options.mobile.fullPage === undefined || options.mobile.fullPage) {
|
|
1754
1801
|
fullPage = true;
|
|
1755
1802
|
} else {
|
|
1756
1803
|
fullPage = false;
|
|
1757
1804
|
}
|
|
1758
|
-
(_a = mobileRenderViewports[os]) == null ?
|
|
1805
|
+
(_a = mobileRenderViewports[os]) == null ? undefined : _a.push({
|
|
1759
1806
|
viewport: { width: portrait ? width : height, height: portrait ? height : width },
|
|
1760
1807
|
viewportString: `${device} (${orientation})`,
|
|
1761
1808
|
fullPage,
|
|
@@ -1865,31 +1912,31 @@ ${chalk6__default.default.yellow("Build ID:")} ${chalk6__default.default.white(r
|
|
|
1865
1912
|
var exec_default = (ctx) => {
|
|
1866
1913
|
var _a;
|
|
1867
1914
|
return {
|
|
1868
|
-
title: `Executing '${(_a = ctx.args.execCommand) == null ?
|
|
1869
|
-
task: (ctx2, task) => __async(
|
|
1915
|
+
title: `Executing '${(_a = ctx.args.execCommand) == null ? undefined : _a.join(" ")}'`,
|
|
1916
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1870
1917
|
if (ctx2.options.fetchResults) {
|
|
1871
1918
|
startPolling(ctx2);
|
|
1872
1919
|
}
|
|
1873
1920
|
updateLogContext({ task: "exec" });
|
|
1874
1921
|
return new Promise((resolve, reject) => {
|
|
1875
1922
|
var _a2, _b, _c;
|
|
1876
|
-
const childProcess = spawn__default.default(ctx2.args.execCommand[0], (_a2 = ctx2.args.execCommand) == null ?
|
|
1923
|
+
const childProcess = spawn__default.default(ctx2.args.execCommand[0], (_a2 = ctx2.args.execCommand) == null ? undefined : _a2.slice(1));
|
|
1877
1924
|
let totalOutput = "";
|
|
1878
1925
|
const output = listr2.createWritable((chunk) => {
|
|
1879
1926
|
totalOutput += chunk;
|
|
1880
1927
|
task.output = chalk6__default.default.gray(totalOutput);
|
|
1881
1928
|
});
|
|
1882
|
-
(_b = childProcess.stdout) == null ?
|
|
1883
|
-
(_c = childProcess.stderr) == null ?
|
|
1929
|
+
(_b = childProcess.stdout) == null ? undefined : _b.pipe(output);
|
|
1930
|
+
(_c = childProcess.stderr) == null ? undefined : _c.pipe(output);
|
|
1884
1931
|
childProcess.on("error", (error) => {
|
|
1885
1932
|
var _a3;
|
|
1886
1933
|
task.output = chalk6__default.default.gray(`error: ${error.message}`);
|
|
1887
|
-
throw new Error(`Execution of '${(_a3 = ctx2.args.execCommand) == null ?
|
|
1934
|
+
throw new Error(`Execution of '${(_a3 = ctx2.args.execCommand) == null ? undefined : _a3.join(" ")}' failed`);
|
|
1888
1935
|
});
|
|
1889
|
-
childProcess.on("close", (code, signal) => __async(
|
|
1936
|
+
childProcess.on("close", (code, signal) => __async(undefined, null, function* () {
|
|
1890
1937
|
var _a3;
|
|
1891
1938
|
if (code !== null) {
|
|
1892
|
-
task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ?
|
|
1939
|
+
task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ? undefined : _a3.join(" ")}' completed; exited with code ${code}`;
|
|
1893
1940
|
} else if (signal !== null) {
|
|
1894
1941
|
throw new Error(`Child process killed with signal ${signal}`);
|
|
1895
1942
|
}
|
|
@@ -1904,7 +1951,7 @@ var exec_default = (ctx) => {
|
|
|
1904
1951
|
var processSnapshot_default = (ctx) => {
|
|
1905
1952
|
return {
|
|
1906
1953
|
title: `Processing snapshots`,
|
|
1907
|
-
task: (ctx2, task) => __async(
|
|
1954
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1908
1955
|
var _a, _b;
|
|
1909
1956
|
try {
|
|
1910
1957
|
if (ctx2.config.delayedUpload) {
|
|
@@ -1948,7 +1995,7 @@ ${snapshot.warnings.length ? chalk6__default.default.gray(`[warning] ${snapshot.
|
|
|
1948
1995
|
var finalizeBuild_default = (ctx) => {
|
|
1949
1996
|
return {
|
|
1950
1997
|
title: `Finalizing build`,
|
|
1951
|
-
task: (ctx2, task) => __async(
|
|
1998
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
1952
1999
|
var _a, _b;
|
|
1953
2000
|
updateLogContext({ task: "finalizeBuild" });
|
|
1954
2001
|
try {
|
|
@@ -1984,7 +2031,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1984
2031
|
var _a, _b;
|
|
1985
2032
|
updateLogContext({ task: "discovery" });
|
|
1986
2033
|
ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
|
|
1987
|
-
const isHeadless = ((_a = process.env.HEADLESS) == null ?
|
|
2034
|
+
const isHeadless = ((_a = process.env.HEADLESS) == null ? undefined : _a.toLowerCase()) === "false" ? false : true;
|
|
1988
2035
|
let launchOptions = {
|
|
1989
2036
|
headless: isHeadless,
|
|
1990
2037
|
args: constants_default.LAUNCH_ARGS
|
|
@@ -1993,7 +2040,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1993
2040
|
javaScriptEnabled: ctx.config.cliEnableJavaScript,
|
|
1994
2041
|
userAgent: constants_default.CHROME_USER_AGENT
|
|
1995
2042
|
};
|
|
1996
|
-
if (!((_b = ctx.browser) == null ?
|
|
2043
|
+
if (!((_b = ctx.browser) == null ? undefined : _b.isConnected())) {
|
|
1997
2044
|
if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY)
|
|
1998
2045
|
launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
|
|
1999
2046
|
if (ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY)
|
|
@@ -2126,7 +2173,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2126
2173
|
const isNotAllEmpty = (obj) => {
|
|
2127
2174
|
var _a2;
|
|
2128
2175
|
for (let key in obj)
|
|
2129
|
-
if ((_a2 = obj[key]) == null ?
|
|
2176
|
+
if ((_a2 = obj[key]) == null ? undefined : _a2.length)
|
|
2130
2177
|
return true;
|
|
2131
2178
|
return false;
|
|
2132
2179
|
};
|
|
@@ -2254,11 +2301,11 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2254
2301
|
return DEFAULT_HEIGHT;
|
|
2255
2302
|
}
|
|
2256
2303
|
const measurements = [
|
|
2257
|
-
(body == null ?
|
|
2258
|
-
(body == null ?
|
|
2259
|
-
(html == null ?
|
|
2260
|
-
(html == null ?
|
|
2261
|
-
(html == null ?
|
|
2304
|
+
(body == null ? undefined : body.scrollHeight) || 0,
|
|
2305
|
+
(body == null ? undefined : body.offsetHeight) || 0,
|
|
2306
|
+
(html == null ? undefined : html.clientHeight) || 0,
|
|
2307
|
+
(html == null ? undefined : html.scrollHeight) || 0,
|
|
2308
|
+
(html == null ? undefined : html.offsetHeight) || 0
|
|
2262
2309
|
];
|
|
2263
2310
|
const allMeasurementsInvalid = measurements.every((measurement) => !measurement);
|
|
2264
2311
|
if (allMeasurementsInvalid) {
|
|
@@ -2311,8 +2358,6 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2311
2358
|
};
|
|
2312
2359
|
});
|
|
2313
2360
|
}
|
|
2314
|
-
|
|
2315
|
-
// src/lib/snapshotQueue.ts
|
|
2316
2361
|
var Queue = class {
|
|
2317
2362
|
constructor(ctx) {
|
|
2318
2363
|
this.snapshots = [];
|
|
@@ -2375,7 +2420,7 @@ var Queue = class {
|
|
|
2375
2420
|
}
|
|
2376
2421
|
generateWebVariants(snapshot, webConfig) {
|
|
2377
2422
|
var _a, _b, _c;
|
|
2378
|
-
const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ?
|
|
2423
|
+
const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? undefined : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
|
|
2379
2424
|
const viewports = webConfig.viewports || [];
|
|
2380
2425
|
for (const browser of browsers) {
|
|
2381
2426
|
for (const viewport of viewports) {
|
|
@@ -2389,7 +2434,7 @@ var Queue = class {
|
|
|
2389
2434
|
generateMobileVariants(snapshot, mobileConfig) {
|
|
2390
2435
|
var _a, _b, _c;
|
|
2391
2436
|
const devices = mobileConfig.devices || [];
|
|
2392
|
-
const orientation = (_c = (_b = mobileConfig.orientation) != null ? _b : (_a = this.ctx.config.mobile) == null ?
|
|
2437
|
+
const orientation = (_c = (_b = mobileConfig.orientation) != null ? _b : (_a = this.ctx.config.mobile) == null ? undefined : _a.orientation) != null ? _c : constants_default.MOBILE_ORIENTATION_PORTRAIT;
|
|
2393
2438
|
for (const device of devices) {
|
|
2394
2439
|
const variant = `${snapshot.name}_${device}_${orientation}`;
|
|
2395
2440
|
this.variants.push(variant);
|
|
@@ -2471,7 +2516,7 @@ var Queue = class {
|
|
|
2471
2516
|
}
|
|
2472
2517
|
filterWebVariants(snapshot, webConfig) {
|
|
2473
2518
|
var _a, _b, _c;
|
|
2474
|
-
const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ?
|
|
2519
|
+
const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? undefined : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
|
|
2475
2520
|
const viewports = webConfig.viewports || [];
|
|
2476
2521
|
let allVariantsDropped = true;
|
|
2477
2522
|
if (!snapshot.options) {
|
|
@@ -2509,8 +2554,8 @@ var Queue = class {
|
|
|
2509
2554
|
snapshot.options = {};
|
|
2510
2555
|
}
|
|
2511
2556
|
const devices = mobileConfig.devices || [];
|
|
2512
|
-
const orientation = (_c = (_b = mobileConfig.orientation) != null ? _b : (_a = this.ctx.config.mobile) == null ?
|
|
2513
|
-
const fullPage = (_f = (_e = mobileConfig.fullPage) != null ? _e : (_d = this.ctx.config.mobile) == null ?
|
|
2557
|
+
const orientation = (_c = (_b = mobileConfig.orientation) != null ? _b : (_a = this.ctx.config.mobile) == null ? undefined : _a.orientation) != null ? _c : constants_default.MOBILE_ORIENTATION_PORTRAIT;
|
|
2558
|
+
const fullPage = (_f = (_e = mobileConfig.fullPage) != null ? _e : (_d = this.ctx.config.mobile) == null ? undefined : _d.fullPage) != null ? _f : true;
|
|
2514
2559
|
let allVariantsDropped = true;
|
|
2515
2560
|
snapshot.options.mobile = { devices: [], orientation: constants_default.MOBILE_ORIENTATION_PORTRAIT, fullPage };
|
|
2516
2561
|
for (const device of devices) {
|
|
@@ -2550,7 +2595,15 @@ var Queue = class {
|
|
|
2550
2595
|
}
|
|
2551
2596
|
if (!drop) {
|
|
2552
2597
|
let { processedSnapshot, warnings } = yield processSnapshot(snapshot, this.ctx);
|
|
2553
|
-
|
|
2598
|
+
if (this.ctx.build && this.ctx.build.useKafkaFlow) {
|
|
2599
|
+
const snapshotUuid = uuid.v4();
|
|
2600
|
+
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
2601
|
+
const uploadUrl = presignedResponse.data.url;
|
|
2602
|
+
yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
2603
|
+
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid);
|
|
2604
|
+
} else {
|
|
2605
|
+
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot);
|
|
2606
|
+
}
|
|
2554
2607
|
this.ctx.totalSnapshots++;
|
|
2555
2608
|
this.processedSnapshots.push({ name: snapshot.name, warnings });
|
|
2556
2609
|
}
|
|
@@ -2709,9 +2762,9 @@ function verifyFigmaWebConfig(ctx) {
|
|
|
2709
2762
|
if (ctx.env.LT_ACCESS_KEY == "") {
|
|
2710
2763
|
throw new Error("Missing LT_ACCESS_KEY in Environment Variables");
|
|
2711
2764
|
}
|
|
2712
|
-
let figma = ctx.config && ((_a = ctx.config) == null ?
|
|
2765
|
+
let figma = ctx.config && ((_a = ctx.config) == null ? undefined : _a.figma) || {};
|
|
2713
2766
|
const screenshots = [];
|
|
2714
|
-
for (let c of figma == null ?
|
|
2767
|
+
for (let c of figma == null ? undefined : figma.configs) {
|
|
2715
2768
|
if (c.screenshot_names && c.screenshot_names.length > 0 && c.figma_ids && c.figma_ids.length != c.screenshot_names.length) {
|
|
2716
2769
|
throw new Error("Mismatch in Figma Ids and Screenshot Names in figma config");
|
|
2717
2770
|
}
|
|
@@ -2787,8 +2840,8 @@ function captureScreenshotsForConfig(_0, _1, _2, _3, _4) {
|
|
|
2787
2840
|
} catch (error) {
|
|
2788
2841
|
throw new Error(`captureScreenshotsForConfig failed for browser ${browserName}; error: ${error}`);
|
|
2789
2842
|
} finally {
|
|
2790
|
-
yield page == null ?
|
|
2791
|
-
yield context == null ?
|
|
2843
|
+
yield page == null ? undefined : page.close();
|
|
2844
|
+
yield context == null ? undefined : context.close();
|
|
2792
2845
|
}
|
|
2793
2846
|
});
|
|
2794
2847
|
}
|
|
@@ -3055,7 +3108,7 @@ function processChunk(ctx, urlConfig) {
|
|
|
3055
3108
|
var captureScreenshots_default = (ctx) => {
|
|
3056
3109
|
return {
|
|
3057
3110
|
title: "Capturing screenshots",
|
|
3058
|
-
task: (ctx2, task) => __async(
|
|
3111
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
3059
3112
|
try {
|
|
3060
3113
|
ctx2.task = task;
|
|
3061
3114
|
if (ctx2.options.fetchResults) {
|
|
@@ -3142,7 +3195,7 @@ var capture_default = command2;
|
|
|
3142
3195
|
var uploadScreenshots_default = (ctx) => {
|
|
3143
3196
|
return {
|
|
3144
3197
|
title: "Uploading screenshots",
|
|
3145
|
-
task: (ctx2, task) => __async(
|
|
3198
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
3146
3199
|
try {
|
|
3147
3200
|
ctx2.task = task;
|
|
3148
3201
|
if (ctx2.options.fetchResults) {
|
|
@@ -3214,7 +3267,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
3214
3267
|
var upload_default = command3;
|
|
3215
3268
|
|
|
3216
3269
|
// src/lib/uploadFigmaDesigns.ts
|
|
3217
|
-
var uploadFigmaDesigns_default = (ctx) => __async(
|
|
3270
|
+
var uploadFigmaDesigns_default = (ctx) => __async(undefined, null, function* () {
|
|
3218
3271
|
const depth = ctx.figmaDesignConfig.depth;
|
|
3219
3272
|
const figmaConfigs = ctx.figmaDesignConfig.figma_config;
|
|
3220
3273
|
let results = "";
|
|
@@ -3241,7 +3294,7 @@ var uploadFigmaDesigns_default = (ctx) => __async(void 0, null, function* () {
|
|
|
3241
3294
|
var uploadFigmaDesigns_default2 = (ctx) => {
|
|
3242
3295
|
return {
|
|
3243
3296
|
title: "Uploading Figma Designs",
|
|
3244
|
-
task: (ctx2, task) => __async(
|
|
3297
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
3245
3298
|
try {
|
|
3246
3299
|
ctx2.task = task;
|
|
3247
3300
|
updateLogContext({ task: "upload-figma" });
|
|
@@ -3263,13 +3316,13 @@ var uploadFigmaDesigns_default2 = (ctx) => {
|
|
|
3263
3316
|
};
|
|
3264
3317
|
|
|
3265
3318
|
// src/lib/uploadWebFigma.ts
|
|
3266
|
-
var uploadWebFigma_default = (ctx) => __async(
|
|
3319
|
+
var uploadWebFigma_default = (ctx) => __async(undefined, null, function* () {
|
|
3267
3320
|
var _a, _b;
|
|
3268
|
-
const figmaConfig = ctx.config && ((_a = ctx.config) == null ?
|
|
3269
|
-
const webConfig = ctx.config && ((_b = ctx.config) == null ?
|
|
3321
|
+
const figmaConfig = ctx.config && ((_a = ctx.config) == null ? undefined : _a.figma) || {};
|
|
3322
|
+
const webConfig = ctx.config && ((_b = ctx.config) == null ? undefined : _b.web) || {};
|
|
3270
3323
|
let results = "";
|
|
3271
3324
|
const buildName = ctx.options.buildName;
|
|
3272
|
-
if (figmaConfig
|
|
3325
|
+
if (figmaConfig.configs && figmaConfig.configs.length > 0) {
|
|
3273
3326
|
const authToken = `Basic ${Buffer.from(`${ctx.env.LT_USERNAME}:${ctx.env.LT_ACCESS_KEY}`).toString("base64")}`;
|
|
3274
3327
|
const requestBody = {
|
|
3275
3328
|
figma_token: ctx.env.FIGMA_TOKEN,
|
|
@@ -3296,7 +3349,7 @@ var uploadWebFigma_default = (ctx) => __async(void 0, null, function* () {
|
|
|
3296
3349
|
});
|
|
3297
3350
|
|
|
3298
3351
|
// src/lib/fetchFigma.ts
|
|
3299
|
-
var fetchFigma_default = (ctx) => __async(
|
|
3352
|
+
var fetchFigma_default = (ctx) => __async(undefined, null, function* () {
|
|
3300
3353
|
const buildId = ctx.build.id;
|
|
3301
3354
|
ctx.log.debug(`Fetching figma results for buildId ${buildId}`);
|
|
3302
3355
|
const startTime = Date.now();
|
|
@@ -3341,7 +3394,7 @@ function callFetchWebFigmaRecursive(startTime, buildId, ctx) {
|
|
|
3341
3394
|
var uploadWebFigma_default2 = (ctx) => {
|
|
3342
3395
|
return {
|
|
3343
3396
|
title: "Processing Web Figma",
|
|
3344
|
-
task: (ctx2, task) => __async(
|
|
3397
|
+
task: (ctx2, task) => __async(undefined, null, function* () {
|
|
3345
3398
|
try {
|
|
3346
3399
|
ctx2.task = task;
|
|
3347
3400
|
updateLogContext({ task: "upload-figma-web" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambdatest/smartui-cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.20",
|
|
4
4
|
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*"
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"listr2": "^7.0.1",
|
|
36
36
|
"sharp": "^0.33.4",
|
|
37
37
|
"tsup": "^7.2.0",
|
|
38
|
+
"uuid": "^11.0.3",
|
|
38
39
|
"which": "^4.0.0",
|
|
39
40
|
"winston": "^3.10.0"
|
|
40
41
|
},
|