npm-check-updates 11.2.0 → 11.3.0

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.
package/lib/index.js CHANGED
@@ -443,10 +443,9 @@ async function run(options = {}) {
443
443
 
444
444
  async function getAnalysis() {
445
445
  const defaultPackageFilename = getPackageFileName(options)
446
- if (options.cwd) {
447
- process.chdir(path.resolve(options.cwd.replace(/^~/, os.homedir())))
448
- }
449
- const pkgs = globby.sync(defaultPackageFilename, {
446
+ const pkgs = globby.sync(options.cwd
447
+ ? path.resolve(options.cwd.replace(/^~/, os.homedir()), defaultPackageFilename)
448
+ : defaultPackageFilename, {
450
449
  ignore: ['**/node_modules/**']
451
450
  })
452
451
  options.deep = options.deep || pkgs.length > 1
@@ -465,7 +464,8 @@ async function run(options = {}) {
465
464
  const [pkgData, pkgFile] = await findPackage(options)
466
465
  return {
467
466
  ...packages,
468
- [pkgFile]: await analyzeProjectDependencies(options, pkgData, pkgFile)
467
+ // index by relative path if cwd was specified
468
+ [options.cwd ? path.relative(path.resolve(options.cwd), pkgFile) : pkgFile]: await analyzeProjectDependencies(options, pkgData, pkgFile)
469
469
  }
470
470
  }, {})
471
471
  if (options.json) {
@@ -8,13 +8,25 @@ const { print } = require('../logging')
8
8
 
9
9
  /** Gets remote versions sorted. */
10
10
  const getSortedVersions = async (name, declaration, options) => {
11
+ // if present, github: is parsed as the protocol. This is not valid when passed into remote-git-tags.
12
+ declaration = declaration.replace(/^github:/, '')
11
13
  const { auth, protocol, host, path } = parseGithubUrl(declaration)
12
- const url = `${protocol ? protocol.replace('git+', '') : 'https:'}//${auth ? auth + '@' : ''}${host}/${path}`
14
+ let tagsPromise = Promise.resolve()
15
+ const protocolKnown = protocol != null
16
+ if (protocolKnown) {
17
+ tagsPromise = tagsPromise.then(() => remoteGitTags(`${protocol ? protocol.replace('git+', '') : 'https:'}//${auth ? auth + '@' : ''}${host}/${path}`))
18
+ }
19
+ else {
20
+ // try ssh first, then https on failure
21
+ tagsPromise = tagsPromise.then(() => remoteGitTags(`ssh://git@${host}/${path}`))
22
+ .catch(() => remoteGitTags(`https://${auth ? auth + '@' : ''}${host}/${path}`))
23
+ }
24
+
13
25
  let tagMap = new Map()
14
26
 
15
27
  // fetch remote tags
16
28
  try {
17
- tagMap = await remoteGitTags(url)
29
+ tagMap = await tagsPromise
18
30
  }
19
31
  // catch a variety of errors that occur on invalid or private repos
20
32
  catch (e) {
@@ -155,7 +155,7 @@ function composeFilter(filterPattern) {
155
155
  }
156
156
  // array
157
157
  else if (Array.isArray(filterPattern)) {
158
- predicate = s => filterPattern.includes(s)
158
+ predicate = s => filterPattern.some(subpattern => composeFilter(subpattern)(s))
159
159
  }
160
160
  // raw RegExp
161
161
  else if (filterPattern instanceof RegExp) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-check-updates",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "author": "Tomas Junnonen <tomas1@gmail.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -63,7 +63,7 @@
63
63
  "fp-and-or": "^0.1.3",
64
64
  "get-stdin": "^8.0.0",
65
65
  "globby": "^11.0.2",
66
- "hosted-git-info": "^3.0.8",
66
+ "hosted-git-info": "^4.0.0",
67
67
  "json-parse-helpfulerror": "^1.0.3",
68
68
  "jsonlines": "^0.1.1",
69
69
  "libnpmconfig": "^1.2.1",
@@ -71,7 +71,7 @@
71
71
  "mem": "^8.0.0",
72
72
  "minimatch": "^3.0.4",
73
73
  "p-map": "^4.0.0",
74
- "pacote": "^11.2.7",
74
+ "pacote": "^11.3.0",
75
75
  "parse-github-url": "^1.0.2",
76
76
  "progress": "^2.0.3",
77
77
  "prompts": "^2.4.0",
@@ -84,7 +84,7 @@
84
84
  "update-notifier": "^5.1.0"
85
85
  },
86
86
  "devDependencies": {
87
- "chai": "^4.3.0",
87
+ "chai": "^4.3.3",
88
88
  "chai-as-promised": "^7.1.1",
89
89
  "chai-string": "^1.5.0",
90
90
  "chokidar-cli": "^2.1.0",
@@ -97,10 +97,10 @@
97
97
  "eslint-plugin-jsdoc": "^32.2.0",
98
98
  "eslint-plugin-node": "^11.1.0",
99
99
  "eslint-plugin-promise": "^4.3.1",
100
- "husky": "^5.1.2",
100
+ "husky": "^5.1.3",
101
101
  "lockfile-lint": "^4.6.2",
102
- "markdownlint-cli": "^0.26.0",
103
- "mocha": "^8.3.0",
102
+ "markdownlint-cli": "^0.27.1",
103
+ "mocha": "^8.3.1",
104
104
  "mock-require": "^3.0.3",
105
105
  "npm-run-all": "^4.1.5",
106
106
  "nyc": "^15.1.0",