@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.
- 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 +1 -1
- 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 +13 -14
- 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/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
|
|
40
|
-
//
|
|
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
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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
|
|
2
|
-
//
|
|
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
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
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
|
|
136
|
-
//
|
|
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
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
-
//
|
|
78
|
-
//
|
|
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()) {
|
package/src/npm/package.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// A tarball
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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,13 @@ export function registryTarball({ name, version, resolution }, where) {
|
|
|
22
19
|
|
|
23
20
|
const FILES = new Set(['file', 'contiguous-file'])
|
|
24
21
|
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
22
|
+
// One global header of a `comment` alone, as git archive writes its commit: tar's releases keep it on each entry
|
|
23
|
+
// and extract by nothing of it. They split a value at a newline into records, and merge a global header into the
|
|
24
|
+
// one before, which the archive reader replaces, so a second ahead of one entry would hide what the first sets.
|
|
25
|
+
const isCommentOnly = (globalPax, extended) => extended.filter(({ kind }) => kind === 'global').length <= 1 && globalPax.entries().every(([key, value]) => key === 'comment' && !value.includes('\n'))
|
|
26
|
+
|
|
27
|
+
// 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
|
|
28
|
+
// to its entry, so a long name, long link or global header between them, and all after, reads otherwise
|
|
31
29
|
function checkPaxSizes(entries, where) {
|
|
32
30
|
for (const { storedName, pax, extended } of entries) {
|
|
33
31
|
if (pax.has('size') && extended.findIndex(({ kind }) => kind === 'pax') < extended.length - 1) {
|
|
@@ -40,12 +38,12 @@ function unpack(entries, where) {
|
|
|
40
38
|
const files = new Map()
|
|
41
39
|
const ignores = new Set()
|
|
42
40
|
let top
|
|
43
|
-
for (const { storedName, storedLinkname, type, mode, data, globalPax } of entries) {
|
|
41
|
+
for (const { storedName, storedLinkname, type, mode, data, globalPax, extended } of entries) {
|
|
44
42
|
const segments = storedName.replace(/(?<=.)\/$/u, '').split('/')
|
|
45
43
|
if (segments.length > 1024 || /[\\\0]/u.test(storedName) || segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {
|
|
46
44
|
throw new DeptreeError(`${quote(storedName)} is a name tar reads otherwise`, where)
|
|
47
45
|
}
|
|
48
|
-
if (globalPax
|
|
46
|
+
if (!isCommentOnly(globalPax, extended)) throw new DeptreeError(`${quote(storedName)} has a pax header tar's releases read otherwise`, where)
|
|
49
47
|
if (top !== undefined && segments[0] !== top) throw new DeptreeError('the tarball has entries under more than one directory', where)
|
|
50
48
|
top = segments[0]
|
|
51
49
|
if (!FILES.has(type)) continue
|
|
@@ -59,6 +57,7 @@ function unpack(entries, where) {
|
|
|
59
57
|
path = path.replace(/\.gitignore$/u, '.npmignore')
|
|
60
58
|
if (ignores.has(path)) continue
|
|
61
59
|
}
|
|
60
|
+
// A .npmignore after a .gitignore renamed to it: its bytes, in the first's file and mode
|
|
62
61
|
files.set(path, { data, mode: files.get(path)?.mode ?? ((mode | 0o666) & ~UMASK & 0o777) })
|
|
63
62
|
}
|
|
64
63
|
return withDirs(files, where)
|
package/src/npm/ratio.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// tar 7.5.19 on gives up once
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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'
|
package/src/npm/settings.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// The project's .npmrc. npm hands the install
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
124
|
-
//
|
|
125
|
-
//
|
|
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()
|
package/src/npm/versions.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// What changes the tree between the npm releases supported. `reuse` is npm
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
2
|
-
//
|
|
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
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
26
|
-
//
|
|
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
|
|
125
|
-
export function applyPatch(files, patch
|
|
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:
|
|
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
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
-
//
|
|
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
|
|
168
|
-
//
|
|
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
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
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
|
|
242
|
-
//
|
|
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
|
|
259
|
-
//
|
|
260
|
-
//
|
|
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
|
|
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) => {
|
package/src/pnpm/filename.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
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'
|
package/src/pnpm/gitignore.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// A gitignore line as pnpm 12 reads
|
|
2
|
-
//
|
|
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
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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:
|
|
11
|
-
//
|
|
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
|
|
78
|
-
//
|
|
79
|
-
//
|
|
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 ?? [])
|
package/src/pnpm/hoisted.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
-
//
|
|
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
|
|
98
|
-
//
|
|
99
|
-
//
|
|
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
|
|
134
|
-
//
|
|
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
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
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
|
-
//
|
|
203
|
-
//
|
|
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
|
|
2
|
-
//
|
|
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'
|