Fix issue with upgrade-interactive and root dependencies #7671
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.
Summary
First of all, I would like to say I love this project 馃挭馃徏
Here is my little contribution, hope you consider it 馃帀
So I encountered the following problem with the
upgrade-interactive --latest
command.If you are using workspaces, and you have some root dependencies and some package specific dependencies. If you run
upgrade-interactive --latest
in one of the package folders, you will be given a choice to upgrade dependencies not only in the current package but also all other packages and the root workspace. If you decide to upgrade a dependency from the root of the workspace, the command won't upgrade the version of the dependency in the rootpackage.json
but will leave that one the same, and add that dependency to the current package folder with the new version.So for example, in the following project: https://github.com/juresotosek/upgrade-interactive-example, if you navigate to the
packages/test
folder and runupgrade-interactive --latest
, and then decide to upgradetypescript
, there will be a newdevDependency
added to thepackages/test/package.json
and the version oftypescript
in rootpackage.json
won't be changed.Solution
It turns out that
upgrade-interactive --latest
looks at the location of the dependency in the workspace, and runs thatAdd
command there. Well, if the dependency is in the root, the location will be en empty string, in that case, it should default to the root of the project while now, it defaults to the current location of where the command was executed. That's what I've changed.Test plan
Clone the above repo see the behavior.