npm-check-updates 9.2.1 → 9.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,8 @@ const { print } = require('../logging')
8
8
 
9
9
  /** Return the highest numbered tag on a remote Git URL. */
10
10
  const greatest = async (name, version, options) => {
11
- const { protocol, host, path } = parseGithubUrl(version)
12
- const url = `${protocol ? protocol.replace('git+', '') : 'https:'}//${host}/${path}`
11
+ const { auth, protocol, host, path } = parseGithubUrl(version)
12
+ const url = `${protocol ? protocol.replace('git+', '') : 'https:'}//${auth ? auth + '@' : ''}${host}/${path}`
13
13
  let tagMap = new Map()
14
14
 
15
15
  // fetch remote tags
@@ -25,7 +25,9 @@ const greatest = async (name, version, options) => {
25
25
  // eslint-disable-next-line fp/no-mutating-methods
26
26
  const tags = [...tagMap.keys()]
27
27
  .map(tag => versionUtil.isSimpleVersion(tag) ? tag + '.0.0' : tag)
28
- .filter(semver.valid)
28
+ // do not pass semver.valid reference directly since the mapping index will be interpreted as the loose option
29
+ // https://github.com/npm/node-semver#functions
30
+ .filter(tag => semver.valid(tag))
29
31
  .sort(versionUtil.compareVersions)
30
32
  const latestVersion = tags[tags.length - 1]
31
33
  return latestVersion
@@ -181,7 +181,7 @@ function upgradeDependencies(currentDependencies, latestVersions, options = {})
181
181
  const isSatisfied = semver.satisfies
182
182
 
183
183
  /**
184
- * Satisfy the latest, and it is not beyond the latest).
184
+ * Check if a version satisfies the latest, and is not beyond the latest). Ignores `v` prefix.
185
185
  *
186
186
  * @param current
187
187
  * @param latest
@@ -200,15 +200,19 @@ function isUpgradeable(current, latest) {
200
200
  if (!range) {
201
201
  throw new Error(`"${current}" could not be parsed by semver-utils. This is probably a bug. Please file an issue at https://github.com/raineorshine/npm-check-updates.`)
202
202
  }
203
+
203
204
  const version = versionUtil.stringify(range)
205
+ const latestNormalized = versionUtil.isSimpleVersion(latest)
206
+ ? latest.replace('v', '') + '.0.0'
207
+ : latest
204
208
 
205
209
  // make sure it is a valid range
206
210
  // not upgradeable if the latest version satisfies the current range
207
211
  // not upgradeable if the specified version is newer than the latest (indicating a prerelease version)
208
212
  // NOTE: When "<" is specified with a single digit version, e.g. "<7", and has the same major version as the latest, e.g. "7", isSatisfied(latest, version) will return true since it ignores the "<". In this case, test the original range (current) rather than the versionUtil output (version).
209
213
  return Boolean(semver.validRange(version)) &&
210
- !isSatisfied(latest, range.operator === '<' ? current : version) &&
211
- !semver.ltr(latest, version)
214
+ !isSatisfied(latestNormalized, range.operator === '<' ? current : version) &&
215
+ !semver.ltr(latestNormalized, version)
212
216
  }
213
217
 
214
218
  /**
@@ -469,33 +473,31 @@ async function queryVersions(packageMap, options = {}) {
469
473
  const npmAlias = versionUtil.parseNpmAlias(packageMap[dep])
470
474
  const [name, version] = npmAlias || [dep, packageMap[dep]]
471
475
 
476
+ let versionNew = null
477
+
472
478
  // use gitTags package manager for git urls
473
479
  if (versionUtil.isGithubUrl(packageMap[dep])) {
474
- return await packageManagers.gitTags.greatest(name, version, options)
475
- }
476
-
477
- let versionNew
478
-
479
- try {
480
- versionNew = await getPackageVersion(name, version, {
481
- ...options,
482
- // upgrade prereleases to newer prereleases by default
483
- pre: options.pre != null ? options.pre : versionUtil.isPre(version)
484
- })
480
+ versionNew = await packageManagers.gitTags.greatest(name, version, options)
485
481
  }
486
- catch (err) {
487
- const errorMessage = err ? (err.message || err).toString() : ''
488
- if (errorMessage.match(/E404|ENOTFOUND|404 Not Found/i)) {
489
- return null
482
+ else {
483
+ try {
484
+ versionNew = await getPackageVersion(name, version, {
485
+ ...options,
486
+ // upgrade prereleases to newer prereleases by default
487
+ pre: options.pre != null ? options.pre : versionUtil.isPre(version)
488
+ })
489
+ versionNew = npmAlias ? versionUtil.createNpmAlias(name, versionNew) : versionNew
490
490
  }
491
- else {
492
-
493
- // print a hint about the --timeout option for network timeout errors
494
- if (!process.env.NCU_TESTS && /(Response|network) timeout/i.test(errorMessage)) {
495
- console.error('\n\n' + chalk.red('FetchError: Request Timeout. npm-registry-fetch defaults to 30000 (30 seconds). Try setting the --timeout option (in milliseconds) to override this.') + '\n')
491
+ catch (err) {
492
+ const errorMessage = err ? (err.message || err).toString() : ''
493
+ if (!errorMessage.match(/E404|ENOTFOUND|404 Not Found/i)) {
494
+ // print a hint about the --timeout option for network timeout errors
495
+ if (!process.env.NCU_TESTS && /(Response|network) timeout/i.test(errorMessage)) {
496
+ console.error('\n\n' + chalk.red('FetchError: Request Timeout. npm-registry-fetch defaults to 30000 (30 seconds). Try setting the --timeout option (in milliseconds) to override this.') + '\n')
497
+ }
498
+
499
+ throw err
496
500
  }
497
-
498
- throw err
499
501
  }
500
502
  }
501
503
 
@@ -503,7 +505,7 @@ async function queryVersions(packageMap, options = {}) {
503
505
  bar.tick()
504
506
  }
505
507
 
506
- return npmAlias ? versionUtil.createNpmAlias(name, versionNew) : versionNew
508
+ return versionNew
507
509
  }
508
510
 
509
511
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-check-updates",
3
- "version": "9.2.1",
3
+ "version": "9.2.4",
4
4
  "author": "Tomas Junnonen <tomas1@gmail.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -51,7 +51,7 @@
51
51
  "chalk": "^4.1.0",
52
52
  "cint": "^8.2.1",
53
53
  "cli-table": "^0.3.1",
54
- "commander": "^6.1.0",
54
+ "commander": "^6.2.0",
55
55
  "find-up": "5.0.0",
56
56
  "get-stdin": "^8.0.0",
57
57
  "json-parse-helpfulerror": "^1.0.3",
@@ -62,7 +62,7 @@
62
62
  "pacote": "^11.1.11",
63
63
  "parse-github-url": "^1.0.2",
64
64
  "progress": "^2.0.3",
65
- "prompts": "^2.3.2",
65
+ "prompts": "^2.4.0",
66
66
  "rc-config-loader": "^3.0.0",
67
67
  "remote-git-tags": "^3.0.0",
68
68
  "rimraf": "^3.0.2",
@@ -76,15 +76,15 @@
76
76
  "chai-as-promised": "^7.1.1",
77
77
  "chai-string": "^1.5.0",
78
78
  "chokidar-cli": "^2.1.0",
79
- "eslint": "^7.10.0",
79
+ "eslint": "^7.12.1",
80
80
  "eslint-config-standard": "^14.1.1",
81
81
  "eslint-plugin-fp": "^2.3.0",
82
82
  "eslint-plugin-import": "^2.22.1",
83
- "eslint-plugin-jsdoc": "^30.6.2",
83
+ "eslint-plugin-jsdoc": "^30.7.5",
84
84
  "eslint-plugin-node": "^11.1.0",
85
85
  "eslint-plugin-promise": "^4.2.1",
86
86
  "eslint-plugin-standard": "^4.0.1",
87
- "mocha": "^8.1.3",
87
+ "mocha": "^8.2.0",
88
88
  "nyc": "^15.1.0",
89
89
  "should": "^13.2.3",
90
90
  "tmp": "0.2.1"