@lambdatest/smartui-cli 4.0.21 → 4.0.22
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 +87 -37
- 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
|
|
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
|
|
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": [
|
|
@@ -966,8 +967,8 @@ var validateWebFigmaConfig = ajv.compile(FigmaWebConfigSchema);
|
|
|
966
967
|
util.promisify(setTimeout);
|
|
967
968
|
var isPollingActive = false;
|
|
968
969
|
function delDir(dir) {
|
|
969
|
-
if (
|
|
970
|
-
|
|
970
|
+
if (fs6__default.default.existsSync(dir)) {
|
|
971
|
+
fs6__default.default.rmSync(dir, { recursive: true });
|
|
971
972
|
}
|
|
972
973
|
}
|
|
973
974
|
function scrollToBottomAndBackToTop({
|
|
@@ -1167,7 +1168,7 @@ function startPolling(ctx) {
|
|
|
1167
1168
|
clearInterval(intervalId);
|
|
1168
1169
|
isPollingActive = false;
|
|
1169
1170
|
}
|
|
1170
|
-
|
|
1171
|
+
fs6__default.default.writeFileSync(ctx.options.fetchResultsFileName, JSON.stringify(resp, null, 2));
|
|
1171
1172
|
ctx.log.debug(`Updated results in ${ctx.options.fetchResultsFileName}`);
|
|
1172
1173
|
if (resp.build.build_status_ind === constants_default.BUILD_COMPLETE || resp.build.build_status_ind === constants_default.BUILD_ERROR) {
|
|
1173
1174
|
clearInterval(intervalId);
|
|
@@ -1252,7 +1253,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
1252
1253
|
bodyLimit: 3e7
|
|
1253
1254
|
});
|
|
1254
1255
|
const opts = {};
|
|
1255
|
-
const SMARTUI_DOM =
|
|
1256
|
+
const SMARTUI_DOM = fs6.readFileSync(path2__default.default.resolve(__dirname, "dom-serializer.js"), "utf-8");
|
|
1256
1257
|
server.get("/healthcheck", opts, (_, reply) => {
|
|
1257
1258
|
reply.code(200).send({ cliVersion: ctx.cliVersion });
|
|
1258
1259
|
});
|
|
@@ -1450,10 +1451,57 @@ var auth_default = (ctx) => {
|
|
|
1450
1451
|
};
|
|
1451
1452
|
|
|
1452
1453
|
// package.json
|
|
1453
|
-
var version = "4.0.
|
|
1454
|
+
var version = "4.0.22";
|
|
1454
1455
|
var package_default = {
|
|
1455
1456
|
name: "@lambdatest/smartui-cli",
|
|
1456
|
-
version
|
|
1457
|
+
version,
|
|
1458
|
+
description: "A command line interface (CLI) to run SmartUI tests on LambdaTest",
|
|
1459
|
+
files: [
|
|
1460
|
+
"dist/**/*"
|
|
1461
|
+
],
|
|
1462
|
+
scripts: {
|
|
1463
|
+
build: "tsup",
|
|
1464
|
+
release: "pnpm run build && pnpm publish --access public --no-git-checks",
|
|
1465
|
+
"local-build": "pnpm run build && pnpm pack"
|
|
1466
|
+
},
|
|
1467
|
+
bin: {
|
|
1468
|
+
smartui: "./dist/index.cjs"
|
|
1469
|
+
},
|
|
1470
|
+
type: "module",
|
|
1471
|
+
keywords: [
|
|
1472
|
+
"lambdatest",
|
|
1473
|
+
"smartui",
|
|
1474
|
+
"cli"
|
|
1475
|
+
],
|
|
1476
|
+
author: "LambdaTest <keys@lambdatest.com>",
|
|
1477
|
+
license: "MIT",
|
|
1478
|
+
dependencies: {
|
|
1479
|
+
"@playwright/browser-chromium": "^1.47.2",
|
|
1480
|
+
"@playwright/browser-firefox": "^1.47.2",
|
|
1481
|
+
"@playwright/browser-webkit": "^1.47.2",
|
|
1482
|
+
"@playwright/test": "^1.47.2",
|
|
1483
|
+
"@types/cross-spawn": "^6.0.4",
|
|
1484
|
+
"@types/node": "^20.8.9",
|
|
1485
|
+
"@types/which": "^3.0.2",
|
|
1486
|
+
ajv: "^8.12.0",
|
|
1487
|
+
"ajv-errors": "^3.0.0",
|
|
1488
|
+
axios: "^1.6.0",
|
|
1489
|
+
chalk: "^4.1.2",
|
|
1490
|
+
commander: "^11.1.0",
|
|
1491
|
+
"cross-spawn": "^7.0.3",
|
|
1492
|
+
fastify: "^4.24.3",
|
|
1493
|
+
"form-data": "^4.0.0",
|
|
1494
|
+
listr2: "^7.0.1",
|
|
1495
|
+
sharp: "^0.33.4",
|
|
1496
|
+
tsup: "^7.2.0",
|
|
1497
|
+
uuid: "^11.0.3",
|
|
1498
|
+
which: "^4.0.0",
|
|
1499
|
+
winston: "^3.10.0"
|
|
1500
|
+
},
|
|
1501
|
+
devDependencies: {
|
|
1502
|
+
typescript: "^5.3.2"
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1457
1505
|
var httpClient = class {
|
|
1458
1506
|
constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN, PROJECT_NAME, LT_USERNAME, LT_ACCESS_KEY, SMARTUI_API_PROXY, SMARTUI_API_SKIP_CERTIFICATES }) {
|
|
1459
1507
|
this.projectToken = PROJECT_TOKEN || "";
|
|
@@ -1491,7 +1539,7 @@ var httpClient = class {
|
|
|
1491
1539
|
request(config, log2) {
|
|
1492
1540
|
return __async(this, null, function* () {
|
|
1493
1541
|
log2.debug(`http request: ${config.method} ${config.url}`);
|
|
1494
|
-
if (config && config.data) {
|
|
1542
|
+
if (config && config.data && !config.data.name) {
|
|
1495
1543
|
log2.debug(config.data);
|
|
1496
1544
|
}
|
|
1497
1545
|
return this.axiosInstance.request(config).then((resp) => {
|
|
@@ -1613,7 +1661,7 @@ var httpClient = class {
|
|
|
1613
1661
|
}
|
|
1614
1662
|
uploadScreenshot({ id: buildId, name: buildName, baseline }, ssPath, ssName, browserName, viewport, log2) {
|
|
1615
1663
|
browserName = browserName === constants_default.SAFARI ? constants_default.WEBKIT : browserName;
|
|
1616
|
-
const file =
|
|
1664
|
+
const file = fs6__default.default.readFileSync(ssPath);
|
|
1617
1665
|
const form = new FormData__default.default();
|
|
1618
1666
|
form.append("screenshot", file, { filename: `${ssName}.png`, contentType: "image/png" });
|
|
1619
1667
|
form.append("browser", browserName);
|
|
@@ -1692,8 +1740,8 @@ var httpClient = class {
|
|
|
1692
1740
|
}, ctx.log);
|
|
1693
1741
|
}
|
|
1694
1742
|
uploadLogs(ctx, uploadURL) {
|
|
1695
|
-
const fileStream =
|
|
1696
|
-
const { size } =
|
|
1743
|
+
const fileStream = fs6__default.default.createReadStream(constants_default.LOG_FILE_PATH);
|
|
1744
|
+
const { size } = fs6__default.default.statSync(constants_default.LOG_FILE_PATH);
|
|
1697
1745
|
return this.request({
|
|
1698
1746
|
url: uploadURL,
|
|
1699
1747
|
method: "PUT",
|
|
@@ -1761,7 +1809,7 @@ var ctx_default = (options) => {
|
|
|
1761
1809
|
let buildNameObj;
|
|
1762
1810
|
try {
|
|
1763
1811
|
if (options.config) {
|
|
1764
|
-
config = JSON.parse(
|
|
1812
|
+
config = JSON.parse(fs6__default.default.readFileSync(options.config, "utf-8"));
|
|
1765
1813
|
if ((_a = config.web) == null ? void 0 : _a.resolutions) {
|
|
1766
1814
|
config.web.viewports = config.web.resolutions;
|
|
1767
1815
|
delete config.web.resolutions;
|
|
@@ -1883,7 +1931,7 @@ function isGitRepo() {
|
|
|
1883
1931
|
}
|
|
1884
1932
|
var git_default = (ctx) => {
|
|
1885
1933
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
1886
|
-
let gitInfo = JSON.parse(
|
|
1934
|
+
let gitInfo = JSON.parse(fs6__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
1887
1935
|
return {
|
|
1888
1936
|
branch: ctx.env.CURRENT_BRANCH || gitInfo.branch || "",
|
|
1889
1937
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
@@ -2063,6 +2111,8 @@ var finalizeBuild_default = (ctx) => {
|
|
|
2063
2111
|
ctx2.log.debug(`Closed server`);
|
|
2064
2112
|
let resp = yield ctx2.client.getS3PreSignedURL(ctx2);
|
|
2065
2113
|
yield ctx2.client.uploadLogs(ctx2, resp.data.url);
|
|
2114
|
+
fs6__default.default.unlinkSync(constants_default.LOG_FILE_PATH);
|
|
2115
|
+
ctx2.log.debug(`Log file deleted: ${constants_default.LOG_FILE_PATH}`);
|
|
2066
2116
|
} catch (error) {
|
|
2067
2117
|
ctx2.log.debug(error);
|
|
2068
2118
|
}
|
|
@@ -2746,13 +2796,13 @@ function createConfig(filepath) {
|
|
|
2746
2796
|
console.log("Error: Config file must have .json extension");
|
|
2747
2797
|
return;
|
|
2748
2798
|
}
|
|
2749
|
-
if (
|
|
2799
|
+
if (fs6__default.default.existsSync(filepath)) {
|
|
2750
2800
|
console.log(`Error: SmartUI Config already exists: ${filepath}`);
|
|
2751
2801
|
console.log(`To create a new file, please specify the file name like: 'smartui config:create .smartui-config.json'`);
|
|
2752
2802
|
return;
|
|
2753
2803
|
}
|
|
2754
|
-
|
|
2755
|
-
|
|
2804
|
+
fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
|
|
2805
|
+
fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_CONFIG, null, 2) + "\n");
|
|
2756
2806
|
console.log(`Created SmartUI Config: ${filepath}`);
|
|
2757
2807
|
}
|
|
2758
2808
|
function createWebStaticConfig(filepath) {
|
|
@@ -2762,13 +2812,13 @@ function createWebStaticConfig(filepath) {
|
|
|
2762
2812
|
console.log("Error: Config file must have .json extension");
|
|
2763
2813
|
return;
|
|
2764
2814
|
}
|
|
2765
|
-
if (
|
|
2815
|
+
if (fs6__default.default.existsSync(filepath)) {
|
|
2766
2816
|
console.log(`Error: web-static config already exists: ${filepath}`);
|
|
2767
2817
|
console.log(`To create a new file, please specify the file name like: 'smartui config:create-web-static links.json'`);
|
|
2768
2818
|
return;
|
|
2769
2819
|
}
|
|
2770
|
-
|
|
2771
|
-
|
|
2820
|
+
fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
|
|
2821
|
+
fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_WEB_STATIC_CONFIG, null, 2) + "\n");
|
|
2772
2822
|
console.log(`Created web-static config: ${filepath}`);
|
|
2773
2823
|
}
|
|
2774
2824
|
function createFigmaConfig(filepath) {
|
|
@@ -2778,13 +2828,13 @@ function createFigmaConfig(filepath) {
|
|
|
2778
2828
|
console.log("Error: designs config file must have .json extension");
|
|
2779
2829
|
return;
|
|
2780
2830
|
}
|
|
2781
|
-
if (
|
|
2831
|
+
if (fs6__default.default.existsSync(filepath)) {
|
|
2782
2832
|
console.log(`Error: designs config already exists: ${filepath}`);
|
|
2783
2833
|
console.log(`To create a new file, please specify the file name like: 'smartui config:figma-config designs.json'`);
|
|
2784
2834
|
return;
|
|
2785
2835
|
}
|
|
2786
|
-
|
|
2787
|
-
|
|
2836
|
+
fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
|
|
2837
|
+
fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.DEFAULT_FIGMA_CONFIG, null, 2) + "\n");
|
|
2788
2838
|
console.log(`Created designs config: ${filepath}`);
|
|
2789
2839
|
}
|
|
2790
2840
|
function createWebFigmaConfig(filepath) {
|
|
@@ -2794,13 +2844,13 @@ function createWebFigmaConfig(filepath) {
|
|
|
2794
2844
|
console.log("Error: figma config file must have .json extension");
|
|
2795
2845
|
return;
|
|
2796
2846
|
}
|
|
2797
|
-
if (
|
|
2847
|
+
if (fs6__default.default.existsSync(filepath)) {
|
|
2798
2848
|
console.log(`Error: figma config already exists: ${filepath}`);
|
|
2799
2849
|
console.log(`To create a new file, please specify the file name like: 'smartui config:create-figma-web <fileName>.json'`);
|
|
2800
2850
|
return;
|
|
2801
2851
|
}
|
|
2802
|
-
|
|
2803
|
-
|
|
2852
|
+
fs6__default.default.mkdirSync(path2__default.default.dirname(filepath), { recursive: true });
|
|
2853
|
+
fs6__default.default.writeFileSync(filepath, JSON.stringify(constants_default.WEB_FIGMA_CONFIG, null, 2) + "\n");
|
|
2804
2854
|
console.log(`Created figma web config: ${filepath}`);
|
|
2805
2855
|
}
|
|
2806
2856
|
function verifyFigmaWebConfig(ctx) {
|
|
@@ -2974,7 +3024,7 @@ function captureScreenshots(ctx) {
|
|
|
2974
3024
|
});
|
|
2975
3025
|
}
|
|
2976
3026
|
function getImageDimensions(filePath) {
|
|
2977
|
-
const buffer =
|
|
3027
|
+
const buffer = fs6__default.default.readFileSync(filePath);
|
|
2978
3028
|
let width, height;
|
|
2979
3029
|
if (buffer.toString("hex", 0, 2) === "ffd8") {
|
|
2980
3030
|
let offset = 2;
|
|
@@ -2999,7 +3049,7 @@ function getImageDimensions(filePath) {
|
|
|
2999
3049
|
function isAllowedImage(filePath) {
|
|
3000
3050
|
return __async(this, null, function* () {
|
|
3001
3051
|
try {
|
|
3002
|
-
const fileBuffer =
|
|
3052
|
+
const fileBuffer = fs6__default.default.readFileSync(filePath);
|
|
3003
3053
|
const isMagicValid = constants_default.MAGIC_NUMBERS.some((magic) => fileBuffer.slice(0, magic.magic.length).equals(magic.magic));
|
|
3004
3054
|
const metadata = yield sharp__default.default(filePath).metadata();
|
|
3005
3055
|
if (metadata.format === constants_default.FILE_EXTENSION_GIFS) {
|
|
@@ -3023,10 +3073,10 @@ function uploadScreenshots(ctx) {
|
|
|
3023
3073
|
let noOfScreenshots = 0;
|
|
3024
3074
|
function processDirectory(directory, relativePath = "") {
|
|
3025
3075
|
return __async(this, null, function* () {
|
|
3026
|
-
const files =
|
|
3076
|
+
const files = fs6__default.default.readdirSync(directory);
|
|
3027
3077
|
for (let file of files) {
|
|
3028
3078
|
const filePath = path2__default.default.join(directory, file);
|
|
3029
|
-
const stat =
|
|
3079
|
+
const stat = fs6__default.default.statSync(filePath);
|
|
3030
3080
|
const relativeFilePath = path2__default.default.join(relativePath, file);
|
|
3031
3081
|
if (stat.isDirectory() && ctx.options.ignorePattern.includes(relativeFilePath)) {
|
|
3032
3082
|
ctx.log.info(`Ignoring Directory ${relativeFilePath}`);
|
|
@@ -3200,12 +3250,12 @@ command2.name("capture").description("Capture screenshots of static sites").argu
|
|
|
3200
3250
|
process.exit(1);
|
|
3201
3251
|
}
|
|
3202
3252
|
let ctx = ctx_default(command7.optsWithGlobals());
|
|
3203
|
-
if (!
|
|
3253
|
+
if (!fs6__default.default.existsSync(file)) {
|
|
3204
3254
|
ctx.log.error(`Web Static Config file ${file} not found.`);
|
|
3205
3255
|
return;
|
|
3206
3256
|
}
|
|
3207
3257
|
try {
|
|
3208
|
-
ctx.webStaticConfig = JSON.parse(
|
|
3258
|
+
ctx.webStaticConfig = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
|
|
3209
3259
|
if (!validateWebStaticConfig(ctx.webStaticConfig))
|
|
3210
3260
|
throw new Error(validateWebStaticConfig.errors[0].message);
|
|
3211
3261
|
if (ctx.webStaticConfig && ctx.webStaticConfig.length === 0) {
|
|
@@ -3281,7 +3331,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
3281
3331
|
process.exit(1);
|
|
3282
3332
|
}
|
|
3283
3333
|
let ctx = ctx_default(command7.optsWithGlobals());
|
|
3284
|
-
if (!
|
|
3334
|
+
if (!fs6__default.default.existsSync(directory)) {
|
|
3285
3335
|
console.log(`Error: The provided directory ${directory} not found.`);
|
|
3286
3336
|
return;
|
|
3287
3337
|
}
|
|
@@ -3479,12 +3529,12 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
|
|
|
3479
3529
|
return __async(this, null, function* () {
|
|
3480
3530
|
var _a, _b;
|
|
3481
3531
|
let ctx = ctx_default(command7.optsWithGlobals());
|
|
3482
|
-
if (!
|
|
3532
|
+
if (!fs6__default.default.existsSync(file)) {
|
|
3483
3533
|
console.log(`Error: Figma Config file ${file} not found.`);
|
|
3484
3534
|
return;
|
|
3485
3535
|
}
|
|
3486
3536
|
try {
|
|
3487
|
-
ctx.figmaDesignConfig = JSON.parse(
|
|
3537
|
+
ctx.figmaDesignConfig = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
|
|
3488
3538
|
if (!validateFigmaDesignConfig(ctx.figmaDesignConfig)) {
|
|
3489
3539
|
const validationError = (_b = (_a = validateFigmaDesignConfig.errors) == null ? void 0 : _a[0]) == null ? void 0 : _b.message;
|
|
3490
3540
|
throw new Error(validationError || "Invalid figma design Config");
|
|
@@ -3520,12 +3570,12 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture screenshots
|
|
|
3520
3570
|
return __async(this, null, function* () {
|
|
3521
3571
|
var _a;
|
|
3522
3572
|
let ctx = ctx_default(command7.optsWithGlobals());
|
|
3523
|
-
if (!
|
|
3573
|
+
if (!fs6__default.default.existsSync(file)) {
|
|
3524
3574
|
console.log(`Error: figma-web config file ${file} not found.`);
|
|
3525
3575
|
return;
|
|
3526
3576
|
}
|
|
3527
3577
|
try {
|
|
3528
|
-
ctx.config = JSON.parse(
|
|
3578
|
+
ctx.config = JSON.parse(fs6__default.default.readFileSync(file, "utf8"));
|
|
3529
3579
|
ctx.log.info(JSON.stringify(ctx.config));
|
|
3530
3580
|
if (!validateWebFigmaConfig(ctx.config)) {
|
|
3531
3581
|
ctx.log.debug(JSON.stringify(validateWebFigmaConfig.errors, null, 2));
|