Skip to content

fix(cli): check the tarball when pack lifecycle scripts print output - #6556

Merged
josephfarina merged 3 commits into
mainfrom
cli-spec/integrations-authoring/pack-check-lifecycle-output
Oct 2, 2026
Merged

josephfarina merged 3 commits into
mainfrom
cli-spec/integrations-authoring/pack-check-lifecycle-output

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

Anyone running astryx integration pack --check on a package whose prepack, prepare, or postpack script prints anything. That's most packages that build before publishing ("prepack": "tsup", "prepare": "npm run build", even a plain echo). The check failed every time with pack_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

  • Why does it fail? The check runs npm pack --json and 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 (--silent only hides npm's own banner).
  • Why does it hurt? The parse fails, the check reports pack_failed, and nothing about the artifact gets examined. The author sees a failure that has nothing to do with their package.
  • Why does it matter? integration pack --check is 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 the pack_failed message 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:

integration pack --check runs the package lifecycle through npm pack, compares the required file inventory with the actual tarball, extracts that tarball into a scratch consumer, and reruns contribution discovery.

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 the pack_failed message so a failing script's output isn't lost when it moves off stderr. No other behavior changes.

Evidence

  • Reproduction before the change: a package with "prepack": "echo building the package" and one doc contribution. astryx integration pack --check --json exits 1 with "tarball": null and one issue, {"code": "pack_failed", "message": "npm pack produced unparseable JSON output."}. Running npm pack --json --silent by hand shows building the package printed before the JSON array.
  • Result after the change: the same package exits 0 with packable: true, tarball.fileCount: 3, and no issues. Text mode prints [ok] [email protected] and 3 packed files; 2/2 required files present.
  • Representative unchanged path: a package with no lifecycle scripts passes as before (existing pack-check.test.mjs), and a failing prepack still fails with pack_failed.
  • Regression test or other mutation-sensitive proof: new packages/cli/api/integration/pack-check.lifecycle-output.test.mjs.
    • checks the tarball when lifecycle scripts print to stdout and still runs a chatty lifecycle script and compares what it packed fail on main (they get pack_failed) and pass with the fix. The second one proves the lifecycle still runs, since a printing prepack that renames a theme is caught as identity_not_packed.
    • keeps a failing lifecycle script output in the pack_failed issue passes on main and with the fix, and fails if the fix drops the stdout error detail.
    • Mutation check. Removing only --foreground-scripts=false turns the first two red. Removing only the stdout error detail turns the third red.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm -F @astryxdesign/cli exec tsc --project tsconfig.api-dts.json
pnpm check:cli-structure
pnpm -F @astryxdesign/cli readme:check
pnpm -F @astryxdesign/cli typecheck:json-api
ASTRYX_STRICT_LINT=1 pnpm exec eslint packages/cli/api/integration/pack-check.mjs packages/cli/api/integration/pack-check.lifecycle-output.test.mjs
pnpm check:repo
pnpm exec vitest run packages/cli

All green. The full CLI suite is 271 files and 4301 tests passing.

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.
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 1, 2026 9:29pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 24, 2026
@astracat-bot

astracat-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 1, 2026, 10:35 PM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as other - shouldn't this be a dr command?

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview availability: Storybook and Sandbox are not both ready on the exact-head Vercel preview.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

15 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
SideNav Resizable in AppShell probe dark 3,208
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

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.
@josephfarina
josephfarina marked this pull request as ready for review October 1, 2026 21:49
@josephfarina
josephfarina merged commit 7683377 into main Oct 2, 2026
40 checks passed
@github-actions
github-actions Bot deleted the cli-spec/integrations-authoring/pack-check-lifecycle-output branch October 2, 2026 06:24

This branch was successfully deployed

1 active deployment
Preview — f3848a20 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant