Giter Club home page Giter Club logo

Comments (7)

bombillazo avatar bombillazo commented on June 9, 2024 2

Nevermind after rereading the thread I got it!

module.exports = {
  target: (name) => {
    if(['chalk', 'react'].includes(name)) return 'minor';
    return 'latest';
  },
};

from npm-check-updates.

jeffersoneagley avatar jeffersoneagley commented on June 9, 2024 1

I'm basically trying to say "here's my list of things I don't want to do large breaking upgrades on yet, upgrade those to the next minor version, and then upgrade everything else to whatever".

from npm-check-updates.

raineorshine avatar raineorshine commented on June 9, 2024 1

There's basically no documentation about how to actually use rejectVersion. A paragraph stating the expected syntax and a couple of examples would help a lot.

Yes, thank you! A glaring omission. I've added the following documentation to the README (though read below for another approach):

rejectVersion

Usage:

ncu --rejectVersion [p]

The inverse of --filterVersion. Exclude versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.

The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. This function is an alias for the reject option function.

/**
  @param name     The name of the dependency.
  @param semver   A parsed Semver object of the upgraded version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        True if the package should be excluded, false if it should be included.
*/
filterVersionFunction: (name, semver) => {
  if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
    return true
  }
  return false
}

I'm basically trying to say "here's my list of things I don't want to do large breaking upgrades on yet, upgrade those to the next minor version, and then upgrade everything else to whatever".

For this, I recommend defining a target predicate function in your .ncurc.js. That allows you to apply the minor strategy to get the behavior you describe.

/**
  @param name The name of the dependency.
  @param parsedVersion A parsed Semver object of the upgraded version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
*/
target: name => name === 'react-router-dom' ? 'minor' : 'latest'

from npm-check-updates.

raineorshine avatar raineorshine commented on June 9, 2024 1

For the moment, I just went with target: minor across the board (and plan to instruct my team to do all major version upgrades by hand, which is probably for the best anyways).

Great! Note there is also target: 'semver'.

I haven't made the jump from .npmrc as a json file to .npmrc.js yet, but it looks more and more like I probably should.

It's a very simple switch. Just rename the file, add module.exports = { ... } and you're good to go. The only difference is that it adds support for some of the options like filter, reject, and target that allow custom functions.

This, plus setting up "doctor mode" is going to make our dependency update story quite a bit more smooth!

Yes, doctor mode has been a big time-saver for me on my other projects! Enjoy.

from npm-check-updates.

jeffersoneagley avatar jeffersoneagley commented on June 9, 2024

Thank you very much for the quick answer back!

For the moment, I just went with target: minor across the board (and plan to instruct my team to do all major version upgrades by hand, which is probably for the best anyways).

I haven't made the jump from .npmrc as a json file to .npmrc.js yet, but it looks more and more like I probably should.

This, plus setting up "doctor mode" is going to make our dependency update story quite a bit more smooth!

from npm-check-updates.

bombillazo avatar bombillazo commented on June 9, 2024

Hey! I too, am having trouble understanding reject and rejectVersion usage, specifically in our .ncurc file.

When we run ncu -i we want to see the latest version (including major) except for some dep we know we cannot upgrade to the major version. For those, we still want to see if the latest minor version has a new version.

At the moment, we are adding to the reject array those deps we don't want to major bump but that means not checking minor versions.

from npm-check-updates.

UmarFKhawaja avatar UmarFKhawaja commented on June 9, 2024

There should be a sample config file demonstrating the various capabilities, especially for the .js and .cjs options.

from npm-check-updates.

Related Issues (20)

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.