laxy-verify 1.1.11 → 1.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/build.js CHANGED
@@ -24,11 +24,16 @@ function runBuild(command, timeoutSec, cwd) {
24
24
  const stderrLines = [];
25
25
  const errorLines = [];
26
26
  console.log(`\n Building: ${command}${cwd ? ` (cwd: ${cwd})` : ""}`);
27
- const proc = (0, node_child_process_1.spawn)(command, {
28
- shell: true,
29
- stdio: ["ignore", "pipe", "pipe"],
30
- cwd,
31
- });
27
+ const proc = process.platform === "win32"
28
+ ? (0, node_child_process_1.spawn)(process.env.ComSpec || "cmd.exe", ["/d", "/c", command], {
29
+ stdio: ["ignore", "pipe", "pipe"],
30
+ cwd,
31
+ })
32
+ : (0, node_child_process_1.spawn)(command, {
33
+ shell: true,
34
+ stdio: ["ignore", "pipe", "pipe"],
35
+ cwd,
36
+ });
32
37
  let timedOut = false;
33
38
  const timer = setTimeout(() => {
34
39
  timedOut = true;
package/dist/e2e.js CHANGED
@@ -70,9 +70,9 @@ function getFillTarget(selectors) {
70
70
  }
71
71
  function getFeedbackTarget(selectors) {
72
72
  return pickSelector(selectors, [
73
- /^\[role=['"]alert['"]\]$/,
74
73
  /^\[role=['"]status['"]\]$/,
75
74
  /^\[aria-live=['"](polite|assertive)['"]\]$/,
75
+ /^\[role=['"]alert['"]\]$/,
76
76
  /^\[data-testid.*(error|success|toast|alert|notice|result)/,
77
77
  /^\.(error|alert|toast|notice|success|status)/,
78
78
  ]);
package/dist/serve.js CHANGED
@@ -74,12 +74,18 @@ function probeServerStatus(port) {
74
74
  async function startDevServer(command, port, timeoutSec, cwd) {
75
75
  return new Promise((resolve, reject) => {
76
76
  console.log(`Starting dev server: ${command}${cwd ? ` (cwd: ${cwd})` : ""}`);
77
- const proc = (0, node_child_process_1.spawn)(command, {
78
- shell: true,
79
- stdio: ["ignore", "pipe", "pipe"],
80
- env: { ...process.env, PORT: String(port) },
81
- cwd,
82
- });
77
+ const proc = process.platform === "win32"
78
+ ? (0, node_child_process_1.spawn)(process.env.ComSpec || "cmd.exe", ["/d", "/c", command], {
79
+ stdio: ["ignore", "pipe", "pipe"],
80
+ env: { ...process.env, PORT: String(port) },
81
+ cwd,
82
+ })
83
+ : (0, node_child_process_1.spawn)(command, {
84
+ shell: true,
85
+ stdio: ["ignore", "pipe", "pipe"],
86
+ env: { ...process.env, PORT: String(port) },
87
+ cwd,
88
+ });
83
89
  // Pipe output to console
84
90
  proc.stdout?.on("data", (chunk) => {
85
91
  const lines = chunk.toString().split("\n").filter(Boolean);
@@ -41,7 +41,6 @@ const fs = __importStar(require("node:fs"));
41
41
  const path = __importStar(require("node:path"));
42
42
  const puppeteer_1 = __importDefault(require("puppeteer"));
43
43
  const pngjs_1 = require("pngjs");
44
- const pixelmatch_1 = __importDefault(require("pixelmatch"));
45
44
  function ensureDir(dir) {
46
45
  fs.mkdirSync(dir, { recursive: true });
47
46
  }
@@ -58,7 +57,12 @@ async function captureScreenshot(url, outputPath) {
58
57
  await browser.close();
59
58
  }
60
59
  }
61
- function compareImages(baselinePath, currentPath, diffOutputPath) {
60
+ async function loadPixelmatch() {
61
+ const dynamicImport = new Function("specifier", "return import(specifier)");
62
+ const mod = await dynamicImport("pixelmatch");
63
+ return mod.default;
64
+ }
65
+ async function compareImages(baselinePath, currentPath, diffOutputPath) {
62
66
  const baselinePng = pngjs_1.PNG.sync.read(fs.readFileSync(baselinePath));
63
67
  const currentPng = pngjs_1.PNG.sync.read(fs.readFileSync(currentPath));
64
68
  const width = Math.min(baselinePng.width, currentPng.width);
@@ -75,7 +79,8 @@ function compareImages(baselinePath, currentPath, diffOutputPath) {
75
79
  const baseData = cropData(baselinePng, width, height);
76
80
  const currData = cropData(currentPng, width, height);
77
81
  const diff = new pngjs_1.PNG({ width, height });
78
- const diffPixels = (0, pixelmatch_1.default)(baseData, currData, diff.data, width, height, { threshold: 0.1 });
82
+ const pixelmatch = await loadPixelmatch();
83
+ const diffPixels = pixelmatch(baseData, currData, diff.data, width, height, { threshold: 0.1 });
79
84
  ensureDir(path.dirname(diffOutputPath));
80
85
  fs.writeFileSync(diffOutputPath, pngjs_1.PNG.sync.write(diff));
81
86
  const totalPixels = width * height;
@@ -102,7 +107,7 @@ async function runVisualDiff(projectDir, url, label = "current") {
102
107
  diffPath: "",
103
108
  };
104
109
  }
105
- const comparison = compareImages(baselinePath, currentPath, diffPath);
110
+ const comparison = await compareImages(baselinePath, currentPath, diffPath);
106
111
  let verdict = "pass";
107
112
  if (comparison.diffPercentage >= 60) {
108
113
  verdict = "rollback";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laxy-verify",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "Frontend quality gate: build + Lighthouse verification",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@lhci/cli": "^0.14.0",
21
21
  "chrome-launcher": "^0.13.4",
22
- "js-yaml": "^4.1.0",
22
+ "js-yaml": "^4.1.0",
23
23
  "lighthouse": "^12.1.0",
24
24
  "pixelmatch": "^7.1.0",
25
25
  "pngjs": "^7.0.0",