Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show outdated packages versions and upgrade all outdated #749

Closed
MrEfrem opened this issue Jan 24, 2020 · 36 comments
Closed

Show outdated packages versions and upgrade all outdated #749

MrEfrem opened this issue Jan 24, 2020 · 36 comments
Labels
enhancement New feature or request

Comments

@MrEfrem
Copy link
Contributor

MrEfrem commented Jan 24, 2020

Thank you for your awesome work. This release is very promising.
But it hasn't at least two important commands.
Yarn v1:
yarn outdated - show list outdated packages versions.
yarn upgrade - upgrade all minor versions of outdated packages.
I use it very often.

First I run yarn upgrade to update automatically all minor versions. Then I run yarn outdated and already manually update packages to major versions with changing my sources.
I think so workflow use the most part of people who use yarn or npm.
Why is it not implemented?
Even here @arcanis mentioned that outdated is the main command a year ago yet: #546 (comment)

@MrEfrem MrEfrem added the enhancement New feature or request label Jan 24, 2020
@MrEfrem MrEfrem changed the title Show outdated packages version and upgrade all outdated Show outdated packages versions and upgrade all outdated Jan 24, 2020
@deini
Copy link
Member

deini commented Jan 24, 2020

@MrEfrem have you tried upgrade-interactive ?

@MrEfrem
Copy link
Contributor Author

MrEfrem commented Jan 24, 2020

Oh, yes. It works and what I wanted. Thank you very much. But I spent much time while I tried to find the same commands I used in npm and yarn v1.
Would be very good if you added link on this command in the migration article and also mentioned there that it replaces outdated and upgrade all packages.
And maybe it should be added to the Usage section: https://yarnpkg.com/getting-started/usage
because really those commands are very important.

@MrEfrem MrEfrem closed this as completed Jan 24, 2020
@milesj
Copy link

milesj commented Jan 24, 2020

@MrEfrem FWIW, upgrade-interactive has existed in v1 since inception.

@MrEfrem
Copy link
Contributor Author

MrEfrem commented Jan 25, 2020

@milesj I hadn’t need to search it because those commands I mentioned above worked for me very well in both packages managers. And what do you mean yet? Because it was re-implemented we should wait at least the outdated command?

@jakst
Copy link

jakst commented Jan 30, 2020

I don't think upgrade-interactive solves the same use case as outdated does.

In yarn-v1 I regularly use both commands - yarn outdated for a quick scan if there are any packages that need upgrade, and then a couple of rounds of yarn upgrade-interactive to progressively upgrade packages from "guaranteed to not break" to "will probably break something".

Here are three reasons why yarn outdated is still needed:

  • It is easier to type than yarn upgrade-interactive which is nice for people like me who run yarn outdated several times a day.
  • It does not capture terminal input and is therefore less abrupt than yarn upgrade-interactive. This behaviour also allows yarn outdated to be combined with other commands, like yarn outdated && yarn start.
  • It does not show all packages, and is therefore faster to scan. (Why does the new upgrade-interactive show all packages by the way?)

@wesrice
Copy link

wesrice commented Feb 12, 2020

I just upgraded from Yarn v1 to v2. I am surprised that commands akin to yarn outdated and yarn upgrade do not exist. This issue is the only place that I've found addressing the topic, so I'll leave my use case here.

I regularly utilize yarn upgrade for minor and patch upgrades, then run a subsequent yarn outdated to see what major upgrades exist for my projects. I use this as a way of measuring technical debt with the thought that the more major upgrades that exist for my project, the harder it is going to be to maintain the project down the road. At work, I use this as a factor in vouching for feature prioritization. Without yarn upgrade and yarn outdated, I have a much more difficult time doing this.

Is there an expectation that voids like this in Yarn v2 should be filled via plugins?

@robclancy
Copy link

This is super weird :/

@danielkcz
Copy link

danielkcz commented Apr 2, 2020

Oh my. So everyone is going to meet in this closed issue after painfully realizing that outdated doesn't work and docs don't mention any migration path. Same for the list and who knows what else. That's a rather sad approach :/

Also, the new upgrade-interactive is fairly confusing. It's not clear that the first column means no update will happen. And it's ugly as hell on Windows.

image

But I do like that it allows choosing upgrading minor or major. In the previous iteration, the --latest was somewhat cumbersome.

@robrichard
Copy link

Is there a non-interactive way to upgrade all packages that satisfy the current ranges in the package.json? We used to use yarn upgrade to do this.

@PutziSan
Copy link

PutziSan commented Nov 2, 2020

Is there a non-interactive way to upgrade all packages that satisfy the current ranges in the package.json? We used to use yarn upgrade to do this.

Is this possible?

