@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 CHANGED
@@ -1,17 +1,30 @@
1
1
  {
2
2
  "name": "@preventive/deptree",
3
- "version": "1.0.0-alpha.1",
4
- "description": "A node_modules tree in memory, as a package manager would install it: pnpm 10 or 11 from its lockfile, tarballs fetched and checked, patches applied",
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/tarball.js"
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.1",
69
- "@preventive/upstream": "1.0.0-alpha.1",
70
- "@preventive/vfs": "1.0.0-beta.1"
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
- // Unset, which it is by default, nothing is cached and nothing is written:
9
- // tarballs are fetched every time, each once for however many snapshots it
10
- // has. It is the one place anything here touches a filesystem.
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 or an 11.x, the two
15
- // built for, each as it differs from the other; `node` the Node it runs
16
- // on, unless the settings name a nodeVersion or, for pnpm 11, the root
17
- // package.json's engines.runtime pins one;
18
- // `os`, `cpu` and `libc` as Node and pnpm name them — `linux`, `x64`,
19
- // `glibc` — with `unknown` for a libc outside Linux, as pnpm has it.
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: string
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
- // The files an install reads, as text: pnpm-lock.yaml; the package.json
32
- // of every project it installs, by the project's directory relative to the
33
- // lockfile's (`.` for the root, then as its importers are keyed); pnpm-
34
- // workspace.yaml and the .npmrc, where there are any; and every patch file
35
- // the settings' patchedDependencies name, by the path from the lockfile's
36
- // directory they name it by. Settings from anywhere else — another
37
- // .npmrc, the environment, the command line — are not read, and are taken
38
- // to be at their defaults.
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 given, and be a
45
- // project those globs take; and every project pnpm would find has to be
46
- // given, which buildPnpmTree cannot check, as it is not given the
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 `vfs` given, and only where the directory is under
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, which are followed here alone:
72
- // a directory with a .npmignore or .gitignore, a package.json with `files`
73
- // or bundled dependencies, or a link in it, is refused. pnpm hardlinks
74
- // those files from the directory into each snapshot of the package, so a
75
- // file linking a bin makes executable is made so in every snapshot and in
76
- // the directory, which is not written here; a CRLF `#!` line it rewrites
77
- // is rewritten as a file of that snapshot's own. One by `file:` to a
78
- // tarball is refused, and so is a `file:` dependency no override names.
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 holds the tree alone. A Vfs
102
- // that holds a node_modules anywhere, or on macOS a name that is one
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. With it given, a
109
- // directory the tree links to that is no project, and is under the
110
- // lockfile's, has to be there with a package.json, whose bins are read as
111
- // pnpm reads them; nothing outside node_modules is written, though pnpm
112
- // 10 makes the files a linked directory's bins run executable too.
113
- // Without it, or outside the lockfile's directory, such a directory's
114
- // bins are not known, and neither are those of a project that has them
115
- // by the files of its directories.bin: where one could win a command a
116
- // package's file is linked by, and so decide whether pnpm fixes that
117
- // file, and fixing it would change it, the tree is refused.
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 11, and no other
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, a
219
- // setting this does not know or does not build for, overrides pnpm cannot
220
- // read, a lockfile not resolved with these settings, a package from
221
- // anywhere but the registry, a pnpmfile, package extensions, an injected
222
- // dependency, a lockfile not up to date with a package.json, another
223
- // package manager, a runtime to download, two projects of one name, a
224
- // patch that does not hash or apply, a check above that fails, text
225
- // that is not well-formed where it is hashed, a patch that would change a
226
- // bin's file between two times pnpm links it, a file whose mode would turn
227
- // on the order a directory is read in — each is refused with a
228
- // DeptreeError, a LockfileError or a YamlError that says where. A
229
- // TypeError is thrown for options of the wrong type.
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 for the workspace at the
233
- // root of `vfs`, by which buildPnpmTree takes their package.json: `.`, the
234
- // root, first, then in order each directory whose package.json a glob of
235
- // `workspace`'s `packages` takes, as pnpm `host.pnpm` finds them.
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
- // `vfs` is a Vfs, or anything with its readdir, lstat and stat, such as a
238
- // view of a directory on disk, by paths from `/`; nothing is written. Of
239
- // it, only the directories pnpm walks into are read: none under
240
- // node_modules or bower_components, and none whose name starts with a dot
241
- // unless a glob spells it there. A manifest is a file, or a link to one; a
242
- // link that leads nowhere, or to a directory, is none, as pnpm has it.
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; and a glob
253
- // buildPnpmTree refuses, or a pnpm not 10.x or 11.x.
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
- workspace?: string
256
- host: Pick<PnpmHost, 'pnpm'>
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 undefined for the call as
264
- // a whole; the message leads with it. `cause` is what a package beneath
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. Nothing here touches a filesystem; tarballs come
4
- // through @preventive/upstream, and whatever cache it keeps is its own.
5
- export { buildPnpmTree, findPnpmProjects } from './src/pnpm/tree.js'
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, nothing is cached and nothing is written.
10
+ // unset, it keeps no cache of its own, and writes nothing.
9
11
  export { setCacheDir } from '@preventive/upstream/npm.js'
10
- // What the inputs beneath are refused with: the lockfile, and the YAML of
11
- // it and of pnpm-workspace.yaml.
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'