@lambdatest/smartui-cli 4.1.56 → 4.1.57

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 +112 -425
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -306,15 +306,6 @@ var constants_default = {
306
306
  // Disallowed file extension
307
307
  FILE_EXTENSION_ZIP: ".zip",
308
308
  FILE_EXTENSION_GIFS: "gif",
309
- // command types
310
- COMMAND_TYPE_EXEC: "exec",
311
- COMMAND_TYPE_EXEC_START: "exec-start",
312
- COMMAND_TYPE_CAPTURE: "capture",
313
- COMMAND_TYPE_UPLOAD: "upload",
314
- COMMAND_TYPE_UPLOAD_FIGMA: "upload-figma",
315
- COMMAND_TYPE_UPLOAD_PDF: "upload-pdf",
316
- COMMAND_TYPE_MERGE: "merge",
317
- ALLOWED_CUSTOM_VIEWPORT_COMMANDS: ["exec", "exec-start"],
318
309
  // Default scrollTime
319
310
  DEFAULT_SCROLL_TIME: 8,
320
311
  // Default page load time
@@ -640,16 +631,11 @@ var ConfigSchema = {
640
631
  type: "array",
641
632
  items: { type: "string", enum: [constants_default.CHROME, constants_default.FIREFOX, constants_default.SAFARI, constants_default.EDGE] },
642
633
  uniqueItems: true,
643
- minItems: 1,
644
634
  maxItems: 4,
645
- errorMessage: {
646
- minItems: "Invalid config; browsers must have at least one entry",
647
- _: `Invalid config; allowed browsers - ${constants_default.CHROME}, ${constants_default.FIREFOX}, ${constants_default.SAFARI}, ${constants_default.EDGE}`
648
- }
635
+ errorMessage: `Invalid config; allowed browsers - ${constants_default.CHROME}, ${constants_default.FIREFOX}, ${constants_default.SAFARI}, ${constants_default.EDGE}`
649
636
  },
650
637
  viewports: {
651
638
  type: "array",
652
- minItems: 1,
653
639
  items: {
654
640
  type: "array",
655
641
  oneOf: [
@@ -671,51 +657,11 @@ var ConfigSchema = {
671
657
  },
672
658
  uniqueItems: true,
673
659
  maxItems: 5,
674
- errorMessage: {
675
- minItems: "Invalid config; viewports must have at least one entry",
676
- maxItems: "Invalid config; max unique viewports allowed - 5"
677
- }
678
- },
679
- customViewports: {
680
- type: "array",
681
- minItems: 1,
682
- items: {
683
- type: "object",
684
- properties: {
685
- browser: {
686
- type: "string",
687
- enum: [constants_default.CHROME, constants_default.FIREFOX, constants_default.SAFARI, constants_default.EDGE],
688
- errorMessage: `Invalid config; allowed browsers - ${constants_default.CHROME}, ${constants_default.FIREFOX}, ${constants_default.SAFARI}, ${constants_default.EDGE}`
689
- },
690
- viewport: {
691
- type: "array",
692
- oneOf: [
693
- {
694
- items: [{ type: "number", minimum: 320, maximum: 7680 }],
695
- minItems: 1,
696
- maxItems: 1
697
- },
698
- {
699
- items: [
700
- { type: "number", minimum: 320, maximum: 7680 },
701
- { type: "number", minimum: 320, maximum: 7680 }
702
- ],
703
- minItems: 2,
704
- maxItems: 2
705
- }
706
- ],
707
- errorMessage: "Invalid config; customViewports viewport width/height must be >= 320 and <= 7680"
708
- }
709
- },
710
- required: ["browser", "viewport"],
711
- additionalProperties: false
712
- },
713
- errorMessage: {
714
- minItems: "Invalid config; customViewports must have at least one entry",
715
- _: "Invalid config; customViewports must be an array of {browser, viewport} objects"
716
- }
660
+ errorMessage: "Invalid config; max unique viewports allowed - 5"
717
661
  }
718
- }
662
+ },
663
+ required: ["browsers", "viewports"],
664
+ additionalProperties: false
719
665
  },
720
666
  mobile: {
721
667
  type: "object",
@@ -1225,30 +1171,10 @@ var SnapshotSchema = {
1225
1171
  },
1226
1172
  uniqueItems: true,
1227
1173
  errorMessage: "Invalid snapshot options; viewports must be an array of unique arrays."
1228
- },
1229
- customViewports: {
1230
- type: "array",
1231
- items: {
1232
- type: "object",
1233
- properties: {
1234
- browser: {
1235
- type: "string",
1236
- enum: [constants_default.CHROME, constants_default.FIREFOX, constants_default.SAFARI, constants_default.EDGE]
1237
- },
1238
- viewport: {
1239
- type: "array",
1240
- items: { type: "number", minimum: 1 },
1241
- minItems: 1,
1242
- maxItems: 2
1243
- }
1244
- },
1245
- required: ["browser", "viewport"],
1246
- additionalProperties: false
1247
- },
1248
- errorMessage: "Invalid snapshot options; customViewports must be an array of {browser, viewport} objects"
1249
1174
  }
1250
1175
  },
1251
- errorMessage: "Invalid snapshot options; web must include viewports or customViewports property."
1176
+ required: ["viewports"],
1177
+ errorMessage: "Invalid snapshot options; web must include viewports property."
1252
1178
  },
1253
1179
  mobile: {
1254
1180
  type: "object",
@@ -1733,55 +1659,20 @@ function closeBrowsers(browsers) {
1733
1659
  function getWebRenderViewports(ctx) {
1734
1660
  let webRenderViewports = [];
1735
1661
  if (ctx.config.web) {
1736
- if (ctx.config.web.browserViewports) {
1737
- const seen = /* @__PURE__ */ new Set();
1738
- for (const viewports of Object.values(ctx.config.web.browserViewports)) {
1739
- for (const viewport of viewports) {
1740
- const key = `${viewport.width}x${viewport.height}`;
1741
- if (!seen.has(key)) {
1742
- seen.add(key);
1743
- webRenderViewports.push({
1744
- viewport,
1745
- viewportString: `${viewport.width}${viewport.height ? "x" + viewport.height : ""}`,
1746
- fullPage: viewport.height ? false : true,
1747
- device: false
1748
- });
1749
- }
1750
- }
1751
- }
1752
- } else {
1753
- for (const viewport of ctx.config.web.viewports) {
1754
- webRenderViewports.push({
1755
- viewport,
1756
- viewportString: `${viewport.width}${viewport.height ? "x" + viewport.height : ""}`,
1757
- fullPage: viewport.height ? false : true,
1758
- device: false
1759
- });
1760
- }
1662
+ for (const viewport of ctx.config.web.viewports) {
1663
+ webRenderViewports.push({
1664
+ viewport,
1665
+ viewportString: `${viewport.width}${viewport.height ? "x" + viewport.height : ""}`,
1666
+ fullPage: viewport.height ? false : true,
1667
+ device: false
1668
+ });
1761
1669
  }
1762
1670
  }
1763
1671
  return webRenderViewports;
1764
1672
  }
1765
1673
  function getWebRenderViewportsForOptions(options) {
1766
1674
  let webRenderViewports = [];
1767
- if (options.web && Array.isArray(options.web.customViewports) && options.web.customViewports.length > 0) {
1768
- const browserViewports = transformCustomViewportsToBrowserViewports(options.web.customViewports);
1769
- const seen = /* @__PURE__ */ new Set();
1770
- for (const viewports of Object.values(browserViewports)) {
1771
- for (const vp of viewports) {
1772
- const key = `${vp.width}x${vp.height}`;
1773
- if (!seen.has(key)) {
1774
- seen.add(key);
1775
- webRenderViewports.push({
1776
- viewport: vp,
1777
- viewportString: `${vp.width}${vp.height ? "x" + vp.height : ""}`,
1778
- fullPage: vp.height ? false : true,
1779
- device: false
1780
- });
1781
- }
1782
- }
1783
- }
1784
- } else if (options.web && Array.isArray(options.web.viewports)) {
1675
+ if (options.web && Array.isArray(options.web.viewports)) {
1785
1676
  for (const viewport of options.web.viewports) {
1786
1677
  if (Array.isArray(viewport) && viewport.length > 0) {
1787
1678
  let viewportObj = {
@@ -1801,22 +1692,6 @@ function getWebRenderViewportsForOptions(options) {
1801
1692
  }
1802
1693
  return webRenderViewports;
1803
1694
  }
1804
- function transformCustomViewportsToBrowserViewports(customViewports) {
1805
- const browserViewports = {};
1806
- for (const entry of customViewports) {
1807
- if (!browserViewports[entry.browser]) {
1808
- browserViewports[entry.browser] = [];
1809
- }
1810
- const vp = { width: entry.viewport[0], height: entry.viewport[1] || 0 };
1811
- const exists = browserViewports[entry.browser].some(
1812
- (existing) => existing.width === vp.width && existing.height === vp.height
1813
- );
1814
- if (!exists) {
1815
- browserViewports[entry.browser].push(vp);
1816
- }
1817
- }
1818
- return browserViewports;
1819
- }
1820
1695
  function getMobileRenderViewports(ctx) {
1821
1696
  var _a;
1822
1697
  let mobileRenderViewports = {};
@@ -2095,15 +1970,9 @@ function stopTunnelHelper(ctx) {
2095
1970
  function calculateVariantCount(config) {
2096
1971
  let variantCount = 0;
2097
1972
  if (config.web) {
2098
- if (config.web.browserViewports) {
2099
- for (const viewports of Object.values(config.web.browserViewports)) {
2100
- variantCount += viewports.length;
2101
- }
2102
- } else {
2103
- const browsers = config.web.browsers || [];
2104
- const viewports = config.web.viewports || [];
2105
- variantCount += browsers.length * viewports.length;
2106
- }
1973
+ const browsers = config.web.browsers || [];
1974
+ const viewports = config.web.viewports || [];
1975
+ variantCount += browsers.length * viewports.length;
2107
1976
  }
2108
1977
  if (config.mobile) {
2109
1978
  const devices = config.mobile.devices || [];
@@ -2115,15 +1984,9 @@ function calculateVariantCountFromSnapshot(snapshot, globalConfig) {
2115
1984
  var _a, _b;
2116
1985
  let variantCount = 0;
2117
1986
  if ((_a = snapshot.options) == null ? void 0 : _a.web) {
2118
- if (snapshot.options.web.browserViewports) {
2119
- for (const viewports of Object.values(snapshot.options.web.browserViewports)) {
2120
- variantCount += viewports.length;
2121
- }
2122
- } else {
2123
- const browsers = snapshot.options.web.browsers || [];
2124
- const viewports = snapshot.options.web.viewports || [];
2125
- variantCount += browsers.length * viewports.length;
2126
- }
1987
+ const browsers = snapshot.options.web.browsers || [];
1988
+ const viewports = snapshot.options.web.viewports || [];
1989
+ variantCount += browsers.length * viewports.length;
2127
1990
  }
2128
1991
  if ((_b = snapshot.options) == null ? void 0 : _b.mobile) {
2129
1992
  const devices = snapshot.options.mobile.devices || [];
@@ -3124,7 +2987,7 @@ var authExec_default = (ctx) => {
3124
2987
  };
3125
2988
 
3126
2989
  // package.json
3127
- var version = "4.1.56";
2990
+ var version = "4.1.57";
3128
2991
  var package_default = {
3129
2992
  name: "@lambdatest/smartui-cli",
3130
2993
  version,
@@ -3981,7 +3844,7 @@ var httpClient = class {
3981
3844
  }
3982
3845
  };
3983
3846
  var ctx_default = (options) => {
3984
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3847
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3985
3848
  let env = env_default();
3986
3849
  let webConfig;
3987
3850
  let mobileConfig;
@@ -4059,49 +3922,18 @@ var ctx_default = (options) => {
4059
3922
  env.LT_USERNAME = options.userName;
4060
3923
  env.LT_ACCESS_KEY = options.accessKey;
4061
3924
  }
4062
- if (((_b = config.web) == null ? void 0 : _b.customViewports) && !constants_default.ALLOWED_CUSTOM_VIEWPORT_COMMANDS.includes(options.commandType)) {
4063
- throw new Error("customViewports is only supported for the exec command. Use browsers and viewports instead.");
4064
- }
4065
3925
  } catch (error) {
4066
3926
  console.log(`[smartui] Error: ${error.message}`);
4067
3927
  process.exit(1);
4068
3928
  }
4069
3929
  if (config.web) {
4070
- const hasCustomViewports = config.web.customViewports && Array.isArray(config.web.customViewports) && config.web.customViewports.length > 0;
4071
- const hasBrowsersAndViewports = config.web.browsers && config.web.browsers.length > 0 && config.web.viewports && config.web.viewports.length > 0;
4072
- if (!hasCustomViewports && !hasBrowsersAndViewports) {
4073
- throw new Error("Invalid config; web config must have either customViewports or both browsers and viewports");
4074
- }
4075
- if (hasCustomViewports) {
4076
- const browserViewports = {};
4077
- for (const entry of config.web.customViewports) {
4078
- const vp = { width: entry.viewport[0], height: entry.viewport[1] || 0 };
4079
- if (!browserViewports[entry.browser]) browserViewports[entry.browser] = [];
4080
- if (!browserViewports[entry.browser].some((v) => v.width === vp.width && v.height === vp.height)) {
4081
- browserViewports[entry.browser].push(vp);
4082
- }
4083
- }
4084
- const browsers = Object.keys(browserViewports);
4085
- const allViewports = [];
4086
- for (const vps of Object.values(browserViewports)) {
4087
- for (const vp of vps) {
4088
- if (!allViewports.some((v) => v.width === vp.width && v.height === vp.height)) {
4089
- allViewports.push(vp);
4090
- }
4091
- }
4092
- }
4093
- webConfig = { browsers, viewports: allViewports, browserViewports };
4094
- } else {
4095
- webConfig = { browsers: config.web.browsers, viewports: [] };
4096
- if ((_c = config.web) == null ? void 0 : _c.viewports) {
4097
- for (let viewport of config.web.viewports) webConfig.viewports.push({ width: viewport[0], height: viewport[1] || 0 });
4098
- }
4099
- }
3930
+ webConfig = { browsers: config.web.browsers, viewports: [] };
3931
+ for (let viewport of (_b = config.web) == null ? void 0 : _b.viewports) webConfig.viewports.push({ width: viewport[0], height: viewport[1] || 0 });
4100
3932
  }
4101
3933
  if (config.mobile) {
4102
3934
  mobileConfig = {
4103
3935
  devices: config.mobile.devices,
4104
- fullPage: (_d = config.mobile.fullPage) != null ? _d : true,
3936
+ fullPage: (_c = config.mobile.fullPage) != null ? _c : true,
4105
3937
  orientation: config.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT
4106
3938
  };
4107
3939
  }
@@ -4168,18 +4000,18 @@ var ctx_default = (options) => {
4168
4000
  waitForPageRender: config.waitForPageRender || 0,
4169
4001
  waitForTimeout: config.waitForTimeout || 0,
4170
4002
  waitForDiscovery: config.waitForDiscovery || 3e4,
4171
- enableJavaScript: (_e = config.enableJavaScript) != null ? _e : false,
4172
- cliEnableJavaScript: (_f = config.cliEnableJavaScript) != null ? _f : true,
4003
+ enableJavaScript: (_d = config.enableJavaScript) != null ? _d : false,
4004
+ cliEnableJavaScript: (_e = config.cliEnableJavaScript) != null ? _e : true,
4173
4005
  scrollTime: config.scrollTime || constants_default.DEFAULT_SCROLL_TIME,
4174
4006
  allowedHostnames: config.allowedHostnames || [],
4175
4007
  allowedAssets: config.allowedAssets || [],
4176
4008
  basicAuthorization: basicAuthObj,
4177
4009
  lazyLoadConfiguration: lazyLoadConfigObj,
4178
- smartIgnore: (_g = config.smartIgnore) != null ? _g : false,
4179
- delayedUpload: (_h = config.delayedUpload) != null ? _h : false,
4180
- useGlobalCache: (_i = config.useGlobalCache) != null ? _i : false,
4181
- ignoreHTTPSErrors: (_j = config.ignoreHTTPSErrors) != null ? _j : false,
4182
- skipBuildCreation: (_k = config.skipBuildCreation) != null ? _k : false,
4010
+ smartIgnore: (_f = config.smartIgnore) != null ? _f : false,
4011
+ delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
4012
+ useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
4013
+ ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
4014
+ skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
4183
4015
  tunnel: tunnelObj,
4184
4016
  dedicatedProxyURL: config.dedicatedProxyURL || "",
4185
4017
  geolocation: config.geolocation || "",
@@ -4192,7 +4024,7 @@ var ctx_default = (options) => {
4192
4024
  loadDomContent,
4193
4025
  approvalThreshold: config.approvalThreshold,
4194
4026
  rejectionThreshold: config.rejectionThreshold,
4195
- showRenderErrors: (_l = config.showRenderErrors) != null ? _l : false,
4027
+ showRenderErrors: (_k = config.showRenderErrors) != null ? _k : false,
4196
4028
  customCSS: config.customCSS
4197
4029
  },
4198
4030
  uploadFilePath: "",
@@ -4726,7 +4558,6 @@ var normalizeSameSite = (value) => {
4726
4558
  };
4727
4559
  function prepareSnapshot(snapshot, ctx) {
4728
4560
  return __async(this, null, function* () {
4729
- var _a, _b;
4730
4561
  let processedOptions = {};
4731
4562
  processedOptions.cliEnableJavascript = ctx.config.cliEnableJavaScript;
4732
4563
  processedOptions.ignoreHTTPSErrors = ctx.config.ignoreHTTPSErrors;
@@ -4748,8 +4579,8 @@ function prepareSnapshot(snapshot, ctx) {
4748
4579
  if (options && Object.keys(options).length) {
4749
4580
  ctx.log.debug(`Snapshot options: ${JSON.stringify(options)}`);
4750
4581
  const isNotAllEmpty = (obj) => {
4751
- var _a2;
4752
- for (let key in obj) if ((_a2 = obj[key]) == null ? void 0 : _a2.length) return true;
4582
+ var _a;
4583
+ for (let key in obj) if ((_a = obj[key]) == null ? void 0 : _a.length) return true;
4753
4584
  return false;
4754
4585
  };
4755
4586
  if (options.loadDomContent) {
@@ -4770,20 +4601,13 @@ function prepareSnapshot(snapshot, ctx) {
4770
4601
  }
4771
4602
  if (options.web && Object.keys(options.web).length) {
4772
4603
  processedOptions.web = {};
4773
- if (options.web.customViewports && Array.isArray(options.web.customViewports) && options.web.customViewports.length > 0) {
4774
- processedOptions.web.browserViewports = transformCustomViewportsToBrowserViewports(options.web.customViewports);
4775
- } else {
4776
- if (options.web.viewports && options.web.viewports.length > 0) {
4777
- processedOptions.web.viewports = options.web.viewports.filter(
4778
- (viewport) => Array.isArray(viewport) && viewport.length > 0
4779
- );
4780
- }
4781
- if (options.web.browsers && options.web.browsers.length > 0) {
4782
- processedOptions.web.browsers = options.web.browsers;
4783
- }
4604
+ if (options.web.viewports && options.web.viewports.length > 0) {
4605
+ processedOptions.web.viewports = options.web.viewports.filter(
4606
+ (viewport) => Array.isArray(viewport) && viewport.length > 0
4607
+ );
4784
4608
  }
4785
- if (Object.keys(processedOptions.web).length === 0) {
4786
- delete processedOptions.web;
4609
+ if (options.web.browsers && options.web.browsers.length > 0) {
4610
+ processedOptions.web.browsers = options.web.browsers;
4787
4611
  }
4788
4612
  }
4789
4613
  if (options.mobile && Object.keys(options.mobile).length) {
@@ -4839,16 +4663,6 @@ function prepareSnapshot(snapshot, ctx) {
4839
4663
  processedOptions.ignoreType = options.ignoreType;
4840
4664
  }
4841
4665
  }
4842
- if (!processedOptions.web && ((_a = ctx.config.web) == null ? void 0 : _a.browserViewports)) {
4843
- processedOptions.web = { browserViewports: ctx.config.web.browserViewports };
4844
- }
4845
- if (!processedOptions.mobile && ctx.config.mobile) {
4846
- processedOptions.mobile = {
4847
- devices: ctx.config.mobile.devices,
4848
- fullPage: (_b = ctx.config.mobile.fullPage) != null ? _b : true,
4849
- orientation: ctx.config.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT
4850
- };
4851
- }
4852
4666
  if (ctx.config.tunnel) {
4853
4667
  if (ctx.tunnelDetails && ctx.tunnelDetails.tunnelPort != -1 && ctx.tunnelDetails.tunnelHost != "") {
4854
4668
  const tunnelAddress = `http://${ctx.tunnelDetails.tunnelHost}:${ctx.tunnelDetails.tunnelPort}`;
@@ -4920,7 +4734,7 @@ function prepareSnapshot(snapshot, ctx) {
4920
4734
  }
4921
4735
  function processSnapshot(snapshot, ctx) {
4922
4736
  return __async(this, null, function* () {
4923
- var _a, _b, _c, _d;
4737
+ var _a, _b;
4924
4738
  updateLogContext({ task: "discovery" });
4925
4739
  ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
4926
4740
  const isHeadless = ((_a = process.env.HEADLESS) == null ? void 0 : _a.toLowerCase()) === "false" ? false : true;
@@ -5209,20 +5023,13 @@ function processSnapshot(snapshot, ctx) {
5209
5023
  }
5210
5024
  if (options.web && Object.keys(options.web).length) {
5211
5025
  processedOptions.web = {};
5212
- if (options.web.customViewports && Array.isArray(options.web.customViewports) && options.web.customViewports.length > 0) {
5213
- processedOptions.web.browserViewports = transformCustomViewportsToBrowserViewports(options.web.customViewports);
5214
- } else {
5215
- if (options.web.viewports && options.web.viewports.length > 0) {
5216
- processedOptions.web.viewports = options.web.viewports.filter(
5217
- (viewport) => Array.isArray(viewport) && viewport.length > 0
5218
- );
5219
- }
5220
- if (options.web.browsers && options.web.browsers.length > 0) {
5221
- processedOptions.web.browsers = options.web.browsers;
5222
- }
5026
+ if (options.web.viewports && options.web.viewports.length > 0) {
5027
+ processedOptions.web.viewports = options.web.viewports.filter(
5028
+ (viewport) => Array.isArray(viewport) && viewport.length > 0
5029
+ );
5223
5030
  }
5224
- if (Object.keys(processedOptions.web).length === 0) {
5225
- delete processedOptions.web;
5031
+ if (options.web.browsers && options.web.browsers.length > 0) {
5032
+ processedOptions.web.browsers = options.web.browsers;
5226
5033
  }
5227
5034
  }
5228
5035
  if (options.mobile && Object.keys(options.mobile).length) {
@@ -5280,16 +5087,6 @@ function processSnapshot(snapshot, ctx) {
5280
5087
  processedOptions.ignoreType = options.ignoreType;
5281
5088
  }
5282
5089
  }
5283
- if (!processedOptions.web && ((_c = ctx.config.web) == null ? void 0 : _c.browserViewports)) {
5284
- processedOptions.web = { browserViewports: ctx.config.web.browserViewports };
5285
- }
5286
- if (!processedOptions.mobile && ctx.config.mobile) {
5287
- processedOptions.mobile = {
5288
- devices: ctx.config.mobile.devices,
5289
- fullPage: (_d = ctx.config.mobile.fullPage) != null ? _d : true,
5290
- orientation: ctx.config.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT
5291
- };
5292
- }
5293
5090
  if (ctx.config.tunnel) {
5294
5091
  if (ctx.tunnelDetails && ctx.tunnelDetails.tunnelPort != -1 && ctx.tunnelDetails.tunnelHost != "") {
5295
5092
  const tunnelAddress = `http://${ctx.tunnelDetails.tunnelHost}:${ctx.tunnelDetails.tunnelPort}`;
@@ -5661,42 +5458,28 @@ var Queue = class {
5661
5458
  }
5662
5459
  }
5663
5460
  processGenerateVariants(snapshot) {
5664
- var _a, _b;
5665
- let hasWebOptions = ((_a = snapshot.options) == null ? void 0 : _a.web) && Object.keys(snapshot.options.web).length > 0;
5666
- let hasMobileOptions = ((_b = snapshot.options) == null ? void 0 : _b.mobile) && Object.keys(snapshot.options.mobile).length > 0;
5667
5461
  if (snapshot.options) {
5668
- if (hasWebOptions) {
5462
+ if (snapshot.options.web) {
5669
5463
  this.generateWebVariants(snapshot, snapshot.options.web);
5670
5464
  }
5671
- if (hasMobileOptions) {
5465
+ if (snapshot.options.mobile) {
5672
5466
  this.generateMobileVariants(snapshot, snapshot.options.mobile);
5673
5467
  }
5674
5468
  }
5675
- if (!snapshot.options || !hasWebOptions && !hasMobileOptions) {
5469
+ if (!snapshot.options || snapshot.options && !snapshot.options.web && !snapshot.options.mobile) {
5676
5470
  this.generateVariants(snapshot, this.ctx.config);
5677
5471
  }
5678
5472
  }
5679
5473
  generateVariants(snapshot, config) {
5680
5474
  if (config.web) {
5681
- if (config.web.browserViewports) {
5682
- for (const [browser, viewports] of Object.entries(config.web.browserViewports)) {
5683
- for (const viewport of viewports) {
5684
- const width = viewport.width;
5685
- const height = viewport.height || 0;
5686
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5687
- this.variants.push(variant);
5688
- }
5689
- }
5690
- } else {
5691
- const browsers = config.web.browsers || [];
5692
- const viewports = config.web.viewports || [];
5693
- for (const browser of browsers) {
5694
- for (const viewport of viewports) {
5695
- const width = viewport.width;
5696
- const height = viewport.height || 0;
5697
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5698
- this.variants.push(variant);
5699
- }
5475
+ const browsers = config.web.browsers || [];
5476
+ const viewports = config.web.viewports || [];
5477
+ for (const browser of browsers) {
5478
+ for (const viewport of viewports) {
5479
+ const width = viewport.width;
5480
+ const height = viewport.height || 0;
5481
+ const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5482
+ this.variants.push(variant);
5700
5483
  }
5701
5484
  }
5702
5485
  }
@@ -5711,24 +5494,15 @@ var Queue = class {
5711
5494
  }
5712
5495
  generateWebVariants(snapshot, webConfig) {
5713
5496
  var _a, _b, _c;
5714
- if (webConfig.customViewports && Array.isArray(webConfig.customViewports) && webConfig.customViewports.length > 0) {
5715
- for (const entry of webConfig.customViewports) {
5716
- const width = entry.viewport[0];
5717
- const height = entry.viewport[1] || 0;
5718
- const variant = `${snapshot.name}_${entry.browser}_viewport[${width}]_viewport[${height}]`;
5497
+ const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? void 0 : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
5498
+ const viewports = webConfig.viewports || [];
5499
+ for (const browser of browsers) {
5500
+ for (const viewport of viewports) {
5501
+ const width = viewport[0];
5502
+ const height = viewport[1] || 0;
5503
+ const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5719
5504
  this.variants.push(variant);
5720
5505
  }
5721
- } else {
5722
- const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? void 0 : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
5723
- const viewports = webConfig.viewports || [];
5724
- for (const browser of browsers) {
5725
- for (const viewport of viewports) {
5726
- const width = viewport[0];
5727
- const height = viewport[1] || 0;
5728
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5729
- this.variants.push(variant);
5730
- }
5731
- }
5732
5506
  }
5733
5507
  }
5734
5508
  generateMobileVariants(snapshot, mobileConfig) {
@@ -5741,19 +5515,16 @@ var Queue = class {
5741
5515
  }
5742
5516
  }
5743
5517
  filterExistingVariants(snapshot, config) {
5744
- var _a, _b;
5745
5518
  let drop = true;
5746
- let hasWebOptions = ((_a = snapshot.options) == null ? void 0 : _a.web) && Object.keys(snapshot.options.web).length > 0;
5747
- let hasMobileOptions = ((_b = snapshot.options) == null ? void 0 : _b.mobile) && Object.keys(snapshot.options.mobile).length > 0;
5748
- if (snapshot.options && hasWebOptions) {
5519
+ if (snapshot.options && snapshot.options.web) {
5749
5520
  const webDrop = this.filterWebVariants(snapshot, snapshot.options.web);
5750
5521
  if (!webDrop) drop = false;
5751
5522
  }
5752
- if (snapshot.options && hasMobileOptions) {
5523
+ if (snapshot.options && snapshot.options.mobile) {
5753
5524
  const mobileDrop = this.filterMobileVariants(snapshot, snapshot.options.mobile);
5754
5525
  if (!mobileDrop) drop = false;
5755
5526
  }
5756
- if (!snapshot.options || !hasWebOptions && !hasMobileOptions) {
5527
+ if (!snapshot.options || snapshot.options && !snapshot.options.web && !snapshot.options.mobile) {
5757
5528
  const configDrop = this.filterVariants(snapshot, config);
5758
5529
  if (!configDrop) drop = false;
5759
5530
  }
@@ -5763,63 +5534,28 @@ var Queue = class {
5763
5534
  var _a;
5764
5535
  let allVariantsDropped = true;
5765
5536
  if (config.web) {
5766
- if (config.web.browserViewports) {
5767
- const customViewports = [];
5768
- for (const [browser, viewports] of Object.entries(config.web.browserViewports)) {
5769
- for (const viewport of viewports) {
5770
- const width = viewport.width;
5771
- const height = viewport.height || 0;
5772
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5773
- if (!this.variants.includes(variant)) {
5774
- allVariantsDropped = false;
5775
- if (height > 0) {
5776
- customViewports.push({ browser, viewport: [width, height] });
5777
- } else {
5778
- customViewports.push({ browser, viewport: [width] });
5779
- }
5780
- }
5781
- }
5782
- }
5783
- if (customViewports.length > 0) {
5784
- if (!snapshot.options) snapshot.options = {};
5785
- snapshot.options.web = { browsers: [], viewports: [], customViewports };
5786
- for (const entry of customViewports) {
5787
- if (!snapshot.options.web.browsers.includes(entry.browser)) {
5788
- snapshot.options.web.browsers.push(entry.browser);
5537
+ const browsers = config.web.browsers || [];
5538
+ const viewports = config.web.viewports || [];
5539
+ for (const browser of browsers) {
5540
+ for (const viewport of viewports) {
5541
+ const width = viewport.width;
5542
+ const height = viewport.height || 0;
5543
+ const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5544
+ if (!this.variants.includes(variant)) {
5545
+ allVariantsDropped = false;
5546
+ if (!snapshot.options) snapshot.options = {};
5547
+ if (!snapshot.options.web) snapshot.options.web = { browsers: [], viewports: [] };
5548
+ if (!snapshot.options.web.browsers.includes(browser)) {
5549
+ snapshot.options.web.browsers.push(browser);
5789
5550
  }
5790
- const vp = entry.viewport;
5791
5551
  const viewportExists = snapshot.options.web.viewports.some(
5792
- (ev) => ev[0] === vp[0] && (ev.length < 2 || ev[1] === (vp[1] || 0))
5552
+ (existingViewport) => existingViewport[0] === width && (existingViewport.length < 2 || existingViewport[1] === height)
5793
5553
  );
5794
5554
  if (!viewportExists) {
5795
- snapshot.options.web.viewports.push(vp);
5796
- }
5797
- }
5798
- }
5799
- } else {
5800
- const browsers = config.web.browsers || [];
5801
- const viewports = config.web.viewports || [];
5802
- for (const browser of browsers) {
5803
- for (const viewport of viewports) {
5804
- const width = viewport.width;
5805
- const height = viewport.height || 0;
5806
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5807
- if (!this.variants.includes(variant)) {
5808
- allVariantsDropped = false;
5809
- if (!snapshot.options) snapshot.options = {};
5810
- if (!snapshot.options.web) snapshot.options.web = { browsers: [], viewports: [] };
5811
- if (!snapshot.options.web.browsers.includes(browser)) {
5812
- snapshot.options.web.browsers.push(browser);
5813
- }
5814
- const viewportExists = snapshot.options.web.viewports.some(
5815
- (existingViewport) => existingViewport[0] === width && (existingViewport.length < 2 || existingViewport[1] === height)
5816
- );
5817
- if (!viewportExists) {
5818
- if (height > 0) {
5819
- snapshot.options.web.viewports.push([width, height]);
5820
- } else {
5821
- snapshot.options.web.viewports.push([width]);
5822
- }
5555
+ if (height > 0) {
5556
+ snapshot.options.web.viewports.push([width, height]);
5557
+ } else {
5558
+ snapshot.options.web.viewports.push([width]);
5823
5559
  }
5824
5560
  }
5825
5561
  }
@@ -5847,60 +5583,31 @@ var Queue = class {
5847
5583
  }
5848
5584
  filterWebVariants(snapshot, webConfig) {
5849
5585
  var _a, _b, _c;
5586
+ const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? void 0 : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
5587
+ const viewports = webConfig.viewports || [];
5850
5588
  let allVariantsDropped = true;
5851
5589
  if (!snapshot.options) {
5852
5590
  snapshot.options = {};
5853
5591
  }
5854
- if (webConfig.customViewports && Array.isArray(webConfig.customViewports) && webConfig.customViewports.length > 0) {
5855
- const filteredCustomViewports = [];
5856
- const browsers = [];
5857
- const viewports = [];
5858
- for (const entry of webConfig.customViewports) {
5859
- const width = entry.viewport[0];
5860
- const height = entry.viewport[1] || 0;
5861
- const variant = `${snapshot.name}_${entry.browser}_viewport[${width}]_viewport[${height}]`;
5592
+ snapshot.options.web = { browsers: [], viewports: [] };
5593
+ for (const browser of browsers) {
5594
+ for (const viewport of viewports) {
5595
+ const width = viewport[0];
5596
+ const height = viewport[1] || 0;
5597
+ const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5862
5598
  if (!this.variants.includes(variant)) {
5863
5599
  allVariantsDropped = false;
5864
- filteredCustomViewports.push(entry);
5865
- if (!browsers.includes(entry.browser)) {
5866
- browsers.push(entry.browser);
5600
+ if (!snapshot.options.web.browsers.includes(browser)) {
5601
+ snapshot.options.web.browsers.push(browser);
5867
5602
  }
5868
- const viewportExists = viewports.some(
5869
- (ev) => ev[0] === width && (ev.length < 2 || ev[1] === height)
5603
+ const viewportExists = snapshot.options.web.viewports.some(
5604
+ (existingViewport) => existingViewport[0] === width && (existingViewport.length < 2 || existingViewport[1] === height)
5870
5605
  );
5871
5606
  if (!viewportExists) {
5872
5607
  if (height > 0) {
5873
- viewports.push([width, height]);
5608
+ snapshot.options.web.viewports.push([width, height]);
5874
5609
  } else {
5875
- viewports.push([width]);
5876
- }
5877
- }
5878
- }
5879
- }
5880
- snapshot.options.web = { browsers, viewports, customViewports: filteredCustomViewports };
5881
- } else {
5882
- snapshot.options.web = { browsers: [], viewports: [] };
5883
- const browsers = (_c = (_b = webConfig.browsers) != null ? _b : (_a = this.ctx.config.web) == null ? void 0 : _a.browsers) != null ? _c : [constants_default.CHROME, constants_default.EDGE, constants_default.FIREFOX, constants_default.SAFARI];
5884
- const viewports = webConfig.viewports || [];
5885
- for (const browser of browsers) {
5886
- for (const viewport of viewports) {
5887
- const width = viewport[0];
5888
- const height = viewport[1] || 0;
5889
- const variant = `${snapshot.name}_${browser}_viewport[${width}]_viewport[${height}]`;
5890
- if (!this.variants.includes(variant)) {
5891
- allVariantsDropped = false;
5892
- if (!snapshot.options.web.browsers.includes(browser)) {
5893
- snapshot.options.web.browsers.push(browser);
5894
- }
5895
- const viewportExists = snapshot.options.web.viewports.some(
5896
- (existingViewport) => existingViewport[0] === width && (existingViewport.length < 2 || existingViewport[1] === height)
5897
- );
5898
- if (!viewportExists) {
5899
- if (height > 0) {
5900
- snapshot.options.web.viewports.push([width, height]);
5901
- } else {
5902
- snapshot.options.web.viewports.push([width]);
5903
- }
5610
+ snapshot.options.web.viewports.push([width]);
5904
5611
  }
5905
5612
  }
5906
5613
  }
@@ -6211,9 +5918,7 @@ command.name("exec").description("Run test commands around SmartUI").argument("<
6211
5918
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
6212
5919
  process.exit(1);
6213
5920
  }
6214
- let opts = command11.optsWithGlobals();
6215
- opts.commandType = constants_default.COMMAND_TYPE_EXEC;
6216
- let ctx = ctx_default(opts);
5921
+ let ctx = ctx_default(command11.optsWithGlobals());
6217
5922
  if (!which__default.default.sync(execCommand[0], { nothrow: true })) {
6218
5923
  ctx.log.error(`Error: Command not found "${execCommand[0]}"`);
6219
5924
  return;
@@ -7054,9 +6759,7 @@ command2.name("capture").description("Capture screenshots of static sites").argu
7054
6759
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
7055
6760
  process.exit(1);
7056
6761
  }
7057
- let opts = command11.optsWithGlobals();
7058
- opts.commandType = constants_default.COMMAND_TYPE_CAPTURE;
7059
- let ctx = ctx_default(opts);
6762
+ let ctx = ctx_default(command11.optsWithGlobals());
7060
6763
  ctx.isSnapshotCaptured = true;
7061
6764
  if (!fs6__default.default.existsSync(file)) {
7062
6765
  ctx.log.error(`Web Static Config file ${file} not found.`);
@@ -7151,9 +6854,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
7151
6854
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
7152
6855
  process.exit(1);
7153
6856
  }
7154
- let opts = command11.optsWithGlobals();
7155
- opts.commandType = constants_default.COMMAND_TYPE_UPLOAD;
7156
- let ctx = ctx_default(opts);
6857
+ let ctx = ctx_default(command11.optsWithGlobals());
7157
6858
  ctx.isSnapshotCaptured = true;
7158
6859
  if (!fs6__default.default.existsSync(directory)) {
7159
6860
  console.log(`Error: The provided directory ${directory} not found.`);
@@ -7436,9 +7137,7 @@ var uploadAppFigmaCommand = new commander.Command();
7436
7137
  uploadFigma.name("upload-figma").description("Capture screenshots of static sites").argument("<file>", "figma design config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").action(function(file, _, command11) {
7437
7138
  return __async(this, null, function* () {
7438
7139
  var _a, _b;
7439
- let opts = command11.optsWithGlobals();
7440
- opts.commandType = constants_default.COMMAND_TYPE_UPLOAD_FIGMA;
7441
- let ctx = ctx_default(opts);
7140
+ let ctx = ctx_default(command11.optsWithGlobals());
7442
7141
  ctx.isSnapshotCaptured = true;
7443
7142
  if (!fs6__default.default.existsSync(file)) {
7444
7143
  console.log(`Error: Figma Config file ${file} not found.`);
@@ -7480,9 +7179,7 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
7480
7179
  uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screenshots into CLI build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command11) {
7481
7180
  return __async(this, null, function* () {
7482
7181
  var _a;
7483
- let opts = command11.optsWithGlobals();
7484
- opts.commandType = constants_default.COMMAND_TYPE_UPLOAD_FIGMA;
7485
- let ctx = ctx_default(opts);
7182
+ let ctx = ctx_default(command11.optsWithGlobals());
7486
7183
  if (!fs6__default.default.existsSync(file)) {
7487
7184
  console.log(`Error: figma-web config file ${file} not found.`);
7488
7185
  return;
@@ -7535,9 +7232,7 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screen
7535
7232
  uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screenshots into App Build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command11) {
7536
7233
  return __async(this, null, function* () {
7537
7234
  var _a;
7538
- let opts = command11.optsWithGlobals();
7539
- opts.commandType = constants_default.COMMAND_TYPE_UPLOAD_FIGMA;
7540
- let ctx = ctx_default(opts);
7235
+ let ctx = ctx_default(command11.optsWithGlobals());
7541
7236
  if (!fs6__default.default.existsSync(file)) {
7542
7237
  console.log(`Error: figma-app config file ${file} not found.`);
7543
7238
  return;
@@ -7596,9 +7291,7 @@ command4.name("exec:start").description("Start SmartUI server").option("-P, --po
7596
7291
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
7597
7292
  process.exit(1);
7598
7293
  }
7599
- let opts = command4.optsWithGlobals();
7600
- opts.commandType = constants_default.COMMAND_TYPE_EXEC_START;
7601
- let ctx = ctx_default(opts);
7294
+ let ctx = ctx_default(command4.optsWithGlobals());
7602
7295
  ctx.snapshotQueue = new Queue(ctx);
7603
7296
  ctx.totalSnapshots = 0;
7604
7297
  ctx.isStartExec = true;
@@ -7798,9 +7491,7 @@ var command7 = new commander.Command();
7798
7491
  command7.name("branch").description("Merge a source branch into the target branch").requiredOption("--source <string>", "Source branch to merge").requiredOption("--target <string>", "Target branch to merge into").action(function(options) {
7799
7492
  return __async(this, null, function* () {
7800
7493
  const { source, target } = options;
7801
- let opts = command7.optsWithGlobals();
7802
- opts.commandType = constants_default.COMMAND_TYPE_MERGE;
7803
- let ctx = ctx_default(opts);
7494
+ let ctx = ctx_default(command7.optsWithGlobals());
7804
7495
  if (!source || source.trim() === "") {
7805
7496
  ctx.log.error("Error: The --source option cannot be empty.");
7806
7497
  process.exit(1);
@@ -7883,9 +7574,7 @@ var command8 = new commander.Command();
7883
7574
  command8.name("build").description("Merge a source build into the target build").requiredOption("--source <string>", "Source build to merge").requiredOption("--target <string>", "Target build to merge into").action(function(options) {
7884
7575
  return __async(this, null, function* () {
7885
7576
  const { source, target } = options;
7886
- let opts = command8.optsWithGlobals();
7887
- opts.commandType = constants_default.COMMAND_TYPE_MERGE;
7888
- let ctx = ctx_default(opts);
7577
+ let ctx = ctx_default(command8.optsWithGlobals());
7889
7578
  if (!source || source.trim() === "") {
7890
7579
  ctx.log.error("Error: The --source option cannot be empty.");
7891
7580
  process.exit(1);
@@ -8057,9 +7746,7 @@ command10.name("upload-pdf").description("Upload PDFs for visual comparison").ar
8057
7746
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
8058
7747
  process.exit(1);
8059
7748
  }
8060
- let opts = command11.optsWithGlobals();
8061
- opts.commandType = constants_default.COMMAND_TYPE_UPLOAD_PDF;
8062
- let ctx = ctx_default(opts);
7749
+ let ctx = ctx_default(command11.optsWithGlobals());
8063
7750
  if (!fs6__default.default.existsSync(directory)) {
8064
7751
  console.log(`Error: The provided directory ${directory} not found.`);
8065
7752
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.56",
3
+ "version": "4.1.57",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"