@lambdatest/smartui-cli 4.1.11 → 4.1.12
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 +331 -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.12";
|
|
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");
|
|
@@ -3775,7 +3828,7 @@ var Queue = class {
|
|
|
3775
3828
|
} else {
|
|
3776
3829
|
if (!((_c = this.ctx.build) == null ? void 0 : _c.id)) {
|
|
3777
3830
|
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);
|
|
3831
|
+
let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
|
|
3779
3832
|
this.ctx.build = {
|
|
3780
3833
|
id: resp.data.buildId,
|
|
3781
3834
|
name: resp.data.buildName,
|
|
@@ -3879,15 +3932,15 @@ var startTunnel_default = (ctx) => {
|
|
|
3879
3932
|
|
|
3880
3933
|
// src/commander/exec.ts
|
|
3881
3934
|
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, _,
|
|
3935
|
+
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
3936
|
return __async(this, null, function* () {
|
|
3884
3937
|
var _a;
|
|
3885
|
-
const options =
|
|
3938
|
+
const options = command9.optsWithGlobals();
|
|
3886
3939
|
if (options.buildName === "") {
|
|
3887
3940
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
3888
3941
|
process.exit(1);
|
|
3889
3942
|
}
|
|
3890
|
-
let ctx = ctx_default(
|
|
3943
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
3891
3944
|
if (!which__default.default.sync(execCommand[0], { nothrow: true })) {
|
|
3892
3945
|
ctx.log.error(`Error: Command not found "${execCommand[0]}"`);
|
|
3893
3946
|
return;
|
|
@@ -4109,14 +4162,21 @@ var createBuild_default = (ctx) => {
|
|
|
4109
4162
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
4110
4163
|
updateLogContext({ task: "createBuild" });
|
|
4111
4164
|
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
|
-
|
|
4165
|
+
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);
|
|
4166
|
+
if (resp && resp.data && resp.data.buildId) {
|
|
4167
|
+
ctx2.build = {
|
|
4168
|
+
id: resp.data.buildId,
|
|
4169
|
+
name: resp.data.buildName,
|
|
4170
|
+
url: resp.data.buildURL,
|
|
4171
|
+
baseline: resp.data.baseline,
|
|
4172
|
+
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
4173
|
+
};
|
|
4174
|
+
} else if (resp && resp.error) {
|
|
4175
|
+
if (resp.error.message) {
|
|
4176
|
+
ctx2.log.error(`Error while creation of build: ${resp.error.message}`);
|
|
4177
|
+
throw new Error(`Error while creation of build: ${resp.error.message}`);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4120
4180
|
task.output = chalk__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
4121
4181
|
task.title = "SmartUI build created";
|
|
4122
4182
|
} catch (error) {
|
|
@@ -4493,15 +4553,15 @@ var captureScreenshots_default = (ctx) => {
|
|
|
4493
4553
|
|
|
4494
4554
|
// src/commander/capture.ts
|
|
4495
4555
|
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, _,
|
|
4556
|
+
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
4557
|
return __async(this, null, function* () {
|
|
4498
4558
|
var _a, _b;
|
|
4499
|
-
const options =
|
|
4559
|
+
const options = command9.optsWithGlobals();
|
|
4500
4560
|
if (options.buildName === "") {
|
|
4501
4561
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4502
4562
|
process.exit(1);
|
|
4503
4563
|
}
|
|
4504
|
-
let ctx = ctx_default(
|
|
4564
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4505
4565
|
ctx.isSnapshotCaptured = true;
|
|
4506
4566
|
if (!fs5__default.default.existsSync(file)) {
|
|
4507
4567
|
ctx.log.error(`Web Static Config file ${file} not found.`);
|
|
@@ -4586,14 +4646,14 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
4586
4646
|
return val.split(",").map((ext) => ext.trim().toLowerCase());
|
|
4587
4647
|
}).option("-E, --removeExtensions", "Strips file extensions from snapshot names").option("-i, --ignoreDir <patterns>", "Comma-separated list of directories to ignore", (val) => {
|
|
4588
4648
|
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, _,
|
|
4649
|
+
}).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
4650
|
return __async(this, null, function* () {
|
|
4591
|
-
const options =
|
|
4651
|
+
const options = command9.optsWithGlobals();
|
|
4592
4652
|
if (options.buildName === "") {
|
|
4593
4653
|
console.log(`Error: The '--buildName' option cannot be an empty string.`);
|
|
4594
4654
|
process.exit(1);
|
|
4595
4655
|
}
|
|
4596
|
-
let ctx = ctx_default(
|
|
4656
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4597
4657
|
ctx.isSnapshotCaptured = true;
|
|
4598
4658
|
if (!fs5__default.default.existsSync(directory)) {
|
|
4599
4659
|
console.log(`Error: The provided directory ${directory} not found.`);
|
|
@@ -4870,10 +4930,10 @@ var uploadAppFigma_default2 = (ctx) => {
|
|
|
4870
4930
|
var uploadFigma = new commander.Command();
|
|
4871
4931
|
var uploadWebFigmaCommand = new commander.Command();
|
|
4872
4932
|
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, _,
|
|
4933
|
+
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
4934
|
return __async(this, null, function* () {
|
|
4875
4935
|
var _a, _b;
|
|
4876
|
-
let ctx = ctx_default(
|
|
4936
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4877
4937
|
ctx.isSnapshotCaptured = true;
|
|
4878
4938
|
if (!fs5__default.default.existsSync(file)) {
|
|
4879
4939
|
console.log(`Error: Figma Config file ${file} not found.`);
|
|
@@ -4912,10 +4972,10 @@ uploadFigma.name("upload-figma").description("Capture screenshots of static site
|
|
|
4912
4972
|
}
|
|
4913
4973
|
});
|
|
4914
4974
|
});
|
|
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, _,
|
|
4975
|
+
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
4976
|
return __async(this, null, function* () {
|
|
4917
4977
|
var _a;
|
|
4918
|
-
let ctx = ctx_default(
|
|
4978
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4919
4979
|
if (!fs5__default.default.existsSync(file)) {
|
|
4920
4980
|
console.log(`Error: figma-web config file ${file} not found.`);
|
|
4921
4981
|
return;
|
|
@@ -4964,10 +5024,10 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screen
|
|
|
4964
5024
|
}
|
|
4965
5025
|
});
|
|
4966
5026
|
});
|
|
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, _,
|
|
5027
|
+
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
5028
|
return __async(this, null, function* () {
|
|
4969
5029
|
var _a;
|
|
4970
|
-
let ctx = ctx_default(
|
|
5030
|
+
let ctx = ctx_default(command9.optsWithGlobals());
|
|
4971
5031
|
if (!fs5__default.default.existsSync(file)) {
|
|
4972
5032
|
console.log(`Error: figma-app config file ${file} not found.`);
|
|
4973
5033
|
return;
|
|
@@ -5118,11 +5178,234 @@ command6.name("exec:ping").description("Ping the SmartUI server to check if it i
|
|
|
5118
5178
|
});
|
|
5119
5179
|
});
|
|
5120
5180
|
var ping_default = command6;
|
|
5181
|
+
var fetchBranchInfo_default = (ctx) => {
|
|
5182
|
+
return {
|
|
5183
|
+
title: `Fetching branch info`,
|
|
5184
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5185
|
+
updateLogContext({ task: "fetchBranchInfo" });
|
|
5186
|
+
try {
|
|
5187
|
+
if (ctx2.mergeBranchSource === ctx2.mergeBranchTarget) {
|
|
5188
|
+
ctx2.log.error(`Merging two similar branch is not possible`);
|
|
5189
|
+
throw new Error(`Merging two similar branch is not possible`);
|
|
5190
|
+
}
|
|
5191
|
+
const requestData = {
|
|
5192
|
+
source: ctx2.mergeBranchSource,
|
|
5193
|
+
target: ctx2.mergeBranchTarget,
|
|
5194
|
+
byBranch: ctx2.mergeByBranch,
|
|
5195
|
+
byBuild: ctx2.mergeByBuild
|
|
5196
|
+
};
|
|
5197
|
+
let resp = yield ctx2.client.fetchBuildInfo(requestData, ctx2);
|
|
5198
|
+
if (resp && resp.data && resp.data.source && resp.data.target) {
|
|
5199
|
+
ctx2.mergeBuildSourceId = resp.data.source;
|
|
5200
|
+
ctx2.mergeBuildTargetId = resp.data.target;
|
|
5201
|
+
ctx2.log.debug(`Merge Build source buildId: ${ctx2.mergeBuildSourceId} and target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5202
|
+
} else if (resp && resp.error) {
|
|
5203
|
+
if (resp.error.message) {
|
|
5204
|
+
ctx2.log.error(`Error while fetching branch Info: ${resp.error.message}`);
|
|
5205
|
+
throw new Error(`Error while fetching branch Info: ${resp.error.message}`);
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
task.title = "Branch info fetched";
|
|
5209
|
+
task.output = chalk__default.default.gray(`Source buildId: ${ctx2.mergeBuildSourceId} and Target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5210
|
+
} catch (error) {
|
|
5211
|
+
ctx2.log.debug(error);
|
|
5212
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5213
|
+
throw new Error("Branch info fetching failed");
|
|
5214
|
+
}
|
|
5215
|
+
}),
|
|
5216
|
+
rendererOptions: { persistentOutput: true }
|
|
5217
|
+
};
|
|
5218
|
+
};
|
|
5219
|
+
var mergeBuilds_default = (ctx) => {
|
|
5220
|
+
return {
|
|
5221
|
+
title: `Merging smartui builds`,
|
|
5222
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5223
|
+
updateLogContext({ task: "mergeBuilds" });
|
|
5224
|
+
try {
|
|
5225
|
+
let resp;
|
|
5226
|
+
if (ctx2.mergeByBranch) {
|
|
5227
|
+
ctx2.git.branch = ctx2.mergeBranchTarget;
|
|
5228
|
+
const requestData = {
|
|
5229
|
+
source: ctx2.mergeBuildSourceId,
|
|
5230
|
+
target: ctx2.mergeBuildTargetId,
|
|
5231
|
+
byBranch: ctx2.mergeByBranch,
|
|
5232
|
+
byBuildName: ctx2.mergeByBuild,
|
|
5233
|
+
sourceBranchName: ctx2.mergeBranchSource,
|
|
5234
|
+
targetBranchName: ctx2.mergeBranchTarget,
|
|
5235
|
+
sourceBuildName: "",
|
|
5236
|
+
targetBuildName: "",
|
|
5237
|
+
git: ctx2.git
|
|
5238
|
+
};
|
|
5239
|
+
resp = yield ctx2.client.mergeBuildsByBuildId(requestData, ctx2);
|
|
5240
|
+
} else {
|
|
5241
|
+
const requestData = {
|
|
5242
|
+
source: ctx2.mergeBuildSourceId,
|
|
5243
|
+
target: ctx2.mergeBuildTargetId,
|
|
5244
|
+
byBranch: ctx2.mergeByBranch,
|
|
5245
|
+
byBuildName: ctx2.mergeByBuild,
|
|
5246
|
+
sourceBranchName: "",
|
|
5247
|
+
targetBranchName: "",
|
|
5248
|
+
sourceBuildName: ctx2.mergeBuildSource,
|
|
5249
|
+
targetBuildName: ctx2.mergeBuildTarget,
|
|
5250
|
+
git: ctx2.git
|
|
5251
|
+
};
|
|
5252
|
+
resp = yield ctx2.client.mergeBuildsByBuildId(requestData, ctx2);
|
|
5253
|
+
}
|
|
5254
|
+
if (resp && resp.data && resp.data.message) {
|
|
5255
|
+
ctx2.log.debug(`${resp.data.message}`);
|
|
5256
|
+
} else {
|
|
5257
|
+
ctx2.log.error(`Error while initiating merging process: ${resp.error.message}`);
|
|
5258
|
+
throw new Error(`Error while initiating merging process: ${resp.error.message}`);
|
|
5259
|
+
}
|
|
5260
|
+
task.title = "Merging SmartUI builds initiated";
|
|
5261
|
+
task.output = chalk__default.default.gray(`${resp.data.message}`);
|
|
5262
|
+
} catch (error) {
|
|
5263
|
+
ctx2.log.debug(error);
|
|
5264
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5265
|
+
throw new Error("Merging SmartUI build failed");
|
|
5266
|
+
}
|
|
5267
|
+
}),
|
|
5268
|
+
rendererOptions: { persistentOutput: true }
|
|
5269
|
+
};
|
|
5270
|
+
};
|
|
5121
5271
|
|
|
5122
|
-
// src/commander/
|
|
5272
|
+
// src/commander/mergeBranch.ts
|
|
5273
|
+
var command7 = new commander.Command();
|
|
5274
|
+
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) {
|
|
5275
|
+
return __async(this, null, function* () {
|
|
5276
|
+
const { source, target } = options;
|
|
5277
|
+
let ctx = ctx_default(command7.optsWithGlobals());
|
|
5278
|
+
if (!source || source.trim() === "") {
|
|
5279
|
+
ctx.log.error("Error: The --source option cannot be empty.");
|
|
5280
|
+
process.exit(1);
|
|
5281
|
+
}
|
|
5282
|
+
if (!target || target.trim() === "") {
|
|
5283
|
+
ctx.log.error("Error: The --target option cannot be empty.");
|
|
5284
|
+
process.exit(1);
|
|
5285
|
+
}
|
|
5286
|
+
ctx.log.debug(`Merging source branch '${source}' into branch branch '${target}'`);
|
|
5287
|
+
ctx.mergeBranchSource = source;
|
|
5288
|
+
ctx.mergeBranchTarget = target;
|
|
5289
|
+
ctx.mergeByBranch = true;
|
|
5290
|
+
let tasks = new listr2.Listr(
|
|
5291
|
+
[
|
|
5292
|
+
auth_default(),
|
|
5293
|
+
getGitInfo_default(),
|
|
5294
|
+
fetchBranchInfo_default(),
|
|
5295
|
+
mergeBuilds_default()
|
|
5296
|
+
],
|
|
5297
|
+
{
|
|
5298
|
+
rendererOptions: {
|
|
5299
|
+
icon: {
|
|
5300
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: "\u2192"
|
|
5301
|
+
},
|
|
5302
|
+
color: {
|
|
5303
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: listr2.color.gray
|
|
5304
|
+
}
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5307
|
+
);
|
|
5308
|
+
try {
|
|
5309
|
+
yield tasks.run(ctx);
|
|
5310
|
+
} catch (error) {
|
|
5311
|
+
console.error("Error during merge operation:", error);
|
|
5312
|
+
}
|
|
5313
|
+
});
|
|
5314
|
+
});
|
|
5315
|
+
var mergeBranch_default = command7;
|
|
5316
|
+
var fetchBuildInfo_default = (ctx) => {
|
|
5317
|
+
return {
|
|
5318
|
+
title: `Fetching build info`,
|
|
5319
|
+
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
5320
|
+
updateLogContext({ task: "fetchBuildInfo" });
|
|
5321
|
+
try {
|
|
5322
|
+
if (ctx2.mergeBuildSource === ctx2.mergeBuildTarget) {
|
|
5323
|
+
ctx2.log.error(`Merging two similar build is not possible`);
|
|
5324
|
+
throw new Error(`Merging two similar build is not possible`);
|
|
5325
|
+
}
|
|
5326
|
+
const requestData = {
|
|
5327
|
+
source: ctx2.mergeBuildSource,
|
|
5328
|
+
target: ctx2.mergeBuildTarget,
|
|
5329
|
+
byBranch: ctx2.mergeByBranch,
|
|
5330
|
+
byBuildName: ctx2.mergeByBuild
|
|
5331
|
+
};
|
|
5332
|
+
let resp = yield ctx2.client.fetchBuildInfo(requestData, ctx2);
|
|
5333
|
+
if (resp && resp.data && resp.data.source && resp.data.target) {
|
|
5334
|
+
ctx2.mergeBuildSourceId = resp.data.source;
|
|
5335
|
+
ctx2.mergeBuildTargetId = resp.data.target;
|
|
5336
|
+
ctx2.log.debug(`Merge Build source buildId: ${ctx2.mergeBuildSourceId} and target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5337
|
+
} else if (resp && resp.error) {
|
|
5338
|
+
if (resp.error.message) {
|
|
5339
|
+
ctx2.log.error(`Error while fetching buildInfo: ${resp.error.message}`);
|
|
5340
|
+
throw new Error(`Error while fetching buildInfo: ${resp.error.message}`);
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
task.title = "Build info fetched";
|
|
5344
|
+
task.output = chalk__default.default.gray(`Source buildId: ${ctx2.mergeBuildSourceId} and Target buildId: ${ctx2.mergeBuildTargetId}`);
|
|
5345
|
+
} catch (error) {
|
|
5346
|
+
ctx2.log.debug(error);
|
|
5347
|
+
task.output = chalk__default.default.gray(error.message);
|
|
5348
|
+
throw new Error("Build info fetching failed");
|
|
5349
|
+
}
|
|
5350
|
+
}),
|
|
5351
|
+
rendererOptions: { persistentOutput: true }
|
|
5352
|
+
};
|
|
5353
|
+
};
|
|
5354
|
+
|
|
5355
|
+
// src/commander/mergeBuild.ts
|
|
5356
|
+
var command8 = new commander.Command();
|
|
5357
|
+
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) {
|
|
5358
|
+
return __async(this, null, function* () {
|
|
5359
|
+
const { source, target } = options;
|
|
5360
|
+
let ctx = ctx_default(command8.optsWithGlobals());
|
|
5361
|
+
if (!source || source.trim() === "") {
|
|
5362
|
+
ctx.log.error("Error: The --source option cannot be empty.");
|
|
5363
|
+
process.exit(1);
|
|
5364
|
+
}
|
|
5365
|
+
if (!target || target.trim() === "") {
|
|
5366
|
+
ctx.log.error("Error: The --target option cannot be empty.");
|
|
5367
|
+
process.exit(1);
|
|
5368
|
+
}
|
|
5369
|
+
ctx.log.debug(`Merging source build '${source}' into target build '${target}'`);
|
|
5370
|
+
ctx.mergeBuildSource = source;
|
|
5371
|
+
ctx.mergeBuildTarget = target;
|
|
5372
|
+
ctx.mergeByBuild = true;
|
|
5373
|
+
let tasks = new listr2.Listr(
|
|
5374
|
+
[
|
|
5375
|
+
auth_default(),
|
|
5376
|
+
getGitInfo_default(),
|
|
5377
|
+
fetchBuildInfo_default(),
|
|
5378
|
+
mergeBuilds_default()
|
|
5379
|
+
],
|
|
5380
|
+
{
|
|
5381
|
+
rendererOptions: {
|
|
5382
|
+
icon: {
|
|
5383
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: "\u2192"
|
|
5384
|
+
},
|
|
5385
|
+
color: {
|
|
5386
|
+
[listr2.ListrDefaultRendererLogLevels.OUTPUT]: listr2.color.gray
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
);
|
|
5391
|
+
try {
|
|
5392
|
+
yield tasks.run(ctx);
|
|
5393
|
+
} catch (error) {
|
|
5394
|
+
console.error("Error during merge operation:", error);
|
|
5395
|
+
}
|
|
5396
|
+
});
|
|
5397
|
+
});
|
|
5398
|
+
var mergeBuild_default = command8;
|
|
5399
|
+
|
|
5400
|
+
// src/commander/merge.ts
|
|
5123
5401
|
var program = new commander.Command();
|
|
5124
|
-
program.name("
|
|
5125
|
-
var
|
|
5402
|
+
program.name("merge").description("Merge a source branch into the target branch").addCommand(mergeBranch_default).addCommand(mergeBuild_default);
|
|
5403
|
+
var merge_default = program;
|
|
5404
|
+
|
|
5405
|
+
// src/commander/commander.ts
|
|
5406
|
+
var program2 = new commander.Command();
|
|
5407
|
+
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);
|
|
5408
|
+
var commander_default = program2;
|
|
5126
5409
|
(function() {
|
|
5127
5410
|
return __async(this, null, function* () {
|
|
5128
5411
|
let client = new httpClient(env_default());
|