From c09c38079ff104ee0ccf61eef2de0dcc4818d7bf Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Sat, 24 Feb 2024 17:09:32 +0000 Subject: [PATCH] README --- README.md | 12 ++++++++---- src/cli-options.ts | 25 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e7fadb31..baa6930c 100644 --- a/README.md +++ b/README.md @@ -444,7 +444,9 @@ Usage: ncu --filter [p] ncu -f [p] -Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. +Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with `--peer`. + +`--filter` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. @@ -467,7 +469,7 @@ filterFunction: (name, semver) => { Filters out upgrades based on a user provided function. -`filterResults` runs _after_ new versions are fetched, in contrast to `filter` and `filterVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change). +`filterResults` runs _after_ new versions are fetched, in contrast to `filter`, `reject`, `filterVersion`, and `rejectVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change). Only available in .ncurc.js or when importing npm-check-updates as a module. @@ -675,7 +677,9 @@ Usage: ncu --reject [p] ncu -x [p] -The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. +The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the `--peer` check. + +`--reject` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_. The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. @@ -711,7 +715,7 @@ The predicate function is only available in .ncurc.js or when importing npm-chec (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) => { +rejectVersionFunction: (name, semver) => { if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) { return true } diff --git a/src/cli-options.ts b/src/cli-options.ts index a91942eb..e71abc02 100755 --- a/src/cli-options.ts +++ b/src/cli-options.ts @@ -124,7 +124,9 @@ const extendedHelpFilterResults: ExtendedHelp = ({ markdown }) => { ${codeInline('filterResults')} runs _after_ new versions are fetched, in contrast to ${codeInline( 'filter', - )} and ${codeInline('filterVersion')}, which run _before_. This allows you to filter out upgrades with ${codeInline( + )}, ${codeInline('reject')}, ${codeInline('filterVersion')}, and ${codeInline( + 'rejectVersion', + )}, which run _before_. This allows you to filter out upgrades with ${codeInline( 'filterResults', )} based on how the version has changed (e.g. a major version change). @@ -201,7 +203,16 @@ const extendedHelpInstall: ExtendedHelp = ({ markdown }) => { /** Extended help for the --filter option. */ const extendedHelpFilterFunction: ExtendedHelp = ({ markdown }) => { - return `Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. + /** If markdown, surround inline code with backticks. */ + const codeInline = (code: string) => (markdown ? `\`${code}\`` : code) + + return `Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with ${codeInline( + '--peer', + )}. + +${codeInline('--filter')} runs _before_ new versions are fetched, in contrast to ${codeInline( + '--filterResults', + )} which runs _after_. The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. @@ -258,7 +269,13 @@ const extendedHelpRejectFunction: ExtendedHelp = ({ markdown }) => { return `The inverse of ${codeInline( '--filter', - )}. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. + )}. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the ${codeInline( + '--peer', + )} check. + +${codeInline('--reject')} runs _before_ new versions are fetched, in contrast to ${codeInline( + '--filterResults', + )} which runs _after_. The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. @@ -299,7 +316,7 @@ ${codeBlock( (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. */`)} -${chalk.green('filterVersionFunction')}: (name, semver) ${chalk.cyan('=>')} { +${chalk.green('rejectVersionFunction')}: (name, semver) ${chalk.cyan('=>')} { ${chalk.red('if')} (name.startsWith(${chalk.yellow(`'@myorg/'`)}) ${chalk.red( '&&', )} parseInt(semver[0]?.major) ${chalk.cyan('>')} ${chalk.cyan(`5`)}) {