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
Feature proposal: provide function to filter #1050
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
- Update cli-options.
- Let's add tests for
reject
,filterVersion
, andrejectVersion
as well. I think they use the same predicate so they automatically get support for filter functions with this PR. - Pass
name
andversionRange
to the predicate function as described here: [FR] Introducesafe
option #1034 (comment). This will make it easier for developers to write conditions using the dependency version. In effect,filter
andfilterVersion
will be identical when a function is passed. I think it's simpler than having two separate predicate signatures.
Oh apparently the CLI options are also contradicting with the types: {
long: 'filter',
short: 'f',
arg: 'matches',
description: 'Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, or /regex/.',
type: 'string | string[] | RegExp',
},
{
long: 'filterVersion',
arg: 'matches',
description: 'Filter on package version using comma-or-space-delimited list, or /regex/.',
type: 'string | string[] | RegExp',
},
{
long: 'reject',
short: 'x',
arg: 'matches',
description: 'Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, or /regex/.',
type: 'string | string[] | RegExp | RegExp[]',
},
{
long: 'rejectVersion',
arg: 'matches',
description: 'Exclude package.json versions using comma-or-space-delimited list, or /regex/.',
type: 'string | string[] | RegExp | RegExp[]',
}, vs. /**
* Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, or /regex/.
*/
filter?: string | string[] | RegExp | RegExp[],
/**
* Filter on package version using comma-or-space-delimited list, or /regex/.
*/
filterVersion?: string | string[] | RegExp | RegExp[],
/**
* Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, or /regex/.
*/
reject?: string | string[] | RegExp,
/**
* Exclude package.json versions using comma-or-space-delimited list, or /regex/.
*/
rejectVersion?: string | string[] | RegExp, So they are exactly the opposite. I would make them all |
Sure!
It is not deliberate. I think they should have the same type. Thanks!
You are right! That code was written by a non-native speak also, but your IDE apparently is a native speaker :).
Yes, I agree. |
done 😄
Should this be part of this MR or a separate one - sunsetting |
It should be part of this PR, since I don't want to publish the feature with the wrong predicate signature. My intention was to keep |
🤔 Given: @types/chai-as-promised ^7.1.4 → ^7.1.5
@types/node ^17.0.10 → ^17.0.18
@typescript-eslint/eslint-plugin ^5.10.0 → ^5.12.0
@typescript-eslint/parser ^5.10.0 → ^5.12.0
filter: (name,version) => {return name.startsWith('@types') && version.startsWith('^7')}, Sorry if I can't fully follow. |
Yes, but You can see See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parserange-rangestring |
Sorry but I can't follow / understand how to implement that. |
No problem. I'll revisit when I have a moment. |
This is what I had in mind: 13cafc5 The It looks ready to merge from my perspective. Let me know if I'm missing anything. |
Ahh cool thanks! 👍🏻 Let me take a final glimpse at it on Monday - thanks for your support! |
OK couldn't wait until Monday 😅 Added a final cleanup commit with tiny changes:
Very excited about this, it was a lot of fun - thank you! |
Thanks!
I need to add Prettier... |
Published to Note that I am going to patch the |
While thinking about how to solve #1034 I was playing around a bit and came up with this draft.
The idea is that one can provide a function - for example via the
.ncurc.js
and then only get's back the matching packages. An alternative to a fancy regex where it can be solved more in detail and programmatically.
test provided:
What do you think?