@lambdatest/smartui-cli 3.0.10 → 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.
Files changed (2) hide show
  1. package/dist/index.cjs +14 -7
  2. 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 _a;
520
+ var _a2;
520
521
  for (let key in obj)
521
- if ((_a = obj[key]) == null ? void 0 : _a.length)
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: 49152 });
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}`;
@@ -1103,7 +1104,7 @@ var auth_default = (ctx) => {
1103
1104
  };
1104
1105
 
1105
1106
  // package.json
1106
- var version = "3.0.10";
1107
+ var version = "3.0.11";
1107
1108
  var package_default = {
1108
1109
  name: "@lambdatest/smartui-cli",
1109
1110
  version,
@@ -1292,6 +1293,7 @@ var ctx_default = (options) => {
1292
1293
  let webConfig;
1293
1294
  let mobileConfig;
1294
1295
  let config = constants_default.DEFAULT_CONFIG;
1296
+ let port;
1295
1297
  try {
1296
1298
  if (options.config) {
1297
1299
  config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
@@ -1303,6 +1305,10 @@ var ctx_default = (options) => {
1303
1305
  throw new Error(validateConfig.errors[0].message);
1304
1306
  }
1305
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
+ }
1306
1312
  } catch (error) {
1307
1313
  console.log(`[smartui] Error: ${error.message}`);
1308
1314
  process.exit();
@@ -1349,7 +1355,8 @@ var ctx_default = (options) => {
1349
1355
  options: {
1350
1356
  parallel: options.parallel ? true : false,
1351
1357
  markBaseline: options.markBaseline ? true : false,
1352
- buildName: options.buildName || ""
1358
+ buildName: options.buildName || "",
1359
+ port
1353
1360
  },
1354
1361
  cliVersion: version,
1355
1362
  totalSnapshots: -1
@@ -1509,7 +1516,7 @@ var finalizeBuild_default = (ctx) => {
1509
1516
 
1510
1517
  // src/commander/exec.ts
1511
1518
  var command = new commander.Command();
1512
- 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) {
1513
1520
  return __async(this, null, function* () {
1514
1521
  var _a, _b;
1515
1522
  let ctx = ctx_default(command4.optsWithGlobals());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"