Reputation: 2057
Is it possible to upgrade all specific scoped packages in the dependencies section of my package.json
by using the Yarn package manager?
For example:
yarn upgrade @scope/*
This will upgrade all scoped packages in yarn.lock
and package.json
file.
Upvotes: 24
Views: 17309
Reputation: 39
Code below upgrade all packages of scope to latest version.
yarn upgrade --scope @scope-name --latest
or
yarn upgrade -S @scope-name --latest
Upvotes: 3
Reputation: 796
In modern versions of Yarn (Yarn 2 and newer), you can use yarn up '@scope/*'
. You don't even need to install the interactive upgrade plugin. It took me way longer than needed to find this! See docs here: https://yarnpkg.com/cli/up Note that yarn upgrade
was deprecated and doesn't exist in newer versions.
Upvotes: 1
Reputation: 10272
yarn upgrade --scope @scopeName --latest
//Example :-
yarn upgrade --scope @angular --latest
// OR
yarn upgrade -S @angular --latest
Upvotes: 2
Reputation: 1
i'm using npm-check-updates
after installing it, just run ncu -u
and then run yarn
Upvotes: 0
Reputation: 589
yarn upgrade-interactive
should do the trick for you with an up-to-date version of yarn. This advice is even output when installing the yarn-update package that @valentinvoilean mentioned above.
Upvotes: 2
Reputation: 1051
In the current version v1.2.1 you can actually use the build in --scope
flag to upgrade only packages that begin with that scope yarn upgrade --scope @angular
. Check out more on yarn upgrade scope on the official website.
Upvotes: 16
Reputation: 2933
https://github.com/torifat/yarn-update says:
Please use yarn upgrade-interactive
instead.
Upvotes: 33
Reputation: 1392
Or better install yarn-update.
I found it very useful.
All you have to do is to run yarn-update
and then select the packages you want to update.
Upvotes: 3
Reputation: 13567
Since there's no way to do this currently with Yarn, I've written a very short Node script to do what you want:
var fs = require('fs');
var child_process = require('child_process');
var filterRegex = /@angular\/.*/;
fs.readFile('./package.json', function(err, data) {
if (err) throw err;
var dependencies = JSON.parse(data)['dependencies'];
Object.keys(dependencies).forEach(function(dependency) {
if (filterRegex.test(dependency)) {
console.log('Upgrading ' + dependency);
child_process.execSync('yarn upgrade ' + dependency);
} else {
console.log('Skipping ' + dependency);
}
});
});
Here's a quick explanation of what that does:
it loads the package.json
from the directory that the terminal is currently in
we then parse the JSON of the package.json
and get the "dependencies"
key
for each dependency, we run the regex specified as the filterRegex
(if you need to change this or want an explanation of the regex syntax, I would test with RegExr. I used @angular
as an example prefix for the regex)
if the dependency matches, we run yarn upgrade [DEPENDENCY]
and log it
Let me know if you have any trouble with this, but it should solve your issue until the Yarn team come up with something better.
Upvotes: 5