@preventive/deptree 1.0.0-alpha.1 → 1.0.0-alpha.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/package.json +38 -6
- package/pnpm.d.ts +224 -77
- package/pnpm.js +9 -6
- package/soldeer.d.ts +168 -0
- package/soldeer.js +12 -0
- package/src/concurrent.js +24 -0
- package/src/hash.js +4 -0
- package/src/mount.js +7 -6
- package/src/patch.js +5 -4
- package/src/pnpm/bins.js +105 -246
- package/src/pnpm/commands.js +273 -0
- package/src/pnpm/filename.js +16 -2
- package/src/pnpm/frozen.js +4 -2
- package/src/pnpm/graph.js +36 -16
- package/src/pnpm/hoist.js +41 -11
- package/src/pnpm/inputs.js +160 -0
- package/src/pnpm/install.js +65 -20
- package/src/pnpm/local.js +95 -33
- package/src/pnpm/packlist.js +64 -29
- package/src/pnpm/project.js +97 -0
- package/src/pnpm/projects.js +97 -10
- package/src/pnpm/readers.js +73 -16
- package/src/pnpm/settings.js +25 -10
- package/src/pnpm/tree.js +68 -119
- package/src/pnpm/workspace.js +70 -35
- package/src/soldeer/config.js +79 -0
- package/src/soldeer/inputs.js +40 -0
- package/src/soldeer/tree.js +111 -0
- package/src/soldeer/zip.js +142 -0
- package/src/tarball.js +26 -12
- package/src/yarn1/bins.js +38 -0
- package/src/yarn1/compat.js +86 -0
- package/src/yarn1/glob.js +52 -0
- package/src/yarn1/hoist.js +264 -0
- package/src/yarn1/inputs.js +125 -0
- package/src/yarn1/manifest.js +79 -0
- package/src/yarn1/package.js +148 -0
- package/src/yarn1/peers.js +58 -0
- package/src/yarn1/requests.js +90 -0
- package/src/yarn1/resolve.js +269 -0
- package/src/yarn1/settings.js +123 -0
- package/src/yarn1/tree.js +212 -0
- package/yarn1.d.ts +267 -0
- package/yarn1.js +14 -0
package/package.json
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preventive/deptree",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
|
+
"description": "A dependency tree in memory, as a package manager would install it: pnpm 10, 11 or 12, or yarn 1.22, from its lockfile, tarballs fetched and checked, patches applied; or Soldeer 0.12, its zips fetched, checked and extracted",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./pnpm.js": {
|
|
8
8
|
"types": "./pnpm.d.ts",
|
|
9
9
|
"default": "./pnpm.js"
|
|
10
|
+
},
|
|
11
|
+
"./yarn1.js": {
|
|
12
|
+
"types": "./yarn1.d.ts",
|
|
13
|
+
"default": "./yarn1.js"
|
|
14
|
+
},
|
|
15
|
+
"./soldeer.js": {
|
|
16
|
+
"types": "./soldeer.d.ts",
|
|
17
|
+
"default": "./soldeer.js"
|
|
10
18
|
}
|
|
11
19
|
},
|
|
12
20
|
"files": [
|
|
13
21
|
"pnpm.d.ts",
|
|
14
22
|
"pnpm.js",
|
|
23
|
+
"soldeer.d.ts",
|
|
24
|
+
"soldeer.js",
|
|
25
|
+
"yarn1.d.ts",
|
|
26
|
+
"yarn1.js",
|
|
27
|
+
"src/concurrent.js",
|
|
15
28
|
"src/error.js",
|
|
16
29
|
"src/hash.js",
|
|
17
30
|
"src/matcher.js",
|
|
@@ -19,24 +32,43 @@
|
|
|
19
32
|
"src/patch.js",
|
|
20
33
|
"src/pnpm/bins.js",
|
|
21
34
|
"src/pnpm/checks.js",
|
|
35
|
+
"src/pnpm/commands.js",
|
|
22
36
|
"src/pnpm/filename.js",
|
|
23
37
|
"src/pnpm/frozen.js",
|
|
24
38
|
"src/pnpm/graph.js",
|
|
25
39
|
"src/pnpm/hook.js",
|
|
26
40
|
"src/pnpm/hoist.js",
|
|
41
|
+
"src/pnpm/inputs.js",
|
|
27
42
|
"src/pnpm/install.js",
|
|
28
43
|
"src/pnpm/local.js",
|
|
29
44
|
"src/pnpm/npmrc.js",
|
|
30
45
|
"src/pnpm/overrides.js",
|
|
31
46
|
"src/pnpm/packlist.js",
|
|
32
47
|
"src/pnpm/patches.js",
|
|
48
|
+
"src/pnpm/project.js",
|
|
33
49
|
"src/pnpm/projects.js",
|
|
34
50
|
"src/pnpm/readers.js",
|
|
35
51
|
"src/pnpm/settings.js",
|
|
36
52
|
"src/pnpm/tree.js",
|
|
37
53
|
"src/pnpm/uptodate.js",
|
|
38
54
|
"src/pnpm/workspace.js",
|
|
39
|
-
"src/
|
|
55
|
+
"src/soldeer/config.js",
|
|
56
|
+
"src/soldeer/inputs.js",
|
|
57
|
+
"src/soldeer/tree.js",
|
|
58
|
+
"src/soldeer/zip.js",
|
|
59
|
+
"src/tarball.js",
|
|
60
|
+
"src/yarn1/bins.js",
|
|
61
|
+
"src/yarn1/compat.js",
|
|
62
|
+
"src/yarn1/glob.js",
|
|
63
|
+
"src/yarn1/hoist.js",
|
|
64
|
+
"src/yarn1/inputs.js",
|
|
65
|
+
"src/yarn1/manifest.js",
|
|
66
|
+
"src/yarn1/package.js",
|
|
67
|
+
"src/yarn1/peers.js",
|
|
68
|
+
"src/yarn1/requests.js",
|
|
69
|
+
"src/yarn1/resolve.js",
|
|
70
|
+
"src/yarn1/settings.js",
|
|
71
|
+
"src/yarn1/tree.js"
|
|
40
72
|
],
|
|
41
73
|
"engines": {
|
|
42
74
|
"node": ">=24.14.0"
|
|
@@ -65,8 +97,8 @@
|
|
|
65
97
|
"dependencies": {
|
|
66
98
|
"@preventive/archive": "1.0.0-beta.3",
|
|
67
99
|
"@preventive/diff": "^1.0.0",
|
|
68
|
-
"@preventive/lockfile": "1.0.0-alpha.
|
|
69
|
-
"@preventive/upstream": "1.0.0-alpha.
|
|
70
|
-
"@preventive/vfs": "1.0.0-beta.
|
|
100
|
+
"@preventive/lockfile": "1.0.0-alpha.2",
|
|
101
|
+
"@preventive/upstream": "1.0.0-alpha.2",
|
|
102
|
+
"@preventive/vfs": "1.0.0-beta.2"
|
|
71
103
|
}
|
|
72
104
|
}
|
package/pnpm.d.ts
CHANGED
|
@@ -1,50 +1,94 @@
|
|
|
1
1
|
// Hand-written against pnpm.js; a change to either belongs with the other.
|
|
2
2
|
|
|
3
|
-
import type { Vfs } from '@preventive/vfs'
|
|
3
|
+
import type { NodeType, Vfs } from '@preventive/vfs'
|
|
4
4
|
|
|
5
|
+
// What the lockfile reader and the YAML parser refuse with: the cause of
|
|
6
|
+
// the DeptreeError that names the file they refused, pnpm-lock.yaml or
|
|
7
|
+
// pnpm-workspace.yaml.
|
|
5
8
|
export { LockfileError, YamlError } from '@preventive/lockfile/pnpm.js'
|
|
6
9
|
|
|
7
10
|
// Where @preventive/upstream caches what it fetches, tarballs among them.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
+
// Tarballs are fetched through it, and that is the one place anything here
|
|
12
|
+
// touches a filesystem. Before the network, it takes a tarball from npm's
|
|
13
|
+
// cache — under $npm_config_cache, or ~/.npm — or from ~/.audit/cache/tgz,
|
|
14
|
+
// where one there has the lockfile's integrity, and writes neither; then
|
|
15
|
+
// from its own cache, where one is set, which is where it writes each
|
|
16
|
+
// tarball it fetches. Unset, which it is by default, it has none, and
|
|
17
|
+
// writes nothing: a tarball in neither of the others is fetched every
|
|
18
|
+
// time, each once for however many snapshots it has. The project is read
|
|
19
|
+
// only through the view given as `project`, and the tree built in a Vfs.
|
|
11
20
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
12
21
|
|
|
13
22
|
// The machine pnpm would install on, which a tree depends on: `pnpm` is
|
|
14
|
-
// the version that installs, and has to be a 10.x
|
|
15
|
-
// built for, each as it differs from the
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
23
|
+
// the version that installs, and has to be a 10.x, an 11.x or a 12.x from
|
|
24
|
+
// 12.8.1 on, the three built for, each as it differs from the others; an
|
|
25
|
+
// earlier 12.x installs otherwise in places, and is refused. Left out, it
|
|
26
|
+
// is the one
|
|
27
|
+
// the root package.json's packageManager pins, which pnpm switches to, and
|
|
28
|
+
// has to be given where that pins none. `node` is the Node it runs on,
|
|
29
|
+
// unless the settings name a nodeVersion or, for pnpm 11, the root
|
|
30
|
+
// package.json's engines.runtime pins one; `os`, `cpu` and `libc` as Node
|
|
31
|
+
// and pnpm name them — `linux`, `x64`, `glibc` — with `unknown` for a libc
|
|
32
|
+
// outside Linux, as pnpm has it.
|
|
20
33
|
// Windows is refused: pnpm links there with junctions to absolute paths.
|
|
21
34
|
// An optional package the machine cannot run is left out, as pnpm leaves
|
|
22
35
|
// it out; supportedArchitectures in the settings widens what is taken.
|
|
23
36
|
export interface PnpmHost {
|
|
24
|
-
pnpm
|
|
37
|
+
pnpm?: string
|
|
25
38
|
node: string
|
|
26
39
|
os: string
|
|
27
40
|
cpu: string
|
|
28
41
|
libc: 'glibc' | 'musl' | 'unknown'
|
|
29
42
|
}
|
|
30
43
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
44
|
+
// A view of the lockfile's directory, by paths from `/`: a Vfs, or
|
|
45
|
+
// anything with its readdir, lstat, stat and readFile, such as one of a
|
|
46
|
+
// directory on disk, of which only this is read: the names in a
|
|
47
|
+
// directory; what a path is, `file`, `directory` or `symlink`, and its
|
|
48
|
+
// mode, with lstat, and what it leads to with stat; and a file's bytes.
|
|
49
|
+
// Each throws an error whose `code` is ENOENT, ENOTDIR or ELOOP for a path
|
|
50
|
+
// that leads nowhere. Nothing is written to it.
|
|
51
|
+
export interface PnpmProject {
|
|
52
|
+
readdir(path: string): string[]
|
|
53
|
+
lstat(path: string): { type: NodeType, mode: number }
|
|
54
|
+
stat(path: string): { type: NodeType }
|
|
55
|
+
readFile(path: string): Uint8Array
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// The files an install reads: pnpm-lock.yaml; the package.json of every
|
|
59
|
+
// project it installs; pnpm-workspace.yaml and the .npmrc, where there are
|
|
60
|
+
// any; and every patch file the settings' patchedDependencies name.
|
|
61
|
+
//
|
|
62
|
+
// With `lockfile`, they are given as text: `manifests` by the project's
|
|
63
|
+
// directory relative to the lockfile's (`.` for the root, then as its
|
|
64
|
+
// importers are keyed), `patches` by the path from the lockfile's
|
|
65
|
+
// directory the settings name each by, and only those.
|
|
66
|
+
//
|
|
67
|
+
// Without it, they are read from `project`, as pnpm reads them there, and
|
|
68
|
+
// none of them may be given: pnpm-lock.yaml, which has to be there;
|
|
69
|
+
// pnpm-workspace.yaml, which, where there is none, pnpm refuses under
|
|
70
|
+
// another name it looks for it by, such as pnpm-workspace.yml; the .npmrc;
|
|
71
|
+
// the package.json of every project pnpm finds, as findPnpmProjects finds
|
|
72
|
+
// them, and no other, an importer pnpm-workspace.yaml's packages do not
|
|
73
|
+
// take refused unread; and each patch the settings name, and no other,
|
|
74
|
+
// which has to be under the lockfile's directory. Each is read as
|
|
75
|
+
// UTF-8, and refused where it is not, a byte order mark kept as it is in
|
|
76
|
+
// text given; a refusal names each as it would given:
|
|
77
|
+
// `manifests["packages/x"]`, `patches["patches/p.patch"]`.
|
|
78
|
+
//
|
|
79
|
+
// Settings from anywhere else — another .npmrc, the environment, the
|
|
80
|
+
// command line — are not read, and are taken to be at their defaults; so
|
|
81
|
+
// is pnpm taken to run as itself, not under corepack, and free to switch
|
|
82
|
+
// to the version a project pins.
|
|
39
83
|
//
|
|
40
84
|
// A workspace is one lockfile for several projects, each a package.json:
|
|
41
85
|
// the root, and every directory pnpm-workspace.yaml's `packages` globs
|
|
42
86
|
// take, as pnpm globs for them — `*` and `**`, a leading `!` to leave out,
|
|
43
87
|
// and no other glob syntax. Without `packages` the root is the only
|
|
44
|
-
// project. Every importer has to have its package.json
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
// directories: findPnpmProjects finds them in those. A project the
|
|
88
|
+
// project. Every importer has to have its package.json, and be a project
|
|
89
|
+
// those globs take; and every project pnpm would find has to be given,
|
|
90
|
+
// which buildPnpmTree cannot check where it is given them, as it is not
|
|
91
|
+
// given the directories: findPnpmProjects finds them in those. A project the
|
|
48
92
|
// lockfile has no importer for is held to an empty one, as pnpm holds it:
|
|
49
93
|
// with no dependencies it is installed, and hoisted by its name, and with
|
|
50
94
|
// any it is refused as not up to date. Its directory has to be given as
|
|
@@ -65,17 +109,22 @@ export interface PnpmHost {
|
|
|
65
109
|
// one is the root package.json's own specifier for `name`, and
|
|
66
110
|
// `catalog:` what the workspace's catalog gives the package. One to a
|
|
67
111
|
// directory — a path alone, such as `./vendor/foo`, `link:` or `file:` —
|
|
68
|
-
// is read only with `
|
|
69
|
-
// the lockfile's and holds a package.json there. pnpm links to it by a
|
|
112
|
+
// is read only with `project` given, and only where the directory is
|
|
113
|
+
// under the lockfile's and holds a package.json there. pnpm links to it by a
|
|
70
114
|
// path alone or `link:`. By `file:` it installs it as a package, of the
|
|
71
|
-
// files npm-packlist's built-in rules keep
|
|
72
|
-
// a directory with a .npmignore or
|
|
73
|
-
// or bundled dependencies, or a
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
115
|
+
// files npm-packlist's built-in rules keep — with pnpm 12, its own port's
|
|
116
|
+
// — which are followed here alone: a directory with a .npmignore or
|
|
117
|
+
// .gitignore, a package.json with `files` or bundled dependencies, or a
|
|
118
|
+
// link in it, is refused. pnpm hardlinks those files from the directory
|
|
119
|
+
// into each snapshot of the package, so a file linking a bin makes
|
|
120
|
+
// executable is made so in every snapshot and in the directory, which is
|
|
121
|
+
// not written here; a CRLF `#!` line it rewrites is rewritten as a file of
|
|
122
|
+
// that snapshot's own. Where it builds the package — an install script, a
|
|
123
|
+
// binding.gyp, which pnpm 11 and 12 pass over with `gypfile: false`, or a
|
|
124
|
+
// .hooks directory — or, with pnpm 11 and 12, where packageImportMethod is
|
|
125
|
+
// other than auto or hardlink, each snapshot has a copy of its own
|
|
126
|
+
// instead. One by `file:` to a tarball is refused, and so is a `file:`
|
|
127
|
+
// dependency no override names.
|
|
79
128
|
//
|
|
80
129
|
// Of the .npmrc, only what pnpm reads for an install is read: its settings
|
|
81
130
|
// by their kebab-case names, those that can change the tree held to what
|
|
@@ -96,31 +145,67 @@ export interface PnpmHost {
|
|
|
96
145
|
// lockfile against the registry by before it installs — each package's
|
|
97
146
|
// publish time, its tarball URL, its trust — are passed over.
|
|
98
147
|
//
|
|
148
|
+
// pnpm 12 reads them so too. Where the root package.json pins a pnpm that
|
|
149
|
+
// host.pnpm is, it fails on a key of pnpm-workspace.yaml it does not know,
|
|
150
|
+
// one of pnpm 11's such as alwaysAuth among them, which is refused; it
|
|
151
|
+
// drops one otherwise, and passes over one not in camelCase it knows. It
|
|
152
|
+
// takes hoistPattern and publicHoistPattern only as lists, and passes over
|
|
153
|
+
// what it has that pnpm 11 has not but `cargo` or `python` enabled, which
|
|
154
|
+
// is refused. It parses every key of pnpm-workspace.yaml into a type of
|
|
155
|
+
// its own, and fails on a value that does not parse, or a `tasks` entry it
|
|
156
|
+
// holds to be wrong: that is not checked here of a key that leaves the
|
|
157
|
+
// tree as it is. Where there is no pnpm-workspace.yaml, it writes one of
|
|
158
|
+
// the root package.json's `workspaces` list, its strings but empty ones,
|
|
159
|
+
// and installs by it, as this does for it.
|
|
160
|
+
//
|
|
161
|
+
// `project` is read only where it is said to be here: for the files an
|
|
162
|
+
// install reads, without `lockfile`; for the directories a `link:` or an
|
|
163
|
+
// override leads to. With it given, a directory the tree links to that is
|
|
164
|
+
// no project, and is under the lockfile's, has to be there with a
|
|
165
|
+
// package.json, whose bins are read as pnpm reads them. Without it, or
|
|
166
|
+
// outside the lockfile's directory, such a directory's bins are not
|
|
167
|
+
// known, and neither are those of a project that has them by the files of
|
|
168
|
+
// its directories.bin: where one could win a command a package's file is
|
|
169
|
+
// linked by, and so decide whether pnpm fixes that file, and fixing it
|
|
170
|
+
// would change it, the tree is refused.
|
|
171
|
+
//
|
|
99
172
|
// `vfs` is a Vfs to mount the tree into, at its root, which is taken to
|
|
100
173
|
// be the lockfile's directory, beside whatever it holds, such as the
|
|
101
|
-
// projects themselves; without one, a new Vfs
|
|
102
|
-
//
|
|
174
|
+
// projects themselves — it may be `project` too; without one, a new Vfs
|
|
175
|
+
// holds the tree alone. Nothing the tree is built from is read from it. A
|
|
176
|
+
// Vfs that holds a node_modules anywhere, or on macOS a name that is one
|
|
103
177
|
// there, is refused before anything is fetched: kept beside the tree, Node
|
|
104
178
|
// would read it as the tree's, and removed, it would be the caller's lost.
|
|
105
179
|
// Nothing there is written over: each directory the tree has is one there
|
|
106
180
|
// or is made, and every file and link is written where nothing is. The
|
|
107
181
|
// tree is built, and held to every check below, before any of it is
|
|
108
|
-
// written, so a refusal leaves the Vfs as it was.
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
export interface PnpmTreeOptions {
|
|
182
|
+
// written, so a refusal leaves the Vfs as it was. Nothing outside
|
|
183
|
+
// node_modules is written, though pnpm 10 makes the files a linked
|
|
184
|
+
// directory's bins run executable too.
|
|
185
|
+
//
|
|
186
|
+
// The two ways the files come, one or the other: given, with `lockfile`
|
|
187
|
+
// and `manifests`, `project` read only for directories; or read, with
|
|
188
|
+
// `project` and none of them.
|
|
189
|
+
export type PnpmTreeOptions = PnpmTreeGiven | PnpmTreeRead
|
|
190
|
+
|
|
191
|
+
export interface PnpmTreeGiven {
|
|
119
192
|
lockfile: string
|
|
120
193
|
manifests: Record<string, string> | Map<string, string>
|
|
121
194
|
workspace?: string
|
|
122
195
|
npmrc?: string
|
|
123
196
|
patches?: Record<string, string> | Map<string, string>
|
|
197
|
+
project?: PnpmProject
|
|
198
|
+
host: PnpmHost
|
|
199
|
+
vfs?: Vfs
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface PnpmTreeRead {
|
|
203
|
+
lockfile?: undefined
|
|
204
|
+
manifests?: undefined
|
|
205
|
+
workspace?: undefined
|
|
206
|
+
npmrc?: undefined
|
|
207
|
+
patches?: undefined
|
|
208
|
+
project: PnpmProject
|
|
124
209
|
host: PnpmHost
|
|
125
210
|
vfs?: Vfs
|
|
126
211
|
}
|
|
@@ -152,7 +237,7 @@ export interface PnpmTree {
|
|
|
152
237
|
}
|
|
153
238
|
|
|
154
239
|
// The node_modules tree `pnpm install --frozen-lockfile --ignore-scripts`
|
|
155
|
-
// makes with the isolated linker of host.pnpm, 10 or
|
|
240
|
+
// makes with the isolated linker of host.pnpm, 10, 11 or 12, and no other
|
|
156
241
|
// install: whatever the
|
|
157
242
|
// settings say of frozen lockfiles, the install is frozen, which is also
|
|
158
243
|
// the only one that hoists by the lockfile's graph alone. It is rooted at
|
|
@@ -175,6 +260,26 @@ export interface PnpmTree {
|
|
|
175
260
|
// aliases, a project's .bin takes the bins of the peers its dependencies
|
|
176
261
|
// require — and each is built as the one given links them.
|
|
177
262
|
//
|
|
263
|
+
// pnpm 12, a rewrite of pnpm, makes its tree otherwise again, and it is
|
|
264
|
+
// built as pnpm 12 makes it. It links each package's own bins into its own
|
|
265
|
+
// node_modules/.bin, beside its dependencies', and of two of one name
|
|
266
|
+
// keeps the one of the package whose name sorts first by its bytes; makes
|
|
267
|
+
// a file a bin runs executable without rewriting a CRLF `#!` line, and
|
|
268
|
+
// fails on a bin that is a directory, which is refused; reads `bin` and
|
|
269
|
+
// directories.bin otherwise, dotfiles among them, and a package's null
|
|
270
|
+
// `bin` beside a directories.bin as its store has the package or not,
|
|
271
|
+
// which is refused. It links no package to
|
|
272
|
+
// a dependency of its own name, and writes a file a patch makes as
|
|
273
|
+
// 0o644, whatever mode the patch gives it. It hoists from a graph of every
|
|
274
|
+
// snapshot, those left out walked through but not hoisted, keeps from
|
|
275
|
+
// hoisting the root project's aliases but its `link:`s, those left out
|
|
276
|
+
// among them, and takes the snapshots of one depth in the order of their
|
|
277
|
+
// directories' names. It names a directory under node_modules/.pnpm by the
|
|
278
|
+
// UTF-8 bytes of its key, which only a key that is not ASCII tells. It
|
|
279
|
+
// shares pnpm 11's store, and takes what pnpm 11 left there, such as a
|
|
280
|
+
// patched package as pnpm 11 built it, which is not followed here: the
|
|
281
|
+
// tree is the one a store of pnpm 12's own gives.
|
|
282
|
+
//
|
|
178
283
|
// The lockfile is held to what a frozen install holds it to, and refused
|
|
179
284
|
// where pnpm would refuse it: the settings that shaped its resolution —
|
|
180
285
|
// catalogs, overrides, package extensions, optional dependencies left out,
|
|
@@ -197,6 +302,33 @@ export interface PnpmTree {
|
|
|
197
302
|
// for it; and a root engines.runtime whose onFail is `error` has to take
|
|
198
303
|
// host.node.
|
|
199
304
|
//
|
|
305
|
+
// pnpm 12 reads devEngines.packageManager over packageManager, as pnpm 11
|
|
306
|
+
// does but for the onFail of a list with no pnpm in it, which is its first
|
|
307
|
+
// entry's own. Unless what to do on a mismatch, or pmOnFail, is to ignore,
|
|
308
|
+
// host.pnpm has to be in the pnpm it pins, or the mismatch only to warn,
|
|
309
|
+
// and another package manager is refused unless it is only to warn; and a
|
|
310
|
+
// pin of devEngines, or of a pnpm 12 by packageManager, has to be recorded
|
|
311
|
+
// in the lockfile's env document, of `pnpm` alone at the version pinned,
|
|
312
|
+
// or at host.pnpm for a range, with its package: pnpm 12 runs that one,
|
|
313
|
+
// and fails a frozen install where it is not there.
|
|
314
|
+
//
|
|
315
|
+
// pnpm 12 makes none of pnpm 11's further checks of a lockfile, but holds
|
|
316
|
+
// a directory a project depends on by `file:` to it: each dependency the
|
|
317
|
+
// snapshot has is one its package.json, overridden, asks for, a peer among
|
|
318
|
+
// them; each it asks for is resolved as it asks, an optional one there or
|
|
319
|
+
// not; and its peers, and which are optional, are what the lockfile
|
|
320
|
+
// records. A project the lockfile has no importer for is held to none
|
|
321
|
+
// where it has no dependencies but peers, and refused otherwise. It checks
|
|
322
|
+
// of the projects only the root's engines.node, with engineStrict, and
|
|
323
|
+
// with engineStrict refuses whatever it installs that the host cannot run,
|
|
324
|
+
// though the lockfile mark it optional. An os, cpu or libc list is read
|
|
325
|
+
// by its first entry that names the host's. A patched package's
|
|
326
|
+
// engines.node is held to nodeVersion, or the host's Node, whatever the
|
|
327
|
+
// root's engines.runtime pins. An engines.node npm's semver does not read,
|
|
328
|
+
// or a range of a `-` with an `x`, pnpm 12 reads otherwise, which is
|
|
329
|
+
// refused where it would decide what is installed. host.node is, for pnpm
|
|
330
|
+
// 12, the `node` it finds on the PATH.
|
|
331
|
+
//
|
|
200
332
|
// And to more than pnpm holds it to, where a lockfile pnpm writes, or a
|
|
201
333
|
// package the registry serves, always holds: each dependency linked where
|
|
202
334
|
// the package.json names a directory for it, a path alone among them; each
|
|
@@ -215,31 +347,44 @@ export interface PnpmTree {
|
|
|
215
347
|
// integrity; each patch to the lockfile's hash of it, and applied only
|
|
216
348
|
// where every hunk matches exactly where it says.
|
|
217
349
|
//
|
|
218
|
-
// Nothing is left to a guess: a lockfile the lockfile reader refuses,
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
// that
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
//
|
|
350
|
+
// Nothing is left to a guess: a lockfile the lockfile reader refuses, or
|
|
351
|
+
// one of the env document pnpm 11 writes alone before anything is
|
|
352
|
+
// installed, a setting this does not know or does not build for, overrides
|
|
353
|
+
// pnpm cannot read, a lockfile not resolved with these settings, a package
|
|
354
|
+
// from anywhere but the registry, a pnpmfile, package extensions, an
|
|
355
|
+
// injected dependency, a lockfile not up to date with a package.json,
|
|
356
|
+
// another package manager, a runtime to download, two projects of one
|
|
357
|
+
// name, a patch that does not hash or apply, a check above that fails,
|
|
358
|
+
// text that is not well-formed where it is hashed, a patch that would
|
|
359
|
+
// change a bin's file between two times pnpm links it, a file whose mode
|
|
360
|
+
// would turn on the order a directory is read in — each is refused with a
|
|
361
|
+
// DeptreeError that says where: where the lockfile reader or the YAML
|
|
362
|
+
// parser refused pnpm-lock.yaml or pnpm-workspace.yaml, it names the file,
|
|
363
|
+
// and its cause is their LockfileError or YamlError. A TypeError is thrown
|
|
364
|
+
// for options of the wrong type.
|
|
230
365
|
export function buildPnpmTree(options: PnpmTreeOptions): Promise<PnpmTree>
|
|
231
366
|
|
|
232
|
-
// The directories of the projects pnpm finds
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
367
|
+
// The directories of the projects pnpm finds in `project`, by which
|
|
368
|
+
// buildPnpmTree takes their package.json given: `.`, the root, first, then
|
|
369
|
+
// in order each directory whose package.json a glob of
|
|
370
|
+
// pnpm-workspace.yaml's `packages` takes, as pnpm `host.pnpm` finds them.
|
|
371
|
+
// pnpm-workspace.yaml is read from `project`, as buildPnpmTree reads it;
|
|
372
|
+
// so is the root package.json, where host.pnpm is left out, for the pnpm
|
|
373
|
+
// its packageManager pins, or, for pnpm 12, where there is no
|
|
374
|
+
// pnpm-workspace.yaml, for its `workspaces`.
|
|
236
375
|
//
|
|
237
|
-
// `
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
376
|
+
// Of `project`, besides those, only the directories pnpm walks into are
|
|
377
|
+
// read: none under node_modules or bower_components, and none whose name
|
|
378
|
+
// starts with a dot unless a glob spells it there. A manifest is a file,
|
|
379
|
+
// or a link to one; a link that leads nowhere, or to a directory, is none,
|
|
380
|
+
// as pnpm has it.
|
|
381
|
+
//
|
|
382
|
+
// pnpm 12 finds them otherwise in places: a `**` may take no directory
|
|
383
|
+
// before one a glob spells with a leading dot; it walks into no
|
|
384
|
+
// node_modules or bower_components, wherever they are; it fails where a
|
|
385
|
+
// glob with a `*` takes a directory whose first manifest there is not a
|
|
386
|
+
// file, which is refused; and the projects come in the order of their
|
|
387
|
+
// paths by name, `a/b` before `a-b`.
|
|
243
388
|
//
|
|
244
389
|
// Refused: a root with no manifest, which pnpm takes for no project; a
|
|
245
390
|
// project, the root among them, whose manifest is package.json5 or
|
|
@@ -249,20 +394,22 @@ export function buildPnpmTree(options: PnpmTreeOptions): Promise<PnpmTree>
|
|
|
249
394
|
// project in a directory a lockfile could not key its importer by, with a
|
|
250
395
|
// control, bidirectional or backslash character in its path, or a drive
|
|
251
396
|
// letter; a node_modules pnpm walks into, which it does only under a
|
|
252
|
-
// directory with a leading dot that a glob spells;
|
|
253
|
-
//
|
|
397
|
+
// directory with a leading dot that a glob spells; a glob buildPnpmTree
|
|
398
|
+
// refuses, or a pnpm not 10.x, 11.x or 12.x; and a pnpm-workspace.yaml
|
|
399
|
+
// that is not YAML, is not a mapping, is not UTF-8, or is under another
|
|
400
|
+
// name pnpm refuses.
|
|
254
401
|
export interface PnpmProjectsOptions {
|
|
255
|
-
|
|
256
|
-
host
|
|
257
|
-
vfs: Pick<Vfs, 'readdir' | 'lstat' | 'stat'>
|
|
402
|
+
project: PnpmProject
|
|
403
|
+
host?: Pick<PnpmHost, 'pnpm'>
|
|
258
404
|
}
|
|
259
405
|
|
|
260
406
|
export function findPnpmProjects(options: PnpmProjectsOptions): string[]
|
|
261
407
|
|
|
262
408
|
// `where` is what a refusal is about — `pnpm-workspace.yaml: nodeLinker`,
|
|
263
|
-
// `.npmrc:3: node-linker`, a package's key — or
|
|
264
|
-
// a whole; the message leads with it. `cause` is
|
|
265
|
-
// refused with, where one did
|
|
409
|
+
// `.npmrc:3: node-linker`, `pnpm-lock.yaml`, a package's key — or
|
|
410
|
+
// undefined for the call as a whole; the message leads with it. `cause` is
|
|
411
|
+
// what a package beneath refused with, where one did: the lockfile
|
|
412
|
+
// reader's LockfileError, its YamlError, a fetch's failure.
|
|
266
413
|
export class DeptreeError extends Error {
|
|
267
414
|
constructor(detail: string, where?: string, options?: { cause?: unknown })
|
|
268
415
|
where: string | undefined
|
package/pnpm.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// A node_modules tree built in memory from a pnpm lockfile, as pnpm 10 or
|
|
2
2
|
// 11 installs it with the isolated linker: pnpm.d.ts says what it takes and
|
|
3
|
-
// what comes back.
|
|
4
|
-
//
|
|
5
|
-
|
|
3
|
+
// what comes back. The project is read through the view given, and the
|
|
4
|
+
// tree built in a Vfs; the one filesystem touched is that of the tarball
|
|
5
|
+
// caches @preventive/upstream reads, and writes where it keeps its own.
|
|
6
|
+
export { buildPnpmTree } from './src/pnpm/tree.js'
|
|
7
|
+
export { findPnpmProjects } from './src/pnpm/inputs.js'
|
|
6
8
|
export { DeptreeError } from './src/error.js'
|
|
7
9
|
// Where @preventive/upstream caches what it fetches, tarballs among it;
|
|
8
|
-
// unset,
|
|
10
|
+
// unset, it keeps no cache of its own, and writes nothing.
|
|
9
11
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
10
|
-
// What the
|
|
11
|
-
//
|
|
12
|
+
// What the readers beneath refuse the lockfile with, and the YAML of it
|
|
13
|
+
// and of pnpm-workspace.yaml: the cause of a DeptreeError that names the
|
|
14
|
+
// file.
|
|
12
15
|
export { LockfileError, YamlError } from '@preventive/lockfile/pnpm.js'
|