git-shots-cli 0.4.1 → 0.5.1
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.js +23 -9
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
+
import "dotenv/config";
|
|
4
5
|
import { Command } from "commander";
|
|
5
6
|
|
|
6
7
|
// src/config.ts
|
|
@@ -110,6 +111,9 @@ async function compare(config, options) {
|
|
|
110
111
|
head: options.head,
|
|
111
112
|
threshold: options.threshold ?? 0.1
|
|
112
113
|
};
|
|
114
|
+
if (options.screens) {
|
|
115
|
+
body.screens = options.screens;
|
|
116
|
+
}
|
|
113
117
|
console.log(chalk3.dim(`Comparing ${body.base} vs ${body.head} for ${config.project}...`));
|
|
114
118
|
try {
|
|
115
119
|
const res = await fetch(url, {
|
|
@@ -125,6 +129,9 @@ async function compare(config, options) {
|
|
|
125
129
|
}
|
|
126
130
|
console.log();
|
|
127
131
|
console.log(`Compared ${chalk3.bold(data.compared)} screens`);
|
|
132
|
+
if (data.unchanged > 0) {
|
|
133
|
+
console.log(chalk3.dim(`${data.unchanged} unchanged (skipped)`));
|
|
134
|
+
}
|
|
128
135
|
console.log();
|
|
129
136
|
if (data.diffs.length === 0) {
|
|
130
137
|
console.log(chalk3.green("No visual differences found!"));
|
|
@@ -281,14 +288,18 @@ async function review(config, options) {
|
|
|
281
288
|
const reviewUrl = `${config.server}/api/reviews`;
|
|
282
289
|
let reviewData;
|
|
283
290
|
try {
|
|
291
|
+
const reviewBody = {
|
|
292
|
+
project: config.project,
|
|
293
|
+
branch,
|
|
294
|
+
gitSha: sha
|
|
295
|
+
};
|
|
296
|
+
if (options.screens) {
|
|
297
|
+
reviewBody.screens = options.screens;
|
|
298
|
+
}
|
|
284
299
|
const res = await fetch(reviewUrl, {
|
|
285
300
|
method: "POST",
|
|
286
301
|
headers: { "Content-Type": "application/json", Origin: config.server, ...authHeaders(config) },
|
|
287
|
-
body: JSON.stringify(
|
|
288
|
-
project: config.project,
|
|
289
|
-
branch,
|
|
290
|
-
gitSha: sha
|
|
291
|
-
})
|
|
302
|
+
body: JSON.stringify(reviewBody)
|
|
292
303
|
});
|
|
293
304
|
const data = await res.json();
|
|
294
305
|
checkAuthError(res);
|
|
@@ -564,7 +575,7 @@ program.command("upload").description("Upload screenshots to git-shots").option(
|
|
|
564
575
|
await syncFlows(config);
|
|
565
576
|
}
|
|
566
577
|
});
|
|
567
|
-
program.command("compare").description("Compare screenshots between branches").requiredOption("--head <branch>", "Head branch to compare").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").option("--base <branch>", "Base branch (default: main)").option("-t, --threshold <number>", "Mismatch threshold 0-1", parseFloat).option("--platform <name>", "Platform tag (e.g., android, web)").action(async (options) => {
|
|
578
|
+
program.command("compare").description("Compare screenshots between branches").requiredOption("--head <branch>", "Head branch to compare").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").option("--base <branch>", "Base branch (default: main)").option("-t, --threshold <number>", "Mismatch threshold 0-1", parseFloat).option("--platform <name>", "Platform tag (e.g., android, web)").option("--screens <patterns>", "Screen slug patterns to compare (comma-separated, supports *)").action(async (options) => {
|
|
568
579
|
const config = loadConfig();
|
|
569
580
|
if (options.project) config.project = options.project;
|
|
570
581
|
if (options.server) config.server = options.server;
|
|
@@ -573,7 +584,8 @@ program.command("compare").description("Compare screenshots between branches").r
|
|
|
573
584
|
console.error("Error: project slug required. Use --project or .git-shots.json");
|
|
574
585
|
process.exit(1);
|
|
575
586
|
}
|
|
576
|
-
|
|
587
|
+
const screens = options.screens ? options.screens.split(",").map((s) => s.trim()) : void 0;
|
|
588
|
+
await compare(config, { base: options.base, head: options.head, threshold: options.threshold, screens });
|
|
577
589
|
});
|
|
578
590
|
program.command("status").description("Show current diff status").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").action(async (options) => {
|
|
579
591
|
const config = loadConfig();
|
|
@@ -595,7 +607,7 @@ program.command("pull-baselines").description("Download baseline screenshots fro
|
|
|
595
607
|
}
|
|
596
608
|
await pullBaselines(config, { branch: options.branch, output: options.output });
|
|
597
609
|
});
|
|
598
|
-
program.command("review").description("Upload screenshots, create review session, and poll for verdict").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").option("-d, --directory <path>", "Screenshots directory").option("-b, --branch <name>", "Git branch (auto-detected)").option("--sha <hash>", "Git SHA (auto-detected)").option("--platform <name>", "Platform tag (e.g., android, web)").option("--open", "Open review URL in browser", true).option("--no-open", "Do not open review URL in browser").option("--poll", "Poll for verdict and exit with code", true).option("--no-poll", "Do not poll for verdict").option("--timeout <seconds>", "Polling timeout in seconds", parseInt, 300).action(async (options) => {
|
|
610
|
+
program.command("review").description("Upload screenshots, create review session, and poll for verdict").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").option("-d, --directory <path>", "Screenshots directory").option("-b, --branch <name>", "Git branch (auto-detected)").option("--sha <hash>", "Git SHA (auto-detected)").option("--platform <name>", "Platform tag (e.g., android, web)").option("--open", "Open review URL in browser", true).option("--no-open", "Do not open review URL in browser").option("--poll", "Poll for verdict and exit with code", true).option("--no-poll", "Do not poll for verdict").option("--timeout <seconds>", "Polling timeout in seconds", parseInt, 300).option("--screens <patterns>", "Screen slug patterns to compare (comma-separated, supports *)").action(async (options) => {
|
|
599
611
|
const config = loadConfig();
|
|
600
612
|
if (options.project) config.project = options.project;
|
|
601
613
|
if (options.server) config.server = options.server;
|
|
@@ -605,12 +617,14 @@ program.command("review").description("Upload screenshots, create review session
|
|
|
605
617
|
console.error("Error: project slug required. Use --project or .git-shots.json");
|
|
606
618
|
process.exit(1);
|
|
607
619
|
}
|
|
620
|
+
const screens = options.screens ? options.screens.split(",").map((s) => s.trim()) : void 0;
|
|
608
621
|
await review(config, {
|
|
609
622
|
branch: options.branch,
|
|
610
623
|
sha: options.sha,
|
|
611
624
|
open: options.open,
|
|
612
625
|
poll: options.poll,
|
|
613
|
-
timeout: options.timeout
|
|
626
|
+
timeout: options.timeout,
|
|
627
|
+
screens
|
|
614
628
|
});
|
|
615
629
|
});
|
|
616
630
|
var hook = program.command("hook").description("Manage git hooks for automatic visual review");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-shots-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "CLI for git-shots visual regression platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"commander": "^12.0.0",
|
|
18
18
|
"chalk": "^5.3.0",
|
|
19
|
+
"dotenv": "^16.4.0",
|
|
19
20
|
"glob": "^11.0.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|