From 59fec361042edd11dbdb39a0bd576e8ee6afa993 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Oct 2026 09:27:42 +0000 Subject: [PATCH] fix(release): skip packages whose version is already on npm A release that bumps only pixel-morph would otherwise fail trying to republish pixel-avatar at its existing version. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01GykcoiqQvD2ZC8e5VwyMYp --- scripts/release.mjs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/release.mjs b/scripts/release.mjs index a2bd66b..de150e2 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -62,14 +62,25 @@ function readToken() { } try { - for (const pkg of ORDER) publish(pkg); + for (const pkg of ORDER) await publish(pkg); } finally { if (tokenDir) rmSync(tokenDir, { recursive: true, force: true }); } -function publish(pkg) { +// A release usually bumps one package; the other is already on npm at its version, and +// publishing it again would fail after the first package went out. +async function published(name, version) { + const res = await fetch(`https://registry.npmjs.org/${name.replace('/', '%2f')}/${version}`); + return res.ok; +} + +async function publish(pkg) { const version = JSON.parse(readFileSync(join(root, pkg.dir, 'package.json'), 'utf8')).version; process.stdout.write(`\n${pkg.name}@${version} — ${pkg.why}\n`); + if (await published(pkg.name, version)) { + process.stdout.write(' already on npm, skipped\n'); + return; + } if (!yes) { process.stdout.write( ` would run: pnpm --filter ${pkg.name} publish --access public${tag ? ` --tag ${tag}` : ''}\n`,