Skip to content

[rush] Keep the PNPM warning box aligned when rewriting the approve-builds command - #6247

Open
Kevuhn wants to merge 5 commits into
microsoft:mainfrom
Kevuhn:fix/5682-approve-builds-box
Open

Kevuhn wants to merge 5 commits into
microsoft:mainfrom
Kevuhn:fix/5682-approve-builds-box

Conversation

@Kevuhn

@Kevuhn Kevuhn commented Dec 3, 2026

Copy link
Copy Markdown

Summary

Fixes #5682

When PNPM skips a dependency's build scripts, it prints an "Ignored build scripts" warning box. During
rush install and rush update, Rush rewrites pnpm approve-builds in that box to
rush-pnpm --subspace <name> approve-builds, which is 24 characters longer. PNPM had already padded the
row to fit the box, so that row's right border ended up 24 characters past the others.

This PR keeps the box aligned when Rush rewrites the command.

Details

I moved the replacement into a new function, replaceTextInPnpmOutput() in
libraries/rush-lib/src/utilities/pnpmOutputUtilities.ts, and called it from WorkspaceInstallManager.ts.
For each line of output that contains the search text:

  • If it isn't a box row (│ … │), it does a plain replacement, as before.
  • If it's a box row and the new text fits, it adjusts the trailing spaces so the row keeps its width.
  • If the new text doesn't fit, which is the case here, it re-wraps that row together with the rows below
    it that continue the same paragraph (stopping at a blank row or the end of the box), and pads each new
    row to the original width.

Color codes around the borders are kept, and the original line endings are kept. Rush receives PNPM's
output in arbitrary chunks, so a row that is cut off at the end of a chunk can't be fixed safely. Such
rows fall back to the plain replacement, so the worst case is the current behavior.

Known limitation: with a subspace name longer than about 30 characters, the command itself can be split
across two rows. I considered keeping it on one row, but then a long command would push past the right
border again, so I let it wrap to keep the box aligned.

An alternative solution could be, leaving PNPM's box unchanged and printing the
rush-pnpm command as a separate tip, would also work. I'm happy to switch if you'd prefer that.

How it was tested

  • Added unit tests in pnpmOutputUtilities.test.ts covering: output without the search text, text
    outside a box, a box row where the new text fits, the real PNPM warning box, the same box with colored
    borders, Windows line endings, and a row cut off at the end of a chunk.
  • Manually, in a new rush init repo using PNPM 10.32.1 with one project depending on
    rs-module-lexer@2.8.0 (with globalNeverBuiltDependencies removed so that PNPM skips the build script):
    ran rush purge and rush update using the locally built Rush (apps/rush/lib-commonjs/start-dev.js)
    and confirmed the box is aligned.

Before:
image

After:
image

@Kevuhn

Kevuhn commented Dec 3, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

[rush] Slightly wrong text formatting for script warning box

1 participant