Add postbuild script for auto-publish to local Verdaccio

Summary

When developing locally with ratings-stack, we need a way to automatically publish package updates to a local Verdaccio registry so that dependent projects (like ratings-ui) can pick up changes without manual steps.

Proposed Solution

Add a postbuild script that automatically publishes to Verdaccio if it's running:

// package.json
{
  "scripts": {
    "postbuild": "node scripts/publish-local.js"
  }
}
// scripts/publish-local.js
const { execSync } = require('child_process');
const http = require('http');

const VERDACCIO_URL = 'http://localhost:4873';

http.get(VERDACCIO_URL, (res) => {
  if (res.statusCode === 200) {
    console.log('[publish-local] Verdaccio detected, publishing...');
    try {
      execSync(\`npm publish --registry \${VERDACCIO_URL}\`, { stdio: 'inherit' });
      console.log('[publish-local] Published to local Verdaccio');
    } catch (err) {
      console.log('[publish-local] Publish skipped (may already exist)');
    }
  }
}).on('error', () => {
  console.log('[publish-local] Verdaccio not running, skipping local publish');
});

Benefits

  • Zero friction workflow: npm run build works normally
  • If Verdaccio is running, package is auto-published
  • If Verdaccio isn't running, build continues without error
  • No file changes needed when switching between local/CI

Related