@lambdatest/smartui-cli 4.1.11 → 4.1.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.
- package/dist/index.cjs +336 -48
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1738,7 +1738,8 @@ var env_default = () => {
|
|
|
1738
1738
|
PROJECT_NAME,
|
|
1739
1739
|
SMARTUI_API_PROXY,
|
|
1740
1740
|
SMARTUI_API_SKIP_CERTIFICATES,
|
|
1741
|
-
USE_REMOTE_DISCOVERY
|
|
1741
|
+
USE_REMOTE_DISCOVERY,
|
|
1742
|
+
SMART_GIT
|
|
1742
1743
|
} = process.env;
|
|
1743
1744
|
return {
|
|
1744
1745
|
PROJECT_TOKEN,
|
|
@@ -1759,7 +1760,8 @@ var env_default = () => {
|
|
|
1759
1760
|
PROJECT_NAME,
|
|
1760
1761
|
SMARTUI_API_PROXY,
|
|
1761
1762
|
SMARTUI_API_SKIP_CERTIFICATES: SMARTUI_API_SKIP_CERTIFICATES === "true",
|
|
1762
|
-
USE_REMOTE_DISCOVERY: USE_REMOTE_DISCOVERY === "true"
|
|
1763
|
+
USE_REMOTE_DISCOVERY: USE_REMOTE_DISCOVERY === "true",
|
|
1764
|
+
SMART_GIT: SMART_GIT === "true"
|
|
1763
1765
|
};
|
|
1764
1766
|
};
|
|
1765
1767
|
var logContext = {};
|
|
@@ -1854,7 +1856,7 @@ var authExec_default = (ctx) => {
|
|
|
1854
1856
|
};
|
|
1855
1857
|
|
|
1856
1858
|
// package.json
|
|
1857
|
-
var version = "4.1.
|
|
1859
|
+
var version = "4.1.13";
|
|
1858
1860
|
var package_default = {
|
|
1859
1861
|
name: "@lambdatest/smartui-cli",
|
|
1860
1862
|
version,
|
|
@@ -2084,7 +2086,7 @@ var httpClient = class {
|
|
|
2084
2086
|
}
|
|
2085
2087
|
});
|
|
2086
2088
|
}
|
|
2087
|
-
createBuild(git, config, log2, buildName, isStartExec) {
|
|
2089
|
+
createBuild(git, config, log2, buildName, isStartExec, smartGit, markBaseline, baselineBuild) {
|
|
2088
2090
|
return this.request({
|
|
2089
2091
|
url: "/build",
|
|
2090
2092
|
method: "POST",
|
|
@@ -2093,7 +2095,10 @@ var httpClient = class {
|
|
|
2093
2095
|
config,
|
|
2094
2096
|
buildName,
|
|
2095
2097
|
isStartExec,
|
|
2096
|
-
packageVersion: package_default.version
|
|
2098
|
+
packageVersion: package_default.version,
|
|
2099
|
+
smartGit,
|
|
2100
|
+
markBaseline,
|
|
2101
|
+
baselineBuild
|
|
2097
2102
|
}
|
|
2098
2103
|
}, log2);
|
|
2099
2104
|
}
|
|
@@ -2411,6 +2416,20 @@ var httpClient = class {
|
|
|
2411
2416
|
params: { buildId }
|
|
2412
2417
|
}, log2);
|
|
2413
2418
|
}
|
|
2419
|
+
fetchBuildInfo(requestData, ctx) {
|
|
2420
|
+
return this.request({
|
|
2421
|
+
url: `/fetchBuildInfo`,
|
|
2422
|
+
method: "GET",
|
|
2423
|
+
data: requestData
|
|
2424
|
+
}, ctx.log);
|
|
2425
|
+
}
|
|
2426
|
+
mergeBuildsByBuildId(requestData, ctx) {
|
|
2427
|
+
return this.request({
|
|
2428
|
+
url: `/mergeBuilds`,
|
|
2429
|
+
method: "POST",
|
|
2430
|
+
data: requestData
|
|
2431
|
+
}, ctx.log);
|
|
2432
|
+
}
|
|
2414
2433
|
};
|
|
2415
2434
|
var ctx_default = (options) => {
|
|
2416
2435
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
@@ -2432,6 +2451,7 @@ var ctx_default = (options) => {
|
|
|
2432
2451
|
try {
|
|
2433
2452
|
if (options.config) {
|
|
2434
2453
|
config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
|
|
2454
|
+
logger_default.debug(`Config file ${options.config} loaded: ${JSON.stringify(config, null, 2)}`);
|
|
2435
2455
|
if ((_a = config.web) == null ? void 0 : _a.resolutions) {
|
|
2436
2456
|
config.web.viewports = config.web.resolutions;
|
|
2437
2457
|
delete config.web.resolutions;
|
|
@@ -2439,6 +2459,8 @@ var ctx_default = (options) => {
|
|
|
2439
2459
|
if (!validateConfig(config)) {
|
|
2440
2460
|
throw new Error(validateConfig.errors[0].message);
|
|
2441
2461
|
}
|
|
2462
|
+
} else {
|
|
2463
|
+
logger_default.info("## No config file provided. Using default config.");
|
|
2442
2464
|
}
|
|
2443
2465
|
port = parseInt(options.port || "49152", 10);
|
|
2444
2466
|
if (isNaN(port) || port < 1 || port > 65535) {
|
|
@@ -2543,7 +2565,9 @@ var ctx_default = (options) => {
|
|
|
2543
2565
|
stripExtension: ignoreStripExtension,
|
|
2544
2566
|
ignorePattern: ignoreFilePattern,
|
|
2545
2567
|
fetchResults: fetchResultObj,
|
|
2546
|
-
fetchResultsFileName: fetchResultsFileObj
|
|
2568
|
+
fetchResultsFileName: fetchResultsFileObj,
|
|
2569
|
+
baselineBranch: options.baselineBranch || "",
|
|
2570
|
+
baselineBuild: options.baselineBuild || ""
|
|
2547
2571
|
},
|
|
2548
2572
|
cliVersion: version,
|
|
2549
2573
|
totalSnapshots: -1,
|
|
@@ -2553,13 +2577,21 @@ var ctx_default = (options) => {
|
|
|
2553
2577
|
buildToSnapshotCountMap: /* @__PURE__ */ new Map(),
|
|
2554
2578
|
fetchResultsForBuild: new Array(),
|
|
2555
2579
|
orgId: 0,
|
|
2556
|
-
userId: 0
|
|
2580
|
+
userId: 0,
|
|
2581
|
+
mergeBranchSource: "",
|
|
2582
|
+
mergeBranchTarget: "",
|
|
2583
|
+
mergeBuildSource: "",
|
|
2584
|
+
mergeBuildTarget: "",
|
|
2585
|
+
mergeBuildSourceId: "",
|
|
2586
|
+
mergeBuildTargetId: "",
|
|
2587
|
+
mergeByBranch: false,
|
|
2588
|
+
mergeByBuild: false
|
|
2557
2589
|
};
|
|
2558
2590
|
};
|
|
2559
|
-
function executeCommand(
|
|
2591
|
+
function executeCommand(command9) {
|
|
2560
2592
|
let dst = process.cwd();
|
|
2561
2593
|
try {
|
|
2562
|
-
return child_process.execSync(
|
|
2594
|
+
return child_process.execSync(command9, {
|
|
2563
2595
|
cwd: dst,
|
|
2564
2596
|
stdio: ["ignore"],
|
|
2565
2597
|
encoding: "utf-8"
|
|
@@ -2577,31 +2609,45 @@ function isGitRepo() {
|
|
|
2577
2609
|
}
|
|
2578
2610
|
}
|
|
2579
2611
|
var git_default = (ctx) => {
|
|
2612
|
+
if (ctx.env.SMART_GIT) {
|
|
2613
|
+
ctx.env.BASELINE_BRANCH = "";
|
|
2614
|
+
if (ctx.options.baselineBranch !== "") {
|
|
2615
|
+
ctx.env.SMART_GIT = false;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2580
2618
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
2581
2619
|
let gitInfo = JSON.parse(fs5__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
2620
|
+
if (ctx.options.markBaseline) {
|
|
2621
|
+
ctx.env.BASELINE_BRANCH = ctx.env.CURRENT_BRANCH || gitInfo.branch || "";
|
|
2622
|
+
ctx.env.SMART_GIT = false;
|
|
2623
|
+
}
|
|
2582
2624
|
return {
|
|
2583
2625
|
branch: ctx.env.CURRENT_BRANCH || gitInfo.branch || "",
|
|
2584
2626
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
2585
2627
|
commitMessage: gitInfo.commit_body || "",
|
|
2586
2628
|
commitAuthor: gitInfo.commit_author || "",
|
|
2587
2629
|
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
2588
|
-
baselineBranch: ctx.env.BASELINE_BRANCH || ""
|
|
2630
|
+
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2589
2631
|
};
|
|
2590
2632
|
} else {
|
|
2591
2633
|
const splitCharacter = "<##>";
|
|
2592
2634
|
const prettyFormat = ["%h", "%H", "%s", "%f", "%b", "%at", "%ct", "%an", "%ae", "%cn", "%ce", "%N", ""];
|
|
2593
|
-
const
|
|
2594
|
-
let res = executeCommand(
|
|
2635
|
+
const command9 = 'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) + '" && git rev-parse --abbrev-ref HEAD && git tag --contains HEAD';
|
|
2636
|
+
let res = executeCommand(command9).split(splitCharacter);
|
|
2595
2637
|
var branchAndTags = res[res.length - 1].split("\n").filter((n) => n);
|
|
2596
2638
|
var branch = ctx.env.CURRENT_BRANCH || branchAndTags[0];
|
|
2597
2639
|
branchAndTags.slice(1);
|
|
2640
|
+
if (ctx.options.markBaseline) {
|
|
2641
|
+
ctx.env.BASELINE_BRANCH = branch || "";
|
|
2642
|
+
ctx.env.SMART_GIT = false;
|
|
2643
|
+
}
|
|
2598
2644
|
return {
|
|
2599
2645
|
branch: branch || "",
|
|
2600
2646
|
commitId: res[0] || "",
|
|
2601
2647
|
commitMessage: res[2] || "",
|
|
2602
2648
|
commitAuthor: res[7] || "",
|
|
2603
2649
|
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
2604
|
-
baselineBranch: ctx.env.BASELINE_BRANCH || ""
|
|
2650
|
+
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2605
2651
|
};
|
|
2606
2652
|
}
|
|
2607
2653
|
};
|
|
@@ -2636,14 +2682,21 @@ var createBuildExec_default = (ctx) => {
|
|
|
2636
2682
|
updateLogContext({ task: "createBuild" });
|
|
2637
2683
|
try {
|
|
2638
2684
|
if (ctx2.authenticatedInitially && !ctx2.config.skipBuildCreation) {
|
|
2639
|
-
let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name, ctx2.isStartExec);
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2685
|
+
let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name, ctx2.isStartExec, ctx2.env.SMART_GIT, ctx2.options.markBaseline, ctx2.options.baselineBuild);
|
|
2686
|
+
if (resp && resp.data && resp.data.buildId) {
|
|
2687
|
+
ctx2.build = {
|
|
2688
|
+
id: resp.data.buildId,
|
|
2689
|
+
name: resp.data.buildName,
|
|
2690
|
+
url: resp.data.buildURL,
|
|
2691
|
+
baseline: resp.data.baseline,
|
|
2692
|
+
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
2693
|
+
};
|
|
2694
|
+
} else if (resp && resp.error) {
|
|
2695
|
+
if (resp.error.message) {
|
|
2696
|
+
ctx2.log.error(`Error while creation of build: ${resp.error.message}`);
|
|
2697
|
+
throw new Error(`Error while creation of build: ${resp.error.message}`);
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2647
2700
|
if (ctx2.build.id === "") {
|
|
2648
2701
|
ctx2.log.debug("Build creation failed: Build ID is empty");
|
|
2649
2702
|
task.output = chalk__default.default.red("Build creation failed: Build ID is empty");
|
|
@@ -2659,6 +2712,7 @@ var createBuildExec_default = (ctx) => {
|
|
|
2659
2712
|
}
|
|
2660
2713
|
}
|
|
2661
2714
|
if (ctx2.config.tunnel && ((_b = ctx2.config.tunnel) == null ? void 0 : _b.type) === "auto") {
|
|
2715
|
+
startPingPolling(ctx2);
|
|
2662
2716
|
if (ctx2.build && ctx2.build.id) {
|
|
2663
2717
|
startPollingForTunnel(ctx2, "", false, "");
|
|
2664
2718
|
}
|
|
@@ -2800,6 +2854,10 @@ var finalizeBuild_default = (ctx) => {
|
|
|
2800
2854
|
}
|
|
2801
2855
|
let buildUrls = `build url: ${ctx2.build.url}
|
|
2802
2856
|
`;
|
|
2857
|
+
if (pingIntervalId !== null) {
|
|
2858
|
+
clearInterval(pingIntervalId);
|
|
2859
|
+
ctx2.log.debug("Ping polling stopped immediately.");
|
|
2860
|
+
}
|
|
2803
2861
|
for (const [sessionId, capabilities] of ctx2.sessionCapabilitiesMap.entries()) {
|
|
2804
2862
|
try {
|
|
2805
2863
|
const buildId = (capabilities == null ? void 0 : capabilities.buildId) || "";
|
|
@@ -3775,7 +3833,7 @@ var Queue = class {
|
|
|
3775
3833
|
} else {
|
|
3776
3834
|
if (!((_c = this.ctx.build) == null ? void 0 : _c.id)) {
|
|
3777
3835
|
if (this.ctx.authenticatedInitially) {
|
|
3778
|
-
let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name);
|
|
3836
|
+
let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
|
|
3779
3837
|
this.ctx.build = {
|
|
3780
3838
|
id: resp.data.buildId,
|
|
3781
3839
|
name: resp.data.buildName,
|
|
@@ -3879,15 +3937,15 @@ var startTunnel_default = (ctx) => {
|
|
|
3879
3937
|
|
|
3880
3938
|
// src/commander/exec.ts
|
|
3881
3939
|
var command = new commander.Command();
|
|
3882
|
-
command.name("exec").description("Run test commands around SmartUI").argument("<command...>", "Command supplied for running tests").option("-P, --port <number>", "Port number for the server").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(execCommand, _,
|
|
3940
|
+
command.name("exec").description("Run test commands around SmartUI").argument("<command...>", "Command supplied for running tests").option("-P, --port <number>", "Port number for the server").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(execCommand, _, command9) {
|
|
3883
3941
|
return __async(this, null, function* () {
|
|
3884
3942
|
var _a;
|
|
3885
|
-
const options =
|
|
3943
|
+
const options = command9.optsWithGlobals();
|
|
3886
3944
|
if (options.buildName === "") {
|
|
3887
3945
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
3888
3946
|
process.exit(1);
|
|
3889
3947
|
}
|
|
3890
|
-
let ctx = ctx_default(
|
|
3948
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
3891
3949
|
if (!which__default.default.sync(execCommand[0], { nothrow: true })) {
|
|
3892
3950
|
ctx.log.error(`Error: Command not found "${execCommand[0]}"`);
|
|
3893
3951
|
return;
|
|
@@ -4109,14 +4167,21 @@ var createBuild_default = (ctx) => {
|
|
|
4109
4167
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
4110
4168
|
updateLogContext({ task: "createBuild" });
|
|
4111
4169
|
try {
|
|
4112
|
-
let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name, ctx2.isStartExec);
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4170
|
+
let resp = yield ctx2.client.createBuild(ctx2.git, ctx2.config, ctx2.log, ctx2.build.name, ctx2.isStartExec, ctx2.env.SMART_GIT, ctx2.options.markBaseline, ctx2.options.baselineBuild);
|
|
4171
|
+
if (resp && resp.data && resp.data.buildId) {
|
|
4172
|
+
ctx2.build = {
|
|
4173
|
+
id: resp.data.buildId,
|
|
4174
|
+
name: resp.data.buildName,
|
|
4175
|
+
url: resp.data.buildURL,
|
|
4176
|
+
baseline: resp.data.baseline,
|
|
4177
|
+
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
4178
|
+
};
|
|
4179
|
+
} else if (resp && resp.error) {
|
|
4180
|
+
if (resp.error.message) {
|
|
4181
|
+
ctx2.log.error(`Error while creation of build: ${resp.error.message}`);
|
|
4182
|
+
throw new Error(`Error while creation of build: ${resp.error.message}`);
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4120
4185
|
task.output = chalk__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
4121
4186
|
task.title = "SmartUI build created";
|
|
4122
4187
|
} catch (error) {
|
|
@@ -4493,15 +4558,15 @@ var captureScreenshots_default = (ctx) => {
|
|
|
4493
4558
|
|
|
4494
4559
|
// src/commander/capture.ts
|
|
4495
4560
|
var command2 = new commander.Command();
|
|
4496
|
-
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("-C, --parallel [number]", "Specify the number of instances per browser", parseInt).option("-F, --force", "forcefully apply the specified parallel instances per browser").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(file, _,
|
|
4561
|
+
command2.name("capture").description("Capture screenshots of static sites").argument("<file>", "Web static config file").option("-C, --parallel [number]", "Specify the number of instances per browser", parseInt).option("-F, --force", "forcefully apply the specified parallel instances per browser").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(file, _, command9) {
|
|
4497
4562
|
return __async(this, null, function* () {
|
|
4498
4563
|
var _a, _b;
|
|
4499
|
-
const options =
|
|
4564
|
+
const options = command9.optsWithGlobals();
|
|
4500
4565
|
if (options.buildName === "") {
|
|
4501
4566
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4502
4567
|
process.exit(1);
|
|
4503
4568
|
}
|
|
4504
|
-
let ctx = ctx_default(
|
|
4569
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4505
4570
|
ctx.isSnapshotCaptured = true;
|
|
4506
4571
|
if (!fs5__default.default.existsSync(file)) {
|
|
4507
4572
|
ctx.log.error(`Web Static Config file ${file} not found.`);
|
|
@@ -4586,14 +4651,14 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
4586
4651
|
return val.split(",").map((ext) => ext.trim().toLowerCase());
|
|
4587
4652
|
}).option("-E, --removeExtensions", "Strips file extensions from snapshot names").option("-i, --ignoreDir <patterns>", "Comma-separated list of directories to ignore", (val) => {
|
|
4588
4653
|
return val.split(",").map((pattern) => pattern.trim());
|
|
4589
|
-
}).option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(directory, _,
|
|
4654
|
+
}).option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").option("--buildName <string>", "Specify the build name").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").action(function(directory, _, command9) {
|
|
4590
4655
|
return __async(this, null, function* () {
|
|
4591
|
-
const options =
|
|
4656
|
+
const options = command9.optsWithGlobals();
|
|
4592
4657
|
if (options.buildName === "") {
|
|
4593
4658
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4594
4659
|
process.exit(1);
|
|
4595
4660
|
}
|
|
4596
|
-
let ctx = ctx_default(
|
|
4661
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4597
4662
|
ctx.isSnapshotCaptured = true;
|
|
4598
4663
|
if (!fs5__default.default.existsSync(directory)) {
|
|
4599
4664
|
console.log(`Error: The provided directory ${directory} not found.`);
|
|
@@ -4870,10 +4935,10 @@ var uploadAppFigma_default2 = (ctx) => {
|
|
|
4870
4935
|
var uploadFigma = new commander.Command();
|
|
4871
4936
|
var uploadWebFigmaCommand = new commander.Command();
|
|
4872
4937
|
var uploadAppFigmaCommand = new commander.Command();
|
|
4873
|
-
uploadFigma.name("upload-figma").description("Capture screenshots of static sites").argument("<file>", "figma design config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").action(function(file, _,
|
|
4938
|
+
uploadFigma.name("upload-figma").description("Capture screenshots of static sites").argument("<file>", "figma design config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").action(function(file, _, command9) {
|
|
4874
4939
|
return __async(this, null, function* () {
|
|
4875
4940
|
var _a, _b;
|
|
4876
|
-
let ctx = ctx_default(
|
|
4941
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4877
4942
|
ctx.isSnapshotCaptured = true;
|
|
4878
4943
|
if (!fs5__default.default.existsSync(file)) {
|
|
4879
4944
|
console.log(`Error: Figma Config file ${file} not found.`);
|
|
@@ -4912,10 +4977,10 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
|
|
|
4912
4977
|
}
|
|
4913
4978
|
});
|
|
4914
4979
|
});
|
|
4915
|
-
uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screenshots into CLI build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _,
|
|
4980
|
+
uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screenshots into CLI build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command9) {
|
|
4916
4981
|
return __async(this, null, function* () {
|
|
4917
4982
|
var _a;
|
|
4918
|
-
let ctx = ctx_default(
|
|
4983
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4919
4984
|
if (!fs5__default.default.existsSync(file)) {
|
|
4920
4985
|
console.log(`Error: figma-web config file ${file} not found.`);
|
|
4921
4986
|
return;
|
|
@@ -4964,10 +5029,10 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screen
|
|
|
4964
5029
|
}
|
|
4965
5030
|
});
|
|
4966
5031
|
});
|
|
4967
|
-
uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screenshots into App Build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _,
|
|
5032
|
+
uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screenshots into App Build").argument("<file>", "figma config config file").option("--markBaseline", "Mark the uploaded images as baseline").option("--buildName <buildName>", "Name of the build").option("--fetch-results [filename]", "Fetch results and optionally specify an output file, e.g., <filename>.json").action(function(file, _, command9) {
|
|
4968
5033
|
return __async(this, null, function* () {
|
|
4969
5034
|
var _a;
|
|
4970
|
-
let ctx = ctx_default(
|
|
5035
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4971
5036
|
if (!fs5__default.default.existsSync(file)) {
|
|
4972
5037
|
console.log(`Error: figma-app config file ${file} not found.`);
|
|
4973
5038
|
return;
|
|
@@ -5118,11 +5183,234 @@ command6.name("exec:ping").description("Ping the SmartUI server to check if it i
|
|
|
5118
5183
|
});
|
|
5119
5184
|
});
|
|
5120
5185
|
var ping_default = command6;
|
|
5186
|
+
var fetchBranchInfo_default = (ctx) => {
|
|
5187
|
+
return {
|
|
5188
|
+
title: `Fetching branch info`,
|
|
5189
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5190
|
+
updateLogContext({ task: "fetchBranchInfo" });
|
|
5191
|
+
try {
|
|
5192
|
+
if (ctx2.mergeBranchSource === ctx2.mergeBranchTarget) {
|
|
5193
|
+
ctx2.log.error(`Merging two similar branch is not possible`);
|
|
5194
|
+
throw new Error(`Merging two similar branch is not possible`);
|
|
5195
|
+
}
|
|
5196
|
+
const requestData = {
|
|
5197
|
+
source: ctx2.mergeBranchSource,
|
|
5198
|
+
target: ctx2.mergeBranchTarget,
|
|
5199
|
+
byBranch: ctx2.mergeByBranch,
|
|
5200
|
+
byBuild: ctx2.mergeByBuild
|
|
5201
|
+
};
|
|
5202
|
+
let resp = yield ctx2.client.fetchBuildInfo(requestData, ctx2);
|
|
5203
|
+
if (resp && resp.data && resp.data.source && resp.data.target) {
|
|
5204
|
+
ctx2.mergeBuildSourceId = resp.data.source;
|
|
5205
|
+
ctx2.mergeBuildTargetId = resp.data.target;
|
|
5206
|
+
ctx2.log.debug(`Merge Build source buildId: ${ctx2.mergeBuildSourceId} and target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5207
|
+
} else if (resp && resp.error) {
|
|
5208
|
+
if (resp.error.message) {
|
|
5209
|
+
ctx2.log.error(`Error while fetching branch Info: ${resp.error.message}`);
|
|
5210
|
+
throw new Error(`Error while fetching branch Info: ${resp.error.message}`);
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
task.title = "Branch info fetched";
|
|
5214
|
+
task.output = chalk__default.default.gray(`Source buildId: ${ctx2.mergeBuildSourceId} and Target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5215
|
+
} catch (error) {
|
|
5216
|
+
ctx2.log.debug(error);
|
|
5217
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5218
|
+
throw new Error("Branch info fetching failed");
|
|
5219
|
+
}
|
|
5220
|
+
}),
|
|
5221
|
+
rendererOptions: { persistentOutput: true }
|
|
5222
|
+
};
|
|
5223
|
+
};
|
|
5224
|
+
var mergeBuilds_default = (ctx) => {
|
|
5225
|
+
return {
|
|
5226
|
+
title: `Merging smartui builds`,
|
|
5227
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5228
|
+
updateLogContext({ task: "mergeBuilds" });
|
|
5229
|
+
try {
|
|
5230
|
+
let resp;
|
|
5231
|
+
if (ctx2.mergeByBranch) {
|
|
5232
|
+
ctx2.git.branch = ctx2.mergeBranchTarget;
|
|
5233
|
+
const requestData = {
|
|
5234
|
+
source: ctx2.mergeBuildSourceId,
|
|
5235
|
+
target: ctx2.mergeBuildTargetId,
|
|
5236
|
+
byBranch: ctx2.mergeByBranch,
|
|
5237
|
+
byBuildName: ctx2.mergeByBuild,
|
|
5238
|
+
sourceBranchName: ctx2.mergeBranchSource,
|
|
5239
|
+
targetBranchName: ctx2.mergeBranchTarget,
|
|
5240
|
+
sourceBuildName: "",
|
|
5241
|
+
targetBuildName: "",
|
|
5242
|
+
git: ctx2.git
|
|
5243
|
+
};
|
|
5244
|
+
resp = yield ctx2.client.mergeBuildsByBuildId(requestData, ctx2);
|
|
5245
|
+
} else {
|
|
5246
|
+
const requestData = {
|
|
5247
|
+
source: ctx2.mergeBuildSourceId,
|
|
5248
|
+
target: ctx2.mergeBuildTargetId,
|
|
5249
|
+
byBranch: ctx2.mergeByBranch,
|
|
5250
|
+
byBuildName: ctx2.mergeByBuild,
|
|
5251
|
+
sourceBranchName: "",
|
|
5252
|
+
targetBranchName: "",
|
|
5253
|
+
sourceBuildName: ctx2.mergeBuildSource,
|
|
5254
|
+
targetBuildName: ctx2.mergeBuildTarget,
|
|
5255
|
+
git: ctx2.git
|
|
5256
|
+
};
|
|
5257
|
+
resp = yield ctx2.client.mergeBuildsByBuildId(requestData, ctx2);
|
|
5258
|
+
}
|
|
5259
|
+
if (resp && resp.data && resp.data.message) {
|
|
5260
|
+
ctx2.log.debug(`${resp.data.message}`);
|
|
5261
|
+
} else {
|
|
5262
|
+
ctx2.log.error(`Error while initiating merging process: ${resp.error.message}`);
|
|
5263
|
+
throw new Error(`Error while initiating merging process: ${resp.error.message}`);
|
|
5264
|
+
}
|
|
5265
|
+
task.title = "Merging SmartUI builds initiated";
|
|
5266
|
+
task.output = chalk__default.default.gray(`${resp.data.message}`);
|
|
5267
|
+
} catch (error) {
|
|
5268
|
+
ctx2.log.debug(error);
|
|
5269
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5270
|
+
throw new Error("Merging SmartUI build failed");
|
|
5271
|
+
}
|
|
5272
|
+
}),
|
|
5273
|
+
rendererOptions: { persistentOutput: true }
|
|
5274
|
+
};
|
|
5275
|
+
};
|
|
5121
5276
|
|
|
5122
|
-
// src/commander/
|
|
5277
|
+
// src/commander/mergeBranch.ts
|
|
5278
|
+
var command7 = new commander.Command();
|
|
5279
|
+
command7.name("branch").description("Merge a source branch into the target branch").requiredOption("--source <string>", "Source branch to merge").requiredOption("--target <string>", "Target branch to merge into").action(function(options) {
|
|
5280
|
+
return __async(this, null, function* () {
|
|
5281
|
+
const { source, target } = options;
|
|
5282
|
+
let ctx = ctx_default(command7.optsWithGlobals());
|
|
5283
|
+
if (!source || source.trim() === "") {
|
|
5284
|
+
ctx.log.error("Error: The --source option cannot be empty.");
|
|
5285
|
+
process.exit(1);
|
|
5286
|
+
}
|
|
5287
|
+
if (!target || target.trim() === "") {
|
|
5288
|
+
ctx.log.error("Error: The --target option cannot be empty.");
|
|
5289
|
+
process.exit(1);
|
|
5290
|
+
}
|
|
5291
|
+
ctx.log.debug(`Merging source branch '${source}' into branch branch '${target}'`);
|
|
5292
|
+
ctx.mergeBranchSource = source;
|
|
5293
|
+
ctx.mergeBranchTarget = target;
|
|
5294
|
+
ctx.mergeByBranch = true;
|
|
5295
|
+
let tasks = new listr2.Listr(
|
|
5296
|
+
[
|
|
5297
|
+
auth_default(),
|
|
5298
|
+
getGitInfo_default(),
|
|
5299
|
+
fetchBranchInfo_default(),
|
|
5300
|
+
mergeBuilds_default()
|
|
5301
|
+
],
|
|
5302
|
+
{
|
|
5303
|
+
rendererOptions: {
|
|
5304
|
+
icon: {
|
|
5305
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: "\u2192"
|
|
5306
|
+
},
|
|
5307
|
+
color: {
|
|
5308
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: listr2.color.gray
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
5311
|
+
}
|
|
5312
|
+
);
|
|
5313
|
+
try {
|
|
5314
|
+
yield tasks.run(ctx);
|
|
5315
|
+
} catch (error) {
|
|
5316
|
+
console.error("Error during merge operation:", error);
|
|
5317
|
+
}
|
|
5318
|
+
});
|
|
5319
|
+
});
|
|
5320
|
+
var mergeBranch_default = command7;
|
|
5321
|
+
var fetchBuildInfo_default = (ctx) => {
|
|
5322
|
+
return {
|
|
5323
|
+
title: `Fetching build info`,
|
|
5324
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5325
|
+
updateLogContext({ task: "fetchBuildInfo" });
|
|
5326
|
+
try {
|
|
5327
|
+
if (ctx2.mergeBuildSource === ctx2.mergeBuildTarget) {
|
|
5328
|
+
ctx2.log.error(`Merging two similar build is not possible`);
|
|
5329
|
+
throw new Error(`Merging two similar build is not possible`);
|
|
5330
|
+
}
|
|
5331
|
+
const requestData = {
|
|
5332
|
+
source: ctx2.mergeBuildSource,
|
|
5333
|
+
target: ctx2.mergeBuildTarget,
|
|
5334
|
+
byBranch: ctx2.mergeByBranch,
|
|
5335
|
+
byBuildName: ctx2.mergeByBuild
|
|
5336
|
+
};
|
|
5337
|
+
let resp = yield ctx2.client.fetchBuildInfo(requestData, ctx2);
|
|
5338
|
+
if (resp && resp.data && resp.data.source && resp.data.target) {
|
|
5339
|
+
ctx2.mergeBuildSourceId = resp.data.source;
|
|
5340
|
+
ctx2.mergeBuildTargetId = resp.data.target;
|
|
5341
|
+
ctx2.log.debug(`Merge Build source buildId: ${ctx2.mergeBuildSourceId} and target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5342
|
+
} else if (resp && resp.error) {
|
|
5343
|
+
if (resp.error.message) {
|
|
5344
|
+
ctx2.log.error(`Error while fetching buildInfo: ${resp.error.message}`);
|
|
5345
|
+
throw new Error(`Error while fetching buildInfo: ${resp.error.message}`);
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
task.title = "Build info fetched";
|
|
5349
|
+
task.output = chalk__default.default.gray(`Source buildId: ${ctx2.mergeBuildSourceId} and Target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5350
|
+
} catch (error) {
|
|
5351
|
+
ctx2.log.debug(error);
|
|
5352
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5353
|
+
throw new Error("Build info fetching failed");
|
|
5354
|
+
}
|
|
5355
|
+
}),
|
|
5356
|
+
rendererOptions: { persistentOutput: true }
|
|
5357
|
+
};
|
|
5358
|
+
};
|
|
5359
|
+
|
|
5360
|
+
// src/commander/mergeBuild.ts
|
|
5361
|
+
var command8 = new commander.Command();
|
|
5362
|
+
command8.name("build").description("Merge a source build into the target build").requiredOption("--source <string>", "Source build to merge").requiredOption("--target <string>", "Target build to merge into").action(function(options) {
|
|
5363
|
+
return __async(this, null, function* () {
|
|
5364
|
+
const { source, target } = options;
|
|
5365
|
+
let ctx = ctx_default(command8.optsWithGlobals());
|
|
5366
|
+
if (!source || source.trim() === "") {
|
|
5367
|
+
ctx.log.error("Error: The --source option cannot be empty.");
|
|
5368
|
+
process.exit(1);
|
|
5369
|
+
}
|
|
5370
|
+
if (!target || target.trim() === "") {
|
|
5371
|
+
ctx.log.error("Error: The --target option cannot be empty.");
|
|
5372
|
+
process.exit(1);
|
|
5373
|
+
}
|
|
5374
|
+
ctx.log.debug(`Merging source build '${source}' into target build '${target}'`);
|
|
5375
|
+
ctx.mergeBuildSource = source;
|
|
5376
|
+
ctx.mergeBuildTarget = target;
|
|
5377
|
+
ctx.mergeByBuild = true;
|
|
5378
|
+
let tasks = new listr2.Listr(
|
|
5379
|
+
[
|
|
5380
|
+
auth_default(),
|
|
5381
|
+
getGitInfo_default(),
|
|
5382
|
+
fetchBuildInfo_default(),
|
|
5383
|
+
mergeBuilds_default()
|
|
5384
|
+
],
|
|
5385
|
+
{
|
|
5386
|
+
rendererOptions: {
|
|
5387
|
+
icon: {
|
|
5388
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: "\u2192"
|
|
5389
|
+
},
|
|
5390
|
+
color: {
|
|
5391
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: listr2.color.gray
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5395
|
+
);
|
|
5396
|
+
try {
|
|
5397
|
+
yield tasks.run(ctx);
|
|
5398
|
+
} catch (error) {
|
|
5399
|
+
console.error("Error during merge operation:", error);
|
|
5400
|
+
}
|
|
5401
|
+
});
|
|
5402
|
+
});
|
|
5403
|
+
var mergeBuild_default = command8;
|
|
5404
|
+
|
|
5405
|
+
// src/commander/merge.ts
|
|
5123
5406
|
var program = new commander.Command();
|
|
5124
|
-
program.name("
|
|
5125
|
-
var
|
|
5407
|
+
program.name("merge").description("Merge a source branch into the target branch").addCommand(mergeBranch_default).addCommand(mergeBuild_default);
|
|
5408
|
+
var merge_default = program;
|
|
5409
|
+
|
|
5410
|
+
// src/commander/commander.ts
|
|
5411
|
+
var program2 = new commander.Command();
|
|
5412
|
+
program2.name("smartui").description("CLI to help you run your SmartUI tests on LambdaTest platform").version(`v${version}`).option("-c --config <filepath>", "Config file path").option("--markBaseline", "Mark this build baseline").option("--baselineBranch <string>", "Mark this build baseline").option("--baselineBuild <string>", "Mark this build baseline").addCommand(exec_default2).addCommand(capture_default).addCommand(configWeb).addCommand(configStatic).addCommand(upload_default).addCommand(server_default2).addCommand(stopServer_default).addCommand(merge_default).addCommand(ping_default).addCommand(configFigma).addCommand(uploadFigma).addCommand(configWebFigma).addCommand(configAppFigma).addCommand(uploadWebFigmaCommand).addCommand(uploadAppFigmaCommand);
|
|
5413
|
+
var commander_default = program2;
|
|
5126
5414
|
(function() {
|
|
5127
5415
|
return __async(this, null, function* () {
|
|
5128
5416
|
let client = new httpClient(env_default());
|