Skip to content

chore: fix deploy version parsing in pre-release script for npm 12 compatibility - #102

Merged
metalwarrior665 merged 1 commit into
masterfrom
claude/npm-publish-failure-fakyxq
Jul 10, 2026
Merged

chore: fix deploy version parsing in pre-release script for npm 12 compatibility#102
metalwarrior665 merged 1 commit into
masterfrom
claude/npm-publish-failure-fakyxq

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Summary

Updated the version parsing logic in the pre-release script to handle inconsistent output formats from different npm versions.

Key Changes

  • Modified addBetaSuffixToVersion() to normalize npm's version output across different npm versions
  • Added handling for npm 12's double-wrapped array format ([[...]])
  • Added handling for single-version packages that return a bare string instead of an array
  • Implemented a robust parsing strategy using flat(Infinity) and type filtering to extract version strings

Implementation Details

The npm CLI returns version information in different formats depending on the npm version and package state:

  • npm 12 wraps the versions array in an extra array layer
  • Packages with only one published version may return a bare string instead of an array

The fix uses [JSON.parse(versionString)].flat(Infinity).filter((v) => typeof v === 'string') to normalize all these cases into a consistent array of version strings, ensuring the script works reliably across npm versions.

https://claude.ai/code/session_01S3skLbP3YnDAYp124zzaS5

npm 12 changed `npm show <pkg> versions --json` to wrap the version
array in an outer array ([[...]]), which broke before-beta-release.js
with "TypeError: v.startsWith is not a function". Since the publish
workflow force-installs npm@latest, this silently regressed once npm 12
was released.

Normalize the parsed output by flattening and keeping only strings,
which also covers the case where npm returns a bare string for a
single-version package.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3skLbP3YnDAYp124zzaS5
@metalwarrior665 metalwarrior665 changed the title Fix version parsing in pre-release script for npm 12 compatibility chore: fix deploy version parsing in pre-release script for npm 12 compatibility Jul 10, 2026
@metalwarrior665
metalwarrior665 merged commit b186a57 into master Jul 10, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants