@lambdatest/smartui-cli 4.1.24 → 4.1.25

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 +87 -13
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -775,6 +775,10 @@ var ConfigSchema = {
775
775
  allowDuplicateSnapshotNames: {
776
776
  type: "boolean",
777
777
  errorMessage: "Invalid config; allowDuplicateSnapshotNames must be true/false"
778
+ },
779
+ useLambdaInternal: {
780
+ type: "boolean",
781
+ errorMessage: "Invalid config; useLambdaInternal must be true/false"
778
782
  }
779
783
  },
780
784
  anyOf: [
@@ -1923,7 +1927,7 @@ var authExec_default = (ctx) => {
1923
1927
  };
1924
1928
 
1925
1929
  // package.json
1926
- var version = "4.1.24";
1930
+ var version = "4.1.25";
1927
1931
  var package_default = {
1928
1932
  name: "@lambdatest/smartui-cli",
1929
1933
  version,
@@ -2043,10 +2047,10 @@ var httpClient = class {
2043
2047
  request(config, log2) {
2044
2048
  return __async(this, null, function* () {
2045
2049
  log2.debug(`http request: ${config.method} ${config.url}`);
2046
- if (config && config.data && !config.data.name && !config.data.snapshot) {
2050
+ if (config && config.data && !config.data.skipLogging && !config.data.name && !config.data.snapshot) {
2047
2051
  log2.debug(config.data);
2048
2052
  }
2049
- if (config && config.data && config.data.snapshotUuid) {
2053
+ if (config && config.data && !config.data.skipLogging && config.data.snapshotUuid) {
2050
2054
  log2.debug(config.data);
2051
2055
  }
2052
2056
  return this.axiosInstance.request(config).then((resp) => {
@@ -2419,6 +2423,36 @@ var httpClient = class {
2419
2423
  }
2420
2424
  }, ctx.log);
2421
2425
  }
2426
+ sendDomToLSRS(ctx, snapshot, snapshotUuid) {
2427
+ return this.request({
2428
+ url: `/upload/dom`,
2429
+ method: "POST",
2430
+ data: {
2431
+ buildId: ctx.build.id,
2432
+ snapshotName: snapshot.name,
2433
+ snapshotUuid,
2434
+ domContent: snapshot,
2435
+ skipLogging: true
2436
+ }
2437
+ }, ctx.log);
2438
+ }
2439
+ sendDomToLSRSForCaps(ctx, snapshot, snapshotUuid, capsBuildId, capsProjectToken) {
2440
+ return this.request({
2441
+ url: `/upload/dom`,
2442
+ method: "POST",
2443
+ headers: {
2444
+ "Content-Type": "application/json",
2445
+ projectToken: capsProjectToken !== "" ? capsProjectToken : this.projectToken
2446
+ },
2447
+ data: {
2448
+ buildId: capsBuildId,
2449
+ snapshotName: snapshot.name,
2450
+ snapshotUuid,
2451
+ domContent: snapshot,
2452
+ skipLogging: true
2453
+ }
2454
+ }, ctx.log);
2455
+ }
2422
2456
  uploadLogs(ctx, uploadURL) {
2423
2457
  const fileStream = fs5__default.default.createReadStream(constants_default.LOG_FILE_PATH);
2424
2458
  const { size } = fs5__default.default.statSync(constants_default.LOG_FILE_PATH);
@@ -2436,6 +2470,18 @@ var httpClient = class {
2436
2470
  // prevent axios from limiting the content size
2437
2471
  }, ctx.log);
2438
2472
  }
2473
+ sendCliLogsToLSRS(ctx) {
2474
+ const logContent = fs5__default.default.readFileSync(constants_default.LOG_FILE_PATH, "utf-8");
2475
+ return this.request({
2476
+ url: `/upload/logs`,
2477
+ method: "POST",
2478
+ data: {
2479
+ buildId: ctx.build.id,
2480
+ logContent,
2481
+ skipLogging: true
2482
+ }
2483
+ }, ctx.log);
2484
+ }
2439
2485
  uploadSnapshotToS3(ctx, uploadURL, snapshot) {
2440
2486
  return this.request({
2441
2487
  url: uploadURL,
@@ -2519,6 +2565,7 @@ var ctx_default = (options) => {
2519
2565
  let fetchResultsFileObj;
2520
2566
  let buildNameObj;
2521
2567
  let allowDuplicateSnapshotNames = false;
2568
+ let useLambdaInternal = false;
2522
2569
  try {
2523
2570
  if (options.config) {
2524
2571
  config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
@@ -2583,6 +2630,9 @@ var ctx_default = (options) => {
2583
2630
  if (config.allowDuplicateSnapshotNames) {
2584
2631
  allowDuplicateSnapshotNames = true;
2585
2632
  }
2633
+ if (config.useLambdaInternal) {
2634
+ useLambdaInternal = true;
2635
+ }
2586
2636
  return {
2587
2637
  env,
2588
2638
  log: logger_default,
@@ -2607,7 +2657,8 @@ var ctx_default = (options) => {
2607
2657
  tunnel: tunnelObj,
2608
2658
  userAgent: config.userAgent || "",
2609
2659
  requestHeaders: config.requestHeaders || {},
2610
- allowDuplicateSnapshotNames
2660
+ allowDuplicateSnapshotNames,
2661
+ useLambdaInternal
2611
2662
  },
2612
2663
  uploadFilePath: "",
2613
2664
  webStaticConfig: [],
@@ -2927,6 +2978,7 @@ ${snapshot.warnings.length ? chalk__default.default.gray(`[warning] ${snapshot.w
2927
2978
  rendererOptions: { persistentOutput: true }
2928
2979
  };
2929
2980
  };
2981
+ var uploadDomToS3ViaEnv = process.env.USE_LAMBDA_INTERNAL || false;
2930
2982
  var finalizeBuild_default = (ctx) => {
2931
2983
  return {
2932
2984
  title: `Finalizing build`,
@@ -2991,9 +3043,15 @@ var finalizeBuild_default = (ctx) => {
2991
3043
  yield (_b = ctx2.server) == null ? void 0 : _b.close();
2992
3044
  ctx2.log.debug(`Closed server`);
2993
3045
  if (ctx2.isSnapshotCaptured) {
2994
- ctx2.log.debug(`Log file to be uploaded`);
2995
- let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
2996
- yield ctx2.client.uploadLogs(ctx2, resp.data.url);
3046
+ let uploadCLILogsToS3 = ctx2.config.useLambdaInternal || uploadDomToS3ViaEnv;
3047
+ if (!uploadCLILogsToS3) {
3048
+ ctx2.log.debug(`Log file to be uploaded`);
3049
+ let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
3050
+ yield ctx2.client.uploadLogs(ctx2, resp.data.url);
3051
+ } else {
3052
+ ctx2.log.debug(`Log file to be uploaded via LSRS`);
3053
+ let resp = ctx2.client.sendCliLogsToLSRS(ctx2);
3054
+ }
2997
3055
  }
2998
3056
  } catch (error) {
2999
3057
  ctx2.log.debug(error);
@@ -3657,6 +3715,7 @@ function processSnapshot(snapshot, ctx) {
3657
3715
  };
3658
3716
  });
3659
3717
  }
3718
+ var uploadDomToS3ViaEnv2 = process.env.USE_LAMBDA_INTERNAL || false;
3660
3719
  var Queue = class {
3661
3720
  constructor(ctx) {
3662
3721
  this.snapshots = [];
@@ -3927,9 +3986,16 @@ var Queue = class {
3927
3986
  if (useCapsBuildId) {
3928
3987
  if (useKafkaFlowCaps) {
3929
3988
  const snapshotUuid = uuid.v4();
3930
- const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
3931
- const uploadUrl = presignedResponse.data.url;
3932
- yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
3989
+ let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv2;
3990
+ if (!uploadDomToS3) {
3991
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL for CAPS`);
3992
+ const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
3993
+ const uploadUrl = presignedResponse.data.url;
3994
+ yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
3995
+ } else {
3996
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
3997
+ yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
3998
+ }
3933
3999
  yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors);
3934
4000
  } else {
3935
4001
  yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors);
@@ -3963,9 +4029,17 @@ var Queue = class {
3963
4029
  }
3964
4030
  if (this.ctx.build && this.ctx.build.useKafkaFlow) {
3965
4031
  const snapshotUuid = uuid.v4();
3966
- const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
3967
- const uploadUrl = presignedResponse.data.url;
3968
- let snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
4032
+ let snapshotUploadResponse;
4033
+ let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv2;
4034
+ if (!uploadDomToS3) {
4035
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL`);
4036
+ const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
4037
+ const uploadUrl = presignedResponse.data.url;
4038
+ snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
4039
+ } else {
4040
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
4041
+ snapshotUploadResponse = yield this.ctx.client.sendDomToLSRS(this.ctx, processedSnapshot, snapshotUuid);
4042
+ }
3969
4043
  if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
3970
4044
  this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
3971
4045
  this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.24",
3
+ "version": "4.1.25",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"