Commit b186a57
chore: fix deploy version parsing in pre-release script for npm 12 compatibility (#102)
## 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
Co-authored-by: Claude <noreply@anthropic.com>1 parent e8dcc42 commit b186a57
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
0 commit comments