Giter VIP home page Giter VIP logo

yarn-upgrade-all's Issues

feat: passing options to yarn

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!

Duplicates arguments to update and installs "add" package incorrectly

> 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

image

Why not make it WAYYY faster and simpler

#!/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}`);
        }
    }
}

Great package but can have destructive results on your package.json

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.

Performance issues

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.