@lambdatest/smartui-cli 4.0.7 → 4.0.8
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 +248 -135
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var commander = require('commander');
|
|
5
5
|
var which = require('which');
|
|
6
6
|
var listr2 = require('listr2');
|
|
7
|
-
var
|
|
7
|
+
var chalk6 = require('chalk');
|
|
8
8
|
var path2 = require('path');
|
|
9
9
|
var fastify = require('fastify');
|
|
10
10
|
var fs5 = require('fs');
|
|
@@ -21,7 +21,7 @@ var sharp = require('sharp');
|
|
|
21
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
22
|
|
|
23
23
|
var which__default = /*#__PURE__*/_interopDefault(which);
|
|
24
|
-
var
|
|
24
|
+
var chalk6__default = /*#__PURE__*/_interopDefault(chalk6);
|
|
25
25
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
26
26
|
var fastify__default = /*#__PURE__*/_interopDefault(fastify);
|
|
27
27
|
var fs5__default = /*#__PURE__*/_interopDefault(fs5);
|
|
@@ -187,6 +187,9 @@ var constants_default = {
|
|
|
187
187
|
MOBILE_OS_IOS: "ios",
|
|
188
188
|
MOBILE_ORIENTATION_PORTRAIT: "portrait",
|
|
189
189
|
MOBILE_ORIENTATION_LANDSCAPE: "landscape",
|
|
190
|
+
// build status
|
|
191
|
+
BUILD_COMPLETE: "completed",
|
|
192
|
+
BUILD_ERROR: "error",
|
|
190
193
|
// CI
|
|
191
194
|
GITHUB_API_HOST: "https://api.github.com",
|
|
192
195
|
// log file path
|
|
@@ -888,7 +891,7 @@ var logger = winston.createLogger({
|
|
|
888
891
|
let message = typeof info.message === "object" ? JSON.stringify(info.message).trim() : info.message.trim();
|
|
889
892
|
switch (info.level) {
|
|
890
893
|
case "warn":
|
|
891
|
-
message =
|
|
894
|
+
message = chalk6__default.default.yellow(message);
|
|
892
895
|
break;
|
|
893
896
|
}
|
|
894
897
|
return info.level === "info" ? message : `[${contextString}:${info.level}] ` + message;
|
|
@@ -915,11 +918,11 @@ var startServer_default = (ctx) => {
|
|
|
915
918
|
updateLogContext({ task: "startServer" });
|
|
916
919
|
try {
|
|
917
920
|
ctx2.server = yield server_default(ctx2);
|
|
918
|
-
task.output =
|
|
921
|
+
task.output = chalk6__default.default.gray(`listening on port ${(_a = ctx2.server.addresses()[0]) == null ? void 0 : _a.port}`);
|
|
919
922
|
task.title = "SmartUI started";
|
|
920
923
|
} catch (error) {
|
|
921
924
|
ctx2.log.debug(error);
|
|
922
|
-
task.output =
|
|
925
|
+
task.output = chalk6__default.default.gray(error.message);
|
|
923
926
|
throw new Error("SmartUI server setup failed");
|
|
924
927
|
}
|
|
925
928
|
}),
|
|
@@ -933,11 +936,11 @@ var auth_default = (ctx) => {
|
|
|
933
936
|
updateLogContext({ task: "auth" });
|
|
934
937
|
try {
|
|
935
938
|
yield ctx2.client.auth(ctx2.log);
|
|
936
|
-
task.output =
|
|
939
|
+
task.output = chalk6__default.default.gray(`using project token '******#${ctx2.env.PROJECT_TOKEN.split("#").pop()}'`);
|
|
937
940
|
task.title = "Authenticated with SmartUI";
|
|
938
941
|
} catch (error) {
|
|
939
942
|
ctx2.log.debug(error);
|
|
940
|
-
task.output =
|
|
943
|
+
task.output = chalk6__default.default.gray(error.message);
|
|
941
944
|
throw new Error("Authentication failed");
|
|
942
945
|
}
|
|
943
946
|
}),
|
|
@@ -946,7 +949,7 @@ var auth_default = (ctx) => {
|
|
|
946
949
|
};
|
|
947
950
|
|
|
948
951
|
// package.json
|
|
949
|
-
var version = "4.0.
|
|
952
|
+
var version = "4.0.8";
|
|
950
953
|
var package_default = {
|
|
951
954
|
name: "@lambdatest/smartui-cli",
|
|
952
955
|
version,
|
|
@@ -1047,6 +1050,13 @@ var httpClient = class {
|
|
|
1047
1050
|
}
|
|
1048
1051
|
}, log2);
|
|
1049
1052
|
}
|
|
1053
|
+
getScreenshotData(buildId, baseline, log2) {
|
|
1054
|
+
return this.request({
|
|
1055
|
+
url: "/screenshot",
|
|
1056
|
+
method: "GET",
|
|
1057
|
+
params: { buildId, baseline }
|
|
1058
|
+
}, log2);
|
|
1059
|
+
}
|
|
1050
1060
|
finalizeBuild(buildId, totalSnapshots, log2) {
|
|
1051
1061
|
let params = { buildId };
|
|
1052
1062
|
if (totalSnapshots > -1)
|
|
@@ -1169,6 +1179,8 @@ var ctx_default = (options) => {
|
|
|
1169
1179
|
let extensionFiles;
|
|
1170
1180
|
let ignoreStripExtension;
|
|
1171
1181
|
let ignoreFilePattern;
|
|
1182
|
+
let fetchResultObj;
|
|
1183
|
+
let fetchResultsFileObj;
|
|
1172
1184
|
try {
|
|
1173
1185
|
if (options.config) {
|
|
1174
1186
|
config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
|
|
@@ -1188,6 +1200,17 @@ var ctx_default = (options) => {
|
|
|
1188
1200
|
extensionFiles = options.files || ["png", "jpeg", "jpg"];
|
|
1189
1201
|
ignoreStripExtension = options.removeExtensions || false;
|
|
1190
1202
|
ignoreFilePattern = options.ignoreDir || [];
|
|
1203
|
+
if (options.fetchResults) {
|
|
1204
|
+
if (options.fetchResults !== true && !options.fetchResults.endsWith(".json")) {
|
|
1205
|
+
console.error("Error: The file extension for --fetch-results must be .json");
|
|
1206
|
+
process.exit(1);
|
|
1207
|
+
}
|
|
1208
|
+
fetchResultObj = true;
|
|
1209
|
+
fetchResultsFileObj = options.fetchResults === true ? "results.json" : options.fetchResults;
|
|
1210
|
+
} else {
|
|
1211
|
+
fetchResultObj = false;
|
|
1212
|
+
fetchResultsFileObj = "";
|
|
1213
|
+
}
|
|
1191
1214
|
} catch (error) {
|
|
1192
1215
|
console.log(`[smartui] Error: ${error.message}`);
|
|
1193
1216
|
process.exit();
|
|
@@ -1248,7 +1271,9 @@ var ctx_default = (options) => {
|
|
|
1248
1271
|
ignoreResolutions: resolutionOff,
|
|
1249
1272
|
fileExtension: extensionFiles,
|
|
1250
1273
|
stripExtension: ignoreStripExtension,
|
|
1251
|
-
ignorePattern: ignoreFilePattern
|
|
1274
|
+
ignorePattern: ignoreFilePattern,
|
|
1275
|
+
fetchResults: fetchResultObj,
|
|
1276
|
+
fetchResultsFileName: fetchResultsFileObj
|
|
1252
1277
|
},
|
|
1253
1278
|
cliVersion: version,
|
|
1254
1279
|
totalSnapshots: -1
|
|
@@ -1315,11 +1340,11 @@ var getGitInfo_default = (ctx) => {
|
|
|
1315
1340
|
}
|
|
1316
1341
|
try {
|
|
1317
1342
|
ctx2.git = git_default(ctx2);
|
|
1318
|
-
task.output =
|
|
1343
|
+
task.output = chalk6__default.default.gray(`branch: ${ctx2.git.branch}, commit: ${ctx2.git.commitId}, author: ${ctx2.git.commitAuthor}`);
|
|
1319
1344
|
task.title = "Fetched git information";
|
|
1320
1345
|
} catch (error) {
|
|
1321
1346
|
ctx2.log.debug(error);
|
|
1322
|
-
task.output =
|
|
1347
|
+
task.output = chalk6__default.default.gray(`${error.message}`);
|
|
1323
1348
|
throw new Error("Error fetching git repo details");
|
|
1324
1349
|
}
|
|
1325
1350
|
}),
|
|
@@ -1339,127 +1364,18 @@ var createBuild_default = (ctx) => {
|
|
|
1339
1364
|
url: resp.data.buildURL,
|
|
1340
1365
|
baseline: resp.data.baseline
|
|
1341
1366
|
};
|
|
1342
|
-
task.output =
|
|
1367
|
+
task.output = chalk6__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
1343
1368
|
task.title = "SmartUI build created";
|
|
1344
1369
|
} catch (error) {
|
|
1345
1370
|
ctx2.log.debug(error);
|
|
1346
|
-
task.output =
|
|
1371
|
+
task.output = chalk6__default.default.gray(error.message);
|
|
1347
1372
|
throw new Error("SmartUI build creation failed");
|
|
1348
1373
|
}
|
|
1349
1374
|
}),
|
|
1350
1375
|
rendererOptions: { persistentOutput: true }
|
|
1351
1376
|
};
|
|
1352
1377
|
};
|
|
1353
|
-
var
|
|
1354
|
-
var _a;
|
|
1355
|
-
return {
|
|
1356
|
-
title: `Executing '${(_a = ctx.args.execCommand) == null ? void 0 : _a.join(" ")}'`,
|
|
1357
|
-
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1358
|
-
updateLogContext({ task: "exec" });
|
|
1359
|
-
return new Promise((resolve, reject) => {
|
|
1360
|
-
var _a2, _b, _c;
|
|
1361
|
-
const childProcess = spawn__default.default(ctx2.args.execCommand[0], (_a2 = ctx2.args.execCommand) == null ? void 0 : _a2.slice(1));
|
|
1362
|
-
let totalOutput = "";
|
|
1363
|
-
const output = listr2.createWritable((chunk) => {
|
|
1364
|
-
totalOutput += chunk;
|
|
1365
|
-
task.output = chalk7__default.default.gray(totalOutput);
|
|
1366
|
-
});
|
|
1367
|
-
(_b = childProcess.stdout) == null ? void 0 : _b.pipe(output);
|
|
1368
|
-
(_c = childProcess.stderr) == null ? void 0 : _c.pipe(output);
|
|
1369
|
-
childProcess.on("error", (error) => {
|
|
1370
|
-
var _a3;
|
|
1371
|
-
task.output = chalk7__default.default.gray(`error: ${error.message}`);
|
|
1372
|
-
throw new Error(`Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' failed`);
|
|
1373
|
-
});
|
|
1374
|
-
childProcess.on("close", (code, signal) => __async(void 0, null, function* () {
|
|
1375
|
-
var _a3;
|
|
1376
|
-
if (code !== null) {
|
|
1377
|
-
task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' completed; exited with code ${code}`;
|
|
1378
|
-
} else if (signal !== null) {
|
|
1379
|
-
throw new Error(`Child process killed with signal ${signal}`);
|
|
1380
|
-
}
|
|
1381
|
-
resolve();
|
|
1382
|
-
}));
|
|
1383
|
-
});
|
|
1384
|
-
}),
|
|
1385
|
-
rendererOptions: { persistentOutput: true },
|
|
1386
|
-
exitOnError: false
|
|
1387
|
-
};
|
|
1388
|
-
};
|
|
1389
|
-
var processSnapshot_default = (ctx) => {
|
|
1390
|
-
return {
|
|
1391
|
-
title: `Processing snapshots`,
|
|
1392
|
-
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1393
|
-
var _a, _b;
|
|
1394
|
-
try {
|
|
1395
|
-
if (ctx2.config.delayedUpload) {
|
|
1396
|
-
ctx2.log.debug("started after processing because of delayedUpload");
|
|
1397
|
-
(_a = ctx2.snapshotQueue) == null ? void 0 : _a.startProcessingfunc();
|
|
1398
|
-
}
|
|
1399
|
-
yield new Promise((resolve) => {
|
|
1400
|
-
let output2 = "";
|
|
1401
|
-
const intervalId = setInterval(() => {
|
|
1402
|
-
var _a2, _b2, _c;
|
|
1403
|
-
if (((_a2 = ctx2.snapshotQueue) == null ? void 0 : _a2.isEmpty()) && !((_b2 = ctx2.snapshotQueue) == null ? void 0 : _b2.isProcessing())) {
|
|
1404
|
-
clearInterval(intervalId);
|
|
1405
|
-
resolve();
|
|
1406
|
-
} else {
|
|
1407
|
-
task.title = `Processing snapshot ${(_c = ctx2.snapshotQueue) == null ? void 0 : _c.getProcessingSnapshot()}`;
|
|
1408
|
-
}
|
|
1409
|
-
}, 500);
|
|
1410
|
-
});
|
|
1411
|
-
let output = "";
|
|
1412
|
-
for (let snapshot of (_b = ctx2.snapshotQueue) == null ? void 0 : _b.getProcessedSnapshots()) {
|
|
1413
|
-
if (snapshot.error)
|
|
1414
|
-
output += `${chalk7__default.default.red("\u2717")} ${chalk7__default.default.gray(`${snapshot.name}
|
|
1415
|
-
[error] ${snapshot.error}`)}
|
|
1416
|
-
`;
|
|
1417
|
-
else
|
|
1418
|
-
output += `${chalk7__default.default.green("\u2713")} ${chalk7__default.default.gray(snapshot.name)}
|
|
1419
|
-
${snapshot.warnings.length ? chalk7__default.default.gray(`[warning] ${snapshot.warnings.join("\n[warning] ")}
|
|
1420
|
-
`) : ""}`;
|
|
1421
|
-
}
|
|
1422
|
-
task.output = output;
|
|
1423
|
-
task.title = "Processed snapshots";
|
|
1424
|
-
} catch (error) {
|
|
1425
|
-
ctx2.log.debug(error);
|
|
1426
|
-
task.output = chalk7__default.default.gray(error.message);
|
|
1427
|
-
throw new Error("Processing of snapshots failed");
|
|
1428
|
-
}
|
|
1429
|
-
}),
|
|
1430
|
-
rendererOptions: { persistentOutput: true }
|
|
1431
|
-
};
|
|
1432
|
-
};
|
|
1433
|
-
var finalizeBuild_default = (ctx) => {
|
|
1434
|
-
return {
|
|
1435
|
-
title: `Finalizing build`,
|
|
1436
|
-
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1437
|
-
var _a, _b;
|
|
1438
|
-
updateLogContext({ task: "finalizeBuild" });
|
|
1439
|
-
try {
|
|
1440
|
-
yield ctx2.client.finalizeBuild(ctx2.build.id, ctx2.totalSnapshots, ctx2.log);
|
|
1441
|
-
task.output = chalk7__default.default.gray(`build url: ${ctx2.build.url}`);
|
|
1442
|
-
task.title = "Finalized build";
|
|
1443
|
-
} catch (error) {
|
|
1444
|
-
ctx2.log.debug(error);
|
|
1445
|
-
task.output = chalk7__default.default.gray(error.message);
|
|
1446
|
-
throw new Error("Finalize build failed");
|
|
1447
|
-
}
|
|
1448
|
-
try {
|
|
1449
|
-
yield (_a = ctx2.browser) == null ? void 0 : _a.close();
|
|
1450
|
-
ctx2.log.debug(`Closed browser`);
|
|
1451
|
-
yield (_b = ctx2.server) == null ? void 0 : _b.close();
|
|
1452
|
-
ctx2.log.debug(`Closed server`);
|
|
1453
|
-
let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
|
|
1454
|
-
yield ctx2.client.uploadLogs(ctx2, resp.data.url);
|
|
1455
|
-
fs5.unlinkSync(constants_default.LOG_FILE_PATH);
|
|
1456
|
-
} catch (error) {
|
|
1457
|
-
ctx2.log.debug(error);
|
|
1458
|
-
}
|
|
1459
|
-
}),
|
|
1460
|
-
rendererOptions: { persistentOutput: true }
|
|
1461
|
-
};
|
|
1462
|
-
};
|
|
1378
|
+
var isPollingActive = false;
|
|
1463
1379
|
function delDir(dir) {
|
|
1464
1380
|
if (fs5__default.default.existsSync(dir)) {
|
|
1465
1381
|
fs5__default.default.rmSync(dir, { recursive: true });
|
|
@@ -1634,6 +1550,197 @@ function getRenderViewportsForOptions(options) {
|
|
|
1634
1550
|
...mobileRenderViewports[constants_default.MOBILE_OS_ANDROID]
|
|
1635
1551
|
];
|
|
1636
1552
|
}
|
|
1553
|
+
process.on("SIGINT", () => {
|
|
1554
|
+
if (isPollingActive) {
|
|
1555
|
+
console.log("Fetching results interrupted. Exiting...");
|
|
1556
|
+
isPollingActive = false;
|
|
1557
|
+
} else {
|
|
1558
|
+
console.log("\nExiting gracefully...");
|
|
1559
|
+
}
|
|
1560
|
+
process.exit(0);
|
|
1561
|
+
});
|
|
1562
|
+
function startPolling(ctx, task) {
|
|
1563
|
+
return __async(this, null, function* () {
|
|
1564
|
+
ctx.log.info("Fetching results in progress....");
|
|
1565
|
+
isPollingActive = true;
|
|
1566
|
+
const intervalId = setInterval(() => __async(this, null, function* () {
|
|
1567
|
+
if (!isPollingActive) {
|
|
1568
|
+
clearInterval(intervalId);
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
try {
|
|
1572
|
+
const resp = yield ctx.client.getScreenshotData(ctx.build.id, ctx.build.baseline, ctx.log);
|
|
1573
|
+
if (!resp.build) {
|
|
1574
|
+
ctx.log.info("Error: Build data is null.");
|
|
1575
|
+
clearInterval(intervalId);
|
|
1576
|
+
isPollingActive = false;
|
|
1577
|
+
}
|
|
1578
|
+
fs5__default.default.writeFileSync(ctx.options.fetchResultsFileName, JSON.stringify(resp, null, 2));
|
|
1579
|
+
ctx.log.debug(`Updated results in ${ctx.options.fetchResultsFileName}`);
|
|
1580
|
+
if (resp.build.build_status_ind === constants_default.BUILD_COMPLETE || resp.build.build_status_ind === constants_default.BUILD_ERROR) {
|
|
1581
|
+
clearInterval(intervalId);
|
|
1582
|
+
ctx.log.info(`Fetching results completed. Final results written to ${ctx.options.fetchResultsFileName}`);
|
|
1583
|
+
isPollingActive = false;
|
|
1584
|
+
let totalScreenshotsWithMismatches = 0;
|
|
1585
|
+
let totalVariantsWithMismatches = 0;
|
|
1586
|
+
const totalScreenshots = Object.keys(resp.screenshots || {}).length;
|
|
1587
|
+
let totalVariants = 0;
|
|
1588
|
+
for (const [screenshot, variants] of Object.entries(resp.screenshots || {})) {
|
|
1589
|
+
let screenshotHasMismatch = false;
|
|
1590
|
+
let variantMismatchCount = 0;
|
|
1591
|
+
totalVariants += variants.length;
|
|
1592
|
+
for (const variant of variants) {
|
|
1593
|
+
if (variant.mismatch_percentage > 0) {
|
|
1594
|
+
screenshotHasMismatch = true;
|
|
1595
|
+
variantMismatchCount++;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
if (screenshotHasMismatch) {
|
|
1599
|
+
totalScreenshotsWithMismatches++;
|
|
1600
|
+
totalVariantsWithMismatches += variantMismatchCount;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
ctx.log.info(
|
|
1604
|
+
chalk6__default.default.green.bold(
|
|
1605
|
+
`
|
|
1606
|
+
Summary of Mismatches:
|
|
1607
|
+
${chalk6__default.default.yellow("Total Variants with Mismatches:")} ${chalk6__default.default.white(totalVariantsWithMismatches)} out of ${chalk6__default.default.white(totalVariants)}
|
|
1608
|
+
${chalk6__default.default.yellow("Total Screenshots with Mismatches:")} ${chalk6__default.default.white(totalScreenshotsWithMismatches)} out of ${chalk6__default.default.white(totalScreenshots)}
|
|
1609
|
+
${chalk6__default.default.yellow("Branch Name:")} ${chalk6__default.default.white(resp.build.branch)}
|
|
1610
|
+
${chalk6__default.default.yellow("Project Name:")} ${chalk6__default.default.white(resp.project.name)}
|
|
1611
|
+
${chalk6__default.default.yellow("Build ID:")} ${chalk6__default.default.white(resp.build.build_id)}
|
|
1612
|
+
`
|
|
1613
|
+
)
|
|
1614
|
+
);
|
|
1615
|
+
}
|
|
1616
|
+
} catch (error) {
|
|
1617
|
+
if (error.message.includes("ENOTFOUND")) {
|
|
1618
|
+
ctx.log.error("Error: Network error occurred while fetching build results. Please check your connection and try again.");
|
|
1619
|
+
clearInterval(intervalId);
|
|
1620
|
+
} else {
|
|
1621
|
+
ctx.log.error(`Error fetching screenshot data: ${error.message}`);
|
|
1622
|
+
}
|
|
1623
|
+
clearInterval(intervalId);
|
|
1624
|
+
isPollingActive = false;
|
|
1625
|
+
}
|
|
1626
|
+
}), 5e3);
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// src/tasks/exec.ts
|
|
1631
|
+
var exec_default = (ctx) => {
|
|
1632
|
+
var _a;
|
|
1633
|
+
return {
|
|
1634
|
+
title: `Executing '${(_a = ctx.args.execCommand) == null ? void 0 : _a.join(" ")}'`,
|
|
1635
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1636
|
+
if (ctx2.options.fetchResults) {
|
|
1637
|
+
startPolling(ctx2);
|
|
1638
|
+
}
|
|
1639
|
+
updateLogContext({ task: "exec" });
|
|
1640
|
+
return new Promise((resolve, reject) => {
|
|
1641
|
+
var _a2, _b, _c;
|
|
1642
|
+
const childProcess = spawn__default.default(ctx2.args.execCommand[0], (_a2 = ctx2.args.execCommand) == null ? void 0 : _a2.slice(1));
|
|
1643
|
+
let totalOutput = "";
|
|
1644
|
+
const output = listr2.createWritable((chunk) => {
|
|
1645
|
+
totalOutput += chunk;
|
|
1646
|
+
task.output = chalk6__default.default.gray(totalOutput);
|
|
1647
|
+
});
|
|
1648
|
+
(_b = childProcess.stdout) == null ? void 0 : _b.pipe(output);
|
|
1649
|
+
(_c = childProcess.stderr) == null ? void 0 : _c.pipe(output);
|
|
1650
|
+
childProcess.on("error", (error) => {
|
|
1651
|
+
var _a3;
|
|
1652
|
+
task.output = chalk6__default.default.gray(`error: ${error.message}`);
|
|
1653
|
+
throw new Error(`Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' failed`);
|
|
1654
|
+
});
|
|
1655
|
+
childProcess.on("close", (code, signal) => __async(void 0, null, function* () {
|
|
1656
|
+
var _a3;
|
|
1657
|
+
if (code !== null) {
|
|
1658
|
+
task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' completed; exited with code ${code}`;
|
|
1659
|
+
} else if (signal !== null) {
|
|
1660
|
+
throw new Error(`Child process killed with signal ${signal}`);
|
|
1661
|
+
}
|
|
1662
|
+
resolve();
|
|
1663
|
+
}));
|
|
1664
|
+
});
|
|
1665
|
+
}),
|
|
1666
|
+
rendererOptions: { persistentOutput: true },
|
|
1667
|
+
exitOnError: false
|
|
1668
|
+
};
|
|
1669
|
+
};
|
|
1670
|
+
var processSnapshot_default = (ctx) => {
|
|
1671
|
+
return {
|
|
1672
|
+
title: `Processing snapshots`,
|
|
1673
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1674
|
+
var _a, _b;
|
|
1675
|
+
try {
|
|
1676
|
+
if (ctx2.config.delayedUpload) {
|
|
1677
|
+
ctx2.log.debug("started after processing because of delayedUpload");
|
|
1678
|
+
(_a = ctx2.snapshotQueue) == null ? void 0 : _a.startProcessingfunc();
|
|
1679
|
+
}
|
|
1680
|
+
yield new Promise((resolve) => {
|
|
1681
|
+
let output2 = "";
|
|
1682
|
+
const intervalId = setInterval(() => {
|
|
1683
|
+
var _a2, _b2, _c;
|
|
1684
|
+
if (((_a2 = ctx2.snapshotQueue) == null ? void 0 : _a2.isEmpty()) && !((_b2 = ctx2.snapshotQueue) == null ? void 0 : _b2.isProcessing())) {
|
|
1685
|
+
clearInterval(intervalId);
|
|
1686
|
+
resolve();
|
|
1687
|
+
} else {
|
|
1688
|
+
task.title = `Processing snapshot ${(_c = ctx2.snapshotQueue) == null ? void 0 : _c.getProcessingSnapshot()}`;
|
|
1689
|
+
}
|
|
1690
|
+
}, 500);
|
|
1691
|
+
});
|
|
1692
|
+
let output = "";
|
|
1693
|
+
for (let snapshot of (_b = ctx2.snapshotQueue) == null ? void 0 : _b.getProcessedSnapshots()) {
|
|
1694
|
+
if (snapshot.error)
|
|
1695
|
+
output += `${chalk6__default.default.red("\u2717")} ${chalk6__default.default.gray(`${snapshot.name}
|
|
1696
|
+
[error] ${snapshot.error}`)}
|
|
1697
|
+
`;
|
|
1698
|
+
else
|
|
1699
|
+
output += `${chalk6__default.default.green("\u2713")} ${chalk6__default.default.gray(snapshot.name)}
|
|
1700
|
+
${snapshot.warnings.length ? chalk6__default.default.gray(`[warning] ${snapshot.warnings.join("\n[warning] ")}
|
|
1701
|
+
`) : ""}`;
|
|
1702
|
+
}
|
|
1703
|
+
task.output = output;
|
|
1704
|
+
task.title = "Processed snapshots";
|
|
1705
|
+
} catch (error) {
|
|
1706
|
+
ctx2.log.debug(error);
|
|
1707
|
+
task.output = chalk6__default.default.gray(error.message);
|
|
1708
|
+
throw new Error("Processing of snapshots failed");
|
|
1709
|
+
}
|
|
1710
|
+
}),
|
|
1711
|
+
rendererOptions: { persistentOutput: true }
|
|
1712
|
+
};
|
|
1713
|
+
};
|
|
1714
|
+
var finalizeBuild_default = (ctx) => {
|
|
1715
|
+
return {
|
|
1716
|
+
title: `Finalizing build`,
|
|
1717
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1718
|
+
var _a, _b;
|
|
1719
|
+
updateLogContext({ task: "finalizeBuild" });
|
|
1720
|
+
try {
|
|
1721
|
+
yield ctx2.client.finalizeBuild(ctx2.build.id, ctx2.totalSnapshots, ctx2.log);
|
|
1722
|
+
task.output = chalk6__default.default.gray(`build url: ${ctx2.build.url}`);
|
|
1723
|
+
task.title = "Finalized build";
|
|
1724
|
+
} catch (error) {
|
|
1725
|
+
ctx2.log.debug(error);
|
|
1726
|
+
task.output = chalk6__default.default.gray(error.message);
|
|
1727
|
+
throw new Error("Finalize build failed");
|
|
1728
|
+
}
|
|
1729
|
+
try {
|
|
1730
|
+
yield (_a = ctx2.browser) == null ? void 0 : _a.close();
|
|
1731
|
+
ctx2.log.debug(`Closed browser`);
|
|
1732
|
+
yield (_b = ctx2.server) == null ? void 0 : _b.close();
|
|
1733
|
+
ctx2.log.debug(`Closed server`);
|
|
1734
|
+
let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
|
|
1735
|
+
yield ctx2.client.uploadLogs(ctx2, resp.data.url);
|
|
1736
|
+
fs5.unlinkSync(constants_default.LOG_FILE_PATH);
|
|
1737
|
+
} catch (error) {
|
|
1738
|
+
ctx2.log.debug(error);
|
|
1739
|
+
}
|
|
1740
|
+
}),
|
|
1741
|
+
rendererOptions: { persistentOutput: true }
|
|
1742
|
+
};
|
|
1743
|
+
};
|
|
1637
1744
|
var MAX_RESOURCE_SIZE = 15 * 1024 ** 2;
|
|
1638
1745
|
var ALLOWED_RESOURCES = ["document", "stylesheet", "image", "media", "font", "other"];
|
|
1639
1746
|
var ALLOWED_STATUSES = [200, 201];
|
|
@@ -2210,7 +2317,7 @@ var Queue = class {
|
|
|
2210
2317
|
|
|
2211
2318
|
// src/commander/exec.ts
|
|
2212
2319
|
var command = new commander.Command();
|
|
2213
|
-
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").action(function(execCommand, _, command5) {
|
|
2320
|
+
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").action(function(execCommand, _, command5) {
|
|
2214
2321
|
return __async(this, null, function* () {
|
|
2215
2322
|
let ctx = ctx_default(command5.optsWithGlobals());
|
|
2216
2323
|
if (!which__default.default.sync(execCommand[0], { nothrow: true })) {
|
|
@@ -2414,13 +2521,13 @@ function captureScreenshots(ctx) {
|
|
|
2414
2521
|
else
|
|
2415
2522
|
yield captureScreenshotsSync(ctx, staticConfig, browsers);
|
|
2416
2523
|
delDir(`screenshots/${staticConfig.name.toLowerCase().replace(/\s/g, "_")}`);
|
|
2417
|
-
output += `${
|
|
2524
|
+
output += `${chalk6__default.default.gray(staticConfig.name)} ${chalk6__default.default.green("\u2713")}
|
|
2418
2525
|
`;
|
|
2419
2526
|
ctx.task.output = output;
|
|
2420
2527
|
capturedScreenshots++;
|
|
2421
2528
|
} catch (error) {
|
|
2422
2529
|
ctx.log.debug(`screenshot capture failed for ${JSON.stringify(staticConfig)}; error: ${error}`);
|
|
2423
|
-
output += `${
|
|
2530
|
+
output += `${chalk6__default.default.gray(staticConfig.name)} ${chalk6__default.default.red("\u2717")}
|
|
2424
2531
|
`;
|
|
2425
2532
|
ctx.task.output = output;
|
|
2426
2533
|
}
|
|
@@ -2538,6 +2645,9 @@ var captureScreenshots_default = (ctx) => {
|
|
|
2538
2645
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
2539
2646
|
try {
|
|
2540
2647
|
ctx2.task = task;
|
|
2648
|
+
if (ctx2.options.fetchResults) {
|
|
2649
|
+
startPolling(ctx2, task);
|
|
2650
|
+
}
|
|
2541
2651
|
updateLogContext({ task: "capture" });
|
|
2542
2652
|
let { capturedScreenshots, output } = yield captureScreenshots(ctx2);
|
|
2543
2653
|
if (capturedScreenshots != ctx2.webStaticConfig.length) {
|
|
@@ -2546,7 +2656,7 @@ var captureScreenshots_default = (ctx) => {
|
|
|
2546
2656
|
task.title = "Screenshots captured successfully";
|
|
2547
2657
|
} catch (error) {
|
|
2548
2658
|
ctx2.log.debug(error);
|
|
2549
|
-
task.output =
|
|
2659
|
+
task.output = chalk6__default.default.gray(`${error.message}`);
|
|
2550
2660
|
throw new Error("Capturing screenshots failed");
|
|
2551
2661
|
}
|
|
2552
2662
|
}),
|
|
@@ -2557,7 +2667,7 @@ var captureScreenshots_default = (ctx) => {
|
|
|
2557
2667
|
|
|
2558
2668
|
// src/commander/capture.ts
|
|
2559
2669
|
var command2 = new commander.Command();
|
|
2560
|
-
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("--parallel", "Capture parallely on all browsers").action(function(file, _, command5) {
|
|
2670
|
+
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("--parallel", "Capture parallely on all browsers").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command5) {
|
|
2561
2671
|
return __async(this, null, function* () {
|
|
2562
2672
|
let ctx = ctx_default(command5.optsWithGlobals());
|
|
2563
2673
|
if (!fs5__default.default.existsSync(file)) {
|
|
@@ -2605,12 +2715,15 @@ var uploadScreenshots_default = (ctx) => {
|
|
|
2605
2715
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
2606
2716
|
try {
|
|
2607
2717
|
ctx2.task = task;
|
|
2718
|
+
if (ctx2.options.fetchResults) {
|
|
2719
|
+
startPolling(ctx2, task);
|
|
2720
|
+
}
|
|
2608
2721
|
updateLogContext({ task: "upload" });
|
|
2609
2722
|
yield uploadScreenshots(ctx2);
|
|
2610
2723
|
task.title = "Screenshots uploaded successfully";
|
|
2611
2724
|
} catch (error) {
|
|
2612
2725
|
ctx2.log.debug(error);
|
|
2613
|
-
task.output =
|
|
2726
|
+
task.output = chalk6__default.default.gray(`${error.message}`);
|
|
2614
2727
|
throw new Error("Uploading screenshots failed");
|
|
2615
2728
|
}
|
|
2616
2729
|
}),
|
|
@@ -2625,7 +2738,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
2625
2738
|
return val.split(",").map((ext) => ext.trim().toLowerCase());
|
|
2626
2739
|
}).option("-E, --removeExtensions", "Strips file extensions from snapshot names").option("-i, --ignoreDir <patterns>", "Comma-separated list of directories to ignore", (val) => {
|
|
2627
2740
|
return val.split(",").map((pattern) => pattern.trim());
|
|
2628
|
-
}).action(function(directory, _, command5) {
|
|
2741
|
+
}).option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(directory, _, command5) {
|
|
2629
2742
|
return __async(this, null, function* () {
|
|
2630
2743
|
let ctx = ctx_default(command5.optsWithGlobals());
|
|
2631
2744
|
if (!fs5__default.default.existsSync(directory)) {
|
|
@@ -2705,7 +2818,7 @@ var uploadFigmaDesigns_default2 = (ctx) => {
|
|
|
2705
2818
|
ctx2.log.debug(`Figma designs processed: ${results}`);
|
|
2706
2819
|
} catch (error) {
|
|
2707
2820
|
ctx2.log.debug(error);
|
|
2708
|
-
task.output =
|
|
2821
|
+
task.output = chalk6__default.default.gray(`${error.message}`);
|
|
2709
2822
|
throw new Error("Uploading Figma designs failed");
|
|
2710
2823
|
}
|
|
2711
2824
|
}),
|
|
@@ -2771,16 +2884,16 @@ var commander_default = program;
|
|
|
2771
2884
|
let { data: { latestVersion, deprecated, additionalDescription } } = yield client.checkUpdate(log2);
|
|
2772
2885
|
log2.info(`
|
|
2773
2886
|
LambdaTest SmartUI CLI v${package_default.version}`);
|
|
2774
|
-
log2.info(
|
|
2887
|
+
log2.info(chalk6__default.default.yellow(`${additionalDescription}`));
|
|
2775
2888
|
if (deprecated) {
|
|
2776
2889
|
log2.warn(`This version is deprecated. A new version ${latestVersion} is available!`);
|
|
2777
2890
|
} else if (package_default.version !== latestVersion) {
|
|
2778
|
-
log2.info(
|
|
2891
|
+
log2.info(chalk6__default.default.green(`A new version ${latestVersion} is available!`));
|
|
2779
2892
|
} else
|
|
2780
|
-
log2.info(
|
|
2893
|
+
log2.info(chalk6__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
|
|
2781
2894
|
} catch (error) {
|
|
2782
2895
|
log2.debug(error);
|
|
2783
|
-
log2.info(
|
|
2896
|
+
log2.info(chalk6__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
|
|
2784
2897
|
}
|
|
2785
2898
|
commander_default.parse();
|
|
2786
2899
|
});
|