@lambdatest/smartui-cli 3.0.9 → 3.0.11
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 +29 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -436,13 +436,14 @@ var ALLOWED_STATUSES = [200, 201];
|
|
|
436
436
|
var REQUEST_TIMEOUT = 1e4;
|
|
437
437
|
var MIN_VIEWPORT_HEIGHT = 1080;
|
|
438
438
|
var processSnapshot_default = (snapshot, ctx) => __async(void 0, null, function* () {
|
|
439
|
+
var _a;
|
|
439
440
|
ctx.log.debug(`Processing snapshot ${snapshot.name}`);
|
|
440
441
|
let launchOptions = { headless: true };
|
|
441
442
|
let contextOptions = {
|
|
442
443
|
javaScriptEnabled: ctx.config.enableJavaScript,
|
|
443
444
|
userAgent: constants_default.CHROME_USER_AGENT
|
|
444
445
|
};
|
|
445
|
-
if (!ctx.browser) {
|
|
446
|
+
if (!((_a = ctx.browser) == null ? void 0 : _a.isConnected())) {
|
|
446
447
|
if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY)
|
|
447
448
|
launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
|
|
448
449
|
ctx.browser = yield test.chromium.launch(launchOptions);
|
|
@@ -516,9 +517,9 @@ var processSnapshot_default = (snapshot, ctx) => __async(void 0, null, function*
|
|
|
516
517
|
if (options && Object.keys(options).length) {
|
|
517
518
|
ctx.log.debug(`Snapshot options: ${JSON.stringify(options)}`);
|
|
518
519
|
const isNotAllEmpty = (obj) => {
|
|
519
|
-
var
|
|
520
|
+
var _a2;
|
|
520
521
|
for (let key in obj)
|
|
521
|
-
if ((
|
|
522
|
+
if ((_a2 = obj[key]) == null ? void 0 : _a2.length)
|
|
522
523
|
return true;
|
|
523
524
|
return false;
|
|
524
525
|
};
|
|
@@ -989,7 +990,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
989
990
|
}
|
|
990
991
|
return reply.code(replyCode).send(replyBody);
|
|
991
992
|
}));
|
|
992
|
-
yield server.listen({ port:
|
|
993
|
+
yield server.listen({ port: ctx.options.port });
|
|
993
994
|
let { port } = server.addresses()[0];
|
|
994
995
|
process.env.SMARTUI_SERVER_ADDRESS = `http://localhost:${port}`;
|
|
995
996
|
process.env.CYPRESS_SMARTUI_SERVER_ADDRESS = `http://localhost:${port}`;
|
|
@@ -1009,7 +1010,9 @@ var env_default = () => {
|
|
|
1009
1010
|
GITHUB_ACTIONS,
|
|
1010
1011
|
FIGMA_TOKEN,
|
|
1011
1012
|
LT_USERNAME,
|
|
1012
|
-
LT_ACCESS_KEY
|
|
1013
|
+
LT_ACCESS_KEY,
|
|
1014
|
+
BASELINE_BRANCH,
|
|
1015
|
+
CURRENT_BRANCH
|
|
1013
1016
|
} = process.env;
|
|
1014
1017
|
return {
|
|
1015
1018
|
PROJECT_TOKEN,
|
|
@@ -1022,7 +1025,9 @@ var env_default = () => {
|
|
|
1022
1025
|
GITHUB_ACTIONS,
|
|
1023
1026
|
FIGMA_TOKEN,
|
|
1024
1027
|
LT_USERNAME,
|
|
1025
|
-
LT_ACCESS_KEY
|
|
1028
|
+
LT_ACCESS_KEY,
|
|
1029
|
+
BASELINE_BRANCH,
|
|
1030
|
+
CURRENT_BRANCH
|
|
1026
1031
|
};
|
|
1027
1032
|
};
|
|
1028
1033
|
var logContext = { task: "smartui-cli" };
|
|
@@ -1099,7 +1104,7 @@ var auth_default = (ctx) => {
|
|
|
1099
1104
|
};
|
|
1100
1105
|
|
|
1101
1106
|
// package.json
|
|
1102
|
-
var version = "3.0.
|
|
1107
|
+
var version = "3.0.11";
|
|
1103
1108
|
var package_default = {
|
|
1104
1109
|
name: "@lambdatest/smartui-cli",
|
|
1105
1110
|
version,
|
|
@@ -1288,6 +1293,7 @@ var ctx_default = (options) => {
|
|
|
1288
1293
|
let webConfig;
|
|
1289
1294
|
let mobileConfig;
|
|
1290
1295
|
let config = constants_default.DEFAULT_CONFIG;
|
|
1296
|
+
let port;
|
|
1291
1297
|
try {
|
|
1292
1298
|
if (options.config) {
|
|
1293
1299
|
config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
|
|
@@ -1299,6 +1305,10 @@ var ctx_default = (options) => {
|
|
|
1299
1305
|
throw new Error(validateConfig.errors[0].message);
|
|
1300
1306
|
}
|
|
1301
1307
|
}
|
|
1308
|
+
port = parseInt(options.port || "49152", 10);
|
|
1309
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
1310
|
+
throw new Error("Invalid port number. Port number must be an integer between 1 and 65535.");
|
|
1311
|
+
}
|
|
1302
1312
|
} catch (error) {
|
|
1303
1313
|
console.log(`[smartui] Error: ${error.message}`);
|
|
1304
1314
|
process.exit();
|
|
@@ -1345,7 +1355,8 @@ var ctx_default = (options) => {
|
|
|
1345
1355
|
options: {
|
|
1346
1356
|
parallel: options.parallel ? true : false,
|
|
1347
1357
|
markBaseline: options.markBaseline ? true : false,
|
|
1348
|
-
buildName: options.buildName || ""
|
|
1358
|
+
buildName: options.buildName || "",
|
|
1359
|
+
port
|
|
1349
1360
|
},
|
|
1350
1361
|
cliVersion: version,
|
|
1351
1362
|
totalSnapshots: -1
|
|
@@ -1375,11 +1386,12 @@ var git_default = (ctx) => {
|
|
|
1375
1386
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
1376
1387
|
let gitInfo = JSON.parse(fs5__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
1377
1388
|
return {
|
|
1378
|
-
branch: gitInfo.branch || "",
|
|
1389
|
+
branch: ctx.env.CURRENT_BRANCH || gitInfo.branch || "",
|
|
1379
1390
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
1380
1391
|
commitMessage: gitInfo.commit_body || "",
|
|
1381
1392
|
commitAuthor: gitInfo.commit_author || "",
|
|
1382
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : ""
|
|
1393
|
+
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
1394
|
+
baselineBranch: ctx.env.BASELINE_BRANCH || ""
|
|
1383
1395
|
};
|
|
1384
1396
|
} else {
|
|
1385
1397
|
const splitCharacter = "<##>";
|
|
@@ -1387,14 +1399,15 @@ var git_default = (ctx) => {
|
|
|
1387
1399
|
const command4 = 'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) + '" && git rev-parse --abbrev-ref HEAD && git tag --contains HEAD';
|
|
1388
1400
|
let res = executeCommand(command4).split(splitCharacter);
|
|
1389
1401
|
var branchAndTags = res[res.length - 1].split("\n").filter((n) => n);
|
|
1390
|
-
var branch = branchAndTags[0];
|
|
1402
|
+
var branch = ctx.env.CURRENT_BRANCH || branchAndTags[0];
|
|
1391
1403
|
branchAndTags.slice(1);
|
|
1392
1404
|
return {
|
|
1393
1405
|
branch: branch || "",
|
|
1394
1406
|
commitId: res[0] || "",
|
|
1395
1407
|
commitMessage: res[2] || "",
|
|
1396
1408
|
commitAuthor: res[7] || "",
|
|
1397
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : ""
|
|
1409
|
+
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
1410
|
+
baselineBranch: ctx.env.BASELINE_BRANCH || ""
|
|
1398
1411
|
};
|
|
1399
1412
|
}
|
|
1400
1413
|
};
|
|
@@ -1405,6 +1418,9 @@ var getGitInfo_default = (ctx) => {
|
|
|
1405
1418
|
return !isGitRepo() && !ctx2.env.SMARTUI_GIT_INFO_FILEPATH ? "[SKIPPED] Fetching git repo details; not a git repo" : "";
|
|
1406
1419
|
},
|
|
1407
1420
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
1421
|
+
if (ctx2.env.CURRENT_BRANCH && ctx2.env.CURRENT_BRANCH.trim() === "") {
|
|
1422
|
+
throw new Error("Error: The environment variable CURRENT_BRANCH cannot be empty.");
|
|
1423
|
+
}
|
|
1408
1424
|
try {
|
|
1409
1425
|
ctx2.git = git_default(ctx2);
|
|
1410
1426
|
task.output = chalk8__default.default.gray(`branch: ${ctx2.git.branch}, commit: ${ctx2.git.commitId}, author: ${ctx2.git.commitAuthor}`);
|
|
@@ -1500,7 +1516,7 @@ var finalizeBuild_default = (ctx) => {
|
|
|
1500
1516
|
|
|
1501
1517
|
// src/commander/exec.ts
|
|
1502
1518
|
var command = new commander.Command();
|
|
1503
|
-
command.name("exec").description("Run test commands around SmartUI").argument("<command...>", "Command supplied for running tests").action(function(execCommand, _, command4) {
|
|
1519
|
+
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, _, command4) {
|
|
1504
1520
|
return __async(this, null, function* () {
|
|
1505
1521
|
var _a, _b;
|
|
1506
1522
|
let ctx = ctx_default(command4.optsWithGlobals());
|