At the moment I find it very difficult to update my packages in a larger workspace. upgrade-interactive shows me about 100 packages (but only 20 at a time and I have to scroll via keyboard arrows), but most of them cannot be upgraded because there is no newer version. The visual selection is very tiring because the lines are very narrow and I often slip in the line. (maybe the UI is only on windows that bad, I don't know)

When I managed to select everything I want, there is often an error (net gone or the files are blocked by the ide), so that nothing is updated and I have to go through the process again.

image

@nicolabello
Copy link

@robrichard @PutziSan I think you are looking for https://yarnpkg.com/cli/up

@PutziSan
Copy link

As far as I know yarn up only works with explicitly naming each dependency.

@merceyz
Copy link
Member

merceyz commented Nov 18, 2020

You can use glob patterns in it, so for example yarn up "**" would upgrade everything

@PutziSan
Copy link

Okay, thx @merceyz .
I don't understand exactly what the default behavior is regarding the semver-modifiers of yarn up "**". It sounds like it always updates everything to the latest state and ignores the modifiers from package.json?
So does this mean that the equivalent of yarn upgrade (yarn v1) is now yarn up "**" --caret?

@mskelton
Copy link
Contributor

mskelton commented Dec 19, 2020

For anyone following this thread looking for the yarn outdated command in Yarn 2, I built a community plugin to provide functionality similar to yarn outdated from Yarn 1. The plugin is still pretty new and the output format is slightly different, but overall it accomplishes the same goals. It also includes a JSON output so this might solve your use case.

You can find my plugin here: https://github.com/mskelton/yarn-plugin-outdated and it can be imported via:

yarn plugin import https://mskelton.dev/yarn-outdated/v3

@Deepak7985
Copy link

Is there a way i can get list of only outdated dependencies.

@PikachuEXE
Copy link

I think the lack of replacement for yarn upgrade and yarn outdated is absurd for a project that's expected to be supportive to developers.
Unless I got that expectation wrong...

This gap should be filled in officially (community plugins support are welcome too but having a built-in support is a must)

Taking away things that worked well with no good enough replacement is a downgrade.

@mskelton
Copy link
Contributor

mskelton commented Oct 1, 2021

@PikachuEXE I don't want to spark a big disagreement or debate, but let me say a few things in defense of Maël and the team.

Yarn is an incredible tool that has grown and matured greatly since its inception and Yarn 2 was no exception. A redesigned core that allowed for faster iteration on features, support for community plugins, project level versioning for easier migration, and much more makes Yarn 2 a fantastic developer experience. While there are certainly some differences (like built in replacement for yarn outdated) the team ultimately had to make the decision of what parts of Yarn 1 were core enough to maintain officially and what should be left for the community to fill in the gaps.

Yarn is not unique in this regard. webpack is extremely successful with it's plugin architecture where webpack maintains some official tools (e.g. webpack-dev-server), while allowing the community to build on the framework webpack has built. Many people probably don't realize that the heavily used html-webpack-plugin was built and is maintained by the community. This approach works very well as it allows the core team to focus on core features while letting outside contributors focus on the features specific to each plugin. For example, I've been able to add many new features to the yarn outdated plugin without that time being taken away from the core team working on Yarn's core features.

Change is hard, and migrations are really hard. I get that. There was discussion before Yarn 2 was released about if it should be named something else since it was such a big change to Yarn. Ultimately, I feel that Maël and the team made the right decision, and the community has began to fill in some of the gaps that Yarn 2 left behind.

P.S. yarn upgrade is available in Yarn 2 but it is named yarn up

@PikachuEXE
Copy link

I re-read the migration guide just to be sure.
For yarn outdated at least this issue is mentioned.
For yarn upgrade, yarn up is mentioned but running yarn up doesn't do what yarn upgrade did at all.
Is there an official answer for yarn upgrade replacement that works like yarn upgrade?

P.S. #1492 is opened for a year and I still don't see any response from dev. This is another blocking issue for my attempt to upgrade to yarn berry.

@MrEfrem
Copy link
Contributor Author

MrEfrem commented Oct 5, 2021

@PikachuEXE I found the yarn upgrade-interactive command covers yarn upgrade and yarn outdated for me and for our team. Really, it's more correct to see what you want to upgrade. So the interactive mode is the best option for it.

@MrEfrem
Copy link
Contributor Author

MrEfrem commented Oct 5, 2021

@PikachuEXE but if you really very want the outdated command check here a community plugin: https://yarnpkg.com/features/plugins

@PikachuEXE
Copy link

@MrEfrem
Thank you for offering alternatives.

I have tried the outdated plugin briefly and it looks fine to me. (Though I already know its presence by reading the plugin authors comment above :) )

But I have tried yarn upgrade-interactive in my last attempt and here is what I think:

  • Using in a project with many direct dependencies = very time consuming to use
  • It offers to update the version constraint for a package even when I am installing the latest version (I see no option in its doc)
  • It does not update nested dependencies

There are already many comments above describing what I am using yarn upgrade for.
So I am not repeating those here.

I have also tried yarn up "**" but it cannot be tested probably due to #1492.

@jameskentTX
Copy link

