@preventive/deptree 1.5.2 → 1.5.3

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.
Files changed (80) hide show
  1. package/bin/compare.js +10 -21
  2. package/bin/deptree.js +5 -10
  3. package/cargo.d.ts +139 -195
  4. package/cargo.js +0 -2
  5. package/cocoapods.d.ts +211 -381
  6. package/cocoapods.js +0 -2
  7. package/npm.d.ts +245 -369
  8. package/npm.js +4 -6
  9. package/package.json +1 -1
  10. package/pnpm.d.ts +258 -667
  11. package/pnpm.js +2 -4
  12. package/soldeer.d.ts +144 -215
  13. package/soldeer.js +0 -2
  14. package/src/cargo/crate.js +21 -46
  15. package/src/cargo/inputs.js +5 -8
  16. package/src/cargo/members.js +6 -12
  17. package/src/cargo/registry.js +5 -9
  18. package/src/cargo/tree.js +8 -13
  19. package/src/cargo/workspace.js +13 -26
  20. package/src/cocoapods/archive.js +19 -40
  21. package/src/cocoapods/clean.js +21 -45
  22. package/src/cocoapods/fnmatch.js +12 -27
  23. package/src/cocoapods/inputs.js +5 -11
  24. package/src/cocoapods/install.js +11 -24
  25. package/src/cocoapods/podspec.js +19 -40
  26. package/src/cocoapods/podtree.js +10 -19
  27. package/src/cocoapods/source.js +13 -30
  28. package/src/cocoapods/tree.js +17 -39
  29. package/src/cocoapods/unicode.js +3 -9
  30. package/src/github.js +12 -24
  31. package/src/glob.js +2 -4
  32. package/src/lazy.js +2 -4
  33. package/src/manifest.js +2 -4
  34. package/src/matcher.js +3 -5
  35. package/src/mount.js +7 -14
  36. package/src/npm/bins.js +3 -5
  37. package/src/npm/compat.js +3 -5
  38. package/src/npm/package.js +6 -12
  39. package/src/npm/ratio.js +3 -5
  40. package/src/npm/settings.js +3 -5
  41. package/src/npm/tree.js +6 -11
  42. package/src/npm/versions.js +3 -4
  43. package/src/npmrc.js +2 -4
  44. package/src/patch.js +8 -14
  45. package/src/pnpm/bins.js +16 -42
  46. package/src/pnpm/filename.js +2 -4
  47. package/src/pnpm/gitignore.js +2 -4
  48. package/src/pnpm/glob.js +3 -5
  49. package/src/pnpm/hoist.js +8 -16
  50. package/src/pnpm/hoisted.js +15 -44
  51. package/src/pnpm/hook.js +2 -4
  52. package/src/pnpm/install.js +5 -10
  53. package/src/pnpm/lazy.js +8 -23
  54. package/src/pnpm/local.js +2 -4
  55. package/src/pnpm/minimatch.js +8 -15
  56. package/src/pnpm/nm-hoist.js +5 -11
  57. package/src/pnpm/npm-packlist.js +3 -6
  58. package/src/pnpm/overrides.js +2 -4
  59. package/src/pnpm/package.js +10 -16
  60. package/src/pnpm/packlist.js +3 -7
  61. package/src/pnpm/patches.js +3 -4
  62. package/src/pnpm/production.js +9 -28
  63. package/src/pnpm/projects.js +2 -6
  64. package/src/pnpm/readers.js +2 -4
  65. package/src/pnpm/settings.js +2 -5
  66. package/src/pnpm/tree.js +14 -37
  67. package/src/pnpm/workspace.js +4 -7
  68. package/src/pnpm/write.js +1 -1
  69. package/src/soldeer/config.js +5 -9
  70. package/src/soldeer/tree.js +2 -4
  71. package/src/soldeer/zip.js +8 -17
  72. package/src/tarball.js +12 -29
  73. package/src/yarn1/compat.js +2 -4
  74. package/src/yarn1/hoist.js +3 -8
  75. package/src/yarn1/package.js +12 -23
  76. package/src/yarn1/resolve.js +6 -11
  77. package/src/yarn1/settings.js +5 -10
  78. package/src/yarn1/tree.js +9 -18
  79. package/yarn1.d.ts +203 -360
  80. package/yarn1.js +4 -6
package/src/manifest.js CHANGED
@@ -36,10 +36,8 @@ export function readManifest(text, where) {
36
36
  return checkNesting(manifest, where)
37
37
  }
38
38
 
