@preventive/deptree 1.5.1 → 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.
- package/bin/compare.js +10 -21
- package/bin/deptree.js +5 -10
- package/cargo.d.ts +139 -195
- package/cargo.js +0 -2
- package/cocoapods.d.ts +211 -381
- package/cocoapods.js +0 -2
- package/npm.d.ts +245 -369
- package/npm.js +4 -6
- package/package.json +2 -2
- package/pnpm.d.ts +258 -667
- package/pnpm.js +2 -4
- package/soldeer.d.ts +144 -215
- package/soldeer.js +0 -2
- package/src/cargo/crate.js +21 -46
- package/src/cargo/inputs.js +5 -8
- package/src/cargo/members.js +6 -12
- package/src/cargo/registry.js +5 -9
- package/src/cargo/tree.js +8 -13
- package/src/cargo/workspace.js +13 -26
- package/src/cocoapods/archive.js +19 -40
- package/src/cocoapods/clean.js +21 -45
- package/src/cocoapods/fnmatch.js +12 -27
- package/src/cocoapods/inputs.js +5 -11
- package/src/cocoapods/install.js +11 -24
- package/src/cocoapods/podspec.js +19 -40
- package/src/cocoapods/podtree.js +10 -19
- package/src/cocoapods/source.js +13 -30
- package/src/cocoapods/tree.js +17 -39
- package/src/cocoapods/unicode.js +3 -9
- package/src/github.js +12 -24
- package/src/glob.js +2 -4
- package/src/lazy.js +2 -4
- package/src/manifest.js +2 -4
- package/src/matcher.js +3 -5
- package/src/mount.js +7 -14
- package/src/npm/bins.js +3 -5
- package/src/npm/compat.js +3 -5
- package/src/npm/package.js +6 -12
- package/src/npm/ratio.js +3 -5
- package/src/npm/settings.js +3 -5
- package/src/npm/tree.js +6 -11
- package/src/npm/versions.js +3 -4
- package/src/npmrc.js +2 -4
- package/src/patch.js +8 -14
- package/src/pnpm/bins.js +16 -42
- package/src/pnpm/filename.js +2 -4
- package/src/pnpm/gitignore.js +2 -4
- package/src/pnpm/glob.js +3 -5
- package/src/pnpm/hoist.js +8 -16
- package/src/pnpm/hoisted.js +15 -44
- package/src/pnpm/hook.js +2 -4
- package/src/pnpm/install.js +5 -10
- package/src/pnpm/lazy.js +8 -23
- package/src/pnpm/local.js +2 -4
- package/src/pnpm/minimatch.js +8 -15
- package/src/pnpm/nm-hoist.js +5 -11
- package/src/pnpm/npm-packlist.js +3 -6
- package/src/pnpm/overrides.js +2 -4
- package/src/pnpm/package.js +10 -16
- package/src/pnpm/packlist.js +3 -7
- package/src/pnpm/patches.js +3 -4
- package/src/pnpm/production.js +9 -28
- package/src/pnpm/projects.js +2 -6
- package/src/pnpm/readers.js +2 -4
- package/src/pnpm/settings.js +2 -5
- package/src/pnpm/tree.js +14 -37
- package/src/pnpm/workspace.js +4 -7
- package/src/pnpm/write.js +1 -1
- package/src/soldeer/config.js +5 -9
- package/src/soldeer/tree.js +2 -4
- package/src/soldeer/zip.js +8 -17
- package/src/tarball.js +12 -29
- package/src/yarn1/compat.js +2 -4
- package/src/yarn1/hoist.js +3 -8
- package/src/yarn1/package.js +12 -23
- package/src/yarn1/resolve.js +6 -11
- package/src/yarn1/settings.js +5 -10
- package/src/yarn1/tree.js +9 -18
- package/yarn1.d.ts +203 -360
- package/yarn1.js +4 -6
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
|
|
16
|
-
//
|
|
17
|
-
//
|
|
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
|
-
//
|
|
58
|
-
//
|
|
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:
|
|
50
|
-
//
|
|
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) {
|
package/src/pnpm/minimatch.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// minimatch as npm-packlist runs it
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
73
|
-
//
|
|
74
|
-
//
|
|
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`:
|
|
221
|
-
//
|
|
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) {
|
package/src/pnpm/nm-hoist.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
-
//
|
|
22
|
-
//
|
|
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
|
|
package/src/pnpm/npm-packlist.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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'
|
package/src/pnpm/overrides.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// Overrides as pnpm's parseOverrides reads them
|
|
2
|
-
//
|
|
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'
|
package/src/pnpm/package.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// A registry package as pnpm installs it
|
|
2
|
-
//
|
|
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
|
|
23
|
-
//
|
|
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 !== '' :
|
|
55
|
-
return named || (
|
|
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 (
|
|
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
|
|
78
|
-
//
|
|
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
|
package/src/pnpm/packlist.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// The files pnpm's directory fetcher installs of a `file:` dependency,
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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'
|
package/src/pnpm/patches.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// pnpm 10 applies the patch patchedDependencies picks for a package's name and
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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'
|
package/src/pnpm/production.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
90
|
-
//
|
|
91
|
-
//
|
|
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
|
|
138
|
-
//
|
|
139
|
-
//
|
|
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)
|
package/src/pnpm/projects.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// Each project's package.json,
|
|
2
|
-
//
|
|
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'
|
package/src/pnpm/readers.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// Each setting pnpm reads, by its pnpm-workspace.yaml name, is
|
|
2
|
-
//
|
|
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'
|
package/src/pnpm/settings.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// The settings an install reads
|
|
2
|
-
//
|
|
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
|
-
//
|
|
3
|
-
//
|
|
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,
|
|
81
|
-
//
|
|
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
|
|
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
|
|
118
|
-
//
|
|
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)
|
|
188
|
-
//
|
|
189
|
-
//
|
|
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
|
-
//
|
|
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,
|
|
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 {
|
package/src/pnpm/workspace.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// The directories pnpm takes for
|
|
2
|
-
//
|
|
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 [
|
|
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) =>
|
|
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
|
|
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)
|
package/src/soldeer/config.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
//
|
|
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
|
-
//
|
|
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
|
|
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
|
|
38
|
-
//
|
|
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`
|
package/src/soldeer/tree.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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'
|
package/src/soldeer/zip.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// A registry zip as Soldeer 0.12 extracts it (download.rs's
|
|
2
|
-
//
|
|
3
|
-
// and the two would read otherwise is refused. As a 0o022 umask leaves them,
|
|
4
|
-
// every directory is 0o755, and a file's mode its Unix mode as the zip crate
|
|
5
|
-
// reads it, or 0o644 where it reads none; a symlink is a file of its target.
|
|
1
|
+
// A registry zip as Soldeer 0.12 extracts it (download.rs's extract_dependency_archive, zip crate 8.6),
|
|
2
|
+
// under a 0o022 umask; what the archive reader takes and the two would read otherwise is refused
|
|
6
3
|
|
|
7
4
|
import { utf8fromStringLoose } from '@exodus/bytes/utf8.js'
|
|
8
5
|
import { ArchiveError, unzip } from '@preventive/archive/zip.js'
|
|
@@ -41,24 +38,18 @@ function unixMode({ system, attributes }) {
|
|
|
41
38
|
return attributes & 0x01 ? mode & ~0o222 : mode
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// one out, with core.protectNTFS, on by default.
|
|
41
|
+
// A component Soldeer holds to `.git` (trim_end_matches(['.', ' ']), eq_ignore_ascii_case), which git's
|
|
42
|
+
// verify_path refuses to check out with core.protectNTFS, on by default
|
|
47
43
|
export const isGit = (component) => component.replace(/[. ]+$/u, '').replace(/[A-Z]/gu, (char) => char.toLowerCase()) === '.git'
|
|
48
44
|
|
|
49
|
-
// getZip has held the zip to its checksum; it is held to it again where it
|
|
50
|
-
// is unpacked.
|
|
45
|
+
// getZip has held the zip to its checksum; it is held to it again where it is unpacked
|
|
51
46
|
export async function extractZip(bytes, checksum, where) {
|
|
52
47
|
if (await bytesSha256Hex(bytes) !== checksum) throw new DeptreeError(`its zip's sha256 is not ${checksum}`, where)
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
entries = await unzip(bytes, { limit: MAX_BYTES })
|
|
56
|
-
} catch (error) {
|
|
48
|
+
const entries = await unzip(bytes, { limit: MAX_BYTES }).catch((error) => {
|
|
57
49
|
if (error instanceof ArchiveError) throw new DeptreeError(`its zip cannot be read: ${error.message}`, where, { cause: error })
|
|
58
50
|
throw error
|
|
59
|
-
}
|
|
60
|
-
// The zip crate keys entries by their names
|
|
61
|
-
// of two of one name, the later is extracted where the first was.
|
|
51
|
+
})
|
|
52
|
+
// The zip crate keys entries by their stored names: of two of one name, the later is extracted where the first was
|
|
62
53
|
const last = new Map()
|
|
63
54
|
for (const [index, entry] of entries.entries()) {
|
|
64
55
|
const here = `${where}: ${quote(entry.storedName)}`
|