@lambdatest/smartui-cli 4.0.11 → 4.0.13

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 +55 -14
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -739,6 +739,10 @@ var SnapshotSchema = {
739
739
  },
740
740
  required: ["devices"],
741
741
  errorMessage: "Invalid snapshot options; mobile must include devices property."
742
+ },
743
+ loadDomContent: {
744
+ type: "boolean",
745
+ errorMessage: "Invalid snapshot options; loadDomContent must be a boolean"
742
746
  }
743
747
  },
744
748
  additionalProperties: false
@@ -861,7 +865,8 @@ var env_default = () => {
861
865
  LT_ACCESS_KEY,
862
866
  LT_SDK_DEBUG,
863
867
  BASELINE_BRANCH,
864
- CURRENT_BRANCH
868
+ CURRENT_BRANCH,
869
+ PROJECT_NAME
865
870
  } = process.env;
866
871
  return {
867
872
  PROJECT_TOKEN,
@@ -878,7 +883,8 @@ var env_default = () => {
878
883
  BASELINE_BRANCH,
879
884
  CURRENT_BRANCH,
880
885
  LT_SDK_DEBUG: LT_SDK_DEBUG === "true",
881
- SMARTUI_DO_NOT_USE_CAPTURED_COOKIES: SMARTUI_DO_NOT_USE_CAPTURED_COOKIES === "true"
886
+ SMARTUI_DO_NOT_USE_CAPTURED_COOKIES: SMARTUI_DO_NOT_USE_CAPTURED_COOKIES === "true",
887
+ PROJECT_NAME
882
888
  };
883
889
  };
884
890
  var logContext = {};
@@ -941,8 +947,14 @@ var auth_default = (ctx) => {
941
947
  task: (ctx2, task) => __async(void 0, null, function* () {
942
948
  updateLogContext({ task: "auth" });
943
949
  try {
944
- yield ctx2.client.auth(ctx2.log);
945
- task.output = chalk6__default.default.gray(`using project token '******#${ctx2.env.PROJECT_TOKEN.split("#").pop()}'`);
950
+ const authResult = yield ctx2.client.auth(ctx2.log, ctx2.env);
951
+ if (authResult === 2) {
952
+ task.output = chalk6__default.default.gray(`New project '${ctx2.env.PROJECT_NAME}' created successfully`);
953
+ } else if (authResult === 0) {
954
+ task.output = chalk6__default.default.gray(`Using existing project token '******#${ctx2.env.PROJECT_TOKEN.split("#").pop()}'`);
955
+ } else if (authResult === 1) {
956
+ task.output = chalk6__default.default.gray(`Using existing project '${ctx2.env.PROJECT_NAME}'`);
957
+ }
946
958
  task.title = "Authenticated with SmartUI";
947
959
  } catch (error) {
948
960
  ctx2.log.debug(error);
@@ -955,7 +967,7 @@ var auth_default = (ctx) => {
955
967
  };
956
968
 
957
969
  // package.json
958
- var version = "4.0.11";
970
+ var version = "4.0.13";
959
971
  var package_default = {
960
972
  name: "@lambdatest/smartui-cli",
961
973
  version,
@@ -1006,10 +1018,20 @@ var package_default = {
1006
1018
  }
1007
1019
  };
1008
1020
  var httpClient = class {
1009
- constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN }) {
1021
+ constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN, PROJECT_NAME, LT_USERNAME, LT_ACCESS_KEY }) {
1022
+ this.projectToken = PROJECT_TOKEN || "";
1023
+ this.projectName = PROJECT_NAME || "";
1024
+ this.username = LT_USERNAME || "";
1025
+ this.accessKey = LT_ACCESS_KEY || "";
1010
1026
  this.axiosInstance = axios__default.default.create({
1011
- baseURL: SMARTUI_CLIENT_API_URL,
1012
- headers: { "projectToken": PROJECT_TOKEN }
1027
+ baseURL: SMARTUI_CLIENT_API_URL
1028
+ });
1029
+ this.axiosInstance.interceptors.request.use((config) => {
1030
+ config.headers["projectToken"] = this.projectToken;
1031
+ config.headers["projectName"] = this.projectName;
1032
+ config.headers["username"] = this.username;
1033
+ config.headers["accessKey"] = this.accessKey;
1034
+ return config;
1013
1035
  });
1014
1036
  }
1015
1037
  request(config, log2) {
@@ -1041,11 +1063,27 @@ var httpClient = class {
1041
1063
  });
1042
1064
  });
1043
1065
  }
1044
- auth(log2) {
1045
- return this.request({
1046
- url: "/token/verify",
1047
- method: "GET"
1048
- }, log2);
1066
+ auth(log2, env) {
1067
+ return __async(this, null, function* () {
1068
+ let result = 1;
1069
+ if (this.projectToken) {
1070
+ result = 0;
1071
+ }
1072
+ const response = yield this.request({
1073
+ url: "/token/verify",
1074
+ method: "GET"
1075
+ }, log2);
1076
+ if (response && response.projectToken) {
1077
+ this.projectToken = response.projectToken;
1078
+ env.PROJECT_TOKEN = response.projectToken;
1079
+ if (response.message && response.message.includes("Project created successfully")) {
1080
+ result = 2;
1081
+ }
1082
+ return result;
1083
+ } else {
1084
+ throw new Error("Authentication failed, project token not received");
1085
+ }
1086
+ });
1049
1087
  }
1050
1088
  createBuild(git, config, log2) {
1051
1089
  return this.request({
@@ -1909,6 +1947,9 @@ function processSnapshot(snapshot, ctx) {
1909
1947
  return true;
1910
1948
  return false;
1911
1949
  };
1950
+ if (options.loadDomContent) {
1951
+ processedOptions.loadDomContent = true;
1952
+ }
1912
1953
  if (options.web && Object.keys(options.web).length) {
1913
1954
  processedOptions.web = {};
1914
1955
  if (options.web.viewports && options.web.viewports.length > 0) {
@@ -2310,7 +2351,7 @@ var Queue = class {
2310
2351
  let drop = false;
2311
2352
  if (!this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
2312
2353
  drop = true;
2313
- this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'delayedUploads' configuration as true in your config file.`);
2354
+ this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'delayedUpload' configuration as true in your config file.`);
2314
2355
  }
2315
2356
  if (this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
2316
2357
  drop = this.filterExistingVariants(snapshot, this.ctx.config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"