@lambdatest/smartui-cli 4.1.48 → 4.1.49

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 +88 -138
  2. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -82,8 +82,7 @@ var __spreadValues = (a, b) => {
82
82
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
83
83
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
84
84
  }) : x)(function(x) {
85
- if (typeof require !== "undefined")
86
- return require.apply(this, arguments);
85
+ if (typeof require !== "undefined") return require.apply(this, arguments);
87
86
  throw Error('Dynamic require of "' + x + '" is not supported');
88
87
  });
89
88
  var __commonJS = (cb, mod) => function __require2() {
@@ -165,10 +164,8 @@ var require_find_free_port = __commonJS({
165
164
  } else {
166
165
  return new Promise((resolve, reject) => {
167
166
  findFreePort(beg, ...rest, (err, ...ports) => {
168
- if (err)
169
- reject(err);
170
- else
171
- resolve(ports);
167
+ if (err) reject(err);
168
+ else resolve(ports);
172
169
  });
173
170
  });
174
171
  }
@@ -1568,10 +1565,8 @@ function launchBrowsers(ctx) {
1568
1565
  }
1569
1566
  if (ctx.config.mobile) {
1570
1567
  for (const device of ctx.config.mobile.devices) {
1571
- if (constants_default.SUPPORTED_MOBILE_DEVICES[device].os === "android" && !browsers[constants_default.CHROME])
1572
- browsers[constants_default.CHROME] = yield test.chromium.launch(launchOptions);
1573
- else if (constants_default.SUPPORTED_MOBILE_DEVICES[device].os === "ios" && !browsers[constants_default.SAFARI])
1574
- browsers[constants_default.SAFARI] = yield test.webkit.launch(launchOptions);
1568
+ if (constants_default.SUPPORTED_MOBILE_DEVICES[device].os === "android" && !browsers[constants_default.CHROME]) browsers[constants_default.CHROME] = yield test.chromium.launch(launchOptions);
1569
+ else if (constants_default.SUPPORTED_MOBILE_DEVICES[device].os === "ios" && !browsers[constants_default.SAFARI]) browsers[constants_default.SAFARI] = yield test.webkit.launch(launchOptions);
1575
1570
  }
1576
1571
  }
1577
1572
  return browsers;
@@ -1580,8 +1575,7 @@ function launchBrowsers(ctx) {
1580
1575
  function closeBrowsers(browsers) {
1581
1576
  return __async(this, null, function* () {
1582
1577
  var _a;
1583
- for (const browserName of Object.keys(browsers))
1584
- yield (_a = browsers[browserName]) == null ? void 0 : _a.close();
1578
+ for (const browserName of Object.keys(browsers)) yield (_a = browsers[browserName]) == null ? void 0 : _a.close();
1585
1579
  });
1586
1580
  }
1587
1581
  function getWebRenderViewports(ctx) {
@@ -1694,7 +1688,7 @@ function startPolling(ctx, build_id, baseline, projectToken) {
1694
1688
  } else if (ctx.build && ctx.build.id) {
1695
1689
  ctx.log.info(`Fetching results for buildId ${ctx.build.id} in progress....`);
1696
1690
  }
1697
- const intervalId = setInterval(() => __async(this, null, function* () {
1691
+ const intervalId = setInterval(() => __async(null, null, function* () {
1698
1692
  try {
1699
1693
  let resp;
1700
1694
  if (build_id) {
@@ -1773,7 +1767,7 @@ function startPingPolling(ctx) {
1773
1767
  ctx.log.error(`Error during initial ping: ${error.message}`);
1774
1768
  }
1775
1769
  let sourceCommand = ctx.sourceCommand ? ctx.sourceCommand : "";
1776
- pingIntervalId = setInterval(() => __async(this, null, function* () {
1770
+ pingIntervalId = setInterval(() => __async(null, null, function* () {
1777
1771
  try {
1778
1772
  ctx.log.debug("Sending ping to server... " + sourceCommand);
1779
1773
  yield ctx.client.ping(ctx.build.id, ctx.log);
@@ -1847,7 +1841,7 @@ function startPollingForTunnel(ctx, build_id, baseline, projectToken, buildName)
1847
1841
  ctx.log.debug("Tunnel polling is already active. Skipping for build_id: " + build_id);
1848
1842
  return;
1849
1843
  }
1850
- const intervalId = setInterval(() => __async(this, null, function* () {
1844
+ const intervalId = setInterval(() => __async(null, null, function* () {
1851
1845
  try {
1852
1846
  let resp;
1853
1847
  if (build_id) {
@@ -1939,7 +1933,7 @@ function startPdfPolling(ctx) {
1939
1933
  let attempts = 0;
1940
1934
  const maxAttempts = 60;
1941
1935
  console.log(chalk__default.default.yellow("Waiting for results..."));
1942
- const interval = setInterval(() => __async(this, null, function* () {
1936
+ const interval = setInterval(() => __async(null, null, function* () {
1943
1937
  var _a;
1944
1938
  attempts++;
1945
1939
  try {
@@ -2134,8 +2128,7 @@ function listenToSmartUISSE(baseURL, accessToken, ctx, onEvent) {
2134
2128
  try {
2135
2129
  while (true) {
2136
2130
  const { done, value } = yield reader.read();
2137
- if (done)
2138
- break;
2131
+ if (done) break;
2139
2132
  const chunk = decoder.decode(value, { stream: true });
2140
2133
  buffer += chunk;
2141
2134
  const lines = buffer.split("\n");
@@ -2377,7 +2370,7 @@ function findAvailablePort(server, startPort, log2) {
2377
2370
  }
2378
2371
  });
2379
2372
  }
2380
- var server_default = (ctx) => __async(void 0, null, function* () {
2373
+ var server_default = (ctx) => __async(null, null, function* () {
2381
2374
  const server = fastify__default.default({
2382
2375
  logger: {
2383
2376
  level: "debug",
@@ -2395,14 +2388,13 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2395
2388
  server.get("/domserializer", opts, (request, reply) => {
2396
2389
  reply.code(200).send({ data: { dom: SMARTUI_DOM } });
2397
2390
  });
2398
- server.post("/snapshot", opts, (request, reply) => __async(void 0, null, function* () {
2391
+ server.post("/snapshot", opts, (request, reply) => __async(null, null, function* () {
2399
2392
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2400
2393
  let replyCode;
2401
2394
  let replyBody;
2402
2395
  try {
2403
2396
  let { snapshot, testType } = request.body;
2404
- if (!validateSnapshot(snapshot))
2405
- throw new Error(validateSnapshot.errors[0].message);
2397
+ if (!validateSnapshot(snapshot)) throw new Error(validateSnapshot.errors[0].message);
2406
2398
  if (((_a = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _a.approvalThreshold) !== void 0 && ((_b = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _b.rejectionThreshold) !== void 0) {
2407
2399
  if (((_c = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _c.rejectionThreshold) <= ((_d = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _d.approvalThreshold)) {
2408
2400
  throw new Error(`Invalid snapshot options; rejectionThreshold (${snapshot.options.rejectionThreshold}) must be greater than approvalThreshold (${snapshot.options.approvalThreshold})`);
@@ -2458,7 +2450,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2458
2450
  }
2459
2451
  return reply.code(replyCode).send(replyBody);
2460
2452
  }));
2461
- server.post("/stop", opts, (_, reply) => __async(void 0, null, function* () {
2453
+ server.post("/stop", opts, (_, reply) => __async(null, null, function* () {
2462
2454
  var _a, _b, _c, _d;
2463
2455
  let replyCode;
2464
2456
  let replyBody;
@@ -2540,7 +2532,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2540
2532
  server.get("/ping", opts, (_, reply) => {
2541
2533
  reply.code(200).send({ status: "Server is running", version: ctx.cliVersion });
2542
2534
  });
2543
- server.get("/snapshot/status", opts, (request, reply) => __async(void 0, null, function* () {
2535
+ server.get("/snapshot/status", opts, (request, reply) => __async(null, null, function* () {
2544
2536
  var _a;
2545
2537
  let replyCode;
2546
2538
  let replyBody;
@@ -2630,7 +2622,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2630
2622
  return reply.code(replyCode).send(replyBody);
2631
2623
  }
2632
2624
  }));
2633
- server.get("/build/info", opts, (request, reply) => __async(void 0, null, function* () {
2625
+ server.get("/build/info", opts, (request, reply) => __async(null, null, function* () {
2634
2626
  let replyCode;
2635
2627
  let replyBody;
2636
2628
  try {
@@ -2774,7 +2766,7 @@ var logger_default = logger;
2774
2766
  var startServer_default = (ctx) => {
2775
2767
  return {
2776
2768
  title: `Setting up SmartUI server`,
2777
- task: (ctx2, task) => __async(void 0, null, function* () {
2769
+ task: (ctx2, task) => __async(null, null, function* () {
2778
2770
  var _a;
2779
2771
  updateLogContext({ task: "startServer" });
2780
2772
  try {
@@ -2793,7 +2785,7 @@ var startServer_default = (ctx) => {
2793
2785
  var authExec_default = (ctx) => {
2794
2786
  return {
2795
2787
  title: `Authenticating with SmartUI`,
2796
- task: (ctx2, task) => __async(void 0, null, function* () {
2788
+ task: (ctx2, task) => __async(null, null, function* () {
2797
2789
  updateLogContext({ task: "auth" });
2798
2790
  try {
2799
2791
  if (!ctx2.env.PROJECT_NAME && !ctx2.env.PROJECT_TOKEN) {
@@ -2825,7 +2817,7 @@ var authExec_default = (ctx) => {
2825
2817
  };
2826
2818
 
2827
2819
  // package.json
2828
- var version = "4.1.48";
2820
+ var version = "4.1.49";
2829
2821
  var package_default = {
2830
2822
  name: "@lambdatest/smartui-cli",
2831
2823
  version,
@@ -2873,7 +2865,6 @@ var package_default = {
2873
2865
  "node-cache": "^5.1.2",
2874
2866
  postcss: "^8.5.6",
2875
2867
  sharp: "^0.33.4",
2876
- tsup: "^7.2.0",
2877
2868
  uuid: "^11.0.3",
2878
2869
  which: "^4.0.0",
2879
2870
  winston: "^3.10.0"
@@ -2883,7 +2874,8 @@ var package_default = {
2883
2874
  },
2884
2875
  devDependencies: {
2885
2876
  "find-free-port": "^2.0.0",
2886
- typescript: "^5.3.2"
2877
+ typescript: "^5.3.2",
2878
+ tsup: "^8.5.1"
2887
2879
  }
2888
2880
  };
2889
2881
  var httpClient = class {
@@ -3174,8 +3166,7 @@ var httpClient = class {
3174
3166
  }
3175
3167
  finalizeBuild(buildId, totalSnapshots, log2) {
3176
3168
  let params = { buildId };
3177
- if (totalSnapshots > -1)
3178
- params.totalSnapshots = totalSnapshots;
3169
+ if (totalSnapshots > -1) params.totalSnapshots = totalSnapshots;
3179
3170
  return this.request({
3180
3171
  url: "/build",
3181
3172
  method: "DELETE",
@@ -3184,8 +3175,7 @@ var httpClient = class {
3184
3175
  }
3185
3176
  finalizeBuildForCapsWithToken(buildId, totalSnapshots, projectToken, log2) {
3186
3177
  let params = { buildId };
3187
- if (totalSnapshots > -1)
3188
- params.totalSnapshots = totalSnapshots;
3178
+ if (totalSnapshots > -1) params.totalSnapshots = totalSnapshots;
3189
3179
  return this.request({
3190
3180
  url: "/build",
3191
3181
  method: "DELETE",
@@ -3737,8 +3727,7 @@ var ctx_default = (options) => {
3737
3727
  }
3738
3728
  if (config.web) {
3739
3729
  webConfig = { browsers: config.web.browsers, viewports: [] };
3740
- for (let viewport of (_b = config.web) == null ? void 0 : _b.viewports)
3741
- webConfig.viewports.push({ width: viewport[0], height: viewport[1] || 0 });
3730
+ for (let viewport of (_b = config.web) == null ? void 0 : _b.viewports) webConfig.viewports.push({ width: viewport[0], height: viewport[1] || 0 });
3742
3731
  }
3743
3732
  if (config.mobile) {
3744
3733
  mobileConfig = {
@@ -3988,7 +3977,7 @@ var getGitInfo_default = (ctx) => {
3988
3977
  skip: (ctx2) => {
3989
3978
  return !isGitRepo(ctx2) && !ctx2.env.SMARTUI_GIT_INFO_FILEPATH ? "[SKIPPED] Fetching git repo details; not a git repo" : "";
3990
3979
  },
3991
- task: (ctx2, task) => __async(void 0, null, function* () {
3980
+ task: (ctx2, task) => __async(null, null, function* () {
3992
3981
  if (ctx2.env.CURRENT_BRANCH && ctx2.env.CURRENT_BRANCH.trim() === "") {
3993
3982
  throw new Error("Error: The environment variable CURRENT_BRANCH cannot be empty.");
3994
3983
  }
@@ -4011,7 +4000,7 @@ var getGitInfo_default = (ctx) => {
4011
4000
  var createBuildExec_default = (ctx) => {
4012
4001
  return {
4013
4002
  title: `Creating SmartUI build`,
4014
- task: (ctx2, task) => __async(void 0, null, function* () {
4003
+ task: (ctx2, task) => __async(null, null, function* () {
4015
4004
  updateLogContext({ task: "createBuild" });
4016
4005
  try {
4017
4006
  if (ctx2.authenticatedInitially && !ctx2.config.skipBuildCreation) {
@@ -4096,7 +4085,7 @@ var exec_default = (ctx) => {
4096
4085
  var _a;
4097
4086
  return {
4098
4087
  title: `Executing '${(_a = ctx.args.execCommand) == null ? void 0 : _a.join(" ")}'`,
4099
- task: (ctx2, task) => __async(void 0, null, function* () {
4088
+ task: (ctx2, task) => __async(null, null, function* () {
4100
4089
  if (ctx2.options.fetchResults) {
4101
4090
  if (ctx2.build && ctx2.build.id) {
4102
4091
  startPolling(ctx2, "", false, "");
@@ -4141,7 +4130,7 @@ var exec_default = (ctx) => {
4141
4130
  task.output = chalk__default.default.gray(`error: ${error.message}`);
4142
4131
  throw new Error(`Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' failed`);
4143
4132
  });
4144
- childProcess.on("close", (code, signal) => __async(void 0, null, function* () {
4133
+ childProcess.on("close", (code, signal) => __async(null, null, function* () {
4145
4134
  var _a3;
4146
4135
  if (code !== null) {
4147
4136
  task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' completed; exited with code ${code}`;
@@ -4162,7 +4151,7 @@ var exec_default = (ctx) => {
4162
4151
  var processSnapshot_default = (ctx) => {
4163
4152
  return {
4164
4153
  title: `Processing snapshots`,
4165
- task: (ctx2, task) => __async(void 0, null, function* () {
4154
+ task: (ctx2, task) => __async(null, null, function* () {
4166
4155
  var _a, _b, _c, _d;
4167
4156
  try {
4168
4157
  if (ctx2.config.delayedUpload) {
@@ -4188,8 +4177,7 @@ var processSnapshot_default = (ctx) => {
4188
4177
  [error] ${snapshot.error}`)}
4189
4178
  `;
4190
4179
  process.exitCode = 1;
4191
- } else
4192
- output += `${chalk__default.default.green("\u2713")} ${chalk__default.default.gray(snapshot.name)}
4180
+ } else output += `${chalk__default.default.green("\u2713")} ${chalk__default.default.gray(snapshot.name)}
4193
4181
  ${snapshot.warnings.length ? chalk__default.default.gray(`[warning] ${snapshot.warnings.join("\n[warning] ")}
4194
4182
  `) : ""}`;
4195
4183
  }
@@ -4212,7 +4200,7 @@ var uploadDomToS3ViaEnv2 = process.env.USE_LAMBDA_INTERNAL || false;
4212
4200
  var finalizeBuild_default = (ctx) => {
4213
4201
  return {
4214
4202
  title: `Finalizing build`,
4215
- task: (ctx2, task) => __async(void 0, null, function* () {
4203
+ task: (ctx2, task) => __async(null, null, function* () {
4216
4204
  var _a, _b, _c;
4217
4205
  updateLogContext({ task: "finalizeBuild" });
4218
4206
  try {
@@ -4326,8 +4314,7 @@ var REQUEST_TIMEOUT = 18e4;
4326
4314
  var MIN_VIEWPORT_HEIGHT = 1080;
4327
4315
  var MAX_WAIT_FOR_REQUEST_CALL = 3e4;
4328
4316
  var normalizeSameSite = (value) => {
4329
- if (!value)
4330
- return "Lax";
4317
+ if (!value) return "Lax";
4331
4318
  const normalized = value.trim().toLowerCase();
4332
4319
  const mapping = {
4333
4320
  "lax": "Lax",
@@ -4350,10 +4337,8 @@ function prepareSnapshot(snapshot, ctx) {
4350
4337
  ctx.config.allowedHostnames.push(new URL(snapshot.url).hostname);
4351
4338
  processedOptions.allowedHostnames = ctx.config.allowedHostnames;
4352
4339
  processedOptions.skipCapturedCookies = ctx.env.SMARTUI_DO_NOT_USE_CAPTURED_COOKIES;
4353
- if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY)
4354
- processedOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
4355
- if (ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY)
4356
- processedOptions.proxy = { server: ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY };
4340
+ if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY) processedOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
4341
+ if (ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY) processedOptions.proxy = { server: ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY };
4357
4342
  let options = snapshot.options;
4358
4343
  let optionWarnings = /* @__PURE__ */ new Set();
4359
4344
  let selectors = [];
@@ -4362,9 +4347,7 @@ function prepareSnapshot(snapshot, ctx) {
4362
4347
  ctx.log.debug(`Snapshot options: ${JSON.stringify(options)}`);
4363
4348
  const isNotAllEmpty = (obj) => {
4364
4349
  var _a;
4365
- for (let key in obj)
4366
- if ((_a = obj[key]) == null ? void 0 : _a.length)
4367
- return true;
4350
+ for (let key in obj) if ((_a = obj[key]) == null ? void 0 : _a.length) return true;
4368
4351
  return false;
4369
4352
  };
4370
4353
  if (options.loadDomContent) {
@@ -4411,14 +4394,10 @@ function prepareSnapshot(snapshot, ctx) {
4411
4394
  }
4412
4395
  }
4413
4396
  if (options.element && Object.keys(options.element).length) {
4414
- if (options.element.id)
4415
- processedOptions.element = "#" + options.element.id;
4416
- else if (options.element.class)
4417
- processedOptions.element = "." + options.element.class;
4418
- else if (options.element.cssSelector)
4419
- processedOptions.element = options.element.cssSelector;
4420
- else if (options.element.xpath)
4421
- processedOptions.element = "xpath=" + options.element.xpath;
4397
+ if (options.element.id) processedOptions.element = "#" + options.element.id;
4398
+ else if (options.element.class) processedOptions.element = "." + options.element.class;
4399
+ else if (options.element.cssSelector) processedOptions.element = options.element.cssSelector;
4400
+ else if (options.element.xpath) processedOptions.element = "xpath=" + options.element.xpath;
4422
4401
  } else if (options.ignoreDOM && Object.keys(options.ignoreDOM).length && isNotAllEmpty(options.ignoreDOM)) {
4423
4402
  processedOptions.ignoreBoxes = {};
4424
4403
  ignoreOrSelectDOM = "ignoreDOM";
@@ -4534,10 +4513,8 @@ function processSnapshot(snapshot, ctx) {
4534
4513
  contextOptions.userAgent = constants_default.CHROME_USER_AGENT;
4535
4514
  }
4536
4515
  if (!((_b = ctx.browser) == null ? void 0 : _b.isConnected())) {
4537
- if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY)
4538
- launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
4539
- if (ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY)
4540
- launchOptions.proxy = { server: ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY };
4516
+ if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY) launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
4517
+ if (ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY) launchOptions.proxy = { server: ctx.env.SMARTUI_HTTP_PROXY || ctx.env.SMARTUI_HTTPS_PROXY };
4541
4518
  ctx.browser = yield test.chromium.launch(launchOptions);
4542
4519
  ctx.log.debug(`Chromium launched with options ${JSON.stringify(launchOptions)}`);
4543
4520
  }
@@ -4547,11 +4524,9 @@ function processSnapshot(snapshot, ctx) {
4547
4524
  const domainName = new URL(snapshot.url).hostname;
4548
4525
  ctx.log.debug(`Setting cookies for domain: ${domainName}`);
4549
4526
  const cookieArray = snapshot.dom.cookies.split("; ").map((cookie) => {
4550
- if (!cookie)
4551
- return null;
4527
+ if (!cookie) return null;
4552
4528
  const [name, value] = cookie.split("=");
4553
- if (!name || !value)
4554
- return null;
4529
+ if (!name || !value) return null;
4555
4530
  return {
4556
4531
  name: name.trim(),
4557
4532
  value: value.trim(),
@@ -4611,7 +4586,7 @@ function processSnapshot(snapshot, ctx) {
4611
4586
  }
4612
4587
  }
4613
4588
  const pendingRequests = /* @__PURE__ */ new Set();
4614
- yield page.route("**/*", (route, request) => __async(this, null, function* () {
4589
+ yield page.route("**/*", (route, request) => __async(null, null, function* () {
4615
4590
  var _a2;
4616
4591
  const requestUrl = request.url();
4617
4592
  const requestHostname = new URL(requestUrl).hostname;
@@ -4624,8 +4599,7 @@ function processSnapshot(snapshot, ctx) {
4624
4599
  throw new Error("resource type mp3/mp4/wav/ogg/webm");
4625
4600
  }
4626
4601
  ctx.config.allowedHostnames.push(new URL(snapshot.url).hostname);
4627
- if (ctx.config.enableJavaScript)
4628
- ALLOWED_RESOURCES.push("script");
4602
+ if (ctx.config.enableJavaScript) ALLOWED_RESOURCES.push("script");
4629
4603
  if (ctx.config.basicAuthorization) {
4630
4604
  ctx.log.debug(`Adding basic authorization to the headers for root url`);
4631
4605
  let token = Buffer.from(`${ctx.config.basicAuthorization.username}:${ctx.config.basicAuthorization.password}`).toString("base64");
@@ -4781,9 +4755,7 @@ function processSnapshot(snapshot, ctx) {
4781
4755
  ctx.log.debug(`Snapshot options: ${JSON.stringify(options)}`);
4782
4756
  const isNotAllEmpty = (obj) => {
4783
4757
  var _a2;
4784
- for (let key in obj)
4785
- if ((_a2 = obj[key]) == null ? void 0 : _a2.length)
4786
- return true;
4758
+ for (let key in obj) if ((_a2 = obj[key]) == null ? void 0 : _a2.length) return true;
4787
4759
  return false;
4788
4760
  };
4789
4761
  if (options.loadDomContent) {
@@ -4827,14 +4799,10 @@ function processSnapshot(snapshot, ctx) {
4827
4799
  }
4828
4800
  }
4829
4801
  if (options.element && Object.keys(options.element).length) {
4830
- if (options.element.id)
4831
- processedOptions.element = "#" + options.element.id;
4832
- else if (options.element.class)
4833
- processedOptions.element = "." + options.element.class;
4834
- else if (options.element.cssSelector)
4835
- processedOptions.element = options.element.cssSelector;
4836
- else if (options.element.xpath)
4837
- processedOptions.element = "xpath=" + options.element.xpath;
4802
+ if (options.element.id) processedOptions.element = "#" + options.element.id;
4803
+ else if (options.element.class) processedOptions.element = "." + options.element.class;
4804
+ else if (options.element.cssSelector) processedOptions.element = options.element.cssSelector;
4805
+ else if (options.element.xpath) processedOptions.element = "xpath=" + options.element.xpath;
4838
4806
  } else if (options.ignoreDOM && Object.keys(options.ignoreDOM).length && isNotAllEmpty(options.ignoreDOM)) {
4839
4807
  processedOptions.ignoreBoxes = {};
4840
4808
  ignoreOrSelectDOM = "ignoreDOM";
@@ -4921,8 +4889,7 @@ function processSnapshot(snapshot, ctx) {
4921
4889
  discoveryErrors.name = snapshot.name;
4922
4890
  yield page.goto(snapshot.url, { waitUntil: "domcontentloaded", timeout: ctx.config.waitForDiscovery });
4923
4891
  yield new Promise((r) => setTimeout(r, 1250));
4924
- if (ctx.config.waitForTimeout)
4925
- yield page.waitForTimeout(ctx.config.waitForTimeout);
4892
+ if (ctx.config.waitForTimeout) yield page.waitForTimeout(ctx.config.waitForTimeout);
4926
4893
  yield page.waitForLoadState("networkidle", { timeout: 1e4 }).catch(() => {
4927
4894
  ctx.log.debug("networkidle event failed to fire within 10s");
4928
4895
  });
@@ -4945,8 +4912,7 @@ function processSnapshot(snapshot, ctx) {
4945
4912
  }
4946
4913
  }
4947
4914
  }
4948
- if (ctx.config.cliEnableJavaScript && fullPage)
4949
- yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
4915
+ if (ctx.config.cliEnableJavaScript && fullPage) yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
4950
4916
  try {
4951
4917
  yield page.waitForLoadState("networkidle", { timeout: 15e3 });
4952
4918
  ctx.log.debug("Network idle 500ms");
@@ -5008,8 +4974,7 @@ function processSnapshot(snapshot, ctx) {
5008
4974
  return Math.max(...measurements);
5009
4975
  });
5010
4976
  ctx.log.debug(`Calculated content height: ${height}`);
5011
- if (!Array.isArray(processedOptions[ignoreOrSelectBoxes][viewportString]))
5012
- processedOptions[ignoreOrSelectBoxes][viewportString] = [];
4977
+ if (!Array.isArray(processedOptions[ignoreOrSelectBoxes][viewportString])) processedOptions[ignoreOrSelectBoxes][viewportString] = [];
5013
4978
  for (const selector of selectors) {
5014
4979
  if (selector.startsWith("coordinates=")) {
5015
4980
  const coordString = selector.replace("coordinates=", "");
@@ -5107,7 +5072,7 @@ function processSnapshot(snapshot, ctx) {
5107
5072
  processedOptions.selectDOM = options == null ? void 0 : options.selectDOM;
5108
5073
  ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
5109
5074
  }
5110
- const checkPending = () => __async(this, null, function* () {
5075
+ const checkPending = () => __async(null, null, function* () {
5111
5076
  let startTime = Date.now();
5112
5077
  ctx.log.debug(`${pendingRequests.size} Pending requests before wait for ${snapshot.name}: ${Array.from(pendingRequests)}`);
5113
5078
  while (pendingRequests.size > 0) {
@@ -5278,18 +5243,15 @@ var Queue = class {
5278
5243
  let drop = true;
5279
5244
  if (snapshot.options && snapshot.options.web) {
5280
5245
  const webDrop = this.filterWebVariants(snapshot, snapshot.options.web);
5281
- if (!webDrop)
5282
- drop = false;
5246
+ if (!webDrop) drop = false;
5283
5247
  }
5284
5248
  if (snapshot.options && snapshot.options.mobile) {
5285
5249
  const mobileDrop = this.filterMobileVariants(snapshot, snapshot.options.mobile);
5286
- if (!mobileDrop)
5287
- drop = false;
5250
+ if (!mobileDrop) drop = false;
5288
5251
  }
5289
5252
  if (!snapshot.options || snapshot.options && !snapshot.options.web && !snapshot.options.mobile) {
5290
5253
  const configDrop = this.filterVariants(snapshot, config);
5291
- if (!configDrop)
5292
- drop = false;
5254
+ if (!configDrop) drop = false;
5293
5255
  }
5294
5256
  return drop;
5295
5257
  }
@@ -5306,10 +5268,8 @@ var Queue = class {
5306
5268
  const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5307
5269
  if (!this.variants.includes(variant)) {
5308
5270
  allVariantsDropped = false;
5309
- if (!snapshot.options)
5310
- snapshot.options = {};
5311
- if (!snapshot.options.web)
5312
- snapshot.options.web = { browsers: [], viewports: [] };
5271
+ if (!snapshot.options) snapshot.options = {};
5272
+ if (!snapshot.options.web) snapshot.options.web = { browsers: [], viewports: [] };
5313
5273
  if (!snapshot.options.web.browsers.includes(browser)) {
5314
5274
  snapshot.options.web.browsers.push(browser);
5315
5275
  }
@@ -5335,10 +5295,8 @@ var Queue = class {
5335
5295
  const variant = `${snapshot.name}_${device}_${orientation}`;
5336
5296
  if (!this.variants.includes(variant)) {
5337
5297
  allVariantsDropped = false;
5338
- if (!snapshot.options)
5339
- snapshot.options = {};
5340
- if (!snapshot.options.mobile)
5341
- snapshot.options.mobile = { devices: [], orientation: constants_default.MOBILE_ORIENTATION_PORTRAIT, fullPage };
5298
+ if (!snapshot.options) snapshot.options = {};
5299
+ if (!snapshot.options.mobile) snapshot.options.mobile = { devices: [], orientation: constants_default.MOBILE_ORIENTATION_PORTRAIT, fullPage };
5342
5300
  if (!snapshot.options.mobile.devices.includes(device)) {
5343
5301
  snapshot.options.mobile.devices.push(device);
5344
5302
  }
@@ -5657,7 +5615,7 @@ var Queue = class {
5657
5615
  var startTunnel_default = (ctx) => {
5658
5616
  return {
5659
5617
  title: `Starting Tunnel`,
5660
- task: (ctx2, task) => __async(void 0, null, function* () {
5618
+ task: (ctx2, task) => __async(null, null, function* () {
5661
5619
  updateLogContext({ task: "startTunnel" });
5662
5620
  try {
5663
5621
  yield startTunnelBinary(ctx2);
@@ -5883,7 +5841,7 @@ configAppFigma.name("config:create-figma-app").description("Create figma config
5883
5841
  var auth_default = (ctx) => {
5884
5842
  return {
5885
5843
  title: `Authenticating with SmartUI`,
5886
- task: (ctx2, task) => __async(void 0, null, function* () {
5844
+ task: (ctx2, task) => __async(null, null, function* () {
5887
5845
  updateLogContext({ task: "auth" });
5888
5846
  try {
5889
5847
  const { authResult, orgId, userId } = yield ctx2.client.auth(ctx2.log, ctx2.env);
@@ -5909,7 +5867,7 @@ var auth_default = (ctx) => {
5909
5867
  var createBuild_default = (ctx) => {
5910
5868
  return {
5911
5869
  title: `Creating SmartUI build`,
5912
- task: (ctx2, task) => __async(void 0, null, function* () {
5870
+ task: (ctx2, task) => __async(null, null, function* () {
5913
5871
  updateLogContext({ task: "createBuild" });
5914
5872
  try {
5915
5873
  let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name, ctx2.isStartExec, ctx2.env.SMART_GIT, ctx2.options.markBaseline, ctx2.options.baselineBuild, ctx2.options.scheduled, ctx2.env.LT_USERNAME, ctx2.env.LT_ACCESS_KEY);
@@ -6029,14 +5987,10 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
6029
5987
  ctx.log.debug(`Failed resolving tunnel/proxy details: ${e}`);
6030
5988
  }
6031
5989
  let page;
6032
- if (browserName == constants_default.CHROME)
6033
- contextOptions.userAgent = constants_default.CHROME_USER_AGENT;
6034
- else if (browserName == constants_default.FIREFOX)
6035
- contextOptions.userAgent = constants_default.FIREFOX_USER_AGENT;
6036
- else if (browserName == constants_default.SAFARI)
6037
- contextOptions.userAgent = constants_default.SAFARI_USER_AGENT;
6038
- else if (browserName == constants_default.EDGE)
6039
- contextOptions.userAgent = constants_default.EDGE_USER_AGENT;
5990
+ if (browserName == constants_default.CHROME) contextOptions.userAgent = constants_default.CHROME_USER_AGENT;
5991
+ else if (browserName == constants_default.FIREFOX) contextOptions.userAgent = constants_default.FIREFOX_USER_AGENT;
5992
+ else if (browserName == constants_default.SAFARI) contextOptions.userAgent = constants_default.SAFARI_USER_AGENT;
5993
+ else if (browserName == constants_default.EDGE) contextOptions.userAgent = constants_default.EDGE_USER_AGENT;
6040
5994
  if (ctx.config.userAgent || userAgent) {
6041
5995
  if (ctx.config.userAgent !== "") {
6042
5996
  contextOptions.userAgent = ctx.config.userAgent;
@@ -6083,7 +6037,7 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
6083
6037
  yield page.setExtraHTTPHeaders(headersObject);
6084
6038
  }
6085
6039
  if (ctx.env.CAPTURE_RENDERING_ERRORS) {
6086
- yield page.route("**/*", (route, request) => __async(this, null, function* () {
6040
+ yield page.route("**/*", (route, request) => __async(null, null, function* () {
6087
6041
  var _a;
6088
6042
  const requestUrl = request.url();
6089
6043
  const requestHostname = new URL(requestUrl).hostname;
@@ -6145,8 +6099,7 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
6145
6099
  }
6146
6100
  let ssPath = `screenshots/${ssId}/${`${browserName}-${viewport.width}x${viewport.height}`}-${ssId}.png`;
6147
6101
  yield page == null ? void 0 : page.setViewportSize({ width: viewport.width, height: viewport.height || constants_default.MIN_VIEWPORT_HEIGHT });
6148
- if (fullPage)
6149
- yield page == null ? void 0 : page.evaluate(scrollToBottomAndBackToTop);
6102
+ if (fullPage) yield page == null ? void 0 : page.evaluate(scrollToBottomAndBackToTop);
6150
6103
  yield page == null ? void 0 : page.waitForTimeout(waitForTimeout || 0);
6151
6104
  yield executeDocumentScripts(ctx, page, "beforeSnapshot", beforeSnapshotScript);
6152
6105
  discoveryErrors.name = name;
@@ -6225,10 +6178,8 @@ function captureScreenshots(ctx) {
6225
6178
  }
6226
6179
  for (let staticConfig of ctx.webStaticConfig) {
6227
6180
  try {
6228
- if (ctx.options.parallel)
6229
- yield captureScreenshotsAsync(ctx, staticConfig, browsers);
6230
- else
6231
- yield captureScreenshotsSync(ctx, staticConfig, browsers);
6181
+ if (ctx.options.parallel) yield captureScreenshotsAsync(ctx, staticConfig, browsers);
6182
+ else yield captureScreenshotsSync(ctx, staticConfig, browsers);
6232
6183
  delDir(`screenshots/${staticConfig.name.toLowerCase().replace(/\s/g, "_")}`);
6233
6184
  output += `${chalk__default.default.gray(staticConfig.name)} ${chalk__default.default.green("\u2713")}
6234
6185
  `;
@@ -6384,7 +6335,7 @@ function captureScreenshotsConcurrent(ctx) {
6384
6335
  let staticURLChunks = splitURLs(ctx.webStaticConfig, urlsPerInstance);
6385
6336
  let totalCapturedScreenshots = 0;
6386
6337
  let output = "";
6387
- const responses = yield Promise.all(staticURLChunks.map((urlConfig) => __async(this, null, function* () {
6338
+ const responses = yield Promise.all(staticURLChunks.map((urlConfig) => __async(null, null, function* () {
6388
6339
  let { capturedScreenshots, finalOutput } = yield processChunk(ctx, urlConfig);
6389
6340
  return { capturedScreenshots, finalOutput };
6390
6341
  })));
@@ -6456,7 +6407,7 @@ function executeDocumentScripts(ctx, page, actionType, script) {
6456
6407
  var captureScreenshots_default = (ctx) => {
6457
6408
  return {
6458
6409
  title: "Capturing screenshots",
6459
- task: (ctx2, task) => __async(void 0, null, function* () {
6410
+ task: (ctx2, task) => __async(null, null, function* () {
6460
6411
  try {
6461
6412
  ctx2.task = task;
6462
6413
  if (ctx2.options.fetchResults) {
@@ -6558,7 +6509,7 @@ var capture_default = command2;
6558
6509
  var uploadScreenshots_default = (ctx) => {
6559
6510
  return {
6560
6511
  title: "Uploading screenshots",
6561
- task: (ctx2, task) => __async(void 0, null, function* () {
6512
+ task: (ctx2, task) => __async(null, null, function* () {
6562
6513
  try {
6563
6514
  ctx2.task = task;
6564
6515
  if (ctx2.options.fetchResults) {
@@ -6632,7 +6583,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
6632
6583
  var upload_default = command3;
6633
6584
 
6634
6585
  // src/lib/uploadFigmaDesigns.ts
6635
- var uploadFigmaDesigns_default = (ctx) => __async(void 0, null, function* () {
6586
+ var uploadFigmaDesigns_default = (ctx) => __async(null, null, function* () {
6636
6587
  const depth = ctx.figmaDesignConfig.depth;
6637
6588
  const figmaConfigs = ctx.figmaDesignConfig.figma_config;
6638
6589
  let results = "";
@@ -6659,7 +6610,7 @@ var uploadFigmaDesigns_default = (ctx) => __async(void 0, null, function* () {
6659
6610
  var uploadFigmaDesigns_default2 = (ctx) => {
6660
6611
  return {
6661
6612
  title: "Uploading Figma Designs",
6662
- task: (ctx2, task) => __async(void 0, null, function* () {
6613
+ task: (ctx2, task) => __async(null, null, function* () {
6663
6614
  try {
6664
6615
  ctx2.task = task;
6665
6616
  updateLogContext({ task: "upload-figma" });
@@ -6681,7 +6632,7 @@ var uploadFigmaDesigns_default2 = (ctx) => {
6681
6632
  };
6682
6633
 
6683
6634
  // src/lib/uploadWebFigma.ts
6684
- var uploadWebFigma_default = (ctx) => __async(void 0, null, function* () {
6635
+ var uploadWebFigma_default = (ctx) => __async(null, null, function* () {
6685
6636
  var _a, _b;
6686
6637
  const figmaConfig = ctx.config && ((_a = ctx.config) == null ? void 0 : _a.figma) || {};
6687
6638
  const webConfig = ctx.config && ((_b = ctx.config) == null ? void 0 : _b.web) || {};
@@ -6719,7 +6670,7 @@ var uploadWebFigma_default = (ctx) => __async(void 0, null, function* () {
6719
6670
  });
6720
6671
 
6721
6672
  // src/lib/fetchFigma.ts
6722
- var fetchFigma_default = (ctx) => __async(void 0, null, function* () {
6673
+ var fetchFigma_default = (ctx) => __async(null, null, function* () {
6723
6674
  const buildId = ctx.build.id;
6724
6675
  ctx.log.debug(`Fetching figma results for buildId ${buildId}`);
6725
6676
  const startTime = Date.now();
@@ -6764,7 +6715,7 @@ function callFetchWebFigmaRecursive(startTime, buildId, ctx) {
6764
6715
  var uploadWebFigma_default2 = (ctx) => {
6765
6716
  return {
6766
6717
  title: "Processing Web Figma",
6767
- task: (ctx2, task) => __async(void 0, null, function* () {
6718
+ task: (ctx2, task) => __async(null, null, function* () {
6768
6719
  try {
6769
6720
  ctx2.task = task;
6770
6721
  updateLogContext({ task: "upload-figma-web" });
@@ -6796,7 +6747,7 @@ var uploadWebFigma_default2 = (ctx) => {
6796
6747
  };
6797
6748
 
6798
6749
  // src/lib/uploadAppFigma.ts
6799
- var uploadAppFigma_default = (ctx) => __async(void 0, null, function* () {
6750
+ var uploadAppFigma_default = (ctx) => __async(null, null, function* () {
6800
6751
  var _a, _b;
6801
6752
  const figmaConfig = ctx.config && ((_a = ctx.config) == null ? void 0 : _a.figma) || {};
6802
6753
  const mobileConfig = ctx.config && ((_b = ctx.config) == null ? void 0 : _b.mobile) || {};
@@ -6838,7 +6789,7 @@ var uploadAppFigma_default = (ctx) => __async(void 0, null, function* () {
6838
6789
  var uploadAppFigma_default2 = (ctx) => {
6839
6790
  return {
6840
6791
  title: "Processing App Figma",
6841
- task: (ctx2, task) => __async(void 0, null, function* () {
6792
+ task: (ctx2, task) => __async(null, null, function* () {
6842
6793
  try {
6843
6794
  ctx2.task = task;
6844
6795
  updateLogContext({ task: "upload-figma-app" });
@@ -7135,7 +7086,7 @@ var ping_default = command6;
7135
7086
  var fetchBranchInfo_default = (ctx) => {
7136
7087
  return {
7137
7088
  title: `Fetching branch info`,
7138
- task: (ctx2, task) => __async(void 0, null, function* () {
7089
+ task: (ctx2, task) => __async(null, null, function* () {
7139
7090
  updateLogContext({ task: "fetchBranchInfo" });
7140
7091
  try {
7141
7092
  if (ctx2.mergeBranchSource === ctx2.mergeBranchTarget) {
@@ -7173,7 +7124,7 @@ var fetchBranchInfo_default = (ctx) => {
7173
7124
  var mergeBuilds_default = (ctx) => {
7174
7125
  return {
7175
7126
  title: `Merging smartui builds`,
7176
- task: (ctx2, task) => __async(void 0, null, function* () {
7127
+ task: (ctx2, task) => __async(null, null, function* () {
7177
7128
  updateLogContext({ task: "mergeBuilds" });
7178
7129
  try {
7179
7130
  let resp;
@@ -7270,7 +7221,7 @@ var mergeBranch_default = command7;
7270
7221
  var fetchBuildInfo_default = (ctx) => {
7271
7222
  return {
7272
7223
  title: `Fetching build info`,
7273
- task: (ctx2, task) => __async(void 0, null, function* () {
7224
+ task: (ctx2, task) => __async(null, null, function* () {
7274
7225
  updateLogContext({ task: "fetchBuildInfo" });
7275
7226
  try {
7276
7227
  if (ctx2.mergeBuildSource === ctx2.mergeBuildTarget) {
@@ -7425,7 +7376,7 @@ var pingTest_default = command9;
7425
7376
  var uploadPdfs_default = (ctx) => {
7426
7377
  return {
7427
7378
  title: "Uploading PDFs",
7428
- task: (ctx2, task) => __async(void 0, null, function* () {
7379
+ task: (ctx2, task) => __async(null, null, function* () {
7429
7380
  try {
7430
7381
  ctx2.task = task;
7431
7382
  updateLogContext({ task: "upload-pdf" });
@@ -7535,8 +7486,7 @@ LambdaTest SmartUI CLI v${package_default.version}`);
7535
7486
  log2.warn(`This version is deprecated. A new version ${latestVersion} is available!`);
7536
7487
  } else if (package_default.version !== latestVersion) {
7537
7488
  log2.info(chalk__default.default.green(`A new version ${latestVersion} is available!`));
7538
- } else
7539
- log2.info(chalk__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
7489
+ } else log2.info(chalk__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
7540
7490
  } catch (error) {
7541
7491
  log2.debug(error);
7542
7492
  log2.info(chalk__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.48",
3
+ "version": "4.1.49",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"
@@ -39,7 +39,6 @@
39
39
  "node-cache": "^5.1.2",
40
40
  "postcss": "^8.5.6",
41
41
  "sharp": "^0.33.4",
42
- "tsup": "^7.2.0",
43
42
  "uuid": "^11.0.3",
44
43
  "which": "^4.0.0",
45
44
  "winston": "^3.10.0"
@@ -49,7 +48,8 @@
49
48
  },
50
49
  "devDependencies": {
51
50
  "find-free-port": "^2.0.0",
52
- "typescript": "^5.3.2"
51
+ "typescript": "^5.3.2",
52
+ "tsup": "^8.5.1"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsup",