@lambdatest/smartui-cli 4.0.21 → 4.1.0

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 +140 -42
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7,7 +7,7 @@ var listr2 = require('listr2');
7
7
  var chalk = require('chalk');
8
8
  var path2 = require('path');
9
9
  var fastify = require('fastify');
10
- var fs5 = require('fs');
10
+ var fs6 = require('fs');
11
11
  var Ajv = require('ajv');
12
12
  var addErrors = require('ajv-errors');
13
13
  var test = require('@playwright/test');
@@ -27,7 +27,7 @@ var which__default = /*#__PURE__*/_interopDefault(which);
27
27
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
28
28
  var path2__default = /*#__PURE__*/_interopDefault(path2);
29
29
  var fastify__default = /*#__PURE__*/_interopDefault(fastify);
30
- var fs5__default = /*#__PURE__*/_interopDefault(fs5);
30
+ var fs6__default = /*#__PURE__*/_interopDefault(fs6);
31
31
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
32
32
  var addErrors__default = /*#__PURE__*/_interopDefault(addErrors);
33
33
  var FormData__default = /*#__PURE__*/_interopDefault(FormData);
@@ -419,6 +419,7 @@ var constants_default = {
419
419
  "Xperia 10 IV": { os: "android", viewport: { width: 412, height: 832 } },
420
420
  "Honeywell CT40": { os: "android", viewport: { width: 360, height: 512 } }
421
421
  },
