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.3.4
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.3.5
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Oct 1, 2022

  1. README: Update module usage.

    When using module:commonjs in the tsconfig, there is no default export. Both run and default are added to module.exports.
    raineorshine committed Oct 1, 2022
    Copy the full SHA
    4778d96 View commit details

Commits on Oct 2, 2022

  1. Copy the full SHA
    215c19c View commit details
  2. 16.3.5

    raineorshine committed Oct 2, 2022
    Copy the full SHA
    c892a70 View commit details
Showing with 85 additions and 8 deletions.
  1. +1 −1 README.md
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +81 −4 src/package-managers/npm.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -324,7 +324,7 @@ npm-check-updates can be imported as a module:
```js
import ncu from 'npm-check-updates'
const upgraded = await ncu({
const upgraded = await ncu.run({
// Pass any cli option
packageFile: '../package.json',
upgrade: true,
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.3.4",
"version": "16.3.5",
"author": "Tomas Junnonen <tomas1@gmail.com>",
"license": "Apache-2.0",
"contributors": [
85 changes: 81 additions & 4 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
@@ -56,13 +56,88 @@ const normalizeNpmConfig = (npmConfig: NpmConfig): NpmConfig => {
'strict-ssl': 'strictSSL',
}

// config variables that need to be converted from strings to boolean values
// store in lowercase since they are strictly for comparison purposes
const booleanKeys = { strictssl: true }
// all config variables are read in as strings, so we need to type coerce non-strings
// lowercased and hyphens removed for comparison purposes
const keyTypes: Index<'boolean' | 'number'> = {
all: 'boolean',
allowsameversion: 'boolean',
audit: 'boolean',
binlinks: 'boolean',
color: 'boolean',
commithooks: 'boolean',
description: 'boolean',
dev: 'boolean',
diffignoreallspace: 'boolean',
diffnameonly: 'boolean',
diffnoprefix: 'boolean',
difftext: 'boolean',
dryrun: 'boolean',
enginestrict: 'boolean',
force: 'boolean',
foregroundscripts: 'boolean',
formatpackagelock: 'boolean',
fund: 'boolean',
gittagversion: 'boolean',
global: 'boolean',
globalstyle: 'boolean',
ifpresent: 'boolean',
ignorescripts: 'boolean',
includestaged: 'boolean',
includeworkspaceroot: 'boolean',
installlinks: 'boolean',
json: 'boolean',
legacybundling: 'boolean',
legacypeerdeps: 'boolean',
link: 'boolean',
long: 'boolean',
offline: 'boolean',
omitlockfileregistryresolved: 'boolean',
packagelock: 'boolean',
packagelockonly: 'boolean',
parseable: 'boolean',
preferoffline: 'boolean',
preferonline: 'boolean',
progress: 'boolean',
readonly: 'boolean',
rebuildbundle: 'boolean',
save: 'boolean',
savebundle: 'boolean',
savedev: 'boolean',
saveexact: 'boolean',
saveoptional: 'boolean',
savepeer: 'boolean',
saveprod: 'boolean',
shrinkwrap: 'boolean',
signgitcommit: 'boolean',
signgittag: 'boolean',
strictpeerdeps: 'boolean',
strictssl: 'boolean',
timing: 'boolean',
unicode: 'boolean',
updatenotifier: 'boolean',
usage: 'boolean',
version: 'boolean',
versions: 'boolean',
workspacesupdate: 'boolean',
diffunified: 'number',
fetchretries: 'number',
fetchretryfactor: 'number',
fetchretrymaxtimeout: 'number',
fetchretrymintimeout: 'number',
fetchtimeout: 'number',
logsmax: 'number',
maxsockets: 'number',
searchlimit: 'number',
searchstaleness: 'number',
ssopollfrequency: 'number',
}

/** Parses a string to a boolean. */
const stringToBoolean = (s: string) => !!s && s !== 'false' && s !== '0'

/** Parses a string to a number. */
const stringToNumber = (s: string) => parseInt(s) || 0

// needed until pacote supports full npm config compatibility
// See: https://github.com/zkat/pacote/issues/156
const config: NpmConfig = keyValueBy(npmConfig, (key: string, value: string | boolean | ((path: string) => any)) => {
@@ -71,8 +146,10 @@ const normalizeNpmConfig = (npmConfig: NpmConfig): NpmConfig => {
typeof value !== 'string'
? value
: // parse stringified booleans
key.replace(/-/g, '').toLowerCase() in booleanKeys
keyTypes[key.replace(/-/g, '').toLowerCase()] === 'boolean'
? stringToBoolean(value)
: keyTypes[key.replace(/-/g, '').toLowerCase()] === 'number'
? stringToNumber(value)
: value.replace(/\${([^}]+)}/, (_, envVar) => process.env[envVar] as string)

// normalize the key for pacote