tylerlong / yarn-upgrade-all Goto Github PK
View Code? Open in Web Editor NEWThis is a command line utility program to upgrade all the packages in your `package.json` to the latest version (potentially upgrading packages across major versions).
This is a command line utility program to upgrade all the packages in your `package.json` to the latest version (potentially upgrading packages across major versions).
so that we can use this tool to update our private dependencies in the company
It would be cool to have option to skip some packages that we dont want to upgrade (or they fail to install).
This is a great package but can have a destructive result if you accidentally control c the running application or it errors out on a cryptic error in node itself.
The package.json will inherit its modified state, which may be incomplete or missing packages. While easy to restore from a version control system it would be beneficial to add some testing case.
One should be to store the original package.json in a .yarn-upgrade-all tmp directory in case an issue was present. If the program was cancelled early by mistake this version could be reverted too.
Either restore the original package.json OR attempt a merge operation. Obviously if you were between a remove and add section the package goes missing. If there was an original backup when rerunning yarn-upgrade-all
the program could check to see if it was interrupted and attempt to merge previous tasks.'
Goal is to have a safer outcome.
So that if you fail somewhere in the middle, it'll continue from there instead of starting over
Trying to use after install:
'yarn-upgrade-all' is not recognized as an internal or external command, operable program or batch file.
yarn remove one two three four
yarn add one two three fours
This works much faster than remove and add every package in sequence
e.g.
"dependencies": {
"foo": "../foo"
}
These should probably just be ignored.
Hi!
Sometimes, it might be needed to pass a specific option to yarn add
.
For example, I want to execute yarn add -D --ignore-workspace-root-check <package>
.
In this case, currently there is no way to pass --ignore-workspace-root-check
option to yarn-upgrade-all
.
How about allowing it?
I think a solution like yarn-upgrade-all --foo-option --bar-option
would be good.
How do you think?
Thanks!
> yarn-upgrade-all
[Start]: yarn add @discordjs/builders @discordjs/rest @prisma/client @tsconfig/recommended @vitalets/google-translate-api common-tags discord-api-types discord-backup discord-tictactoe discord-together discord.js dotenv glob ms quick.db topgg-autoposter ts-node
[Done]: yarn add @discordjs/builders @discordjs/rest @prisma/client @tsconfig/recommended @vitalets/google-translate-api common-tags discord-api-types discord-backup discord-tictactoe discord-together discord.js dotenv glob ms quick.db topgg-autoposter ts-node
[Start]: yarn add @discordjs/builders @discordjs/rest @prisma/client @tsconfig/recommended @vitalets/google-translate-api common-tags discord-api-types discord-backup discord-tictactoe discord-together discord.js dotenv glob ms quick.db topgg-autoposter ts-node add @types/common-tags @types/glob @types/ms @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint prisma typescript --dev
[Done]: yarn add @discordjs/builders @discordjs/rest @prisma/client @tsconfig/recommended @vitalets/google-translate-api common-tags discord-api-types discord-backup discord-tictactoe discord-together discord.js dotenv glob ms quick.db topgg-autoposter ts-node add @types/common-tags @types/glob @types/ms @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint prisma typescript --dev
It takes a really long time to upgrade each package in particular. It would be a lot faster if you use the npm-api to fetch the versions, replace these in the package.json
and run yarn
after it.
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const childProcess = require("child_process");
const chalk = require("chalk");
const logError = message => {
console.log(chalk.red("[Error]: " + message));
};
const logInfo = message => {
console.log(chalk.blue("[Start]: " + message));
};
const logSuccess = message => {
console.log(chalk.green("[Done]: " + message));
};
let global = "";
let packagePath = path.resolve(process.cwd(), "package.json");
if (!fs.existsSync(packagePath)) {
logError("Cannot find package.json file in the current directory");
process.exit(1);
}
const packageJson = require(packagePath);
const options = {
dependencies: "",
devDependencies: " --dev",
peerDependencies: " --peer"
};
let ignorePkgs = [];
if (packageJson["ignore-upgrade"]) {
ignorePkgs = packageJson["ignore-upgrade"];
}
let upgraded = { before: {}, after: {} };
for (let element of ["dependencies", "devDependencies", "peerDependencies"]) {
if (packageJson[element]) {
const packages = Object.keys(packageJson[element]);
let packagesList = packages
.filter(pkk => !ignorePkgs.includes(pkk))
.map(pkk => {
upgraded["before"][pkk] = packageJson[element][pkk];
return pkk + "@latest";
})
.join(" ");
let command = `yarn${global} add --dev ${packagesList}`;
try {
// logInfo(command);
childProcess.execSync(command, { stdio: [] });
const packageJsonAfter = JSON.parse(fs.readFileSync(packagePath));
const packagesAfter = Object.keys(packageJsonAfter[element]);
let packagesListAfter = packagesAfter
.filter(pkk => !ignorePkgs.includes(pkk))
.map(pkk => {
upgraded["after"][pkk] = packageJsonAfter[element][pkk];
return upgraded["before"][pkk] !== upgraded["after"][pkk]
? `Updated: ${pkk} from: ${upgraded["before"][pkk]} | to: ${
upgraded["after"][pkk]
}\n`
: ``;
})
.join("");
logSuccess(packagesListAfter);
} catch (e) {
logError(`${command} - ${e}`);
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.