@npmcli/arborist 6.1.0 → 6.1.2

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.
@@ -7,9 +7,8 @@ const cacache = require('cacache')
7
7
  const promiseCallLimit = require('promise-call-limit')
8
8
  const realpath = require('../../lib/realpath.js')
9
9
  const { resolve, dirname } = require('path')
10
- const { promisify } = require('util')
11
10
  const treeCheck = require('../tree-check.js')
12
- const readdir = promisify(require('readdir-scoped-modules'))
11
+ const { readdirScoped } = require('@npmcli/fs')
13
12
  const { lstat, readlink } = require('fs/promises')
14
13
  const { depth } = require('treeverse')
15
14
  const log = require('proc-log')
@@ -447,7 +446,8 @@ module.exports = cls => class IdealTreeBuilder extends cls {
447
446
  const globalExplicitUpdateNames = []
448
447
  if (this[_global] && (this[_updateAll] || this[_updateNames].length)) {
449
448
  const nm = resolve(this.path, 'node_modules')
450
- for (const name of await readdir(nm).catch(() => [])) {
449
+ const paths = await readdirScoped(nm).catch(() => [])
450
+ for (const name of paths.map((p) => p.replace(/\\/g, '/'))) {
451
451
  tree.package.dependencies = tree.package.dependencies || {}
452
452
  const updateName = this[_updateNames].includes(name)
453
453
  if (this[_updateAll] || updateName) {
@@ -3,8 +3,7 @@
3
3
  const { relative, dirname, resolve, join, normalize } = require('path')
4
4
 
5
5
  const rpj = require('read-package-json-fast')
6
- const { promisify } = require('util')
7
- const readdir = promisify(require('readdir-scoped-modules'))
6
+ const { readdirScoped } = require('@npmcli/fs')
8
7
  const walkUp = require('walk-up-path')
9
8
  const ancestorPath = require('common-ancestor-path')
10
9
  const treeCheck = require('../tree-check.js')
@@ -362,7 +361,7 @@ module.exports = cls => class ActualLoader extends cls {
362
361
  async [_loadFSChildren] (node) {
363
362
  const nm = resolve(node.realpath, 'node_modules')
364
363
  try {
365
- const kids = await readdir(nm)
364
+ const kids = await readdirScoped(nm).then(paths => paths.map(p => p.replace(/\\/g, '/')))
366
365
  return Promise.all(
367
366
  // ignore . dirs and retired scoped package folders
368
367
  kids.filter(kid => !/^(@[^/]+\/)?\./.test(kid))
@@ -411,8 +410,8 @@ module.exports = cls => class ActualLoader extends cls {
411
410
  break
412
411
  }
413
412
 
414
- const entries = nmContents.get(p) ||
415
- await readdir(p + '/node_modules').catch(() => [])
413
+ const entries = nmContents.get(p) || await readdirScoped(p + '/node_modules')
414
+ .catch(() => []).then(paths => paths.map(p => p.replace(/\\/g, '/')))
416
415
  nmContents.set(p, entries)
417
416
  if (!entries.includes(name)) {
418
417
  continue
@@ -345,7 +345,6 @@ module.exports = cls => class Builder extends cls {
345
345
  event,
346
346
  path,
347
347
  pkg,
348
- stdioString: true,
349
348
  stdio,
350
349
  env,
351
350
  scriptShell: this[_scriptShell],
@@ -9,6 +9,7 @@ const semver = require('semver')
9
9
  const debug = require('../debug.js')
10
10
  const walkUp = require('walk-up-path')
11
11
  const log = require('proc-log')
12
+ const hgi = require('hosted-git-info')
12
13
 
13
14
  const { dirname, resolve, relative } = require('path')
14
15
  const { depth: dfwalk } = require('treeverse')
@@ -18,7 +19,7 @@ const {
18
19
  rm,
19
20
  symlink,
20
21
  } = require('fs/promises')
21
- const moveFile = require('@npmcli/move-file')
22
+ const { moveFile } = require('@npmcli/fs')
22
23
  const PackageJson = require('@npmcli/package-json')
23
24
  const packageContents = require('@npmcli/installed-package-contents')
24
25
  const runScript = require('@npmcli/run-script')
@@ -640,10 +641,15 @@ module.exports = cls => class Reifier extends cls {
640
641
  // and no 'bundled: true' setting.
641
642
  // Do the best with what we have, or else remove it from the tree
642
643
  // entirely, since we can't possibly reify it.
643
- const res = node.resolved ? `${node.name}@${this[_registryResolved](node.resolved)}`
644
- : node.packageName && node.version
645
- ? `${node.packageName}@${node.version}`
646
- : null
644
+ let res = null
645
+ if (node.resolved) {
646
+ const registryResolved = this[_registryResolved](node.resolved)
647
+ if (registryResolved) {
648
+ res = `${node.name}@${registryResolved}`
649
+ }
650
+ } else if (node.packageName && node.version) {
651
+ res = `${node.packageName}@${node.version}`
652
+ }
647
653
 
648
654
  // no idea what this thing is. remove it from the tree.
649
655
  if (!res) {
@@ -721,12 +727,20 @@ module.exports = cls => class Reifier extends cls {
721
727
  // ${REGISTRY} or something. This has to be threaded through the
722
728
  // Shrinkwrap and Node classes carefully, so for now, just treat
723
729
  // the default reg as the magical animal that it has been.
724
- const resolvedURL = new URL(resolved)
730
+ const resolvedURL = hgi.parseUrl(resolved)
731
+
732
+ if (!resolvedURL) {
733
+ // if we could not parse the url at all then returning nothing
734
+ // here means it will get removed from the tree in the next step
735
+ return
736
+ }
737
+
725
738
  if ((this.options.replaceRegistryHost === resolvedURL.hostname)
726
739
  || this.options.replaceRegistryHost === 'always') {
727
740
  // this.registry always has a trailing slash
728
- resolved = `${this.registry.slice(0, -1)}${resolvedURL.pathname}${resolvedURL.searchParams}`
741
+ return `${this.registry.slice(0, -1)}${resolvedURL.pathname}${resolvedURL.searchParams}`
729
742
  }
743
+
730
744
  return resolved
731
745
  }
732
746
 
@@ -1544,7 +1558,6 @@ module.exports = cls => class Reifier extends cls {
1544
1558
  event,
1545
1559
  path,
1546
1560
  pkg,
1547
- stdioString: true,
1548
1561
  stdio,
1549
1562
  scriptShell: this.options.scriptShell,
1550
1563
  })
package/package.json CHANGED
@@ -1,25 +1,26 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",
7
+ "@npmcli/fs": "^3.1.0",
7
8
  "@npmcli/installed-package-contents": "^2.0.0",
8
9
  "@npmcli/map-workspaces": "^3.0.0",
9
10
  "@npmcli/metavuln-calculator": "^5.0.0",
10
- "@npmcli/move-file": "^3.0.0",
11
11
  "@npmcli/name-from-folder": "^1.0.1",
12
12
  "@npmcli/node-gyp": "^3.0.0",
13
13
  "@npmcli/package-json": "^3.0.0",
14
14
  "@npmcli/query": "^3.0.0",
15
- "@npmcli/run-script": "^5.0.0",
15
+ "@npmcli/run-script": "^6.0.0",
16
16
  "bin-links": "^4.0.1",
17
- "cacache": "^17.0.1",
17
+ "cacache": "^17.0.2",
18
18
  "common-ancestor-path": "^1.0.1",
19
+ "hosted-git-info": "^6.1.1",
19
20
  "json-parse-even-better-errors": "^3.0.0",
20
21
  "json-stringify-nice": "^1.1.4",
21
22
  "minimatch": "^5.1.0",
22
- "nopt": "^6.0.0",
23
+ "nopt": "^7.0.0",
23
24
  "npm-install-checks": "^6.0.0",
24
25
  "npm-package-arg": "^10.0.0",
25
26
  "npm-pick-manifest": "^8.0.1",
@@ -31,7 +32,6 @@
31
32
  "promise-all-reject-late": "^1.0.0",
32
33
  "promise-call-limit": "^1.0.1",
33
34
  "read-package-json-fast": "^3.0.1",
34
- "readdir-scoped-modules": "^1.1.0",
35
35
  "semver": "^7.3.7",
36
36
  "ssri": "^10.0.0",
37
37
  "treeverse": "^3.0.0",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@npmcli/eslint-config": "^4.0.0",
42
- "@npmcli/template-oss": "4.6.2",
42
+ "@npmcli/template-oss": "4.9.0",
43
43
  "benchmark": "^2.1.4",
44
44
  "chalk": "^4.1.0",
45
45
  "minify-registry-metadata": "^2.1.0",
@@ -101,7 +101,7 @@
101
101
  },
102
102
  "templateOSS": {
103
103
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
104
- "version": "4.6.2",
104
+ "version": "4.9.0",
105
105
  "content": "../../scripts/template-oss/index.js"
106
106
  }
107
107
  }