styleproof 2.5.0 → 3.0.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.0.0] - 2026-06-27
11
+
12
+ **Milestone: the committed-map gate is how StyleProof works now.** Capture runs
13
+ **pre-push** (parallel, with auto-detected `@media` breakpoints), the lean computed-
14
+ style map is committed and **pushed in a single `git push`**, and CI is a
15
+ **browser-less diff** of two precomputed maps — measured ~5400× cheaper on the
16
+ compare step, and it skips build + serve entirely. `styleproof-init` scaffolds **and
17
+ activates** the whole gate in one command. Coverage stays **full and sound**: every
18
+ surface is captured (parallelised) and what changed is determined by _measuring_ the
19
+ map, never by guessing which pages a code change touched. **No breaking API changes**
20
+ — existing specs and the classic capture-both-in-CI flow keep working unchanged; the
21
+ major marks the new default paradigm.
22
+
23
+ ### Changed
24
+
25
+ - **`styleproof-init` now activates the pre-push hook for you** (`git config
26
+ core.hooksPath .githooks`), so a single `styleproof-init` is all it takes — no
27
+ follow-up command. It never clobbers a repo that already manages hooks: if
28
+ `core.hooksPath` is already set or a `.husky/` dir exists, it leaves them alone and
29
+ prints the one-liner instead.
30
+
10
31
  ## [2.5.0] - 2026-06-26
11
32
 
12
33
  ### Changed
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import fs from 'node:fs';
22
22
  import path from 'node:path';
23
+ import { spawnSync } from 'node:child_process';
23
24
  import { discoverNextRoutes } from '../dist/index.js';
24
25
 
25
26
  const HELP = `styleproof-init — scaffold a styleproof capture spec
@@ -238,7 +239,8 @@ export default defineConfig({
238
239
  // always carries a base map and CI is a fast, browser-less diff of two precomputed
239
240
  // maps. The hook redirects capture into a committed `stylemaps/` dir and drops
240
241
  // screenshots via the STYLEPROOF_BASEDIR / STYLEPROOF_SCREENSHOTS env knobs.
241
- const HOOK_PATH = '.githooks/pre-push';
242
+ const HOOK_DIR = '.githooks';
243
+ const HOOK_PATH = `${HOOK_DIR}/pre-push`;
242
244
  const PREPUSH_HOOK = `#!/bin/sh
243
245
  # StyleProof pre-push hook (generated by styleproof-init).
244
246
  #
@@ -358,9 +360,33 @@ if (ci.wrote) {
358
360
  console.log(`${CI_PATH} already exists — left untouched`);
359
361
  }
360
362
 
363
+ // Activate the hook so ONE `styleproof-init` is all it takes — but never clobber a
364
+ // repo that already manages its hooks (husky, or an existing core.hooksPath); there
365
+ // we leave it and print the one-liner instead.
366
+ const git = (a) => spawnSync('git', a, { encoding: 'utf8' });
367
+ const inGitRepo = git(['rev-parse', '--is-inside-work-tree']).status === 0;
368
+ const existingHooksPath = inGitRepo ? git(['config', '--local', '--get', 'core.hooksPath']).stdout.trim() : '';
369
+ const managesHooks = existingHooksPath !== '' || fs.existsSync('.husky');
370
+ let hookActivated = false;
371
+ if (inGitRepo && !managesHooks) {
372
+ if (git(['config', 'core.hooksPath', HOOK_DIR]).status === 0) {
373
+ hookActivated = true;
374
+ console.log(`activated the pre-push hook (core.hooksPath → ${HOOK_DIR})`);
375
+ wroteSomething = true;
376
+ }
377
+ }
378
+
361
379
  console.log('\nHow the gate works — capture local, CI just diffs:');
362
- console.log(' 1. Activate the pre-push hook (once per clone):');
363
- console.log(' git config core.hooksPath .githooks');
380
+ if (hookActivated) {
381
+ console.log(' 1. Pre-push hook is active — nothing to do.');
382
+ } else if (managesHooks) {
383
+ console.log(` 1. Your repo already manages git hooks (${existingHooksPath || '.husky'}), so the hook`);
384
+ console.log(` wasn't auto-activated. Point your hook runner at ${HOOK_DIR}/pre-push, or run:`);
385
+ console.log(` git config core.hooksPath ${HOOK_DIR}`);
386
+ } else {
387
+ console.log(' 1. Activate the pre-push hook (once per clone):');
388
+ console.log(` git config core.hooksPath ${HOOK_DIR}`);
389
+ }
364
390
  console.log(' 2. Push your branch. The hook captures the computed-style map against a');
365
391
  console.log(' PRODUCTION build, commits it (lean .json.gz under stylemaps/), and pushes it');
366
392
  console.log(' with your branch — one `git push`, never two.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styleproof",
3
- "version": "2.5.0",
3
+ "version": "3.0.0",
4
4
  "description": "Catch every CSS change before it ships — review PRs and certify refactors by the browser's computed styles, not pixels. Works with any styling system.",
5
5
  "keywords": [
6
6
  "playwright",