39
- // The package.json texts given by directory, in a Map or a Record: the
40
- // project's, and its workspaces', each in a directory under it, as one
41
- // found in a project is. A workspace's dependencies are written in its
42
- // directory, and a link made to it.
39
+ // The package.json texts by directory, in a Map or a Record: the project's at `.`, and its workspaces',
40
+ // each in a directory under it
43
41
  export function readManifests(texts) {
44
42
  const read = new Map()
45
43
  for (const [dir, text] of texts instanceof Map ? texts : Object.entries(texts)) {
package/src/matcher.js CHANGED
@@ -2,11 +2,9 @@
2
2
  // `public-hoist-pattern` read them; and the walk of a path through a glob,
3
3
  // which pnpm's workspace globs and yarn's share.
4
4
 
5
- // Whether a text matches `pattern`, `*` any run of what `any` takes and,
6
- // with `one`, `?` any one code point; anything else itself. The places of
7
- // `pattern` a text reaches are kept a code point at a time, in O(n*m) for
8
- // any pattern, where a regexp of k `*`s backtracks in O(n^k): a glob from a
9
- // project's own files is no one's to stall.
5
+ // `*` any run of what `any` takes and, with `one`, `?` any one code point. The places reached are kept a
6
+ // code point at a time, O(n*m) for any pattern, where a regexp of k `*`s backtracks in O(n^k): a glob
7
+ // from a project's own files is no one's to stall.
10
8
  export function wildcard(pattern, { one = false, any = () => true } = {}) {
11
9
  const parts = [...pattern]
12
10
  const end = parts.length
package/src/mount.js CHANGED
@@ -1,7 +1,5 @@
1
- // A tree mounted into the caller's Vfs at the lockfile's directory, writing
2
- // over and removing nothing; Vfs.mount judges it whole first, so a refusal
3
- // leaves the Vfs as it was. A node_modules there already is refused: kept,
4
- // Node would read it as the tree's, and removed, the caller's would be lost.
1
+ // A tree mounted into the caller's Vfs, judged whole first so a refusal leaves it as it was. A
2
+ // node_modules there already is refused: kept, Node would read it as the tree's; removed, it would be lost.
5
3
 
6
4
  import { VfsError } from '@preventive/vfs'
7
5
  import { basename, dirname } from '@preventive/vfs/path.js'
@@ -50,12 +48,9 @@ export const UNSAFE = /[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\\]/u
50
48
 
51
49
  const asRefusal = (error, what, path) => (error instanceof VfsError ? new DeptreeError(`cannot be ${what}: ${error.message}`, quote(path), { cause: error }) : error)
52
50
 
53
- // Each builder holds what a tarball names and where a package goes to that
54
- // first, and makes no link where a package is written after. What is made
55
- // is held to it again, so that one slip puts nothing out of the tree or the
56
- // package's directory. A directory: a place within the tree, each one on
57
- // the way made where its parent is, or there already and no link. `real`
58
- // keeps the directories found so, as a package's files share them.
51
+ // What a builder makes is held again to staying within the tree, so one slip puts nothing outside it:
52
+ // each directory on the way made where its parent is, or there already and no link. `real` keeps those
53
+ // found so, as a package's files share them.
59
54
  export function makeDirs(vfs, path, real = new Set()) {
60
55
  if (!isInside(path)) throw new DeptreeError('is not a place within the tree', quote(path))
61
56
  let at = ''
@@ -132,10 +127,8 @@ export function writeFiles(vfs, root, { dirs, files, links = new Map() }, stats,
132
127
  }
133
128
  }
134
129
 
135
- // `target` with `tree` in it, or `tree` where there is none; on macOS, two
136
- // names that are one there are refused first. A clash is refused by what is
137
- // there; at the root, a path there is the tree's too. The tree's bytes are
138
- // shared with `target`, not copied.
130
+ // `target` with `tree` in it, or `tree` where there is none, names one on macOS refused first. A clash
131
+ // is refused by what is there; the tree's bytes are shared with `target`, not copied.
139
132
  export function mount(tree, target, folded, check = checkNoModules) {
140
133
  if (folded) checkCollisions(tree)
141
134
  if (target === undefined) return tree
package/src/npm/bins.js CHANGED
@@ -1,8 +1,6 @@
1
- // What bin-links does to the packages' files, the .bin links aside. Bins
2
- // come from the lockfile; in a node_modules, the first package to claim a
3
- // name links it, by Intl.Collator('en') on paths, as npm sorts its nodes,
4
- // even where its target is missing. A linked target is made 0o755, its
5
- // first line's CRLF made LF where that is a shebang in the first 2048 bytes.
1
+ // What bin-links does to the packages' files, the .bin links aside: in a node_modules, the first package
2
+ // by Intl.Collator('en') on paths claims a lockfile bin's name, even where its target is missing; a
3
+ // linked target is made 0o755, and a CRLF shebang in its first 2048 bytes LF
6
4
 
7
5
  import { basename, dirname, join } from '@preventive/vfs/path.js'
8
6
  import { DeptreeError, quote } from '../error.js'
package/src/npm/compat.js CHANGED
@@ -73,11 +73,9 @@ function optionalSet(node, host, skipped) {
73
73
 
74
74
  const whereOf = (node) => `packages[${quote(node.location)}]`
75
75
 
76
- // npm 11 checks optional packages in inventory order, passing over one an
77
- // earlier set took; npm 10 checks them all as it extracts. What is in the
78
- // node_modules of a node left out goes with it. Of those `omitted` leaves
79
- // out, npm 10 checks only those that are not optional, before it extracts,
80
- // and npm 11 only those that are.
76
+ // npm 11 checks optional packages in inventory order, passing over one an earlier set took, npm 10 all
77
+ // as it extracts; what is beneath one left out goes with it. Of those `omitted` leaves out, npm 10 checks
78
+ // only those not optional, before it extracts, and npm 11 only those optional.
81
79
  export function skippedOf(nodes, host, settings, omitted = new Set()) {
82
80
  const skipped = new Set()
83
81
  for (const node of nodes.values()) {
@@ -1,9 +1,6 @@
1
- // A tarball unpacked as pacote has tar unpack it: files alone, so no empty
2
- // directory; modes with read and write for all, less a 0o022 umask, and no
3
- // execute bits added, as npm reads no packument for a resolved URL. Where a
4
- // .npmignore follows a .gitignore renamed to it, tar writes the second's
5
- // bytes into the first's file, keeping its mode. What tar's releases read
6
- // otherwise, or npm never packs, is refused.
1
+ // A tarball as pacote has tar unpack it: files alone, so no empty directory; modes with read and write for
2
+ // all, less a 0o022 umask, and no execute bit added, as npm reads no packument for a resolved URL. What
3
+ // tar's releases read otherwise, or npm never packs, is refused.
7
4
 
8
5
  import { DeptreeError, quote } from '../error.js'
9
6
  import { fetchTarball, fromMirror, isModules, ownTarball, withDirs } from '../tarball.js'
@@ -22,12 +19,8 @@ export function registryTarball({ name, version, resolution }, where) {
22
19
 
23
20
  const FILES = new Set(['file', 'contiguous-file'])
24
21
 
25
- // Every tar release takes a pax size over the header's. Up to 7.5.15, as
26
- // npm 10.9.8 and 11.16 and before bundle it, tar reads it into each header
27
- // after the pax one up to its entry too, so a long name, a long link or a
28
- // global header between them is read by it, and all that follows otherwise
29
- // than later releases read it. The archive reader lists the extended headers
30
- // ahead of each entry, in their order.
22
+ // tar up to 7.5.15 (npm 10.9.8, 11.16 and before) reads a pax size into each header after the pax one up
23
+ // to its entry, so a long name, long link or global header between them, and all after, reads otherwise
31
24
  function checkPaxSizes(entries, where) {
32
25
  for (const { storedName, pax, extended } of entries) {
33
26
  if (pax.has('size') && extended.findIndex(({ kind }) => kind === 'pax') < extended.length - 1) {
@@ -59,6 +52,7 @@ function unpack(entries, where) {
59
52
  path = path.replace(/\.gitignore$/u, '.npmignore')
60
53
  if (ignores.has(path)) continue
61
54
  }
55
+ // A .npmignore after a .gitignore renamed to it: its bytes, in the first's file and mode
62
56
  files.set(path, { data, mode: files.get(path)?.mode ?? ((mode | 0o666) & ~UMASK & 0o777) })
63
57
  }
64
58
  return withDirs(files, where)
package/src/npm/ratio.js CHANGED
@@ -1,8 +1,6 @@
1
- // tar 7.5.19 on gives up once what it has inflated is over 1000 times what
2
- // it has read, checked at each piece of output, so where depends on how the
3
- // bytes arrive: a tarball is refused if any prefix inflates 900 times. Such
4
- // a prefix is no longer than 1/900 of what all of it, or any longer prefix,
5
- // inflates to: a bound that shrinks each time it is taken again.
1
+ // tar 7.5.19 on gives up once it has inflated over 1000 times what it has read, at each piece of output,
2
+ // so where depends on how the bytes come: refused where any prefix inflates 900 times. Such a prefix is
3
+ // no longer than 1/900 of what any longer one inflates to, a bound that shrinks each time it is taken.
6
4
 
7
5
  import { decompress } from '@preventive/archive/compression.js'
8
6
  import { DeptreeError } from '../error.js'
@@ -1,8 +1,6 @@
1
- // The project's .npmrc. npm hands the install its settings as ini reads
2
- // them, before validating them (`bin-links=0` links bins, "0" being
3
- // truthy), so one that can change the tree is read only in a form with one
4
- // reading. The rest only change where and how npm fetches, which the
5
- // lockfile's integrities make moot, or what it prints.
1
+ // The project's .npmrc. npm hands the install each setting as ini reads it, unvalidated (`bin-links=0`
2
+ // links bins, "0" being truthy), so one that can change the tree is read only in a form with one reading;
3
+ // the rest change where and how npm fetches, which the integrities make moot, or what it prints.
6
4
 
7
5
  import { DeptreeError, quote } from '../error.js'
8
6
  import { parseNpmrc } from '../npmrc.js'
package/src/npm/tree.js CHANGED
@@ -1,9 +1,6 @@
1
- // The tree `npm ci --ignore-scripts` makes, but node_modules/.bin and npm's
2
- // node_modules/.package-lock.json. With `sizeEstimateOnly`, its directories
3
- // and links alone, each package's sized by its version document, of which
4
- // nothing is fetched but those documents. With `lazy`, its directories and
5
- // links alone too, fetching nothing, and each package unpacked into it as
6
- // it is asked for (lazyUnpacker). With `production`, as --omit=dev leaves it.
1
+ // The tree `npm ci --ignore-scripts` makes, but node_modules/.bin and .package-lock.json, with `production`
2
+ // as --omit=dev leaves it. `sizeEstimateOnly` and `lazy` lay out its directories and links alone, the
3
+ // first sizing each package by its version document, the second unpacking each when asked.
7
4
 
8
5
  import { parseNpmLockfile } from '@preventive/lockfile/npm.js'
9
6
  import { Vfs } from '@preventive/vfs'
@@ -120,11 +117,9 @@ function writeTree({ lockfile, kept, fetched, changed, residue, sizeEstimateOnly
120
117
  return { vfs, stats }
121
118
  }
122
119
 
123
- // A lazy tree's unpack (../lazy.js): each tarball fetched once for all the
124
- // packages it is, a few at a time, and held to what the full tree holds it
125
- // to; each package written as the full tree writes it, with the bins it
126
- // links fixed, which the lockfile alone tells. A tarball's files are let go
127
- // once each of its packages is unpacked.
120
+ // A lazy tree's unpack (../lazy.js): each tarball fetched once for its packages, a few at a time, held to
121
+ // what the full tree holds it to, and let go once each is written as the full tree writes it, with the
122
+ // bins it links fixed, which the lockfile alone tells
128
123
  function lazyUnpacker({ vfs, kept, tarballOf, settings, host, fetching, stats, folded, entryOf }) {
129
124
  const limit = limited()
130
125
  const claimed = settings.binLinks ? claimedBins(kept) : new Map()
@@ -1,7 +1,6 @@
1
- // What changes the tree between the npm releases supported. `reuse` is npm
2
- // 10's ci, building on the tree it loaded the lockfile into: lockfile flags
3
- // as written, optional packages left out after their directories are made,
4
- // an unmet optional peer resolved again, a workspace's prepare script run.
1
+ // What changes the tree between the npm releases supported. `reuse` is npm 10's ci on the tree it loaded
2
+ // the lockfile into: flags as written, optional packages left out after their directories are made, an
3
+ // unmet optional peer resolved again, a workspace's prepare script run.
5
4
 
6
5
  import { DeptreeError, quote } from '../error.js'
7
6
 
package/src/npmrc.js CHANGED
@@ -1,7 +1,5 @@
1
- // An .npmrc as the `ini` package reads it for npm and pnpm, as far as a key
2
- // and the text after its `=` go; each settings.js refuses a value ini would
3
- // unquote, unescape, cut at a `;` or `#`, or fill in from the environment. A
4
- // section, which npm reads under a prefix no setting here has, is refused.
1
+ // An .npmrc as `ini` reads it for npm and pnpm, as far as a key and the text after its `=`; each
2
+ // settings.js refuses a value ini would unquote, unescape, cut or fill from the environment
5
3
 
6
4
  import { DeptreeError } from './error.js'
7
5
 
package/src/patch.js CHANGED
@@ -1,9 +1,6 @@
1
- // A patch as `pnpm patch-commit` writes one: a git diff of files changed,
2
- // created or deleted. A hunk applies where it says, its context and removed
3
- // lines the same byte for byte. pnpm (@pnpm/patch-package) would also look
4
- // up to twenty lines away and drop trailing whitespace, and puts a hunk that
5
- // inserts after a line with no context a line early; a patch that needs any
6
- // of that is refused, so one applied here leaves the file as pnpm would.
1
+ // A patch as `pnpm patch-commit` writes one, each hunk applied where it says, byte for byte. A patch that
2
+ // needs pnpm's fuzz (twenty lines away, trailing whitespace dropped, a context-free insert a line early)
3
+ // is refused, so one applied here leaves the file as pnpm would.
7
4
 
8
5
  import { utf8fromString } from '@exodus/bytes/utf8.js'
9
6
  import { applyChangeSet, parseDiff } from '@preventive/diff'
@@ -22,11 +19,8 @@ function pathOf(header) {
22
19
  return rest === `${path} b/${path}` ? path : undefined
23
20
  }
24
21
 
25
- // git quotes a path with a control character, and by default one with any
26
- // other non-ASCII one. Of what it may leave unquoted, a backslash, a
27
- // separator on Windows, and what reads otherwise than it is written (a line
28
- // or paragraph separator, a bidirectional control) are refused, as the
29
- // lockfile reader refuses them in a path.
22
+ // git quotes a path with a control or by default any non-ASCII character; of what it leaves unquoted,
23
+ // what the lockfile reader refuses in a path is refused too
30
24
  function checkPath(path, where) {
31
25
  if (path === undefined || path.startsWith('"') || UNSAFE.test(path) || !isInside(path)) {
32
26
  throw new DeptreeError('expected a header naming one relative path on both sides', where)
@@ -121,15 +115,15 @@ const parentsOf = (path) => path.split('/').slice(0, -1).map((_, index, names) =
121
115
 
122
116
  // `files` maps each path to `{ data, mode }` or `{ directory: true }`. A
123
117
  // deleted file leaves its directory, empty or not, as pnpm does; a created
124
- // one has `createdMode` where given, as pnpm 12 writes one plain.
125
- export function applyPatch(files, patch, { createdMode } = {}) {
118
+ // one has the mode the patch gives it.
119
+ export function applyPatch(files, patch) {
126
120
  const next = new Map(files)
127
121
  for (const file of patch) {
128
122
  const current = next.get(file.path)
129
123
  if (file.change === 'create') {
130
124
  const taken = current !== undefined || next.keys().some((path) => path.startsWith(`${file.path}/`)) || parentsOf(file.path).some((dir) => next.get(dir)?.data !== undefined)
131
125
  if (taken) throw new DeptreeError('creates a file that is there', file.where)
132
- next.set(file.path, { data: bytesOf(applyTo('', file), file.where), mode: createdMode ?? file.mode })
126
+ next.set(file.path, { data: bytesOf(applyTo('', file), file.where), mode: file.mode })
133
127
  continue
134
128
  }
135
129
  if (current?.data === undefined) throw new DeptreeError('changes a file that is not there', file.where)
package/src/pnpm/bins.js CHANGED
@@ -1,11 +1,6 @@
1
- // The files pnpm's bin linking fixes (@pnpm/link-bins, bin-links' fixBin):
2
- // no .bin is written, but the file of each command it links by a name is
3
- // made executable and a CRLF ending its `#!` line made LF. pnpm 10 sets
4
- // 0o755 and pnpm 11 adds 0o111, as pnpm 12 (its cmd-shim crate) does, which
5
- // rewrites no `#!` line.
6
- // Where any patch is configured, pnpm 10 and 11 build each package patched
7
- // or with an install script, which links its own bins beside its children's
8
- // before the patch; pnpm 12 links them together, with no build pass.
1
+ // What pnpm's bin linking (@pnpm/link-bins) does to the files, as no .bin is written: each a command links
2
+ // made executable (0o755 by pnpm 10, | 0o111 by 11 and 12), a CRLF `#!` made LF but by 12. With a patch
3
+ // configured, 10 and 11 build each package patched or with an install script, linking its bins before it.
9
4
 
10
5
  import { DeptreeError, quote } from '../error.js'
11
6
  import { crlfShebang, fixShebang } from '../tarball.js'
@@ -32,10 +27,8 @@ function peersOf(children, nodes) {
32
27
  export const requiresBuild = (manifest, files, major) => Boolean((manifest.scripts != null && (manifest.scripts.preinstall || manifest.scripts.install || manifest.scripts.postinstall))
33
28
  || (files.has('binding.gyp') && !(major >= 11 && manifest.gypfile === false)) || files.keys().some((path) => /^\.hooks[\\/]/u.test(path)))
34
29
 
35
- // `contested` holds the files that may be fixed or not, and why; `ordered`
36
- // is whether pnpm always comes to the commands in this order; `fixNode`
37
- // whether pnpm 12 links a project's bins again, which fixes a direct
38
- // dependency's `node` already linked.
30
+ // `contested` holds the files that may be fixed or not, and why; `ordered` is whether pnpm always comes
31
+ // to the commands in this order; `fixNode` whether pnpm 12 links again, fixing a direct `node`
39
32
  function linker(major) {
40
33
  const fixed = new Map()
41
34
  const contested = new Map()
@@ -164,11 +157,8 @@ export function binTargets({ nodes, projects, direct, links, publicHoist, buildi
164
157
  return fixedFiles(nodes, fixed, contested, major)
165
158
  }
166
159
 
167
- // The packages of `nodes` whose files binTargets reads, given the same
168
- // options, but those it reads for their own build alone, which the lockfile
169
- // says have no bins: building one whose children are all packages links
170
- // again what their first link did, and fixes nothing of theirs. The others
171
- // are read as having no bins (lazy.js).
160
+ // The packages whose files binTargets reads, but those it reads only for a build the lockfile says
161
+ // links nothing: building one whose children are all packages fixes nothing of theirs (lazy.js)
172
162
  export function binReads({ nodes, projects, direct, links, publicHoist, peers, major }) {
173
163
  const mayHaveBin = mayHaveBinIn(nodes)
174
164
  const reads = new Set()
@@ -191,13 +181,9 @@ export function binReads({ nodes, projects, direct, links, publicHoist, peers, m
191
181
  return new Set(reads.values().filter((dir) => nodes.has(dir)))
192
182
  }
193
183
 
194
- // The copies of one package pnpm's build pass makes hardlinks of the one it
195
- // builds (hoisted.js): what is fixed in that one before, as each copy's own
196
- // bins are where pnpm fills its node_modules, is in all; and so is what is
197
- // fixed in any after. Where the copies it may build differ in what is fixed
198
- // before, so may the outcome. A phase's marks are `before` that, or not, or
199
- // a function of the package's build saying which. pnpm 11 links no file
200
- // under a node_modules (`keepsModules`), which each copy keeps its own of.
184
+ // pnpm's build pass hardlinks one built copy into the others (hoisted.js), so what is fixed in any copy
185
+ // is in all, and where the copies it may build differ in what is fixed before, so may the outcome. A
186
+ // phase's marks are `before` or not, or say per build; from 11.25 files under a node_modules stay apart.
201
187
  function linkCopies(builds, phases, fixed, contested, { keepsModules, major }) {
202
188
  const ownerOf = new Map()
203
189
  for (const build of builds) {
@@ -238,13 +224,8 @@ function linkCopies(builds, phases, fixed, contested, { keepsModules, major }) {
238
224
  }
239
225
  }
240
226
 
241
- // The packages of `nodes` whose files hoistedBinTargets reads, with
242
- // hoistedBuilds where any patch is configured (`building`), but those it
243
- // reads as pnpm's hoisted linker reads each package in a node_modules it
244
- // fills, which the lockfile says have no bins, and those it reads for their
245
- // own build alone: building one none of whose dependencies have bins, as
246
- // `packages`, the lockfile's, say, links nothing of the others'. The others
247
- // are read as having no bins, and as built where patched alone (lazy.js).
227
+ // The packages whose files hoistedBinTargets reads, but those the lockfile says have no bins and whose
228
+ // build, where any patch is configured (`building`), links none of their dependencies' (lazy.js)
248
229
  export function hoistedBinReads({ nodes, building, packages }) {
249
230
  const reads = new Set()
250
231
  for (const node of nodes.values()) {
@@ -255,13 +236,9 @@ export function hoistedBinReads({ nodes, building, packages }) {
255
236
  return reads
256
237
  }
257
238
 
258
- // pnpm's hoisted linker links the bins of each node_modules it fills, by
259
- // what it reads there, as it fills it; then each project's again, with its
260
- // links in, a command of its own dependencies over any other. `modules` are
261
- // those node_modules, each with its packages by alias, and its project's
262
- // package.json where it is a project's. Between the two, where any patch is
263
- // configured, each package of `builds` links its dependencies' bins and its
264
- // own (hoisted.js), as the isolated linker's build does.
239
+ // pnpm's hoisted linker links each node_modules' bins as it fills it, then each project's again, its own
240
+ // dependencies first; between, where a patch is configured, each of `builds` links its dependencies' and
241
+ // its own. `modules` are those node_modules, with their packages by alias and a project's package.json.
265
242
  export function hoistedBinTargets({ nodes, projects, modules, builds = [], hardlinks = true, keepsModules = false, idOf = (key) => key, major }) {
266
243
  const commandsOfDir = commandReader(nodes, projects, major)
267
244
  const filling = linker(major)
@@ -274,10 +251,7 @@ export function hoistedBinTargets({ nodes, projects, modules, builds = [], hardl
274
251
  }
275
252
  projectsAgain.link(preferOwn(entries, manifest, commandsOfDir), { ordered: false, where })
276
253
  }
277
- // A package's dependencies are built first, but for those it is built
278
- // before or after as they depend on each other.
279
- // What each snapshot reaches through the copies' dependencies, each taken
280
- // for the copies of its id.
254
+ // A package's dependencies are built first, but where they depend on each other
281
255
  const pkgs = new Map(nodes.values().map((node) => [idOf(node.key), node.pkg]))
282
256
  const edges = (id) => Object.values({ ...pkgs.get(id)?.dependencies, ...pkgs.get(id)?.optionalDependencies }).map(idOf)
283
257
  const building = builds.map((build) => {
@@ -1,7 +1,5 @@
1
- // The directory pnpm gives a snapshot under node_modules/.pnpm, as its
2
- // depPathToFilename (@pnpm/dependency-path) spells it: `a@1.0.0(b@2.0.0)` is
3
- // `a@1.0.0_b@2.0.0`, `@s/a@1.0.0` `@s+a@1.0.0`, and one too long or with a
4
- // capital is cut short and hashed.
1
+ // A snapshot's directory under node_modules/.pnpm, as @pnpm/dependency-path's depPathToFilename spells
2
+ // it: `a@1.0.0(b@2.0.0)` is `a@1.0.0_b@2.0.0`, and one too long or with a capital is cut and hashed.
5
3
 
6
4
  import { quote } from '../error.js'
7
5
  import { sha256Hex } from '../hash.js'
@@ -1,7 +1,5 @@
1
- // A gitignore line as pnpm 12 reads one, by the ignore crate (0.4.32) and
2
- // its glob by globset (0.4.18): matched against a path's UTF-8 bytes, case
3
- // and all, from the directory of the file it is in. Only `*`, `?` and `**`
4
- // are followed of glob syntax, as in minimatch.js.
1
+ // A gitignore line as pnpm 12 reads it, by the ignore crate 0.4.32 and globset 0.4.18: matched against a
2
+ // path's UTF-8 bytes, case and all, from its file's directory; only `*`, `?` and `**` are followed
5
3
 
6
4
  import { utf8fromStringLoose } from '@exodus/bytes/utf8.js'
7
5
  import { checkGlob, checkLength } from './minimatch.js'
package/src/pnpm/glob.js CHANGED
@@ -1,8 +1,6 @@
1
- // glob 8 as npm-packlist 5 globs a `files` pattern for pnpm 10: dot
2
- // and nocase, a leading `!` or `#` taken as it is. Each path found is spelled
3
- // as glob spells it, a directory's with the trailing slash a pattern gave
4
- // it, and a file named by a pattern with no part to match against names
5
- // found alone where it is there.
1
+ // glob 8 as npm-packlist 5 globs `files` for pnpm 10: dot and nocase, a leading `!` or `#` as it is. A path is
2
+ // spelled as glob spells it, a directory's with the slash a pattern gave it; a pattern with nothing to match
3
+ // names a file alone, where it is there.
6
4
 
7
5
  import { GLOBSTAR, OBJECT_5, checkGlob, checkLength, checkParts, readPart } from './minimatch.js'
8
6
 
package/src/pnpm/hoist.js CHANGED
@@ -1,16 +1,13 @@
1
- // Hoisting as @pnpm/hoist does it: an alias a pattern matches is linked in
2
- // node_modules (public) or node_modules/.pnpm/node_modules (private), and the
3
- // first to take it keeps it, in pnpm's order: the projects' direct
4
- // dependencies, then the graph by depth, then by directory.
1
+ // @pnpm/hoist: an alias a pattern matches is linked in node_modules (public) or .pnpm/node_modules (private),
2
+ // the first to take it keeping it, in pnpm's order: the projects' direct dependencies, then the graph by
3
+ // depth, then by directory
5
4
 
6
5
  import { compareNames } from '@preventive/vfs/path.js'
7
6
  import { DeptreeError, quote } from '../error.js'
8
7
  import { createMatcher } from '../matcher.js'
9
8
 
10
- // pnpm's graphWalker: each node's children are walked to the bottom before the
11
- // next node's, so a node's depth is not always its least. A level's nodes are
12
- // listed, and all their children stepped to, before the first child's are;
13
- // on a stack of its own, where pnpm recurses, so a long chain runs out of none.
9
+ // pnpm's graphWalker on a stack: a level's nodes are listed, and all their children stepped to, before the
10
+ // first child's are, so a node's depth is not always its least
14
11
  function walk(nodes, starts) {
15
12
  const visited = new Set()
16
13
  const step = (dirs) => {
@@ -74,14 +71,9 @@ function hoistGraph(nodes, starts, taken, typeOf, { projects = new Map(), instal
74
71
  return links
75
72
  }
76
73
 
77
- // `projects` are the named projects by directory, which hoistWorkspacePackages
78
- // hoists by name too. pnpm 10 lists their names first among the root's aliases,
79
- // a direct dependency of the same name replacing one; a hoisted project takes
80
- // no name, and wins over a package hoisted to its place, as pnpm replaces a
81
- // link into the store with it but not its own with one. pnpm 10 takes the
82
- // root's aliases as spelled; pnpm 11 folds them too, and hoists a project
83
- // unless a project's direct dependency in the graph has its name. pnpm 12 walks
84
- // `hoisting`, through the skipped snapshots though it hoists none of them.
74
+ // `projects`, by directory, are hoisted by name too. pnpm 10 lists them first among the root's aliases, as
75
+ // spelled, a project winning over a package hoisted to its place; pnpm 11 folds case and skips one a project's
76
+ // direct dependency is named as; pnpm 12 walks `hoisting`, through the skipped snapshots, hoisting none.
85
77
  export function hoist(nodes, direct, { hoistPattern, publicHoistPattern }, projects = new Map(), major = 10, hoisting) {
86
78
  if (hoistPattern === undefined && publicHoistPattern === undefined) return new Map()
87
79
  const isPublic = createMatcher(publicHoistPattern ?? [])
@@ -1,11 +1,6 @@
1
- // Where the hoisted linker (nodeLinker: hoisted) of pnpm 10 and 11 puts
2
- // each package: @pnpm/real-hoist makes a tree of the lockfile, the root's
3
- // dependencies and each other project's under the root, which @yarnpkg/nm
4
- // hoists (nm-hoist.js; what pnpm 11 has of it, 4.0.7 to 4.1.1, differs
5
- // only with hoistingLimits, which is not supported); each package is then
6
- // copied to node_modules/<alias> under where it landed, and each project's
7
- // own lands in its node_modules. A project's `link:` dependencies are linked
8
- // there, as are none of a package's.
1
+ // pnpm 10 and 11's hoisted linker: real-hoist's tree of the lockfile, every project under the root, hoisted
2
+ // by @yarnpkg/nm (nm-hoist.js; pnpm 11's 4.0.7 to 4.1.1 differs only with hoistingLimits, not supported),
3
+ // each package copied to node_modules/<alias> where it lands; a project's `link:`s alone are linked
9
4
 
10
5
  import { packageKeyOf } from '@preventive/lockfile/pnpm.js'
11
6
  import { valid } from '@preventive/upstream/semver.js'
@@ -14,10 +9,8 @@ import { DeptreeError, quote } from '../error.js'
14
9
  import { createMatcher } from '../matcher.js'
15
10
  import { REGULAR, WORKSPACE, depthFirst, hoist, reachable } from './nm-hoist.js'
16
11
 
17
- // pnpm's name@version of a snapshot, by which it takes every snapshot of a
18
- // package for the first it comes to. A directory has no version in the
19
- // lockfile, so all of one name are one; from pnpm 11.24 (`directories`),
20
- // each snapshot of one is its own.
12
+ // pnpm's name@version of a snapshot, by which it takes every snapshot of a package for the first. A
13
+ // directory has no version, so all of one name are one; from pnpm 11.24 (`directories`) each is its own.
21
14
  export function packageIdOf(key, pkg, directories = false) {
22
15
  if (directories && pkg.resolution.type === 'directory') return key
23
16
  const base = packageKeyOf(key)
@@ -94,13 +87,9 @@ export function hoistedTree(lockfile, autoInstallPeers, bounds, { directories =
94
87
  return hoist(treeOf(lockfile, autoInstallPeers, { directories, rootLinks }), bounds)
95
88
  }
96
89
 
97
- // Each directory a package is copied to, from the lockfile's, in the order
98
- // pnpm makes them, a parent before what lands in its node_modules, with the
99
- // snapshot copied there, the node_modules it is in and its alias there; the
100
- // `link:`s of each project, by where they go; and the node_modules of the
101
- // projects pnpm fills, the root's first. `skipped` are the snapshots left
102
- // out, which are hoisted all the same. pnpm hoists from the importers the
103
- // lockfile has, not those made for projects it has none for.
90
+ // Each copy pnpm makes, a parent before what lands in its node_modules; each project's `link:`s by where
91
+ // they go; and the projects' node_modules, the root's first. pnpm hoists from the lockfile's importers,
92
+ // `skipped` snapshots too, and not those made for projects it has none for.
104
93
  export function hoistedLayout(lockfile, { autoInstallPeers, skipped, directories = false, rootLinks = false }, bounds) {
105
94
  const tree = hoistedTree(lockfile, autoInstallPeers, bounds, { directories, rootLinks })
106
95
  const placed = new Map()
@@ -130,10 +119,8 @@ export function hoistedLayout(lockfile, { autoInstallPeers, skipped, directories
130
119
  return { placed, links, projects }
131
120
  }
132
121
 
133
- // pnpm from 11.28 links each project named in `names` into the root's
134
- // node_modules by its name where a hoist pattern matches it, unless the root
135
- // depends on that name, or a package landed there by it, with their case
136
- // folded.
122
+ // From pnpm 11.28, each project in `names` linked into the root's node_modules by its name where a hoist
123
+ // pattern matches it, unless the root depends on that name or a package landed there by it, case folded
137
124
  export function workspaceHoists(placed, lockfile, { hoistPattern, publicHoistPattern }, names) {
138
125
  const isPublic = createMatcher(publicHoistPattern ?? [])
139
126
  const isPrivate = createMatcher(hoistPattern ?? [])
@@ -149,21 +136,9 @@ export function workspaceHoists(placed, lockfile, { hoistPattern, publicHoistPat
149
136
  return links
150
137
  }
151
138
 
152
- // What pnpm's build pass does where any patch is configured, which it runs
153
- // though scripts are ignored: it builds each package patched or with an
154
- // install script in one of its copies, the first it comes to of those a
155
- // project's node_modules reaches through each package's dependencies, each
156
- // at the first copy of its snapshot, or from pnpm 11.23 of its package
157
- // (`idOf`). Then it links the built copy's files into every other: from
158
- // 10.21 (`hardlinks`) it puts a copy of hardlinks in place of the copy, with
159
- // no node_modules, which drops the copy's own; before, in place, where a
160
- // file is not already, which leaves the others unpatched. From pnpm 11.25
161
- // (`keepsModules`) it links each file but those under a node_modules in
162
- // place of the copy's own, and leaves the copy's node_modules and what the
163
- // built one has not. Which copy it builds turns on its build order, which is
164
- // not followed here. `projects` are the node_modules of the projects;
165
- // `byDir` the copies, in the order pnpm makes them; `changesOf` the changes
166
- // of a patched one's patch; `pnpm` the version, for what is refused.
139
+ // pnpm's build pass where any patch is configured, scripts ignored or not: each package patched or with an
140
+ // install script built at the first reached copy (of its snapshot, or from 11.23 its package: `idOf`), its
141
+ // files then linked into the others as the refusals say. Which copy it builds turns on an order not followed.
167
142
  export function hoistedBuilds(byDir, projects, builds, { hardlinks, keepsModules = false, idOf = (key) => key, changesOf, pnpm = '10' }) {
168
143
  const first = new Map()
169
144
  for (const node of byDir.values()) if (!first.has(idOf(node.key))) first.set(idOf(node.key), node.dir)
@@ -199,12 +174,8 @@ export function hoistedBuilds(byDir, projects, builds, { hardlinks, keepsModules
199
174
  return built
200
175
  }
201
176
 
202
- // Where any patch is configured, from pnpm 10.21 to before 11.25, pnpm
203
- // builds one copy of each package patched or with an install script, which
204
- // only its tarball tells, and puts hardlinks of it in place of the others,
205
- // dropping their node_modules (hoistedBuilds): the packages of more than one
206
- // copy, one with a node_modules, which may lose it, by key, each with that
207
- // copy. `placed` are the copies, as hoistedLayout places them.
177
+ // The packages of several copies, by key, with the copy whose node_modules pnpm 10.21 to before 11.25 may
178
+ // drop where any patch is configured: it puts hardlinks of one built copy in place of the others
208
179
  export function mayDrop(placed) {
209
180
  const placedIn = new Set(placed.values().map((node) => node.modules))
210
181
  const dropping = new Map()
package/src/pnpm/hook.js CHANGED
@@ -1,7 +1,5 @@
1
- // pnpm's read-package hook (@pnpm/hooks.read-package-hook), less a pnpmfile's
2
- // readPackage, refused elsewhere, and Yarn's compatibility database, not
3
- // reproduced. pnpm runs it on every package and on each project's
4
- // package.json before holding it to its importer.
1
+ // pnpm's read-package hook, less a pnpmfile's readPackage (refused elsewhere) and Yarn's compatibility
2
+ // database: run on every package, and on each project's package.json before it is held to its importer
5
3
 
6
4
  import { intersects, satisfies, validRange } from '@preventive/upstream/semver.js'
7
5
  import { relative } from '@preventive/vfs/path.js'
@@ -1,8 +1,5 @@
1
- // Which snapshots a frozen install leaves out. pnpm 10 walks depth first
2
- // (@pnpm/lockfile.filtering's pkgAllDeps) and leave out an optional one the
3
- // host cannot run or first reached through one not installed: the first
4
- // reach decides. Projects go in lockfile order, pnpm's being the order it
5
- // finds them on disk, which only a snapshot reached both ways can tell.
1
+ // Which snapshots a frozen install leaves out. pnpm 10 walks depth first (@pnpm/lockfile.filtering),
2
+ // the first reach deciding, the projects in lockfile order; pnpm 11 breadth first by edge kind.
6
3
 
7
4
  import { satisfies, validRange } from '@preventive/upstream/semver.js'
8
5
  import { DeptreeError, quote } from '../error.js'
@@ -105,10 +102,9 @@ export function checkProject(manifest, where, { host, settings, root }) {
105
102
  if (settings.engineStrict && !takesEngine(engines, node)) throw new DeptreeError(`its engines.node, ${quote(String(engines.node))}, does not take Node ${node}, which engineStrict refuses`, where)
106
103
  }
107
104
 
108
- // True where the host can run a snapshot, false where it is optional and
109
- // cannot, null where it cannot but is installed anyway. pnpm 11 and 12 take
110
- // `optional` from the edge. A patched one's engines are checked later
111
- // (patchedLater), save its published ones by pnpm 12 `walking` the lockfile.
105
+ // True where the host can run a snapshot, false where it is optional and cannot, null where it is
106
+ // installed anyway. pnpm 11 and 12 take `optional` from the edge; a patched one's engines are checked
107
+ // later (patchedLater), but for its published ones when pnpm 12 is `walking` the lockfile.
112
108
  function createCheck(context) {
113
109
  const { host, settings } = context
114
110
  const node = nodeOf(context)
@@ -166,7 +162,6 @@ function projectKeys(lockfile, ids, walked) {
166
162
  return all
167
163
  }
168
164
 
169
- // Each key by `check`: false adds it to `skipped`, null to `incompatible`.
170
165
  function checkEach(keys, check, skipped = new Set()) {
171
166
  const incompatible = new Set()
172
167
  for (const key of keys) {