422
+ FIGMA_API: "https://api.figma.com/v1/",
422
423
  DEFAULT_FIGMA_CONFIG: {
423
424
  "depth": 2,
424
425
  "figma_config": [
@@ -637,6 +638,17 @@ var WebStaticConfigSchema = {
637
638
  minimum: 0,
638
639
  maximum: 3e4,
639
640
  errorMessage: "waitForTimeout must be > 0 and <= 30000"
641
+ },
642
+ execute: {
643
+ type: "object",
644
+ properties: {
645
+ afterNavigation: {
646
+ type: "string"
647
+ },
648
+ beforeSnapshot: {
649
+ type: "string"
650
+ }
651
+ }
640
652
  }
641
653
  },
642
654
  required: ["name", "url"],
@@ -966,8 +978,8 @@ var validateWebFigmaConfig = ajv.compile(FigmaWebConfigSchema);
966
978
  util.promisify(setTimeout);
967
979
  var isPollingActive = false;
968
980
  function delDir(dir) {
969
- if (fs5__default.default.existsSync(dir)) {
970
- fs5__default.default.rmSync(dir, { recursive: true });
981
+ if (fs6__default.default.existsSync(dir)) {
982
+ fs6__default.default.rmSync(dir, { recursive: true });
971
983
  }
972
984
  }
973
985
  function scrollToBottomAndBackToTop({
@@ -1167,7 +1179,7 @@ function startPolling(ctx) {
1167
1179
  clearInterval(intervalId);
1168
1180
  isPollingActive = false;
1169
1181
  }
1170
- fs5__default.default.writeFileSync(ctx.options.fetchResultsFileName, JSON.stringify(resp, null, 2));
1182
+ fs6__default.default.writeFileSync(ctx.options.fetchResultsFileName, JSON.stringify(resp, null, 2));
1171
1183
  ctx.log.debug(`Updated results in ${ctx.options.fetchResultsFileName}`);
1172
1184
  if (resp.build.build_status_ind === constants_default.BUILD_COMPLETE || resp.build.build_status_ind === constants_default.BUILD_ERROR) {
1173
1185
  clearInterval(intervalId);
@@ -1252,7 +1264,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
1252
1264
  bodyLimit: 3e7
1253
1265
  });
1254
1266
  const opts = {};
1255
- const SMARTUI_DOM = fs5.readFileSync(path2__default.default.resolve(__dirname, "dom-serializer.js"), "utf-8");
1267
+ const SMARTUI_DOM = fs6.readFileSync(path2__default.default.resolve(__dirname, "dom-serializer.js"), "utf-8");
1256
1268
  server.get("/healthcheck", opts, (_, reply) => {
1257
1269
  reply.code(200).send({ cliVersion: ctx.cliVersion });
1258
1270
  });
@@ -1388,6 +1400,9 @@ var logger = winston.createLogger({
1388
1400
  case "warn":
1389
1401
  message = chalk__default.default.yellow(message);
1390
1402
  break;
1403
+ case "error":
1404
+ message = chalk__default.default.red(message);
1405
+ break;
1391
1406
  }
1392
1407
  return info.level === "info" ? message : `[${contextString}:${info.level}] ` + message;
1393
1408
  })
@@ -1450,10 +1465,57 @@ var auth_default = (ctx) => {
1450
1465
  };
1451
1466
 
1452
1467
  // package.json
1453
- var version = "4.0.21";
1468
+ var version = "4.1.0";
1454
1469
  var package_default = {
1455
1470
  name: "@lambdatest/smartui-cli",
1456
- version};
1471
+ version,
1472
+ description: "A command line interface (CLI) to run SmartUI tests on LambdaTest",
1473
+ files: [
1474
+ "dist/**/*"
1475
+ ],
1476
+ scripts: {
1477
+ build: "tsup",
1478
+ release: "pnpm run build && pnpm publish --access public --no-git-checks",
1479
+ "local-build": "pnpm run build && pnpm pack"
1480
+ },
1481
+ bin: {
1482
+ smartui: "./dist/index.cjs"
1483
+ },
1484
+ type: "module",
1485
+ keywords: [
1486
+ "lambdatest",
1487
+ "smartui",
1488
+ "cli"
1489
+ ],
1490
+ author: "LambdaTest <keys@lambdatest.com>",
1491
+ license: "MIT",
1492
+ dependencies: {
1493
+ "@playwright/browser-chromium": "^1.47.2",
1494
+ "@playwright/browser-firefox": "^1.47.2",
1495
+ "@playwright/browser-webkit": "^1.47.2",
1496
+ "@playwright/test": "^1.47.2",
1497
+ "@types/cross-spawn": "^6.0.4",
1498
+ "@types/node": "^20.8.9",
1499
+ "@types/which": "^3.0.2",
1500
+ ajv: "^8.12.0",
1501
+ "ajv-errors": "^3.0.0",
1502
+ axios: "^1.6.0",
1503
+ chalk: "^4.1.2",
1504
+ commander: "^11.1.0",
1505
+ "cross-spawn": "^7.0.3",
1506
+ fastify: "^4.24.3",
1507
+ "form-data": "^4.0.0",
1508
+ listr2: "^7.0.1",
1509
+ sharp: "^0.33.4",
1510
+ tsup: "^7.2.0",
1511
+ uuid: "^11.0.3",
1512
+ which: "^4.0.0",
1513
+ winston: "^3.10.0"
1514
+ },
1515
+ devDependencies: {
1516
+ typescript: "^5.3.2"
1517
+ }
1518
+ };
1457
1519
  var httpClient = class {
1458
1520
  constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN, PROJECT_NAME, LT_USERNAME, LT_ACCESS_KEY, SMARTUI_API_PROXY, SMARTUI_API_SKIP_CERTIFICATES }) {
1459
1521
  this.projectToken = PROJECT_TOKEN || "";
@@ -1491,7 +1553,7 @@ var httpClient = class {
1491
1553
  request(config, log2) {
1492
1554
  return __async(this, null, function* () {
1493
1555
  log2.debug(`http request: ${config.method} ${config.url}`);
1494
- if (config && config.data) {
1556
+ if (config && config.data && !config.data.name) {
1495
1557
  log2.debug(config.data);
1496
1558
  }
1497
1559
  return this.axiosInstance.request(config).then((resp) => {
@@ -1613,7 +1675,7 @@ var httpClient = class {
1613
1675
  }
1614
1676
  uploadScreenshot({ id: buildId, name: buildName, baseline }, ssPath, ssName, browserName, viewport, log2) {
1615
1677
  browserName = browserName === constants_default.SAFARI ? constants_default.WEBKIT : browserName;
1616
- const file = fs5__default.default.readFileSync(ssPath);
1678
+ const file = fs6__default.default.readFileSync(ssPath);
1617
1679
  const form = new FormData__default.default();
1618
1680
  form.append("screenshot", file, { filename: `${ssName}.png`, contentType: "image/png" });
1619
1681
  form.append("browser", browserName);
@@ -1692,8 +1754,8 @@ var httpClient = class {
1692
1754
  }, ctx.log);
1693
1755
  }
1694
1756
  uploadLogs(ctx, uploadURL) {
1695
- const fileStream = fs5__default.default.createReadStream(constants_default.LOG_FILE_PATH);
1696
- const { size } = fs5__default.default.statSync(constants_default.LOG_FILE_PATH);
1757
+ const fileStream = fs6__default.default.createReadStream(constants_default.LOG_FILE_PATH);
1758
+ const { size } = fs6__default.default.statSync(constants_default.LOG_FILE_PATH);
1697
1759
  return this.request({
1698
1760
  url: uploadURL,
1699
1761
  method: "PUT",
@@ -1761,7 +1823,7 @@ var ctx_default = (options) => {
1761
1823
  let buildNameObj;
1762
1824
  try {
1763
1825
  if (options.config) {
1764
- config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
1826
+ config = JSON.parse(fs6__default.default.readFileSync(options.config, "utf-8"));
1765
1827
  if ((_a = config.web) == null ? void 0 : _a.resolutions) {
1766
1828
  config.web.viewports = config.web.resolutions;
1767
1829
  delete config.web.resolutions;
@@ -1883,7 +1945,7 @@ function isGitRepo() {
1883
1945
  }
1884
1946
  var git_default = (ctx) => {
1885
1947
  if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
1886
- let gitInfo = JSON.parse(fs5__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
1948
+ let gitInfo = JSON.parse(fs6__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
1887
1949
  return {
1888
1950
  branch: ctx.env.CURRENT_BRANCH || gitInfo.branch || "",
1889
1951
  commitId: gitInfo.commit_id.slice(0, 6) || "",
@@ -2063,6 +2125,8 @@ var finalizeBuild_default = (ctx) => {
2063
2125
  ctx2.log.debug(`Closed server`);
2064
2126
  let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
2065
2127
  yield ctx2.client.uploadLogs(ctx2, resp.data.url);
2128
+ fs6__default.default.unlinkSync(constants_default.LOG_FILE_PATH);
2129
+ ctx2.log.debug(`Log file deleted: ${constants_default.LOG_FILE_PATH}`);
2066
2130
  } catch (error) {
2067
2131
  ctx2.log.debug(error);
2068
2132
  }
@@ -2746,13 +2810,13 @@ function createConfig(filepath) {
2746
2810
  console.log("Error: Config file must have .json extension");
2747
2811
  return;
2748
2812
  }
2749
- if (fs5__default.default.existsSync(filepath)) {
2813
+ if (fs6__default.default.existsSync(filepath)) {
2750
2814
  console.log(`Error: SmartUI Config already exists: ${filepath}`);
2751
2815
  console.log(`To create a new file, please specify the file name like: 'smartui config:create .smartui-config.json'`);
2752
2816
  return;
2753
2817
  }
2754
- fs5__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2755
- fs5__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_CONFIG, null, 2) + "\n");
2818
+ fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2819
+ fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_CONFIG, null, 2) + "\n");
2756
2820
  console.log(`Created SmartUI Config: ${filepath}`);
2757
2821
  }
2758
2822
  function createWebStaticConfig(filepath) {
@@ -2762,13 +2826,13 @@ function createWebStaticConfig(filepath) {
2762
2826
  console.log("Error: Config file must have .json extension");
2763
2827
  return;
2764
2828
  }
2765
- if (fs5__default.default.existsSync(filepath)) {
2829
+ if (fs6__default.default.existsSync(filepath)) {
2766
2830
  console.log(`Error: web-static config already exists: ${filepath}`);
2767
2831
  console.log(`To create a new file, please specify the file name like: 'smartui config:create-web-static links.json'`);
2768
2832
  return;
2769
2833
  }
2770
- fs5__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2771
- fs5__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_WEB_STATIC_CONFIG, null, 2) + "\n");
2834
+ fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2835
+ fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_WEB_STATIC_CONFIG, null, 2) + "\n");
2772
2836
  console.log(`Created web-static config: ${filepath}`);
2773
2837
  }
2774
2838
  function createFigmaConfig(filepath) {
@@ -2778,13 +2842,13 @@ function createFigmaConfig(filepath) {
2778
2842
  console.log("Error: designs config file must have .json extension");
2779
2843
  return;
2780
2844
  }
2781
- if (fs5__default.default.existsSync(filepath)) {
2845
+ if (fs6__default.default.existsSync(filepath)) {
2782
2846
  console.log(`Error: designs config already exists: ${filepath}`);
2783
2847
  console.log(`To create a new file, please specify the file name like: 'smartui config:figma-config designs.json'`);
2784
2848
  return;
2785
2849
  }
2786
- fs5__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2787
- fs5__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_FIGMA_CONFIG, null, 2) + "\n");
2850
+ fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2851
+ fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_FIGMA_CONFIG, null, 2) + "\n");
2788
2852
  console.log(`Created designs config: ${filepath}`);
2789
2853
  }
2790
2854
  function createWebFigmaConfig(filepath) {
@@ -2794,13 +2858,13 @@ function createWebFigmaConfig(filepath) {
2794
2858
  console.log("Error: figma config file must have .json extension");
2795
2859
  return;
2796
2860
  }
2797
- if (fs5__default.default.existsSync(filepath)) {
2861
+ if (fs6__default.default.existsSync(filepath)) {
2798
2862
  console.log(`Error: figma config already exists: ${filepath}`);
2799
2863
  console.log(`To create a new file, please specify the file name like: 'smartui config:create-figma-web <fileName>.json'`);
2800
2864
  return;
2801
2865
  }
2802
- fs5__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2803
- fs5__default.default.writeFileSync(filepath, JSON.stringify(constants_default.WEB_FIGMA_CONFIG, null, 2) + "\n");
2866
+ fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
2867
+ fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.WEB_FIGMA_CONFIG, null, 2) + "\n");
2804
2868
  console.log(`Created figma web config: ${filepath}`);
2805
2869
  }
2806
2870
  function verifyFigmaWebConfig(ctx) {
@@ -2860,8 +2924,12 @@ configWebFigma.name("config:create-figma-web").description("Create figma config
2860
2924
  createWebFigmaConfig(filepath);
2861
2925
  });
2862
2926
  });
2863
- function captureScreenshotsForConfig(_0, _1, _2, _3, _4) {
2864
- return __async(this, arguments, function* (ctx, browsers, { name, url, waitForTimeout }, browserName, renderViewports) {
2927
+ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, renderViewports) {
2928
+ return __async(this, null, function* () {
2929
+ ctx.log.debug(`*** urlConfig ${JSON.stringify(urlConfig)}`);
2930
+ let { name, url, waitForTimeout, execute } = urlConfig;
2931
+ let afterNavigationScript = execute == null ? void 0 : execute.afterNavigation;
2932
+ let beforeSnapshotScript = execute == null ? void 0 : execute.beforeSnapshot;
2865
2933
  let pageOptions = { waitUntil: process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || "load", timeout: ctx.config.waitForPageRender || constants_default.DEFAULT_PAGE_LOAD_TIMEOUT };
2866
2934
  let ssId = name.toLowerCase().replace(/\s/g, "_");
2867
2935
  let context;
@@ -2880,12 +2948,14 @@ function captureScreenshotsForConfig(_0, _1, _2, _3, _4) {
2880
2948
  context = yield browser == null ? void 0 : browser.newContext(contextOptions);
2881
2949
  page = yield context == null ? void 0 : context.newPage();
2882
2950
  yield page == null ? void 0 : page.goto(url.trim(), pageOptions);
2951
+ yield executeDocumentScripts(ctx, page, "afterNavigation", afterNavigationScript);
2883
2952
  for (let { viewport, viewportString, fullPage } of renderViewports) {
2884
2953
  let ssPath = `screenshots/${ssId}/${`${browserName}-${viewport.width}x${viewport.height}`}-${ssId}.png`;
2885
2954
  yield page == null ? void 0 : page.setViewportSize({ width: viewport.width, height: viewport.height || constants_default.MIN_VIEWPORT_HEIGHT });
2886
2955
  if (fullPage)
2887
2956
  yield page == null ? void 0 : page.evaluate(scrollToBottomAndBackToTop);
2888
2957
  yield page == null ? void 0 : page.waitForTimeout(waitForTimeout || 0);
2958
+ yield executeDocumentScripts(ctx, page, "beforeSnapshot", beforeSnapshotScript);
2889
2959
  yield page == null ? void 0 : page.screenshot({ path: ssPath, fullPage });
2890
2960
  yield ctx.client.uploadScreenshot(ctx.build, ssPath, name, browserName, viewportString, ctx.log);
2891
2961
  }
@@ -2962,7 +3032,7 @@ function captureScreenshots(ctx) {
2962
3032
  ctx.task.output = output;
2963
3033
  capturedScreenshots++;
2964
3034
  } catch (error) {
2965
- ctx.log.debug(`screenshot capture failed for ${JSON.stringify(staticConfig)}; error: ${error}`);
3035
+ ctx.log.debug(`captureScreenshots failed for ${JSON.stringify(staticConfig)}; error: ${error}`);
2966
3036
  output += `${chalk__default.default.gray(staticConfig.name)} ${chalk__default.default.red("\u2717")}
2967
3037
  `;
2968
3038
  ctx.task.output = output;
@@ -2974,7 +3044,7 @@ function captureScreenshots(ctx) {
2974
3044
  });
2975
3045
  }
2976
3046
  function getImageDimensions(filePath) {
2977
- const buffer = fs5__default.default.readFileSync(filePath);
3047
+ const buffer = fs6__default.default.readFileSync(filePath);
2978
3048
  let width, height;
2979
3049
  if (buffer.toString("hex", 0, 2) === "ffd8") {
2980
3050
  let offset = 2;
@@ -2999,7 +3069,7 @@ function getImageDimensions(filePath) {
2999
3069
  function isAllowedImage(filePath) {
3000
3070
  return __async(this, null, function* () {
3001
3071
  try {
3002
- const fileBuffer = fs5__default.default.readFileSync(filePath);
3072
+ const fileBuffer = fs6__default.default.readFileSync(filePath);
3003
3073
  const isMagicValid = constants_default.MAGIC_NUMBERS.some((magic) => fileBuffer.slice(0, magic.magic.length).equals(magic.magic));
3004
3074
  const metadata = yield sharp__default.default(filePath).metadata();
3005
3075
  if (metadata.format === constants_default.FILE_EXTENSION_GIFS) {
@@ -3023,10 +3093,10 @@ function uploadScreenshots(ctx) {
3023
3093
  let noOfScreenshots = 0;
3024
3094
  function processDirectory(directory, relativePath = "") {
3025
3095
  return __async(this, null, function* () {
3026
- const files = fs5__default.default.readdirSync(directory);
3096
+ const files = fs6__default.default.readdirSync(directory);
3027
3097
  for (let file of files) {
3028
3098
  const filePath = path2__default.default.join(directory, file);
3029
- const stat = fs5__default.default.statSync(filePath);
3099
+ const stat = fs6__default.default.statSync(filePath);
3030
3100
  const relativeFilePath = path2__default.default.join(relativePath, file);
3031
3101
  if (stat.isDirectory() && ctx.options.ignorePattern.includes(relativeFilePath)) {
3032
3102
  ctx.log.info(`Ignoring Directory ${relativeFilePath}`);
@@ -3157,6 +3227,23 @@ function processChunk(ctx, urlConfig) {
3157
3227
  return { capturedScreenshots, finalOutput };
3158
3228
  });
3159
3229
  }
3230
+ function executeDocumentScripts(ctx, page, actionType, script) {
3231
+ return __async(this, null, function* () {
3232
+ try {
3233
+ if (!page) {
3234
+ throw new Error("Page instance not available");
3235
+ }
3236
+ if (script !== "") {
3237
+ yield page.evaluate((script2) => {
3238
+ new Function(script2)();
3239
+ }, script);
3240
+ }
3241
+ } catch (error) {
3242
+ ctx.log.error(`Error executing script for action ${actionType}: `, error);
3243
+ throw error;
3244
+ }
3245
+ });
3246
+ }
3160
3247
  var captureScreenshots_default = (ctx) => {
3161
3248
  return {
3162
3249
  title: "Capturing screenshots",
@@ -3194,20 +3281,31 @@ var captureScreenshots_default = (ctx) => {
3194
3281
  var command2 = new commander.Command();
3195
3282
  command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("-C, --parallel [number]", "Specify the number of instances per browser", parseInt).option("-F, --force", "forcefully apply the specified parallel instances per browser").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").action(function(file, _, command7) {
3196
3283
  return __async(this, null, function* () {
3284
+ var _a, _b;
3197
3285
  const options = command7.optsWithGlobals();
3198
3286
  if (options.buildName === "") {
3199
3287
  console.log(`Error: The '--buildName' option cannot be an empty string.`);
3200
3288
  process.exit(1);
3201
3289
  }
3202
3290
  let ctx = ctx_default(command7.optsWithGlobals());
3203
- if (!fs5__default.default.existsSync(file)) {
3291
+ if (!fs6__default.default.existsSync(file)) {
3204
3292
  ctx.log.error(`Web Static Config file ${file} not found.`);
3205
3293
  return;
3206
3294
  }
3207
3295
  try {
3208
- ctx.webStaticConfig = JSON.parse(fs5__default.default.readFileSync(file, "utf8"));
3209
- if (!validateWebStaticConfig(ctx.webStaticConfig))
3210
- throw new Error(validateWebStaticConfig.errors[0].message);
3296
+ ctx.webStaticConfig = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
3297
+ if (!validateWebStaticConfig(ctx.webStaticConfig)) {
3298
+ ctx.log.debug(JSON.stringify(validateWebStaticConfig.errors, null, 2));
3299
+ (_a = validateWebStaticConfig.errors) == null ? void 0 : _a.forEach((error) => {
3300
+ if (error.keyword === "additionalProperties") {
3301
+ ctx.log.warn(`Additional property "${error.params.additionalProperty}" is not allowed.`);
3302
+ } else {
3303
+ const validationError = error.message;
3304
+ throw new Error(validationError || "Invalid Web Static config found in file : " + file);
3305
+ }
3306
+ });
3307
+ throw new Error((_b = validateWebStaticConfig.errors[0]) == null ? void 0 : _b.message);
3308
+ }
3211
3309
  if (ctx.webStaticConfig && ctx.webStaticConfig.length === 0) {
3212
3310
  ctx.log.error(`No URLs found in the specified config file -> ${file}`);
3213
3311
  return;
@@ -3281,7 +3379,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
3281
3379
  process.exit(1);
3282
3380
  }
3283
3381
  let ctx = ctx_default(command7.optsWithGlobals());
3284
- if (!fs5__default.default.existsSync(directory)) {
3382
+ if (!fs6__default.default.existsSync(directory)) {
3285
3383
  console.log(`Error: The provided directory ${directory} not found.`);
3286
3384
  return;
3287
3385
  }
@@ -3479,12 +3577,12 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
3479
3577
  return __async(this, null, function* () {
3480
3578
  var _a, _b;
3481
3579
  let ctx = ctx_default(command7.optsWithGlobals());
3482
- if (!fs5__default.default.existsSync(file)) {
3580
+ if (!fs6__default.default.existsSync(file)) {
3483
3581
  console.log(`Error: Figma Config file ${file} not found.`);
3484
3582
  return;
3485
3583
  }
3486
3584
  try {
3487
- ctx.figmaDesignConfig = JSON.parse(fs5__default.default.readFileSync(file, "utf8"));
3585
+ ctx.figmaDesignConfig = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
3488
3586
  if (!validateFigmaDesignConfig(ctx.figmaDesignConfig)) {
3489
3587
  const validationError = (_b = (_a = validateFigmaDesignConfig.errors) == null ? void 0 : _a[0]) == null ? void 0 : _b.message;
3490
3588
  throw new Error(validationError || "Invalid figma design Config");
@@ -3520,12 +3618,12 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture screenshots
3520
3618
  return __async(this, null, function* () {
3521
3619
  var _a;
3522
3620
  let ctx = ctx_default(command7.optsWithGlobals());
3523
- if (!fs5__default.default.existsSync(file)) {
3621
+ if (!fs6__default.default.existsSync(file)) {
3524
3622
  console.log(`Error: figma-web config file ${file} not found.`);
3525
3623
  return;
3526
3624
  }
3527
3625
  try {
3528
- ctx.config = JSON.parse(fs5__default.default.readFileSync(file, "utf8"));
3626
+ ctx.config = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
3529
3627
  ctx.log.info(JSON.stringify(ctx.config));
3530
3628
  if (!validateWebFigmaConfig(ctx.config)) {
3531
3629
  ctx.log.debug(JSON.stringify(validateWebFigmaConfig.errors, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.0.21",
3
+ "version": "4.1.0",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"