Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: raineorshine/npm-check-updates
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v16.12.1
Choose a base ref
...
head repository: raineorshine/npm-check-updates
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v16.12.2
Choose a head ref
  • 4 commits
  • 10 files changed
  • 1 contributor

Commits on Aug 17, 2023

  1. Copy the full SHA
    79e7441 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5709ba6 View commit details
  3. Copy the full SHA
    03757c0 View commit details
  4. 16.12.2

    raineorshine committed Aug 17, 2023
    Copy the full SHA
    bbfdc73 View commit details
59 changes: 36 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -273,7 +273,7 @@ Options that take no arguments can be negated by prefixing them with `--no-`, e.
</tr>
<tr>
<td>-p, --packageManager <s></td>
<td>npm, yarn, pnpm, deno, staticRegistry (default: npm).</td>
<td>npm, yarn, pnpm, deno (default: npm).</td>
</tr>
<tr>
<td>--peer</td>
@@ -289,7 +289,11 @@ Options that take no arguments can be negated by prefixing them with `--no-`, e.
</tr>
<tr>
<td>-r, --registry <uri></td>
<td>Third-party npm registry.</td>
<td>Specify the registry to use when looking up package versions.</td>
</tr>
<tr>
<td>--registryType <type></td>
<td>Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm)</td>
</tr>
<tr>
<td>-x, --reject <p></td>
@@ -492,26 +496,13 @@ Usage:
ncu --packageManager [s]
ncu -p [s]
Specifies the package manager to use when looking up version numbers.
Specifies the package manager to use when looking up versions.
<table>
<tr><td>npm</td><td>System-installed npm. Default.</td></tr>
<tr><td>yarn</td><td>System-installed yarn. Automatically used if yarn.lock is present.</td></tr>
<tr><td>pnpm</td><td>System-installed pnpm. Automatically used if pnpm-lock.yaml is present.</td></tr>
<tr><td>staticRegistry</td><td>Checks versions from a file or url to a simple JSON registry. Must include the `--registry` option.
Example:
$ ncu --packageManager staticRegistry --registry ./my-registry.json
my-registry.json:
{
"prettier": "2.7.1",
"typescript": "4.7.4"
}
</td></tr>
<tr><td>staticRegistry</td><td>Deprecated. Use --registryType json.</td></tr>
</table>
## peer
@@ -556,17 +547,39 @@ As a comparison: without using the `--peer` option, ncu will suggest the latest
ncu-test-peer-update 1.0.0 → 1.1.0
ncu-test-return-version 1.0.0 → 2.0.0
## registry
## registryType
Usage:
ncu --registry [uri]
ncu -r [uri]
ncu --registryType [type]
Specify whether --registry refers to a full npm registry or a simple JSON file.
Specify the registry to use when looking up package version numbers.
<table>
<tr><td>npm</td><td>Default npm registry</td></tr>
<tr><td>json</td><td>Checks versions from a file or url to a simple JSON registry. Must include the `--registry` option.
Example:
// local file
$ ncu --registryType json --registry ./registry.json
// url
$ ncu --registryType json --registry https://api.mydomain/registry.json
// you can omit --registryType when the registry ends in .json
$ ncu --registry ./registry.json
$ ncu --registry https://api.mydomain/registry.json
registry.json:
When `--packageManager staticRegistry` is set, `--registry` must specify a file path or url
to a simple JSON registry.
{
"prettier": "2.7.1",
"typescript": "4.7.4"
}
</td></tr>
</table>
## target
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-check-updates",
"version": "16.12.1",
"version": "16.12.2",
"author": "Tomas Junnonen <tomas1@gmail.com>",
"license": "Apache-2.0",
"contributors": [
56 changes: 43 additions & 13 deletions src/cli-options.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ import path from 'path'
import { defaultCacheFile } from './lib/cache'
import chalk from './lib/chalk'
import table from './lib/table'
import wrap from './lib/wrap'
import CLIOption from './types/CLIOption'
import ExtendedHelp from './types/ExtendedHelp'
import { Index } from './types/IndexType'
@@ -39,7 +38,7 @@ export const renderExtendedHelp = (option: CLIOption, { markdown }: { markdown?:
}

if (option.default !== undefined && !(Array.isArray(option.default) && option.default.length === 0)) {
output += `Default: ${option.default}\n`
output += `\nDefault: ${option.default}\n`
}
if (option.help) {
const helpText =
@@ -262,25 +261,51 @@ ${chalk.green(
`
}

/** Extended help for the --format option. */
/** Extended help for the --packageManager option. */
const extendedHelpPackageManager: ExtendedHelp = ({ markdown }) => {
const header = 'Specifies the package manager to use when looking up version numbers.'
const header = 'Specifies the package manager to use when looking up versions.'
const tableString = table({
colAligns: ['right', 'left'],
markdown,
rows: [
['npm', `System-installed npm. Default.`],
['yarn', `System-installed yarn. Automatically used if yarn.lock is present.`],
['pnpm', `System-installed pnpm. Automatically used if pnpm-lock.yaml is present.`],
['staticRegistry', `Deprecated. Use --registryType json.`],
],
})

return `${header}\n\n${padLeft(tableString, markdown ? 0 : 4)}
`
}

/** Extended help for the --registryType option. */
const extendedHelpRegistryType: ExtendedHelp = ({ markdown }) => {
const header = 'Specify whether --registry refers to a full npm registry or a simple JSON file.'
const tableString = table({
colAligns: ['right', 'left'],
markdown,
rows: [
['npm', `Default npm registry`],
[
'staticRegistry',
`Checks versions from a file or url to a simple JSON registry. Must include the \`--registry\` option.
'json',
`Checks versions from a file or url to a simple JSON registry. Must include the ${chalk.cyan(
'`--registry`',
)} option.
Example:
${chalk.cyan('$')} ncu --packageManager staticRegistry --registry ./my-registry.json
${chalk.gray('// local file')}
${chalk.cyan('$')} ncu --registryType json --registry ./registry.json
${chalk.gray('// url')}
${chalk.cyan('$')} ncu --registryType json --registry https://api.mydomain/registry.json
${chalk.gray('// you can omit --registryType when the registry ends in .json')}
${chalk.cyan('$')} ncu --registry ./registry.json
${chalk.cyan('$')} ncu --registry https://api.mydomain/registry.json
my-registry.json:
registry.json:
{
"prettier": "2.7.1",
@@ -558,7 +583,7 @@ const cliOptions: CLIOption[] = [
long: 'packageManager',
short: 'p',
arg: 's',
description: 'npm, yarn, pnpm, deno, staticRegistry (default: npm).',
description: 'npm, yarn, pnpm, deno (default: npm).',
help: extendedHelpPackageManager,
type: `'npm' | 'yarn' | 'pnpm' | 'deno' | 'staticRegistry'`,
},
@@ -586,12 +611,17 @@ const cliOptions: CLIOption[] = [
long: 'registry',
short: 'r',
arg: 'uri',
description: 'Third-party npm registry.',
help: wrap(`Specify the registry to use when looking up package version numbers.
When \`--packageManager staticRegistry\` is set, \`--registry\` must specify a file path or url to a simple JSON registry.`),
description: 'Specify the registry to use when looking up package versions.',
type: 'string',
},
{
long: 'registryType',
arg: 'type',
description:
'Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm)',
help: extendedHelpRegistryType,
type: `'npm' | 'json'`,
},
{
long: 'reject',
short: 'x',
2 changes: 2 additions & 0 deletions src/lib/getPackageManager.ts
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ function getPackageManager(options: Options, name: Maybe<string>): PackageManage
// default to npm
if (!name || name === 'deno') {
return packageManagers.npm
} else if (options.registryType === 'json') {
return packageManagers.staticRegistry
}

if (!packageManagers[name]) {
26 changes: 20 additions & 6 deletions src/lib/initOptions.ts
Original file line number Diff line number Diff line change
@@ -76,10 +76,18 @@ async function initOptions(runOptions: RunOptions, { cli }: { cli?: boolean } =
}

// warn about deprecated options
const deprecatedOptions = cliOptions.filter(({ long, deprecated }) => deprecated && options[long as keyof Options])
const deprecatedOptions = cliOptions.filter(
({ long, deprecated }) =>
(deprecated && options[long as keyof Options]) ||
// special case to deprecate a value but not the entire option
(long === 'packageManager' && options.packageManager === 'staticRegistry'),
)
if (deprecatedOptions.length > 0) {
deprecatedOptions.forEach(({ long, description }) => {
const deprecationMessage = `--${long}: ${description}`
const deprecationMessage =
long === 'packageManager'
? '--packageManager staticRegistry is deprecated. Use --registryType json.'
: `--${long}: ${description}`
print(options, chalk.yellow(deprecationMessage), 'warn')
})
print(options, '', 'warn')
@@ -140,14 +148,19 @@ async function initOptions(runOptions: RunOptions, { cli }: { cli?: boolean } =
else if (options.doctor && (options.workspace?.length || options.workspaces)) {
programError(options, `Doctor mode is not currently supported with --workspace${options.workspaces ? 's' : ''}.`)
}

// disallow incorrect or missing registry path when selecting staticRegistry as packageManager
if (options.packageManager === 'staticRegistry' && !options.registry) {
// disallow missing registry path when using registryType
else if (options.packageManager === 'staticRegistry' && !options.registry) {
programError(
options,
'When --package-manager staticRegistry is specified, you must provide the path for the registry file with --registry. Run "ncu --help --packageManager" for details.',
'When --package-manager staticRegistry is specified, you must provide the path for the registry file with --registry.',
)
} else if (options.registryType === 'json' && !options.registry) {
programError(
options,
'When --registryType json is specified, you must provide the path for the registry file with --registry. Run "ncu --help registryType" for details.',
)
}

const target: Target = options.target || 'latest'

const autoPre = target === 'newest' || target === 'greatest'
@@ -174,6 +187,7 @@ async function initOptions(runOptions: RunOptions, { cli }: { cli?: boolean } =
// imply upgrade in interactive mode when json is not specified as the output
...(options.interactive && options.upgrade === undefined ? { upgrade: !json } : null),
packageManager,
registryType: options.registryType || (options.registry?.endsWith('.json') ? 'json' : 'npm'),
}
resolvedOptions.cacher = await cacher(resolvedOptions)

9 changes: 7 additions & 2 deletions src/types/RunOptions.json
Original file line number Diff line number Diff line change
@@ -344,7 +344,7 @@
"type": "string"
},
"packageManager": {
"description": "npm, yarn, pnpm, deno, staticRegistry (default: npm). Run \"ncu --help --packageManager\" for details.",
"description": "npm, yarn, pnpm, deno (default: npm). Run \"ncu --help --packageManager\" for details.",
"enum": ["deno", "npm", "pnpm", "staticRegistry", "yarn"],
"type": "string"
},
@@ -361,7 +361,12 @@
"type": "string"
},
"registry": {
"description": "Third-party npm registry. Run \"ncu --help --registry\" for details.",
"description": "Specify the registry to use when looking up package versions.",
"type": "string"
},
"registryType": {
"description": "Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm) Run \"ncu --help --registryType\" for details.",
"enum": ["json", "npm"],
"type": "string"
},
"reject": {
7 changes: 5 additions & 2 deletions src/types/RunOptions.ts
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ export interface RunOptions {
/** Package file(s) location. (default: ./package.json) */
packageFile?: string

/** npm, yarn, pnpm, deno, staticRegistry (default: npm). Run "ncu --help --packageManager" for details. */
/** npm, yarn, pnpm, deno (default: npm). Run "ncu --help --packageManager" for details. */
packageManager?: 'npm' | 'yarn' | 'pnpm' | 'deno' | 'staticRegistry'

/** Check peer dependencies of installed packages and filter updates to compatible versions. Run "ncu --help --peer" for details. */
@@ -133,9 +133,12 @@ export interface RunOptions {
/** Current working directory of npm. */
prefix?: string

/** Third-party npm registry. Run "ncu --help --registry" for details. */
/** Specify the registry to use when looking up package versions. */
registry?: string

/** Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm) Run "ncu --help --registryType" for details. */
registryType?: 'npm' | 'json'

/** Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. */
reject?: string | string[] | RegExp | RegExp[] | FilterFunction

Loading