@lambdatest/smartui-cli 4.0.3 → 4.0.4
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 +39 -37
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -822,7 +822,7 @@ var auth_default = (ctx) => {
|
|
|
822
822
|
};
|
|
823
823
|
|
|
824
824
|
// package.json
|
|
825
|
-
var version = "4.0.
|
|
825
|
+
var version = "4.0.4";
|
|
826
826
|
var package_default = {
|
|
827
827
|
name: "@lambdatest/smartui-cli",
|
|
828
828
|
version,
|
|
@@ -1512,7 +1512,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1512
1512
|
return __async(this, null, function* () {
|
|
1513
1513
|
var _a;
|
|
1514
1514
|
updateLogContext({ task: "discovery" });
|
|
1515
|
-
ctx.log.debug(`Processing snapshot ${snapshot.name}`);
|
|
1515
|
+
ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
|
|
1516
1516
|
let launchOptions = { headless: true };
|
|
1517
1517
|
let contextOptions = {
|
|
1518
1518
|
javaScriptEnabled: ctx.config.cliEnableJavaScript,
|
|
@@ -1526,29 +1526,39 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
const context = yield ctx.browser.newContext(contextOptions);
|
|
1528
1528
|
ctx.log.debug(`Browser context created with options ${JSON.stringify(contextOptions)}`);
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1529
|
+
if (snapshot.dom.cookies) {
|
|
1530
|
+
const domainName = new URL(snapshot.url).hostname;
|
|
1531
|
+
ctx.log.debug(`Setting cookies for domain: ${domainName}`);
|
|
1532
|
+
const cookieArray = snapshot.dom.cookies.split("; ").map((cookie) => {
|
|
1533
|
+
if (!cookie)
|
|
1534
|
+
return null;
|
|
1535
|
+
const [name, value] = cookie.split("=");
|
|
1536
|
+
if (!name || !value)
|
|
1537
|
+
return null;
|
|
1538
|
+
return {
|
|
1539
|
+
name: name.trim(),
|
|
1540
|
+
value: value.trim(),
|
|
1541
|
+
domain: domainName,
|
|
1542
|
+
path: "/"
|
|
1543
|
+
};
|
|
1544
|
+
}).filter(Boolean);
|
|
1545
|
+
if (cookieArray.length > 0) {
|
|
1546
|
+
yield context.addCookies(cookieArray);
|
|
1547
|
+
} else {
|
|
1548
|
+
ctx.log.debug("No valid cookies to add");
|
|
1549
|
+
}
|
|
1549
1550
|
}
|
|
1550
1551
|
const page = yield context.newPage();
|
|
1551
1552
|
let cache = {};
|
|
1553
|
+
if (snapshot.dom.resources.length) {
|
|
1554
|
+
for (let resource of snapshot.dom.resources) {
|
|
1555
|
+
let body = resource.mimetype == "text/css" ? Buffer.from(resource.content).toString("base64") : resource.content;
|
|
1556
|
+
cache[resource.url] = {
|
|
1557
|
+
body,
|
|
1558
|
+
type: resource.mimetype
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1552
1562
|
yield page.route("**/*", (route, request) => __async(this, null, function* () {
|
|
1553
1563
|
const requestUrl = request.url();
|
|
1554
1564
|
const requestHostname = new URL(requestUrl).hostname;
|
|
@@ -1574,6 +1584,12 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1574
1584
|
headers: () => ({ "content-type": "text/html" })
|
|
1575
1585
|
};
|
|
1576
1586
|
body = snapshot.dom.html;
|
|
1587
|
+
} else if (cache[requestUrl]) {
|
|
1588
|
+
response = {
|
|
1589
|
+
status: () => 200,
|
|
1590
|
+
headers: () => ({ "content-type": cache[requestUrl].mimetype })
|
|
1591
|
+
};
|
|
1592
|
+
body = cache[requestUrl].body;
|
|
1577
1593
|
} else {
|
|
1578
1594
|
response = yield page.request.fetch(request, requestOptions);
|
|
1579
1595
|
body = yield response.body();
|
|
@@ -1704,7 +1720,6 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1704
1720
|
} catch (error) {
|
|
1705
1721
|
ctx.log.debug(`Network idle failed due to ${error}`);
|
|
1706
1722
|
}
|
|
1707
|
-
yield new Promise((r) => setTimeout(r, 1e3));
|
|
1708
1723
|
if (processedOptions.element) {
|
|
1709
1724
|
let l = yield page.locator(processedOptions.element).all();
|
|
1710
1725
|
if (l.length === 0) {
|
|
@@ -1736,15 +1751,6 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1736
1751
|
}
|
|
1737
1752
|
}
|
|
1738
1753
|
}
|
|
1739
|
-
if (snapshot.dom.resources.length) {
|
|
1740
|
-
for (let resource of snapshot.dom.resources) {
|
|
1741
|
-
let body = resource.mimetype == "text/css" ? Buffer.from(resource.content).toString("base64") : resource.content;
|
|
1742
|
-
cache[resource.url] = {
|
|
1743
|
-
body,
|
|
1744
|
-
type: resource.mimetype
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
1754
|
return {
|
|
1749
1755
|
processedSnapshot: {
|
|
1750
1756
|
name: snapshot.name,
|
|
@@ -2318,18 +2324,14 @@ var commander_default = program;
|
|
|
2318
2324
|
let client = new httpClient(env_default());
|
|
2319
2325
|
let log2 = logger_default;
|
|
2320
2326
|
try {
|
|
2321
|
-
let { data: { latestVersion, deprecated, additionalDescription
|
|
2327
|
+
let { data: { latestVersion, deprecated, additionalDescription } } = yield client.checkUpdate(log2);
|
|
2322
2328
|
log2.info(`
|
|
2323
2329
|
LambdaTest SmartUI CLI v${package_default.version}`);
|
|
2324
2330
|
log2.info(chalk7__default.default.yellow(`${additionalDescription}`));
|
|
2325
2331
|
if (deprecated) {
|
|
2326
2332
|
log2.warn(`This version is deprecated. A new version ${latestVersion} is available!`);
|
|
2327
|
-
log2.warn(`${additionalDescriptionLatestVersion}
|
|
2328
|
-
`);
|
|
2329
2333
|
} else if (package_default.version !== latestVersion) {
|
|
2330
2334
|
log2.info(chalk7__default.default.green(`A new version ${latestVersion} is available!`));
|
|
2331
|
-
log2.info(chalk7__default.default.red(`${additionalDescriptionLatestVersion}
|
|
2332
|
-
`));
|
|
2333
2335
|
} else
|
|
2334
2336
|
log2.info(chalk7__default.default.gray("https://www.npmjs.com/package/@lambdatest/smartui-cli\n"));
|
|
2335
2337
|
} catch (error) {
|