fix: --fix applies fixes scoped to the workspace member, not the root - #986
Merged
Merged
Conversation
The --fix executor built its install command via buildFixCommandParts, which produced a flat, unscoped `npm install X@ver` / `pnpm add X@ver`. In a monorepo that installs the fix into the root manifest instead of the member that declares it. #972 fixed all the displayed/copy-run commands but not the executor. Extract buildTargetCommand in fix-commands.ts (the workspace-scoped per-target command, factored out of findSuggestedCommandForFinding) and use it in the apply path so the displayed command and the applied command are identical. Multi-member commands are `&&`-split into one spawn each. Removes the now-dead buildFixCommandParts.
Covers the workspace-scoped direct apply (npm install -w <member> ...) and the flat non-workspace case via the injected command runner. Adds the new buildTargetCommand export to the cli-integration fix-commands mock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--fixexecutor built its install command throughbuildFixCommandParts, which produced an unscoped command. In a monorepo that meant a direct fix was installed at the repository root instead of the workspace member that actually declares the dependency, so the change landed in the wrongpackage.json.#972 corrected the commands we display, but the executor still built its own unscoped command, so what
--fixapplied could diverge from what we showed.This extracts
buildTargetCommand, shared by both the display path and the apply path, so the command that runs is exactly the command shown, scoped to the declaring workspace member. Commands for multiple members joined with&&are split and spawned individually. The now-deadbuildFixCommandPartsis removed.In-house.
Closes #978