git-shots-cli 0.5.1 → 0.5.3

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -18
  2. package/package.json +27 -27
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // src/index.ts
4
4
  import "dotenv/config";
5
5
  import { Command } from "commander";
6
+ import { createRequire } from "module";
6
7
 
7
8
  // src/config.ts
8
9
  import { readFileSync, existsSync } from "fs";
@@ -108,8 +109,7 @@ async function compare(config, options) {
108
109
  const body = {
109
110
  project: config.project,
110
111
  base: options.base ?? "main",
111
- head: options.head,
112
- threshold: options.threshold ?? 0.1
112
+ head: options.head
113
113
  };
114
114
  if (options.screens) {
115
115
  body.screens = options.screens;
@@ -137,14 +137,8 @@ async function compare(config, options) {
137
137
  console.log(chalk3.green("No visual differences found!"));
138
138
  return;
139
139
  }
140
- console.log(chalk3.dim("Screen".padEnd(30) + "Mismatch".padEnd(15) + "Pixels"));
141
- console.log(chalk3.dim("-".repeat(55)));
142
140
  for (const d of data.diffs) {
143
- const pct = d.mismatchPercentage.toFixed(2) + "%";
144
- const color = d.mismatchPercentage > 10 ? chalk3.red : d.mismatchPercentage > 1 ? chalk3.yellow : chalk3.green;
145
- console.log(
146
- d.screen.padEnd(30) + color(pct.padEnd(15)) + chalk3.dim(d.mismatchPixels.toLocaleString())
147
- );
141
+ console.log(chalk3.yellow(` changed: ${d.screen}`));
148
142
  }
149
143
  } catch (err) {
150
144
  console.error(chalk3.red(`Request failed: ${err}`));
@@ -312,19 +306,22 @@ async function review(config, options) {
312
306
  console.error(chalk6.red(`Request failed: ${err}`));
313
307
  process.exit(1);
314
308
  }
315
- const allZero = reviewData.diffs.length === 0 || reviewData.diffs.every((d) => d.mismatchPercentage === 0);
316
- if (allZero) {
309
+ if (reviewData.diffs.length === 0) {
317
310
  console.log(chalk6.green("No visual changes detected."));
318
311
  process.exit(0);
319
312
  }
320
313
  const sessionUrl = `${config.server}/reviews/${reviewData.review.id}`;
321
314
  console.log();
322
- console.log(chalk6.bold("Visual changes detected:"));
315
+ console.log(chalk6.bold(`${reviewData.diffs.length} screen${reviewData.diffs.length === 1 ? "" : "s"} changed:`));
323
316
  console.log();
324
317
  for (const d of reviewData.diffs) {
325
- const pct = d.mismatchPercentage.toFixed(2) + "%";
326
- const color = d.mismatchPercentage > 10 ? chalk6.red : d.mismatchPercentage > 1 ? chalk6.yellow : chalk6.green;
327
- console.log(` ${d.screen.padEnd(30)} ${color(pct)}`);
318
+ if (d.mismatchPercentage > 0) {
319
+ const pct = d.mismatchPercentage.toFixed(2) + "%";
320
+ const color = d.mismatchPercentage > 10 ? chalk6.red : d.mismatchPercentage > 1 ? chalk6.yellow : chalk6.green;
321
+ console.log(` ${d.screen.padEnd(30)} ${color(pct)}`);
322
+ } else {
323
+ console.log(` ${d.screen.padEnd(30)} ${chalk6.cyan("changed")}`);
324
+ }
328
325
  }
329
326
  console.log();
330
327
  console.log(`Review: ${chalk6.cyan(sessionUrl)}`);
@@ -558,8 +555,10 @@ async function syncFlows(config) {
558
555
  }
559
556
 
560
557
  // src/index.ts
558
+ var require2 = createRequire(import.meta.url);
559
+ var { version } = require2("../package.json");
561
560
  var program = new Command();
562
- program.name("git-shots").description("CLI for git-shots visual regression platform").version("0.1.0");
561
+ program.name("git-shots").description("CLI for git-shots visual regression platform").version(version);
563
562
  program.command("upload").description("Upload screenshots to git-shots").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)").action(async (options) => {
564
563
  const config = loadConfig();
565
564
  if (options.project) config.project = options.project;
@@ -575,7 +574,7 @@ program.command("upload").description("Upload screenshots to git-shots").option(
575
574
  await syncFlows(config);
576
575
  }
577
576
  });
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) => {
577
+ 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("--platform <name>", "Platform tag (e.g., android, web)").option("--screens <patterns>", "Screen slug patterns to compare (comma-separated, supports *)").action(async (options) => {
579
578
  const config = loadConfig();
580
579
  if (options.project) config.project = options.project;
581
580
  if (options.server) config.server = options.server;
@@ -585,7 +584,7 @@ program.command("compare").description("Compare screenshots between branches").r
585
584
  process.exit(1);
586
585
  }
587
586
  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 });
587
+ await compare(config, { base: options.base, head: options.head, screens });
589
588
  });
590
589
  program.command("status").description("Show current diff status").option("-p, --project <slug>", "Project slug").option("-s, --server <url>", "Server URL").action(async (options) => {
591
590
  const config = loadConfig();
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "git-shots-cli",
3
- "version": "0.5.1",
4
- "description": "CLI for git-shots visual regression platform",
5
- "type": "module",
6
- "bin": {
7
- "git-shots": "./dist/index.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "tsup src/index.ts --format esm --dts",
14
- "dev": "tsup src/index.ts --format esm --watch"
15
- },
16
- "dependencies": {
17
- "commander": "^12.0.0",
18
- "chalk": "^5.3.0",
19
- "dotenv": "^16.4.0",
20
- "glob": "^11.0.0"
21
- },
22
- "devDependencies": {
23
- "tsup": "^8.0.0",
24
- "typescript": "^5.0.0",
25
- "@types/node": "^22.0.0"
26
- }
27
- }
1
+ {
2
+ "name": "git-shots-cli",
3
+ "version": "0.5.3",
4
+ "description": "CLI for git-shots visual regression platform",
5
+ "type": "module",
6
+ "bin": {
7
+ "git-shots": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsup src/index.ts --format esm --dts",
14
+ "dev": "tsup src/index.ts --format esm --watch"
15
+ },
16
+ "dependencies": {
17
+ "commander": "^12.0.0",
18
+ "chalk": "^5.3.0",
19
+ "dotenv": "^16.4.0",
20
+ "glob": "^11.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "tsup": "^8.0.0",
24
+ "typescript": "^5.0.0",
25
+ "@types/node": "^22.0.0"
26
+ }
27
+ }