chore: fix deploy version parsing in pre-release script for npm 12 compatibility - #102
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updated the version parsing logic in the pre-release script to handle inconsistent output formats from different npm versions.
Key Changes
addBetaSuffixToVersion()to normalize npm's version output across different npm versions[[...]])flat(Infinity)and type filtering to extract version stringsImplementation Details
The npm CLI returns version information in different formats depending on the npm version and package state:
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