Repository navigation
fix(cli): check the tarball when pack lifecycle scripts print output - #6556
josephfarina merged 3 commits into
Conversation
integration pack --check parsed npm pack's stdout as JSON, but npm prints foreground prepack/prepare/postpack output to the same stream, so any package whose lifecycle printed anything failed before its tarball was examined. Run the lifecycle scripts in background mode and keep a failing script's output in the pack_failed message.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This fix restores astryx integration pack --check for packages whose prepack, prepare, or postpack scripts print output. Keeping lifecycle output off the npm pack --json stdout stream lets the check again run the lifecycle, compare the tarball inventory, extract the tarball, and rerun discovery, and a failing lifecycle script still fails with its output preserved in the pack_failed message. No option, exit code, or response field changes.
The regression tests cover a chatty lifecycle passing, a chatty lifecycle that changes what is packed being caught, and a failing script keeping its output in the failure message. No blocking findings.
[Automated review]
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] `astryx integration pack --check` now checks the tarball when a `prepack`, `prepare`, or `postpack` script prints to stdout. Before, any lifecycle output made the check fail with "npm pack produced unparseable JSON output" before it looked at the tarball. A failing lifecycle script still fails the check, and its output stays in the `pack_failed` message. |
There was a problem hiding this comment.
same as other - shouldn't this be a dr command?
PR Analysis Report
No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | View full report |
…riptor Main no longer reads a themes/manifest.json catalog (#6498), so the fixture's theme came back as invalid_theme. It now ships oceanTheme.doc.mjs, the way pack-check.test.mjs does, and the renaming lifecycle script edits that descriptor.
User impact
Anyone running
astryx integration pack --checkon a package whoseprepack,prepare, orpostpackscript prints anything. That's most packages that build before publishing ("prepack": "tsup","prepare": "npm run build", even a plainecho). The check failed every time withpack_failed: npm pack produced unparseable JSON output.and never looked at the tarball, so the gate couldn't pass for those packages at all. After the fix the check runs the lifecycle, compares the files, extracts the tarball, and reruns discovery like it does for a quiet package.Problem and solution fit
npm pack --jsonand parses stdout as JSON. npm runs pack lifecycle scripts in the foreground, so their stdout lands in front of the JSON on the same stream (--silentonly hides npm's own banner).pack_failed, and nothing about the artifact gets examined. The author sees a failure that has nothing to do with their package.integration pack --checkis the publish gate. A gate that can't pass for normal packages gets skipped, and then nothing proves the tarball matches what the author sees locally.The fix passes
--foreground-scripts=false. npm still runs every lifecycle script, but in the background, so stdout carries only the JSON result. In that mode npm reports a failing script as a JSON error on stdout instead of on stderr, so thepack_failedmessage now reads that error when stderr is empty. A failing script still fails the check with its output in the message.Expected behavior and authority
docs/architecture/cli-surface.md(current), INV17:With lifecycle output the command did none of the last three steps. The command doc and
integrationPackCheck()doc already describe the restored behavior, so they don't change.Compatibility (AST-017 FR5): contract-restoring fix, nonbreaking. No option, exit code, or response field changes. The only output difference is that a package with a chatty lifecycle can now pass.
Smallest restoration
One npm flag in
runNpmPack, plus reading npm's JSON error for thepack_failedmessage so a failing script's output isn't lost when it moves off stderr. No other behavior changes.Evidence
"prepack": "echo building the package"and one doc contribution.astryx integration pack --check --jsonexits 1 with"tarball": nulland one issue,{"code": "pack_failed", "message": "npm pack produced unparseable JSON output."}. Runningnpm pack --json --silentby hand showsbuilding the packageprinted before the JSON array.packable: true,tarball.fileCount: 3, and no issues. Text mode prints[ok] [email protected]and3 packed files; 2/2 required files present.pack-check.test.mjs), and a failingprepackstill fails withpack_failed.packages/cli/api/integration/pack-check.lifecycle-output.test.mjs.checks the tarball when lifecycle scripts print to stdoutandstill runs a chatty lifecycle script and compares what it packedfail on main (they getpack_failed) and pass with the fix. The second one proves the lifecycle still runs, since a printingprepackthat renames a theme is caught asidentity_not_packed.keeps a failing lifecycle script output in the pack_failed issuepasses on main and with the fix, and fails if the fix drops the stdout error detail.--foreground-scripts=falseturns the first two red. Removing only the stdout error detail turns the third red.Scope
Testing
All green. The full CLI suite is 271 files and 4301 tests passing.