You can always use ncu. It uses yarn (probably old version) and shows outdated packages.

@xstable
Copy link

xstable commented Feb 26, 2022

Heavily missing the Links to the source-packages we had in "outdated"
I generally click on those links and check if they describe any "breaking changes" in their changelog / release messages.

On linux, the navigation isn't smooth. If you move to another line, the whole screen refresh with result in flickering by navigation. You can not move "fast" trough the entries.

image

Even a bit confusing.. how can that range be higher as the "latest" version?
image

@jkhaui
Copy link

jkhaui commented Mar 5, 2022

You can always use ncu. It uses yarn (probably old version) and shows outdated packages.

Thanks, this was a great tip. From here it's easy to replicate the old behaviour by adding the following to package.json: scripts: "outdated": "ncu". Still a bit perplexing why this command was removed from yarn.

@cdauth
Copy link

cdauth commented Mar 23, 2022

I just upgrade to Yarn Berry and I'm super confused about this. In my package.json I have dependencies specified by their major version only. Both using yarn up '**' and yarn upgrade-interactive change my package.json and put the exact version number in there. Also, yarn upgrade-interactive is not a good replacement for yarn outdated, since it does not show the currently installed version of the dependencies (only the specified version range), and it also lists packages that are up to date.

I need a command that does the same as yarn upgrade: Install the newest versions of all direct and nested dependencies according to the version ranges specified in package.json, without changing the package.json file.

It seems like what I can do as a workaround right now is delete yarn.lock and then run yarn install again.

@mskelton
Copy link
Contributor

@cdauth There is a recursive option for yarn up that does what you are trying to do: update dependencies in your lockfile without updating the manifest (package.json).

https://yarnpkg.com/cli/up#options-R%2C-recursive

To use it, just add -R or --recursive as a flag when calling yarn up.

@cdauth
Copy link

cdauth commented Mar 23, 2022

@mskelton Thank you, I can confirm that yarn up -R '**' did upgrade everything in the same way that yarn upgrade used to. I must say that I saw this option in the docs but didn't understand its description at all.

@alamothe
Copy link

alamothe commented Mar 25, 2022

It seems that -R arbitrarily and magically changes behavior of different yarn commands to be more in line with user expectations 🙂 (same thing with foreach, info, but I also fail to understand the logic)

@arcanis
Copy link
Member

arcanis commented Mar 25, 2022

If you imagine the commands operate on a tree, by default they'll only run on the roots of these trees. The -R flag makes them follow the whole tree.

In the case of foreach it's a little special although it's loosely similar, I'd like to re-syntax the cli options to clarify those behaviors.

@rohitkandhal
Copy link

For me yarn upgrade-interactive hung up on loading

2022-04-28_11-13-55

thlmenezes added a commit to TMTecnologia/turborepo-tmtecnologia that referenced this issue Aug 10, 2022
if checking package versions for upgrades, its better to use this

yarnpkg/berry#749
https://yarnpkg.com/cli/upgrade-interactive
@manast
Copy link

manast commented Aug 18, 2022

My 2 cents after reading this long thread:
yarn used to be a drop-in replacement of npm with some nice extra features. Since version 2.0 it is not that thing anymore.

@joshuapinter
Copy link

You can use glob patterns in it, so for example yarn up "**" would upgrade everything

I tried this and it didn't work as expected. It updated my package.json file which is not what I'm after. I'm only looking to update my yarn.lock file based on the constraints I have listed in package.json.

Is there any command that does that?

The only thing that has worked for me since upgrading to Yarn 2 is deleting the yarn.lock file and running yarn install again.

@rudolfbyker
Copy link

Is there any command that does that?

It seems to me like yarn up -R '**' might be what you want. It's different from yarn up '**' in two ways:

  • It's recursive (dependencies of dependencies are updated)
  • It does not touch package.json

@joshuapinter
Copy link

@rudolfbyker Damn, I think you're right, based on the docs:

If -R,--recursive is set the command will change behavior and no other switch will be allowed. When operating under this mode yarn up will force all ranges matching the selected packages to be resolved again (often to the highest available versions) before being stored in the lockfile. It however won't touch your manifests anymore, so depending on your needs you might want to run both yarn up and yarn up -R to cover all bases.

I just tested it and it did exactly what I wanted. Upgrade all packages within the constraints in package.json and only update yarn.lock.

Thank you for pointing this out!

My only complaint now is why the command is so unintuitive. :)

@Linksku
Copy link

Linksku commented Nov 28, 2023

Is there a way to not upgrade major versions with yarn up '**' or yarn up -R '**'? There are a few packages I'm keeping at older versions because the new versions are broken. With yarn upgrade, it ignored the major upgrades.

With yarn up, seems like my options are:

  1. yarn up '**', then individually install the older versions
  2. yarn upgrade-interactive, then press right + down a few dozen times

Option 2 would be easier if yarn upgrade-interactive supported toggling all packages, like with Yarn 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests