From 9e9aff14acb97492b7e961829235be676335cc86 Mon Sep 17 00:00:00 2001 From: Roy Osherove <575051+royosherove@users.noreply.github.com> Date: Sat, 16 May 2026 21:28:30 +0000 Subject: [PATCH] refactor: extract postpublish verification to separate script - Created scripts/verify-publish.mjs with absolute path resolution - Updated package.json postpublish to call node scripts/verify-publish.mjs - Added trailing newline to package.json - Improved maintainability and readability over inline node -e The postpublish script spawns a background agent to verify npm publish succeeded. --- package.json | 5 ++-- scripts/verify-publish.mjs | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 scripts/verify-publish.mjs diff --git a/package.json b/package.json index cac4896..ff5fd8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@inceptionstack/roundhouse", - "version": "0.5.38", + "version": "0.5.40", "type": "module", "description": "Multi-platform chat gateway that routes messages through a configured AI agent", "license": "MIT", @@ -26,7 +26,8 @@ "start": "tsx src/index.ts", "dev": "tsx watch src/index.ts", "test": "vitest run", - "test:watch": "vitest" + "test:watch": "vitest", + "postpublish": "node scripts/verify-publish.mjs" }, "files": [ "src/", diff --git a/scripts/verify-publish.mjs b/scripts/verify-publish.mjs new file mode 100755 index 0000000..541c348 --- /dev/null +++ b/scripts/verify-publish.mjs @@ -0,0 +1,49 @@ +#!/usr/bin/env node +/** + * Verify npm publish succeeded by spawning a background agent + * to check registry, version, and dist tags. + * + * Only runs in interactive shells (skip CI, dry-run, non-TTY). + * Detaches to background to avoid blocking npm publish. + */ + +import { spawn } from 'child_process'; +import { fileURLToPath } from 'url'; +import { dirname, resolve } from 'path'; +import { existsSync } from 'fs'; + +// Skip in CI, dry-run, or non-interactive shells +if (process.env.CI || process.env.npm_config_dry_run || !process.stdout.isTTY) { + process.exit(0); +} + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const repoRoot = dirname(__dirname); + +// Try to find roundhouse: global PATH or local bin +let roundhouseCmd = 'roundhouse'; +const localBin = resolve(repoRoot, 'node_modules/.bin/roundhouse'); +if (existsSync(localBin)) { + roundhouseCmd = localBin; +} + +// Spawn agent in background (detached, non-blocking) +try { + const child = spawn(roundhouseCmd, [ + 'subagent', 'spawn', + '--role', 'review', + '--task', 'Verify npm publish succeeded for @inceptionstack/roundhouse. Check registry, version, and dist tags.', + '--cwd', repoRoot, + '--timeout', '120000' + ], { + detached: true, + stdio: 'ignore' + }); + + child.unref(); // Allow parent (npm publish) to exit without waiting +} catch (err) { + if (err.code === 'ENOENT') { + console.warn(`⚠️ Warning: roundhouse not found on PATH. Publish verification skipped. Install roundhouse globally or ensure it's in your PATH.`); + } + process.exit(0); +}