@preventive/deptree 1.5.2 → 1.5.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.
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 +13 -14
  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
@@ -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) {
package/src/pnpm/lazy.js CHANGED
@@ -12,15 +12,9 @@ import { binsOf } from './commands.js'
12
12
  import { checkFetched, fetchPackage } from './package.js'
13
13
  import { compose, writeNode } from './write.js'
14
14
 
15
- // Whether what is done to a package's files turns on other packages', once
16
- // fetched: with the hoisted linker where any patch is configured, pnpm's
17
- // build pass builds it (`builds`), patched or with an install script, which
18
- // turns on its other copies and what else is built; or which of its bins pnpm
19
- // links could change them, one linked being fixed otherwise than it is, made
20
- // executable or its CRLF `#!` line made LF; or pnpm 12 fails on one that
21
- // is a directory; or the package is patched, which is held to its bins as
22
- // linked; or its commands cannot be read alone. Else its files are as fetched
23
- // and patched, whatever pnpm links of its bins, and of anything else's.
15
+ // Whether its files turn on others' once fetched: pnpm's build pass builds it (`builds`); a bin it links could
16
+ // be fixed otherwise, made executable or its CRLF `#!` made LF; pnpm 12 fails on a bin that is a directory; it
17
+ // is patched, held to its bins as linked; or its commands cannot be read alone.
24
18
  function bound(node, major, builds) {
25
19
  if (builds?.(node)) return true
26
20
  let bins
@@ -53,20 +47,9 @@ function filesIn(vfs, dir, dirs) {
53
47
  return files
54
48
  }
55
49
 
56
- // Each registry package fetched once for all its snapshots, a few at a time,
57
- // and held to what the full tree holds it to; each snapshot written as the
58
- // full tree writes it, `patched` and `composing` being what compose takes, and
59
- // listed by `entryOf`. What linking bins fixes of it turns on the other
60
- // packages' bins only where a package is bound (above): the first such
61
- // unpack fetches those of `reads()` not unpacked yet, every package where it
62
- // is not given, and reads the fixes by `fixes`, as the full tree does, one
63
- // unpacked before read back from the tree, where it is as it came, and one
64
- // not at hand read as having no bins, as the lockfile says. One read so that
65
- // is bound once unpacked has the fixes read again, with its own files. A
66
- // package's files are let go once it is unpacked, and its tarball once each
67
- // of its snapshots is, but a patched one's, and every one's once the fixes
68
- // are read. `early.nodes` are fetched before anything is unpacked, and held
69
- // to `early.check()`.
50
+ // Each registry package fetched once for all its snapshots, a few at a time, each snapshot written as the full
51
+ // tree writes it. Only a `bound` one waits on the others' bins: the first fetches those `reads()` names, or all,
52
+ // and reads the fixes by `fixes`, a package not at hand read as binless. `early.nodes` are fetched first.
70
53
  export async function lazyUnpacker({ vfs, byDir, stats, fixes, reads, builds, early, checks, patched, composing, entryOf, fetching, folded }) {
71
54
  const { major } = composing
72
55
  const limit = limited()
@@ -120,9 +103,11 @@ export async function lazyUnpacker({ vfs, byDir, stats, fixes, reads, builds, ea
120
103
  await eachConcurrently([...byDir.values()].filter((other) => read?.has(other.dir) ?? true), prepare, (other) => quote(other.key))
121
104
  return readFixes()
122
105
  })()
106
+ // One read as binless before it was at hand has the fixes read again, with its own files
123
107
  if ((await made).stubbed.has(node.dir)) made = Promise.try(readFixes)
124
108
  return made
125
109
  }
110
+ // A tarball is let go once each of its snapshots is written, and the files until the fixes are read
126
111
  const release = (node) => {
127
112
  const id = packageKeyOf(node.key)
128
113
  left.set(id, left.get(id) - 1)
package/src/pnpm/local.js CHANGED
@@ -46,10 +46,8 @@ export function readDirectoryPackage(project, pkg, where, host) {
46
46
  // which no other resolver takes, and links to a directory of that name.
47
47
  const ALIASED = /(?:^|\/)(npm:(@[^/]+\/[^/]+)@(workspace:[^/]*))$/u
48
48
 
49
- // pnpm links to a directory that is not there all the same: pnpm 10 and 11
50
- // warn as they resolve, and none does as a frozen install. Refused, with the
51
- // project given or, for the spec it takes for a path, without, but where the
52
- // project holds a directory of that name.
49
+ // pnpm links to a directory that is not there all the same, warning at most as it resolves: refused, from the
50
+ // project given, or without it for the spec pnpm takes for a path, unless the project holds that directory
53
51
  export function readLinked(links, nodes, projects, project) {
54
52
  const linked = new Map()
55
53
  for (const [path, target] of links) {
@@ -1,9 +1,6 @@
1
- // minimatch as npm-packlist runs it, with matchBase, dot, flipNegate and
2
- // nocase, of patterns whose only glob syntax is `*`, `?` and `**`: 5.1.6 for
3
- // pnpm 10 before 10.31, 5.1.9 from 10.31, which matches
4
- // `**` by other steps, and 10.2 for pnpm 11. Its regexps have no `u`, as
5
- // minimatch's have none: they take UTF-16 code units, and fold case as such
6
- // a regexp folds it.
1
+ // minimatch as npm-packlist runs it (matchBase, dot, flipNegate, nocase) on `*`, `?` and `**` alone: 5.1.6
2
+ // for pnpm 10 before 10.31, 5.1.9 from 10.31, which matches `**` by other steps, and 10.2 for pnpm 11. No `u`
3
+ // on its regexps, as on minimatch's: they take UTF-16 code units, and fold case as such regexps fold it.
7
4
 
8
5
  import { DeptreeError, quote } from '../error.js'
9
6
 
@@ -69,11 +66,9 @@ const ANY = -2
69
66
  const SLASH = 0x2F
70
67
  const LINE_TERMINATORS = new Set([0x0A, 0x0D, 0x2028, 0x2029])
71
68
 
72
- // A part as minimatch's regexp of it matches a name, in time linear in
73
- // both: `*` any run of code units but `/`, `?` any one, each other one
74
- // itself without case. `lookahead` is minimatch 5's `(?=.)`, which takes no
75
- // name that is empty or starts with a line terminator; `traversal` its
76
- // lookahead that takes no `.` or `..`.
69
+ // A part as minimatch's regexp matches a name, in time linear in both: `*` any run but `/`, `?` any one unit,
70
+ // the rest caseless. `lookahead` is minimatch 5's `(?=.)`, which takes no empty name nor one opening with a
71
+ // line terminator; `traversal` takes no `.` or `..`.
77
72
  function partOf(text, { lookahead = false, traversal = false, empty = true } = {}) {
78
73
  const units = Array.from({ length: text.length }, (_, i) => {
79
74
  const unit = unitAt(text, i)
@@ -217,10 +212,8 @@ function matchNew(file, pattern, partial) {
217
212
  return Boolean(matchSections(file, { sections, after, partial, sawTail: tailMatch > 0, memo: new Map() }, fileIndex, 0))
218
213
  }
219
214
 
220
- // Whether the sections from `index` match from `fileIndex`: minimatch's
221
- // answer, false, null where no later start can do, or true; each pair
222
- // reckoned once here. minimatch gives up past 200 sections, which more
223
- // than 100 `**` are refused before reaching.
215
+ // Whether the sections from `index` match from `fileIndex`: false, null where no later start can, or true,
216
+ // each pair reckoned once. minimatch gives up past 200 sections, and more than 100 `**` are refused first.
224
217
  function matchSections(file, walk, fileIndex, index) {
225
218
  const { sections, after, partial, sawTail, memo } = walk
226
219
  if (index === sections.length) {
@@ -1,10 +1,6 @@
1
- // The hoist of @yarnpkg/nm 4.0.5, which pnpm 10 bundles for the hoisted
2
- // linker: each package is moved as near the root as it can go without
3
- // shadowing a different one of its name for a package that needs that one.
4
- // Step for step as it runs, with its recursions on stacks of their own, and
5
- // its debug output and checks left out, which change nothing. pnpm sets no
6
- // hoisting limits, hoist priorities or external soft links, which are left
7
- // out too: the root alone is a hoist border, and nothing depends on it.
1
+ // @yarnpkg/nm 4.0.5's hoist, which pnpm 10 bundles: each package moved as near the root as it goes without
2
+ // shadowing another of its name that a package needs. Step for step, recursions on stacks, debug output and
3
+ // checks left out; pnpm sets no limits, priorities or external links, so only the root is a border.
8
4
 
9
5
  import { DeptreeError } from '../error.js'
10
6
  import { REGULAR, WORKSPACE, buildPreferenceMap, depthFirst, getHoistIdentMap, getUsedDependencies, getZeroRoundUsedDependencies, hoistGraph, regularDependencies, walk } from './nm-hoist-graph.js'
@@ -18,10 +14,8 @@ const makeIdent = (name, reference) => {
18
14
  }
19
15
  const getIdentName = (locator) => locator.slice(0, locator.indexOf('@', 1))
20
16
 
21
- // The steps hoisting may take, and the nodes of the tree it gives, past
22
- // which it is refused: on a graph made to defeat it, the hoist walks each
23
- // path through what it cannot hoist, and the tree has a copy of a package
24
- // for each, of which there can be more than there is time or memory for.
17
+ // Refused past these: on a graph made to defeat it, the hoist walks every path through what it cannot hoist,
18
+ // and the tree holds a copy of a package for each
25
19
  const MAX_STEPS = 50_000_000
26
20
  const MAX_NODES = 100_000
27
21
 
@@ -1,9 +1,6 @@
1
- // The walks of npm-packlist over ignore-walk that pnpm 10 (npm-packlist
2
- // 5.1.3, ignore-walk 5) and pnpm 11 (npm-packlist 10.0.4, ignore-walk 8)
3
- // run over a directory, kept to their steps, odd ones and all: a walker of a
4
- // directory asks its parent of each entry by a path from there, and reads
5
- // the ignore files among its entries, in the order ignoreFiles lists them.
6
- // `view` reads the directory, and refuses what is not followed here.
1
+ // npm-packlist's walks over ignore-walk, kept to their steps, odd ones and all: 5.1.3 over ignore-walk 5 for
2
+ // pnpm 10, 10.0.4 over 8 for pnpm 11. A walker asks its parent of each entry by a path from there, and reads
3
+ // the ignore files among its entries in ignoreFiles' order; `view` refuses what is not followed here.
7
4
 
8
5
  import { basename, dirname, join, normalize } from '@preventive/vfs/path.js'
9
6
  import { quote } from '../error.js'
@@ -1,7 +1,5 @@
1
- // Overrides as pnpm's parseOverrides reads them. A frozen install holds them
2
- // only to the lockfile's `overrides`, which they were resolved with. pnpm 11
3
- // reads `name@` and an exact version as converging: a dependency on `name`
4
- // whose range takes that version is given it where no override is chosen.
1
+ // Overrides as pnpm's parseOverrides reads them, held by a frozen install only to the lockfile's. pnpm 11 reads
2
+ // `name@` and an exact version as converging: a dependency whose range takes it gets it, where none is chosen.
5
3
 
6
4
  import { valid } from '@preventive/upstream/semver.js'
7
5
  import { join } from '@preventive/vfs/path.js'
@@ -1,7 +1,5 @@
1
- // A registry package as pnpm installs it: its tarball read as @pnpm/store.cafs
2
- // reads it, and held to what npm packs, more than pnpm holds it to. A
3
- // dependency the lockfile left out of a snapshot would leave the package to
4
- // find it wherever it is hoisted, if anywhere.
1
+ // A registry package as pnpm installs it, its tarball read as @pnpm/store.cafs reads it and held to what npm
2
+ // packs, more than pnpm holds it to: a dependency the lockfile left out would be found wherever it is hoisted
5
3
 
6
4
  import { packageKeyOf } from '@preventive/lockfile/pnpm.js'
7
5
  import { compareVersions } from '@preventive/upstream/semver.js'
@@ -19,10 +17,8 @@ function nameOf(stored) {
19
17
  return name.replaceAll('//', '/')
20
18
  }
21
19
 
22
- // pnpm 10 and 11 drop a name's first segment at a `\` as at a `/` where the
23
- // ustar header holds the name, and pnpm 10 and 11, where a name has a `.\`,
24
- // turn each `\` into a `/` before normalizing it; pnpm 12 takes every `\` for
25
- // a separator, and fails on a `..` that makes.
20
+ // A `\` is refused: pnpm 10 and 11 drop a name's first segment at one as at a `/` and, in a name with a `.\`,
21
+ // turn each into a `/`; pnpm 12 takes every one for a separator, and fails on a `..` that makes
26
22
  function filesOf(entries, where) {
27
23
  const files = new Map()
28
24
  const tops = new Set()
@@ -43,6 +39,7 @@ function filesOf(entries, where) {
43
39
  }
44
40
 
45
41
  const decoder = new TextDecoder('utf-8', { fatal: true })
42
+ const isMapping = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
46
43
  const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
47
44
  const names = (value) => Object.keys(value ?? {})
48
45
 
@@ -51,8 +48,8 @@ const names = (value) => Object.keys(value ?? {})
51
48
  // linked as the lockfile has it.
52
49
  function hasBin({ bin, directories }, major) {
53
50
  if (major >= 12) {
54
- const named = typeof bin === 'string' ? bin !== '' : bin !== null && typeof bin === 'object' && !Array.isArray(bin) && Object.keys(bin).length > 0
55
- return named || (directories !== null && typeof directories === 'object' && !Array.isArray(directories) && typeof directories.bin === 'string' && directories.bin !== '')
51
+ const named = typeof bin === 'string' ? bin !== '' : isMapping(bin) && Object.keys(bin).length > 0
52
+ return named || (isMapping(directories) && typeof directories.bin === 'string' && directories.bin !== '')
56
53
  }
57
54
  if (bin == null) return Boolean(directories?.bin)
58
55
  if (bin && Object.keys(bin).length > 0) return true
@@ -68,17 +65,14 @@ function readManifest(files, pkg, where) {
68
65
  } catch {
69
66
  throw new DeptreeError('package.json is not JSON', where)
70
67
  }
71
- if (manifest === null || typeof manifest !== 'object' || Array.isArray(manifest)) throw new DeptreeError('package.json is not an object', where)
68
+ if (!isMapping(manifest)) throw new DeptreeError('package.json is not an object', where)
72
69
  checkNesting(manifest, `${where}: package.json`)
73
70
  if (manifest.name !== pkg.name || manifest.version !== pkg.version) throw new DeptreeError(`package.json is for ${quote(`${manifest.name}@${manifest.version}`)}`, where)
74
71
  return manifest
75
72
  }
76
73
 
77
- // npm's abbreviated metadata, which pnpm resolves from unless a setting such
78
- // as supportedArchitectures.libc has it ask for the full document, has no
79
- // libc, nor has the package.json pnpm 10 keeps in the store: a lockfile
80
- // may leave out a libc a registry package's package.json has. One it names is
81
- // held to it, as a directory's always is: pnpm reads that package.json whole.
74
+ // npm's abbreviated metadata, which pnpm resolves from unless a setting like supportedArchitectures.libc asks
75
+ // for the full document, has no libc, so a registry package's snapshot may lack one; one it names is held
82
76
  export function checkManifest(manifest, pkg, where, major, registry = false) {
83
77
  for (const field of ['os', 'cpu', 'libc']) {
84
78
  if (registry && field === 'libc' && pkg.libc === undefined) continue
@@ -1,10 +1,6 @@
1
- // The files pnpm's directory fetcher installs of a `file:` dependency, as its
2
- // packlist picks them: npm-packlist 5.1.3 for pnpm 10, 10.0.4 for pnpm
3
- // 11, and pnpm 12's own port of it, by package.json's `files`, `main` and
4
- // `bin`, the .npmignore and .gitignore files where they read them, and their
5
- // own rules. Of glob syntax only `*`, `?` and `**` are followed, which they
6
- // all read alike. Refused are a link the walk comes on, which they treat
7
- // differently, and a mode a checkout does not have under umask 022 or 002.
1
+ // The files pnpm's directory fetcher installs of a `file:` dependency: npm-packlist 5.1.3 for pnpm 10, 10.0.4
2
+ // for 11, pnpm 12's own port, of whose glob syntax only `*`, `?` and `**`, read alike, are followed. Refused:
3
+ // a link the walk meets, which they treat differently, and a mode no checkout has under umask 022 or 002.
8
4
 
9
5
  import { utf8toString } from '@exodus/bytes/utf8.js'
10
6
  import { compareVersions, valid } from '@preventive/upstream/semver.js'
@@ -1,7 +1,6 @@
1
- // pnpm 10 applies the patch patchedDependencies picks for a package's name and
2
- // version (@pnpm/patching.config's getPatchInfo), not the one its snapshot key
3
- // names, so every snapshot must name that pick's hash. Every patch must be some
4
- // snapshot's, which pnpm checks only when resolving.
1
+ // pnpm 10 applies the patch patchedDependencies picks for a package's name and version (getPatchInfo), not
2
+ // the one its snapshot key names, so every snapshot must name that pick's hash; and every patch must be some
3
+ // snapshot's, which pnpm checks only when resolving
5
4
 
6
5
  import { packageKeyOf } from '@preventive/lockfile/pnpm.js'
7
6
  import { isExactVersion, satisfies, valid, validRange } from '@preventive/upstream/semver.js'
@@ -1,22 +1,6 @@
1
- // What `pnpm install --prod` installs of a lockfile, as
2
- // @pnpm/lockfile.filtering's filterLockfileByImportersAndEngine filters it
3
- // with devDependencies left out: every project's devDependencies dropped, and
4
- // of the snapshots those the rest reach, through dependencies,
5
- // optionalDependencies and `link:`s, which lead only to projects, all of them
6
- // installed anyway.
7
- //
8
- // From pnpm 11.28 and 12.7.0 on (@pnpm/lockfile.peer-edges), an edge to an
9
- // optional peer that a snapshot has only as the projects that reach it list
10
- // the peer themselves is not walked, and is dropped from the snapshot where
11
- // nothing else reaches the peer: a devDependency only there to satisfy an
12
- // optional peer of a production one is left out. From 11.28.7 and 12.15.0,
13
- // only an edge to a peer the snapshot's key binds is such an edge, or any of
14
- // one whose key ends in a hash of its peers; before, any edge by the name of
15
- // an optional peer was, though the snapshot resolved it as its own.
16
- //
17
- // pnpm 12 before 12.7.0 walks such an edge too, as pnpm 11 before 11.28
18
- // does, which is pnpm's bug and not built for: a lockfile where walking the
19
- // edges 12.15.0 does not walk installs otherwise is refused.
1
+ // `pnpm install --prod`, as lockfile.filtering filters: devDependencies dropped, the snapshots the rest reach.
2
+ // From 11.28 and 12.7.0 an edge to an optional peer that only the projects reaching it list is not walked;
3
+ // from 11.28.7 and 12.15.0 only one the key binds. pnpm 12 before 12.7.0 walks it: refused where that tells.
20
4
 
21
5
  import { compareVersions } from '@preventive/upstream/semver.js'
22
6
  import { packageKeyOf } from '@preventive/lockfile/pnpm.js'
@@ -86,10 +70,9 @@ function optionalPeerEdges(packages, bound) {
86
70
 
87
71
  const directOf = ({ dependencies, devDependencies, optionalDependencies }) => edgesOf({ ...dependencies, ...devDependencies, ...optionalDependencies })
88
72
 
89
- // pnpm's collectPeerSatisfactionEdges: by each edge's target, the projects
90
- // that do not list it among their own (none, where it is the root's
91
- // devDependency and resolvePeersFromWorkspaceRoot is set); an edge is one to
92
- // skip where nothing those projects list reaches its snapshot.
73
+ // pnpm's collectPeerSatisfactionEdges: by target, the projects that do not list it (none, where it is the
74
+ // root's devDependency under resolvePeersFromWorkspaceRoot); an edge is skipped where nothing they list
75
+ // reaches its snapshot
93
76
  function satisfactionEdges(lockfile, rule, fromRoot) {
94
77
  const entries = optionalPeerEdges(lockfile.packages, rule.bound)
95
78
  const edges = new Map()
@@ -134,11 +117,9 @@ function refusalOf(edges, all, fixed, packages) {
134
117
  return new DeptreeError(`pnpm 12 before 12.7.0 walks its edge to its optional peer ${quote(edge.alias)}, which pnpm 12.7.0 on does not, and installs otherwise with devDependencies left out, which is not supported`, `snapshots[${quote(edge.parent)}]`)
135
118
  }
136
119
 
137
- // `installing`, the lockfile the tree is laid out from: the snapshots
138
- // reached, each but for the edges pnpm does not walk to a snapshot not
139
- // reached; and what `skippedOf` makes of what pnpm walks to leave out what
140
- // the host cannot run: every snapshot, but for those edges. Each importer's
141
- // devDependencies are empty.
120
+ // `installing` is the snapshots reached, each less its unwalked edges to snapshots not reached; `skippedOf`
121
+ // is given every snapshot less those edges, to leave out what the host cannot run. No importer keeps its
122
+ // devDependencies.
142
123
  export function productionLockfile(lockfile, { pnpm, major, resolvePeersFromWorkspaceRoot }, skippedOf) {
143
124
  const importers = Object.fromEntries(Object.entries(lockfile.importers).map(([id, importer]) => [id, { ...importer, devDependencies: {} }]))
144
125
  const starts = Object.values(importers).flatMap(prodEdgesOf)
@@ -1,9 +1,5 @@
1
- // Each project's package.json, read through its read-package hook (hook.js),
2
- // held to its importer as a frozen install holds it
3
- // (@pnpm/lockfile.verification's satisfiesPackageManifest). Every importer
4
- // has to be a project, or pnpm would leave it out. The check pnpm 10 makes
5
- // only when not frozen, that workspace packages are linked exactly where
6
- // their version is in range, is not made.
1
+ // Each project's package.json, through its read-package hook, held to its importer as a frozen install
2
+ // holds it (@pnpm/lockfile.verification). Every importer has to be a project, or pnpm would leave it out.
7
3
 
8
4
  import { isExactVersion, satisfies, valid, validRange } from '@preventive/upstream/semver.js'
9
5
  import { DeptreeError, difference, quote } from '../error.js'
@@ -1,7 +1,5 @@
1
- // Each setting pnpm reads, by its pnpm-workspace.yaml name, is either read
2
- // and checked (READ, READ_11, READ_12) or passed over as leaving
3
- // the tree as it is (IGNORED, IGNORED_11, IGNORED_12); any other is
4
- // refused.
1
+ // Each setting pnpm reads, by its pnpm-workspace.yaml name, is read and checked (READ, READ_11, READ_12)
2
+ // or passed over as leaving the tree as it is (IGNORED, IGNORED_11, IGNORED_12); any other is refused.
5
3
 
6
4
  import { valid } from '@preventive/upstream/semver.js'
7
5
  import { DeptreeError, quote } from '../error.js'
@@ -1,8 +1,5 @@
1
- // The settings an install reads. pnpm 10 reads the .npmrc beside the
2
- // lockfile, pnpm-workspace.yaml and the root package.json's `pnpm` field,
3
- // each over the one before; pnpm 11 and 12 read pnpm-workspace.yaml alone.
4
- // Settings from anywhere else (a user or global .npmrc, `npm_config_*`, the
5
- // command line) are taken to be at their defaults.
1
+ // The settings an install reads: pnpm 10 the .npmrc, pnpm-workspace.yaml and the package.json's `pnpm`,
2
+ // each over the one before; pnpm 11 and 12 pnpm-workspace.yaml alone. Any others are at their defaults.
6
3
 
7
4
  import { valid, validRange } from '@preventive/upstream/semver.js'
8
5
  import { DeptreeError, quote } from '../error.js'
package/src/pnpm/tree.js CHANGED
@@ -1,13 +1,6 @@
1
- // The node_modules tree pnpm 10, 11 or 12 installs from a frozen lockfile
2
- // with the isolated linker and --ignore-scripts, in a Vfs rooted at the
3
- // lockfile's directory; patched still, as pnpm patches before scripts. Bins are
4
- // not linked, though what linking does to their files is (bins.js). With
5
- // `sizeEstimateOnly`, its directories and links alone, each package's sized
6
- // by its version document, of which nothing is fetched but those documents.
7
- // With `lazy`, its directories and links alone too, fetching nothing, and
8
- // each package unpacked into it as it is asked for (lazy.js). With
9
- // `production`, as --prod installs it (production.js): laid out from the
10
- // lockfile it leaves, and held to the whole one.
1
+ // The node_modules tree pnpm 10, 11 or 12 installs from a frozen lockfile with --ignore-scripts, patched,
2
+ // as pnpm patches before scripts. With `sizeEstimateOnly` or `lazy` its directories and links alone, the
3
+ // one sized by version documents, the other unpacked as asked (lazy.js); `production` as --prod lays it out.
11
4
 
12
5
  import { packageKeyOf } from '@preventive/lockfile/pnpm.js'
13
6
  import { compareVersions } from '@preventive/upstream/semver.js'
@@ -77,11 +70,8 @@ function checkSource(node, installed) {
77
70
 
78
71
  const bytesOf = (files) => files.values().reduce((sum, file) => sum + file.data.length, 0)
79
72
 
80
- // By name@version, as the lockfile reader gives a package's snapshots one
81
- // resolution and manifest. With `sizeEstimateOnly`, a registry package's size
82
- // alone, with no files or package.json; with `lazy`, nothing of one, which is
83
- // fetched as it is unpacked. A directory is read whole all the same, and its
84
- // size is its files'.
73
+ // By name@version, which the lockfile reader gives one resolution and manifest. With `sizeEstimateOnly`
74
+ // a registry package's size alone, with `lazy` nothing of one; a directory is read whole either way.
85
75
  async function fetchAll(nodes, project, host, fetching) {
86
76
  const packages = new Map([...nodes.values()].map(({ key, pkg }) => [packageKeyOf(key), pkg]))
87
77
  const fetched = new Map()
@@ -100,9 +90,7 @@ async function fetchAll(nodes, project, host, fetching) {
100
90
  return fetched
101
91
  }
102
92
 
103
- // With `lazy`, a registry package's snapshots have no files yet, and are held
104
- // to them as each is unpacked; `checks` are what that takes, of the whole
105
- // lockfile.
93
+ // With `lazy`, a registry package's snapshots are held to its files as each is unpacked, by `checks`
106
94
  async function fetchNodes(nodes, checks, project, host, fetching) {
107
95
  const fetched = await fetchAll(nodes, project, host, fetching)
108
96
  const byDir = new Map()
@@ -114,10 +102,8 @@ async function fetchNodes(nodes, checks, project, host, fetching) {
114
102
  return { byDir, tarballs: [...fetched.values()].filter((got) => !got.local).length }
115
103
  }
116
104
 
117
- // pnpm hardlinks a directory package's files into each of its snapshots, so a
118
- // file fixBin makes executable in one is so in all (a CRLF `#!` it rewrites
119
- // stays that snapshot's own), but where pnpm builds the package or, with
120
- // pnpm 11 and 12, packageImportMethod is neither auto nor hardlink.
105
+ // pnpm hardlinks a directory package's files into each snapshot, so a file made executable in one is so
106
+ // in all (a CRLF `#!` rewritten stays its own), unless it builds it or, from 11, imports otherwise
121
107
  function executableElsewhere(byDir, targets, packageImportMethod, major) {
122
108
  if (major >= 11 && packageImportMethod !== 'auto' && packageImportMethod !== 'hardlink') return new Map()
123
109
  const shared = [...byDir.values()].filter((node) => node.pkg.resolution.type === 'directory' && !requiresBuild(node.manifest, node.files, major))
@@ -184,15 +170,9 @@ function linksOf(byDir, direct, settings, projects, major, hoisting) {
184
170
  // The import methods with which each copy of a package is its own.
185
171
  const COPYING = new Set(['copy', 'clone', 'clone-or-copy'])
186
172
 
187
- // The hoisted layout of pnpm 10 and 11 (hoisted.js): nothing but the packages
188
- // and links, each copy a parent before what lands in its node_modules, as
189
- // pnpm keeps only its state in node_modules/.pnpm. `fixes` are what linking
190
- // bins does to the files, with what pnpm's build pass does to them, read once
191
- // every package's files are at hand; with `sizeEstimateOnly` they are not
192
- // followed, nor with `lazy` but where a package unpacked needs them. `builds`
193
- // tells, where any patch is configured, what the build pass builds; `reads`
194
- // the packages the fixes read the files of (hoistedBinReads). `lockfile` is
195
- // the one the tree is laid out from, and `checks` hold it to the whole one.
173
+ // The hoisted layout of pnpm 10 and 11 (hoisted.js), each copy a parent before what lands in its
174
+ // node_modules. `fixes` are what linking bins and the build pass do to the files, read once every
175
+ // package's are at hand; `builds` what the build pass builds; `checks` hold the lockfile to the whole one.
196
176
  async function buildHoisted({ lockfile, checks, settings, host, project, installed, manifests, names, patched, skipped, fetching }) {
197
177
  const { major } = host
198
178
  const since = (version) => compareVersions(host.pnpm, version) >= 0
@@ -227,9 +207,8 @@ async function buildHoisted({ lockfile, checks, settings, host, project, install
227
207
  return { byDir, links, fixes, reads: () => hoistedBinReads({ nodes: byDir, building, packages: lockfile.packages }), builds, early, tarballs, dev }
228
208
  }
229
209
 
230
- // The isolated layout: each package in node_modules/.pnpm, linked from what
231
- // needs it and where it is hoisted; `fixes` as buildHoisted's, and `reads`
232
- // the packages they read the files of (binReads).
210
+ // The isolated layout: each package in node_modules/.pnpm, linked from what needs it and where it is
211
+ // hoisted; `reads` are the packages `fixes` read the files of (binReads)
233
212
  async function buildIsolated({ lockfile, checks, settings, host, project, installed, manifests, names, skipped, fetching }) {
234
213
  const { major } = host
235
214
  const { nodes, direct, hoisting } = await buildGraph(lockfile, skipped, settings.virtualStoreDirMaxLength, major)
@@ -309,9 +288,7 @@ export async function buildPnpmTree(options) {
309
288
  const stats = { projects: manifests.size, snapshots: Object.keys(lockfile.packages).length, installed: byDir.size, skipped: skipped.size, incompatible: incompatible.size, tarballs, patched: [...byDir.values()].filter((node) => node.pkg.patchHash !== undefined).length, files: 0, bytes: 0, links: links.size }
310
289
  const listed = []
311
290
  const composing = { major, checkPatched: createPatchedCheck({ host, settings }) }
312
- // Each node is let go once written, and a package's files with its last.
313
- // With `sizeEstimateOnly`, its directory alone is made, and its size
314
- // counted; with `lazy`, its directory alone, and the node is kept to unpack.
291
+ // Each node is let go once written, so a package's files go with its last; `lazy` keeps them to unpack
315
292
  for (const node of byDir.values()) {
316
293
  if (!fetching.lazy) byDir.delete(node.dir)
317
294
  try {
@@ -1,8 +1,5 @@
1
- // The directories pnpm takes for a workspace's projects: the root, and each
2
- // whose package.json a glob of pnpm-workspace.yaml's `packages` takes, as
3
- // @pnpm/fs.find-packages globs for them with tinyglobby, or
4
- // as pnpm 12 walks (wax). pnpm 11 matches `!` globs with micromatch, dotted
5
- // names and all.
1
+ // The directories pnpm takes for projects: the root, and each whose package.json a `packages` glob takes,
2
+ // as @pnpm/fs.find-packages globs with tinyglobby, or pnpm 12 walks; pnpm 11 matches `!` with micromatch.
6
3
 
7
4
  import { compareNames, normalize } from '@preventive/vfs/path.js'
8
5
  import { DeptreeError, quote } from '../error.js'
@@ -48,7 +45,7 @@ function enters({ names: glob, dot }, names) {
48
45
  // whether a glob with a `*` takes it (manifestOf).
49
46
  function compileAll(packages, major) {
50
47
  const twelve = major >= 12
51
- const [enters_, ignored_, dropped] = twelve ? [enters12, underLeftOut, underLeftOut] : [enters, ignored, () => false]
48
+ const [walks, skips, dropped] = twelve ? [enters12, underLeftOut, underLeftOut] : [enters, ignored, () => false]
52
49
  const include = []
53
50
  const exclude = []
54
51
  for (const glob of packages ?? []) {
@@ -57,7 +54,7 @@ function compileAll(packages, major) {
57
54
  ;(negative ? exclude : include).push({ ...compiled, wild: twelve && glob.includes('*') })
58
55
  }
59
56
  return {
60
- walked: (names) => include.some((glob) => enters_(glob, names)) && !ignored_(names),
57
+ walked: (names) => include.some((glob) => walks(glob, names)) && !skips(names),
61
58
  taken: takenBy(include, exclude, dropped),
62
59
  wild: (names) => include.some((glob) => glob.wild && takes(glob, names)),
63
60
  }
package/src/pnpm/write.js CHANGED
@@ -23,7 +23,7 @@ export function compose(node, patches, { targets, executable }, { major, checkPa
23
23
  if (patchHash !== undefined) {
24
24
  const patch = parsedPatch(patches, patchHash)
25
25
  patch.applied ??= new WeakMap()
26
- if (!patch.applied.has(files)) patch.applied.set(files, applyPatch(files, patch.parsed, { createdMode: major >= 12 ? 0o644 : undefined }))
26
+ if (!patch.applied.has(files)) patch.applied.set(files, applyPatch(files, patch.parsed))
27
27
  files = patch.applied.get(files)
28
28
  const manifest = checkPatchOfBins(node, files, targets, where, major)
29
29
  checkPatched?.(manifest, where)
@@ -1,12 +1,10 @@
1
- // The config Soldeer 0.12 reads: foundry.toml where it has a [dependencies]
2
- // table, else soldeer.toml where there is no foundry.toml.
1
+ // foundry.toml where it has a [dependencies] table, else soldeer.toml where there is no foundry.toml
3
2
 
4
3
  import { TomlError, isInlineTable, parseToml } from '@preventive/lockfile/toml.js'
5
4
  import { DeptreeError } from '../error.js'
6
5
 
7
6
  const isTable = (value) => typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === null
8
- // A table toml_edit gives as one, from a header or a dotted key, not inline:
9
- // Soldeer reads no dependencies from that, and fails on it for a profile.
7
+ // From a header or a dotted key, not inline, which Soldeer reads no dependencies from and fails on for a profile
10
8
  const isTableItem = (value) => isTable(value) && !isInlineTable(value)
11
9
 
12
10
  function parse(text, file) {
@@ -18,8 +16,7 @@ function parse(text, file) {
18
16
  }
19
17
  }
20
18
 
21
- // update_config_libs, which expects each of these to be what it adds where
22
- // it is not there, and panics on another.
19
+ // update_config_libs expects each to be what it adds where it is not there, and panics on another
23
20
  function checkLibs(doc) {
24
21
  const { profile } = doc
25
22
  if (profile === undefined) return
@@ -34,9 +31,8 @@ function checkLibs(doc) {
34
31
  const BOOLEANS = ['remappings_generate', 'remappings_regenerate', 'remappings_version', 'recursive_deps']
35
32
  const SETTINGS = new Set([...BOOLEANS, 'remappings_prefix', 'remappings_location'])
36
33
 
37
- // read_soldeer_config's SoldeerConfig, by serde, which passes over a field
38
- // it does not have; one is refused here, as a later Soldeer may install
39
- // otherwise by it.
34
+ // read_soldeer_config's SoldeerConfig; serde passes over a field it does not have, which is refused here,
35
+ // as a later Soldeer may install otherwise by it
40
36
  function checkSettings(settings, file) {
41
37
  if (settings === undefined) return
42
38
  const where = `${file}: soldeer`
@@ -12,12 +12,10 @@ import { checkoutOf, githubRepoOf } from '../github.js'
12
12
  import { checkHost, inputsOf } from './inputs.js'
13
13
  import { extractZip } from './zip.js'
14
14
 
15
- // What the registry takes, as @preventive/upstream/soldeer.js checks a name
16
- // and version, which Soldeer's sanitize_filename leaves as they are on Unix.
15
+ // A name and version as upstream's soldeer.js checks them, which sanitize_filename leaves as they are on Unix
17
16
  const NAME = /^(?=.{3,100}$)[@\da-z][\da-z-]*[\da-z]$/u
18
17
  const VERSION = /^(?=.{1,128}$)[\dA-Za-z][\w.+-]*$/u
19
- // A folder sanitize_filename leaves as it is on Unix: none of the characters
20
- // it replaces, and at most 255 bytes, past which it cuts the name short.
18
+ // Neither a character sanitize_filename replaces nor past the 255 bytes it cuts a name at
21
19
  const isKept = (folder) => !/[/?<>\\:*|"\p{Cc}]/u.test(folder) && utf8fromStringLoose(folder).length <= 255
22
20
 
23
21
  const GITHUB = 'github must be a GitHub client from createClient, which a git dependency is fetched through'