Repository navigation
Conversation
npm 12 changed `npm pack --json` from an array of entries to an object keyed by package name (npm/cli#9247). buildPackageTarball read `packed[0]`, so any run with npm >= 12 threw "npm pack did not report an artifact", failing the release check and `bun run check`. Read the first entry from either shape, and pin the object shape with a fake npm so the regression is covered even where the installed npm still emits an array.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangesPackage verification
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change addresses npm 12’s object-shaped pack output. The malformed-output concern does not establish a production failure, so no merge-blocking issue remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
buildPackageTarballaccepts bothnpm pack --jsonshapes — widens the cast toPackResult[] | Record<string, PackResult>and normalizes viaArray.isArray(packed) ? packed[0] : Object.values(packed)[0], matching the npm 12 object-keyed-by-package-name change (npm/cli#9247).- Regression test for the object shape — a fake npm emitting
{ "cc-safety-net": { filename, size, files } }drives the realbuildPackageTarballand asserts the packedgitHead, so the npm 12 path is covered on a runner whose bundled npm still emits an array.readPackedManifestwas extracted to share tarball extraction.
The npm 12 claim checks out against npm/cli#9247 (latest emits { [tar.name]: tarball }; array is npm <= 11). Before the fix packed[0] is undefined on the object, so the test genuinely fails without the change. This is the only pack-json parse site, and publish.yml consumes the tarball through this script rather than re-parsing the JSON, so no other caller is left array-shaped. Focused suite passes (2 pass, 0 fail).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
|
Thanks for the report. I'm closing this in favor of #218. It test re-keys real npm output instead of building a tarball by hand, which leaves the existing test unchanged. |
Why: - npm 12 prints `npm pack --json` as an object keyed by package name instead of an array, so `packed[0]` was undefined and verify:package and `bun run check` failed with "npm pack did not report an artifact" (kenryu42#206). CI and the publish job still run npm 11, but `npm install -g npm` now installs 12. What: - Take the first value of the report with Object.values, which reads an npm 11 array and an npm 12 object alike. - The new test runs the real npm and re-keys its report by package name, as npm 12 does, so the tarball, file list and modes stay real on an npm 11 runner. Validation: - Red first: the new test failed on main with "npm pack did not report an artifact" and passes with the fix. - buildPackageTarball run through `npx npm@12` (12.2.0) produced cc-safety-net-2.5.2.tgz with 23 files. - bun run check passed (3753 pass, 4 skip, 0 fail; lines 98.81%). LOC: src/ +0 / -0 = net +0 tests/ +15 / -0 = net +15 *.md +0 / -0 = net +0 Total +17 / -2 = net +15 Fixes kenryu42#206. Supersedes kenryu42#207.

Summary
buildPackageTarballnow reads the packed artifact from either shape ofnpm pack --json, sobun run verify:packageandbun run checkno longer fail on npm >= 12.Fixes #206.
Root cause
npm 12.0.0 changed
npm pack --jsonfrom an array of entries to an object keyed by package name (npm/cli#9247):scripts/verify-package.tscast the parsed output toPackResult[]and readpacked[0]. For the object shape that index isundefined, so it threwnpm pack did not report an artifactbefore the tarball was ever inspected.Fix
CI stays green today only because the runners' bundled npm is 11.x (array shape) and
publish.ymlpinsnpm@11.5.1. Once those runners ship npm 12, both release verification and every contributor'sbun run checkbreak on an unrelated change.Tests
Added
reads the artifact from npm 12 object-shaped pack outputtotests/scripts/package-git-head.test.ts. It drivesbuildPackageTarballwith a fake npm that emits the object shape, so the regression is covered even on a runner whose npm still emits an array. The sharedreadPackedManifesthelper was extracted to avoid duplicating the tarball extraction.Red (before the fix):
Green (after):
2 pass, 0 fail.bun run check:3509 pass, 4 skip, 0 fail, coverage verified.Notes
Per
CONTRIBUTING.md, small bug fixes with an obvious solution normally go straight to a PR. This one also affects release tooling, so it is tracked in #206 for traceability.Summary by CodeRabbit
preparescript.