@lambdatest/smartui-cli 4.1.4 → 4.1.5
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.
- package/dist/index.cjs +97 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -629,6 +629,14 @@ var ConfigSchema = {
|
|
|
629
629
|
skipBuildCreation: {
|
|
630
630
|
type: "boolean",
|
|
631
631
|
errorMessage: "Invalid config; skipBuildCreation must be true/false"
|
|
632
|
+
},
|
|
633
|
+
tunnel: {
|
|
634
|
+
type: "boolean",
|
|
635
|
+
errorMessage: "Invalid config; tunnel must be true/false"
|
|
636
|
+
},
|
|
637
|
+
tunnelName: {
|
|
638
|
+
type: "string",
|
|
639
|
+
errorMessage: "Invalid config; tunnelName must be string"
|
|
632
640
|
}
|
|
633
641
|
},
|
|
634
642
|
anyOf: [
|
|
@@ -1517,7 +1525,7 @@ var authExec_default = (ctx) => {
|
|
|
1517
1525
|
};
|
|
1518
1526
|
|
|
1519
1527
|
// package.json
|
|
1520
|
-
var version = "4.1.
|
|
1528
|
+
var version = "4.1.5";
|
|
1521
1529
|
var package_default = {
|
|
1522
1530
|
name: "@lambdatest/smartui-cli",
|
|
1523
1531
|
version,
|
|
@@ -1642,7 +1650,11 @@ var httpClient = class {
|
|
|
1642
1650
|
headers: resp.headers,
|
|
1643
1651
|
body: resp.data
|
|
1644
1652
|
})}`);
|
|
1645
|
-
|
|
1653
|
+
if (resp.data !== "") {
|
|
1654
|
+
return resp.data;
|
|
1655
|
+
} else {
|
|
1656
|
+
return resp;
|
|
1657
|
+
}
|
|
1646
1658
|
} else {
|
|
1647
1659
|
log2.debug(`empty response: ${JSON.stringify(resp)}`);
|
|
1648
1660
|
return {};
|
|
@@ -1696,7 +1708,8 @@ var httpClient = class {
|
|
|
1696
1708
|
git,
|
|
1697
1709
|
config,
|
|
1698
1710
|
buildName,
|
|
1699
|
-
isStartExec
|
|
1711
|
+
isStartExec,
|
|
1712
|
+
packageVersion: package_default.version
|
|
1700
1713
|
}
|
|
1701
1714
|
}, log2);
|
|
1702
1715
|
}
|
|
@@ -1708,6 +1721,15 @@ var httpClient = class {
|
|
|
1708
1721
|
headers: { projectToken }
|
|
1709
1722
|
}, log2);
|
|
1710
1723
|
}
|
|
1724
|
+
getTunnelDetails(tunnelName, log2) {
|
|
1725
|
+
return this.request({
|
|
1726
|
+
url: "/tunnel",
|
|
1727
|
+
method: "POST",
|
|
1728
|
+
data: {
|
|
1729
|
+
tunnelName
|
|
1730
|
+
}
|
|
1731
|
+
}, log2);
|
|
1732
|
+
}
|
|
1711
1733
|
ping(buildId, log2) {
|
|
1712
1734
|
return this.request({
|
|
1713
1735
|
url: "/build/ping",
|
|
@@ -1998,7 +2020,7 @@ var httpClient = class {
|
|
|
1998
2020
|
}
|
|
1999
2021
|
};
|
|
2000
2022
|
var ctx_default = (options) => {
|
|
2001
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2023
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2002
2024
|
let env = env_default();
|
|
2003
2025
|
let webConfig;
|
|
2004
2026
|
let mobileConfig;
|
|
@@ -2083,7 +2105,9 @@ var ctx_default = (options) => {
|
|
|
2083
2105
|
delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
|
|
2084
2106
|
useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
|
|
2085
2107
|
ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
|
|
2086
|
-
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false
|
|
2108
|
+
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
|
|
2109
|
+
tunnel: (_k = config.tunnel) != null ? _k : false,
|
|
2110
|
+
tunnelName: config.tunnelName || ""
|
|
2087
2111
|
},
|
|
2088
2112
|
uploadFilePath: "",
|
|
2089
2113
|
webStaticConfig: [],
|
|
@@ -2101,6 +2125,11 @@ var ctx_default = (options) => {
|
|
|
2101
2125
|
url: ""
|
|
2102
2126
|
},
|
|
2103
2127
|
args: {},
|
|
2128
|
+
tunnelDetails: {
|
|
2129
|
+
tunnelPort: -1,
|
|
2130
|
+
tunnelHost: "",
|
|
2131
|
+
tunnelName: ""
|
|
2132
|
+
},
|
|
2104
2133
|
options: {
|
|
2105
2134
|
parallel: parallelObj,
|
|
2106
2135
|
force: options.force ? true : false,
|
|
@@ -2210,12 +2239,37 @@ var createBuildExec_default = (ctx) => {
|
|
|
2210
2239
|
baseline: resp.data.baseline,
|
|
2211
2240
|
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
2212
2241
|
};
|
|
2242
|
+
if (ctx2.build.id === "") {
|
|
2243
|
+
ctx2.log.debug("Build creation failed: Build ID is empty");
|
|
2244
|
+
task.output = chalk__default.default.red("Build creation failed: Build ID is empty");
|
|
2245
|
+
throw new Error("SmartUI build creation failed");
|
|
2246
|
+
}
|
|
2213
2247
|
task.output = chalk__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
2214
2248
|
task.title = "SmartUI build created";
|
|
2215
2249
|
} else {
|
|
2216
2250
|
task.output = chalk__default.default.gray(`Empty PROJECT_TOKEN and PROJECT_NAME. Skipping Creation of Build!`);
|
|
2217
2251
|
task.title = "Skipped SmartUI build creation";
|
|
2218
2252
|
}
|
|
2253
|
+
if (ctx2.config.tunnel) {
|
|
2254
|
+
let tunnelResp = yield ctx2.client.getTunnelDetails(ctx2.config.tunnelName, ctx2.log);
|
|
2255
|
+
ctx2.log.debug(`Tunnel Response: ${JSON.stringify(tunnelResp)}`);
|
|
2256
|
+
if (tunnelResp && tunnelResp.data && tunnelResp.data.host && tunnelResp.data.port && tunnelResp.data.tunnel_name) {
|
|
2257
|
+
ctx2.tunnelDetails = {
|
|
2258
|
+
tunnelHost: tunnelResp.data.host,
|
|
2259
|
+
tunnelPort: tunnelResp.data.port,
|
|
2260
|
+
tunnelName: tunnelResp.data.tunnel_name
|
|
2261
|
+
};
|
|
2262
|
+
ctx2.log.debug(`Tunnel Details: ${JSON.stringify(ctx2.tunnelDetails)}`);
|
|
2263
|
+
} else if (tunnelResp && tunnelResp.error) {
|
|
2264
|
+
if (tunnelResp.error.message) {
|
|
2265
|
+
if (tunnelResp.error.code && tunnelResp.error.code === 400) {
|
|
2266
|
+
ctx2.log.warn(tunnelResp.error.message);
|
|
2267
|
+
} else {
|
|
2268
|
+
ctx2.log.warn(`Error while fetch tunnel details; Either tunnel is not running or tunnel parameters are different`);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2219
2273
|
} catch (error) {
|
|
2220
2274
|
ctx2.log.debug(error);
|
|
2221
2275
|
task.output = chalk__default.default.gray(error.message);
|
|
@@ -2657,6 +2711,13 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2657
2711
|
processedOptions.ignoreType = options.ignoreType;
|
|
2658
2712
|
}
|
|
2659
2713
|
}
|
|
2714
|
+
if (ctx.config.tunnel) {
|
|
2715
|
+
if (ctx.tunnelDetails && ctx.tunnelDetails.tunnelPort != -1 && ctx.tunnelDetails.tunnelHost != "") {
|
|
2716
|
+
const tunnelAddress = `http://${ctx.tunnelDetails.tunnelHost}:${ctx.tunnelDetails.tunnelPort}`;
|
|
2717
|
+
processedOptions.tunnelAddress = tunnelAddress;
|
|
2718
|
+
ctx.log.debug(`Tunnel address added to processedOptions: ${tunnelAddress}`);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2660
2721
|
let navigated = false;
|
|
2661
2722
|
let previousDeviceType = null;
|
|
2662
2723
|
let renderViewports;
|
|
@@ -2691,7 +2752,19 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2691
2752
|
ctx.log.debug(`Navigated to ${snapshot.url}`);
|
|
2692
2753
|
} catch (error) {
|
|
2693
2754
|
ctx.log.debug(`Navigation to discovery page failed; ${error}`);
|
|
2694
|
-
|
|
2755
|
+
if (error && error.name && error.name === "TimeoutError") {
|
|
2756
|
+
ctx.log.debug(`Payload uploaded tough navigation to discovery page failed; ${error}`);
|
|
2757
|
+
return {
|
|
2758
|
+
processedSnapshot: {
|
|
2759
|
+
name: snapshot.name,
|
|
2760
|
+
url: snapshot.url,
|
|
2761
|
+
dom: Buffer.from(snapshot.dom.html).toString("base64"),
|
|
2762
|
+
resources: cache,
|
|
2763
|
+
options: processedOptions
|
|
2764
|
+
},
|
|
2765
|
+
warnings: [...optionWarnings, ...snapshot.dom.warnings]
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2695
2768
|
}
|
|
2696
2769
|
}
|
|
2697
2770
|
if (ctx.config.cliEnableJavaScript && fullPage)
|
|
@@ -3086,8 +3159,24 @@ var Queue = class {
|
|
|
3086
3159
|
const snapshotUuid = uuid.v4();
|
|
3087
3160
|
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
3088
3161
|
const uploadUrl = presignedResponse.data.url;
|
|
3089
|
-
yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
3090
|
-
|
|
3162
|
+
let snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
3163
|
+
if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
|
|
3164
|
+
this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
|
|
3165
|
+
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
|
|
3166
|
+
if (this.ctx.browser) {
|
|
3167
|
+
for (let context of this.ctx.browser.contexts()) {
|
|
3168
|
+
for (let page of context.pages()) {
|
|
3169
|
+
yield page.close();
|
|
3170
|
+
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
|
|
3171
|
+
}
|
|
3172
|
+
yield context.close();
|
|
3173
|
+
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
this.processNext();
|
|
3177
|
+
} else {
|
|
3178
|
+
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
|
|
3179
|
+
}
|
|
3091
3180
|
} else {
|
|
3092
3181
|
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
|
|
3093
3182
|
}
|