@preventive/deptree 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/bin/compare.js +10 -21
  2. package/bin/deptree.js +5 -10
  3. package/cargo.d.ts +139 -195
  4. package/cargo.js +0 -2
  5. package/cocoapods.d.ts +211 -381
  6. package/cocoapods.js +0 -2
  7. package/npm.d.ts +245 -369
  8. package/npm.js +4 -6
  9. package/package.json +1 -1
  10. package/pnpm.d.ts +258 -667
  11. package/pnpm.js +2 -4
  12. package/soldeer.d.ts +144 -215
  13. package/soldeer.js +0 -2
  14. package/src/cargo/crate.js +21 -46
  15. package/src/cargo/inputs.js +5 -8
  16. package/src/cargo/members.js +6 -12
  17. package/src/cargo/registry.js +5 -9
  18. package/src/cargo/tree.js +8 -13
  19. package/src/cargo/workspace.js +13 -26
  20. package/src/cocoapods/archive.js +19 -40
  21. package/src/cocoapods/clean.js +21 -45
  22. package/src/cocoapods/fnmatch.js +12 -27
  23. package/src/cocoapods/inputs.js +5 -11
  24. package/src/cocoapods/install.js +11 -24
  25. package/src/cocoapods/podspec.js +19 -40
  26. package/src/cocoapods/podtree.js +10 -19
  27. package/src/cocoapods/source.js +13 -30
  28. package/src/cocoapods/tree.js +17 -39
  29. package/src/cocoapods/unicode.js +3 -9
  30. package/src/github.js +12 -24
  31. package/src/glob.js +2 -4
  32. package/src/lazy.js +2 -4
  33. package/src/manifest.js +2 -4
  34. package/src/matcher.js +3 -5
  35. package/src/mount.js +7 -14
  36. package/src/npm/bins.js +3 -5
  37. package/src/npm/compat.js +3 -5
  38. package/src/npm/package.js +13 -14
  39. package/src/npm/ratio.js +3 -5
  40. package/src/npm/settings.js +3 -5
  41. package/src/npm/tree.js +6 -11
  42. package/src/npm/versions.js +3 -4
  43. package/src/npmrc.js +2 -4
  44. package/src/patch.js +8 -14
  45. package/src/pnpm/bins.js +16 -42
  46. package/src/pnpm/filename.js +2 -4
  47. package/src/pnpm/gitignore.js +2 -4
  48. package/src/pnpm/glob.js +3 -5
  49. package/src/pnpm/hoist.js +8 -16
  50. package/src/pnpm/hoisted.js +15 -44
  51. package/src/pnpm/hook.js +2 -4
  52. package/src/pnpm/install.js +5 -10
  53. package/src/pnpm/lazy.js +8 -23
  54. package/src/pnpm/local.js +2 -4
  55. package/src/pnpm/minimatch.js +8 -15
  56. package/src/pnpm/nm-hoist.js +5 -11
  57. package/src/pnpm/npm-packlist.js +3 -6
  58. package/src/pnpm/overrides.js +2 -4
  59. package/src/pnpm/package.js +10 -16
  60. package/src/pnpm/packlist.js +3 -7
  61. package/src/pnpm/patches.js +3 -4
  62. package/src/pnpm/production.js +9 -28
  63. package/src/pnpm/projects.js +2 -6
  64. package/src/pnpm/readers.js +2 -4
  65. package/src/pnpm/settings.js +2 -5
  66. package/src/pnpm/tree.js +14 -37
  67. package/src/pnpm/workspace.js +4 -7
  68. package/src/pnpm/write.js +1 -1
  69. package/src/soldeer/config.js +5 -9
  70. package/src/soldeer/tree.js +2 -4
  71. package/src/soldeer/zip.js +8 -17
  72. package/src/tarball.js +12 -29
  73. package/src/yarn1/compat.js +2 -4
  74. package/src/yarn1/hoist.js +3 -8
  75. package/src/yarn1/package.js +12 -23
  76. package/src/yarn1/resolve.js +6 -11
  77. package/src/yarn1/settings.js +5 -10
  78. package/src/yarn1/tree.js +9 -18
  79. package/yarn1.d.ts +203 -360
  80. package/yarn1.js +4 -6
package/yarn1.d.ts CHANGED
@@ -1,390 +1,233 @@
1
- import type { CacheOptions, PackageBugs, PackageRepository } from '@preventive/upstream/npm.js'
2
- import type { NodeType, Vfs } from '@preventive/vfs'
1
+ /**
2
+ * A node_modules tree built in memory from a yarn.lock, as yarn 1.22 installs it with its node_modules
3
+ * linker
4
+ *
5
+ * ```js
6
+ * import { buildYarn1Tree, findYarn1Workspaces } from '@preventive/deptree/yarn1.js'
7
+ * ```
8
+ *
9
+ * Nothing is left to a guess: a lockfile the reader refuses, a setting not followed, a package from
10
+ * anywhere but npm's registry or a directory of the project, bundled dependencies, another package
11
+ * manager, or a check that fails is refused with a DeptreeError or a LockfileError saying where. Options of
12
+ * the wrong type throw a TypeError.
13
+ *
14
+ * @module @preventive/deptree/yarn1.js
15
+ */
3
16
 
4
- export { LockfileError } from '@preventive/lockfile/yarn1.js'
17
+ import type { CacheOptions, PackageBugs, PackageRepository } from '@preventive/upstream/npm.js';
18
+ import type { NodeType, Vfs } from '@preventive/vfs';
5
19
 
6
- // Where @preventive/upstream caches what it fetches, tarballs among them.
7
- // Tarballs are fetched through it, and that is the one place anything here
8
- // touches a filesystem. Before the network, it takes a tarball from npm's
9
- // cache -- under $npm_config_cache, or ~/.npm -- from ~/.audit/cache/tgz, or
10
- // from its own default cache directory or stasis's, where one there has the
11
- // lockfile's integrity, and writes none of them; then from its own cache,
12
- // where one is set, which is where it writes each tarball it fetches:
13
- // setCacheDir() sets the default one, and setCacheDir(false) unsets it.
14
- // Unset, which it is until set, it writes nothing. yarn's own cache is
15
- // never read. The project is read only through the view given as
16
- // `project`, and the tree built in a Vfs.
17
- export { setCacheDir } from '@preventive/upstream/npm.js'
20
+ export { LockfileError } from '@preventive/lockfile/yarn1.js';
18
21
 
19
- // The machine yarn would install on, which a tree depends on: `yarn` is
20
- // the version that installs, and has to be a 1.22.x; left out, it is the
21
- // one the root package.json's packageManager pins, which corepack runs,
22
- // and has to be given where that pins none, and to be that one where it
23
- // does. `node` is the Node yarn runs on, an exact version, or left out
24
- // for one unknown, which every range for Node, and for what Node reports
25
- // in process.versions, takes; `os` and `cpu`
26
- // as Node names them -- `linux`, `x64`. Windows is refused: yarn links bins
27
- // there with shims, and workspaces with junctions.
28
- // A package whose os, cpu or engines the machine does not take is left
29
- // out where it is optional, and refused where it is not, as yarn fails
30
- // on it; so is the root project. ignore-platform and ignore-engines, where
31
- // the settings set them, have neither checked. Of two references of one
32
- // package, as a tag or an alias asked for twice makes, yarn fetches and
33
- // reads the first alone, and the second has its lockfile entry for a
34
- // package.json: no os, cpu, engines, peers or bins, as yarn has it, so it
35
- // is never left out, and links no bins. Of engines, `node` (and `iojs`, which
36
- // yarn takes for it) and `yarn` are checked as yarn checks them, and one
37
- // yarn has no version for is passed over, as yarn passes over it; one any
38
- // Node reports in process.versions, such as `v8` or `merve`, which yarn
39
- // would check against the Node it runs on, is refused, but for a Node
40
- // unknown.
22
+ /**
23
+ * Sets where @preventive/upstream caches what it fetches, which is unset until set
24
+ *
25
+ * Tarballs are fetched through it, the one place anything here touches a filesystem: before the network
26
+ * it reads npm's cache, ~/.audit/cache/tgz and its own or stasis's default directory for one of the
27
+ * lockfile's integrity, writing none of them, then this one, which it writes each tarball it fetches to.
28
+ * `setCacheDir()` sets the default directory and `setCacheDir(false)` unsets it. yarn's cache is never read.
29
+ */
30
+ export { setCacheDir } from '@preventive/upstream/npm.js';
31
+
32
+ /**
33
+ * The machine yarn would install on; Windows is refused, as yarn links bins there with shims
34
+ *
35
+ * A package whose os, cpu or engines the host does not take is left out where optional and refused where
36
+ * not, as yarn fails on it; so is the root. Engines `node` (and `iojs`) and `yarn` are checked as yarn
37
+ * checks them and one yarn has no version for is passed over; one Node reports in process.versions, such
38
+ * as `v8`, is refused but for a Node unknown. ignore-engines and ignore-platform, set, skip the checks.
39
+ * Of two references yarn's cache keeps as one, as a tag asked for twice makes, the second has its lockfile
40
+ * entry for package.json, so it is never left out and links no bins.
41
+ */
41
42
  export interface Yarn1Host {
42
- yarn?: string
43
- node?: string
44
- os: string
45
- cpu: string
43
+ /** The yarn that installs, a 1.22.x (default: what the root's packageManager pins, which it has to be) */
44
+ yarn?: string;
45
+ /** The Node yarn runs on, exact, or left out for one unknown, which takes every range */
46
+ node?: string;
47
+ /** As Node names it, such as `linux` */
48
+ os: string;
49
+ /** As Node names it, such as `x64` */
50
+ cpu: string;
46
51
  }
47
52
 
48
- // A view of the lockfile's directory, by paths from `/`: a Vfs, or
49
- // anything with its readdir, lstat, stat and readFile, such as one of a
50
- // directory on disk, of which only this is read: the names in a
51
- // directory; what a path is, `file`, `directory` or `symlink`, and its
52
- // mode, with lstat, and what it leads to with stat; and a file's bytes.
53
- // Each throws an error whose `code` is ENOENT, ENOTDIR or ELOOP for a path
54
- // that leads nowhere. Nothing is written to it.
53
+ /**
54
+ * A view of the lockfile's directory by paths from `/`, such as a Vfs; nothing is written to it
55
+ *
56
+ * Each method throws an error whose `code` is ENOENT, ENOTDIR or ELOOP for a path that leads nowhere.
57
+ */
55
58
  export interface Yarn1Project {
56
- readdir(path: string): string[]
57
- lstat(path: string): { type: NodeType, mode: number }
58
- stat(path: string): { type: NodeType }
59
- readFile(path: string): Uint8Array
59
+ readdir(path: string): string[];
60
+ /** What a path is, and its mode */
61
+ lstat(path: string): { type: NodeType; mode: number };
62
+ /** What a path leads to */
63
+ stat(path: string): { type: NodeType };
64
+ readFile(path: string): Uint8Array;
60
65
  }
61
66
 
62
- // The files an install reads: yarn.lock; the package.json of the root and
63
- // of every workspace; and the .yarnrc and the .npmrc, where there are any.
64
- //
65
- // With `lockfile`, they are given as text: `manifests` by the project's
66
- // directory relative to the lockfile's (`.` for the root, then each
67
- // workspace's, as findYarn1Workspaces lists them: a directory under the
68
- // lockfile's, with no `.`, `..` or empty segment). Every workspace yarn
69
- // would find has to be given, which buildYarn1Tree cannot check where it
70
- // is given them, as it is not given the directories; and the lockfile
71
- // reader refuses a manifest of any directory the root's `workspaces` do
72
- // not take.
73
- //
74
- // Without it, they are read from `project`, as yarn reads them there, and
75
- // none of them may be given: yarn.lock, which has to be there; the root
76
- // package.json, which has to be there too; the package.json of every
77
- // directory the root's `workspaces` globs take, as yarn globs for them,
78
- // outside node_modules; the .yarnrc and the .npmrc. Each is read as UTF-8,
79
- // and refused where it is not; a byte order mark is dropped, as yarn drops
80
- // it. A refusal names each as it would given: `manifests["packages/x"]`.
81
- // Refused there: a link anywhere the globs reach, which node-glob follows
82
- // or not by where it is; a node_modules the globs would take, whose
83
- // package.json yarn would read as a workspace; a yarn.json, which yarn
84
- // reads as a manifest too; and a .yarnrc.yml, whose yarnPath yarn 1.22
85
- // runs in its stead.
86
- //
87
- // Settings from anywhere else -- a .yarnrc or .npmrc above the project or
88
- // in the home directory, the environment, the command line -- are not read,
89
- // and are taken to be at their defaults.
90
- //
91
- // Of the .yarnrc and the .npmrc, as yarn 1.22 reads them: yarn reads an
92
- // option by its name from the .yarnrc, or else from the .npmrc, and takes
93
- // a `--` line of the .yarnrc as a flag on its command line. Two settings
94
- // are followed as yarn follows them: ignore-engines, by the flag
95
- // `--ignore-engines true` or `--install.ignore-engines true`, or by the
96
- // option where it is truthy as yarn reads it -- a quoted "false" is; and
97
- // ignore-platform, by its flag alone, as yarn does not act on the option.
98
- // Options yarn reads that change what it installs are refused --
99
- // ignore-optional, production, bin-links, workspaces-experimental and the
100
- // like -- and so is yarn-path, which has another yarn run, and
101
- // global-folder, which, where it is the project's own directory, has yarn
102
- // read its package.json files otherwise; any other option
103
- // is passed over, as yarn reads it only for where it fetches from, how,
104
- // and what it keeps, which the tree is held to the lockfile's integrities
105
- // against whatever serves it, or for no install at all, as with most of
106
- // npm's own. A flag is passed over where it does not change the tree --
107
- // --registry, --frozen-lockfile, --network-timeout and the like -- and
108
- // refused where it may or is not known here: --production, --flat,
109
- // --modules-folder, --ignore-optional, --no-bin-links, --no-lockfile,
110
- // which has yarn read no yarn.lock, --global-folder, --cwd and the rest. A .yarnrc line indented under another, which yarn reads into it,
111
- // is refused too, and so is a value of those two followed that is not true
112
- // or false, or for the .yarnrc's option a quoted string.
113
- //
114
- // A workspace project is the root, marked private, and every directory its
115
- // `workspaces` globs take -- `*`, `?` and `**`, as the lockfile reader takes
116
- // them -- with a package.json that has a name and a version. `nohoist`,
117
- // Plug'n'Play, and a root package.json's `flat` are refused.
118
- //
119
- // `vfs` is a Vfs to mount the tree into, at its root, which is taken to
120
- // be the lockfile's directory, beside whatever it holds, such as the
121
- // projects themselves -- it may be `project` too; without one, a new Vfs
122
- // holds the tree alone. Nothing the tree is built from is read from it. A
123
- // Vfs that holds a node_modules anywhere, or on macOS a name that is one
124
- // there, is refused before anything is fetched: kept beside the tree, Node
125
- // would read it as the tree's, and removed, it would be the caller's lost.
126
- // Nothing there is written over: each directory the tree has is one there
127
- // or is made, and every file and link is written where nothing is. The
128
- // tree is built, and held to every check below, before any of it is
129
- // written, so a refusal leaves the Vfs as it was.
130
- //
131
- // `metadata`, true unless given false, has each registry package's version
132
- // document asked for beside its tarball, through getMeta of
133
- // @preventive/upstream given the lockfile's dist: the one `cache` keeps,
134
- // where its dist is that one, else the registry's, a request for each name
135
- // and version. Its dist has to be the lockfile's, the tarball
136
- // the registry's own URL and the integrity the lockfile's sha512, compared
137
- // as text, with nothing hashed again, as the lockfile copies the
138
- // registry's; and its gitHead, repository, homepage and bugs are the
139
- // package's. False fetches none, and gives none of them, but for a package
140
- // whose sha512 the lockfile does not record, whose document is fetched for
141
- // the registry's either way, and gives them.
142
- //
143
- // `cache` is where each registry package's tarball and version document
144
- // are kept, as @preventive/upstream's CacheOptions take it: in setCacheDir's
145
- // cache where it is left out; in a store of the caller's, with `read` and
146
- // `write`, in place of it; or with false, nowhere, though setCacheDir's
147
- // cache is read all the same. Other tools' caches are read for tarballs
148
- // whatever it is. A TypeError is thrown for anything else.
149
- //
150
- // `sizeEstimateOnly` and `lazy`, which buildPnpmTree and buildNpmTree take
151
- // for a tree's directories and links alone, are not taken, as yarn hoists
152
- // and leaves out packages by what their package.json says, which only their
153
- // tarballs hold: a TypeError is thrown for either given true.
154
- //
155
- // `production`, false unless given true, builds the tree `yarn install
156
- // --production` makes, as below.
157
- //
158
- // The two ways the files come, one or the other: given, with `lockfile`
159
- // and `manifests`; or read, with `project` and none of them. `project`
160
- // given with `lockfile` is read only to tell whether a tag a top-level
161
- // dependency asks for is a directory, which yarn would install instead.
162
- export type Yarn1TreeOptions = Yarn1TreeGiven | Yarn1TreeRead
67
+ /**
68
+ * The files an install reads, either given as text or read from `project`
69
+ *
70
+ * Read, they are yarn.lock and the root's package.json, which have to be there; the package.json of each
71
+ * directory the root's `workspaces` globs take, outside node_modules; the .yarnrc and the .npmrc. Each is
72
+ * UTF-8, a byte order mark dropped, and a refusal names it as it would given: `manifests["packages/x"]`.
73
+ * Refused there: a link the globs reach, a node_modules they would take, a yarn.json, a .yarnrc.yml.
74
+ * Settings from anywhere else are taken at their defaults.
75
+ *
76
+ * Of the .yarnrc and .npmrc, as yarn reads them, an option of the .yarnrc over the .npmrc's and a `--`
77
+ * line of the .yarnrc as a flag: ignore-engines is followed, by its flag or by the option where truthy as
78
+ * yarn reads it, and ignore-platform by its flag alone. One that may change what yarn installs is refused,
79
+ * such as production, ignore-optional, bin-links, yarn-path, global-folder, --flat or --modules-folder, and
80
+ * so is an indented .yarnrc line; one for where and how yarn fetches, or no install, is passed over.
81
+ *
82
+ * A workspace project is the root, marked private, and each directory its `workspaces` take (`*`, `?`,
83
+ * `**`) with a package.json naming a name and a version; nohoist, Plug'n'Play and `flat` are refused.
84
+ */
85
+ export type Yarn1TreeOptions = Yarn1TreeGiven | Yarn1TreeRead;
86
+
87
+ interface Yarn1TreeShared {
88
+ host: Yarn1Host;
89
+ /**
90
+ * A Vfs to mount the tree into, at the lockfile's directory, beside what it holds (default: a new one)
91
+ *
92
+ * One holding a node_modules, or on macOS a name that is one there, is refused before anything is
93
+ * fetched. Nothing there is written over, and the tree is built and checked first, so a refusal leaves
94
+ * it as it was.
95
+ */
96
+ vfs?: Vfs;
97
+ /**
98
+ * Fetch each registry package's version document by @preventive/upstream's getMeta, its dist held to the
99
+ * lockfile's, for `commit`, `repository`, `homepage` and `bugs` (default: true)
100
+ *
101
+ * One whose sha512 the lockfile does not record has its document fetched either way.
102
+ */
103
+ metadata?: boolean;
104
+ /** Where tarballs and version documents are kept, as @preventive/upstream's CacheOptions take it */
105
+ cache?: CacheOptions['cache'];
106
+ /**
107
+ * The tree `--production` makes (default: false)
108
+ *
109
+ * No workspace's devDependencies are asked for. The root's are resolved, fetched, checked and hoisted all
110
+ * the same, taking the places they hoist to, but each copy is installed only where something else needs it.
111
+ */
112
+ production?: boolean;
113
+ }
163
114
 
164
- export interface Yarn1TreeGiven {
165
- lockfile: string
166
- manifests: Record<string, string> | Map<string, string>
167
- yarnrc?: string
168
- npmrc?: string
169
- project?: Yarn1Project
170
- host: Yarn1Host
171
- vfs?: Vfs
172
- metadata?: boolean
173
- cache?: CacheOptions['cache']
174
- production?: boolean
115
+ export interface Yarn1TreeGiven extends Yarn1TreeShared {
116
+ lockfile: string;
117
+ /**
118
+ * Each project's package.json by its directory from the lockfile's, `.` for the root, as
119
+ * findYarn1Workspaces lists them; every workspace yarn would find has to be among them
120
+ */
121
+ manifests: Record<string, string> | Map<string, string>;
122
+ yarnrc?: string;
123
+ npmrc?: string;
124
+ /** Read only to tell whether a tag a top-level dependency asks for is a directory, which yarn would install */
125
+ project?: Yarn1Project;
175
126
  }
176
127
 
177
- export interface Yarn1TreeRead {
178
- lockfile?: undefined
179
- manifests?: undefined
180
- yarnrc?: undefined
181
- npmrc?: undefined
182
- project: Yarn1Project
183
- host: Yarn1Host
184
- vfs?: Vfs
185
- metadata?: boolean
186
- cache?: CacheOptions['cache']
187
- production?: boolean
128
+ export interface Yarn1TreeRead extends Yarn1TreeShared {
129
+ lockfile?: undefined;
130
+ manifests?: undefined;
131
+ yarnrc?: undefined;
132
+ npmrc?: undefined;
133
+ project: Yarn1Project;
188
134
  }
189
135
 
190
- // What buildYarn1Tree counts, all of it plain numbers: `packages` the
191
- // packages yarn resolves, each fetched from the registry or read from a
192
- // directory of the project; `skipped` the optional
193
- // ones left out, as the host cannot run them; `installed` the copies of
194
- // them in the tree; `files` and `bytes` what is written; `links` the
195
- // workspaces linked.
136
+ /** What buildYarn1Tree counts */
196
137
  export interface Yarn1TreeStats {
197
- packages: number
198
- skipped: number
199
- installed: number
200
- files: number
201
- bytes: number
202
- links: number
138
+ /** The packages yarn resolves, each fetched from the registry or read from a directory of the project */
139
+ packages: number;
140
+ /** The optional ones left out, as the host cannot run them */
141
+ skipped: number;
142
+ /** Their copies in the tree */
143
+ installed: number;
144
+ /** Written */
145
+ files: number;
146
+ /** Written */
147
+ bytes: number;
148
+ /** The workspaces linked */
149
+ links: number;
203
150
  }
204
151
 
205
- // A copy of a package in the tree, as an SBOM would list it: `path` is
206
- // where its files really are, from the lockfile's directory, which is `/`
207
- // of the Vfs -- node_modules/<alias>, or beneath a workspace, in that
208
- // workspace's own node_modules. `name` and `version` are the package's
209
- // own, which its package.json is held to, whatever alias it is installed
210
- // as; `integrity` the sha512 its tarball is held to, for a registry
211
- // package, and `directory` the directory of the project it is copied
212
- // from, for one by `file:`, in place of an integrity. For a registry
213
- // package alone, where its version document is fetched: `commit` is its
214
- // gitHead, where that is a full commit id, the commit npm read off the
215
- // checkout it published from; `repository`, `homepage` and `bugs` the
216
- // document's, as getMeta of @preventive/upstream reads them; each left out
217
- // where there is none, and all of it the publisher's word, held to no
218
- // repository. `dev` is
219
- // whether dev dependencies alone reach this copy, the root's and the
220
- // workspaces' devDependencies: nothing else does, each dependency, and
221
- // each peer yarn finds, looked for from where what asks for it is, as Node
222
- // finds it and yarn marks what an install requires, past what the host
223
- // cannot run. Two copies of one package may differ: one beneath a
224
- // devDependency that only it needs is dev. With `production`, none is.
225
- // `optional` is whether optional dependencies alone reach this copy, so.
152
+ /** A copy of a package in the tree, as an SBOM would list it */
226
153
  export interface Yarn1Installed {
227
- path: string
228
- name: string
229
- version: string
230
- integrity?: string
231
- directory?: string
232
- commit?: string
233
- repository?: string | PackageRepository
234
- homepage?: string
235
- bugs?: string | PackageBugs
236
- dev: boolean
237
- optional: boolean
154
+ /** Where its files are, from the lockfile's directory: node_modules/<alias>, or in a workspace's own */
155
+ path: string;
156
+ /** The package's own, whatever alias it is installed as */
157
+ name: string;
158
+ version: string;
159
+ /** The sha512 a registry package's tarball is held to */
160
+ integrity?: string;
161
+ /** The directory of the project a `file:` package is copied from */
162
+ directory?: string;
163
+ /** Its version document's gitHead, where fetched and a full commit id: the publisher's word */
164
+ commit?: string;
165
+ /** Its version document's, as getMeta reads it, where fetched; held to no repository */
166
+ repository?: string | PackageRepository;
167
+ homepage?: string;
168
+ bugs?: string | PackageBugs;
169
+ /** Whether only dev dependencies reach this copy, past what the host cannot run; none with `production` */
170
+ dev: boolean;
171
+ /** Whether only optional dependencies reach this copy */
172
+ optional: boolean;
238
173
  }
239
174
 
240
- // `vfs` is the one given, the tree mounted into it, or a new one.
241
- // `installed` is each copy in the tree, once for each path, by path in
242
- // the order of its code points, whatever the locale; a workspace, whose
243
- // files the tree does not hold, is not among them.
244
175
  export interface Yarn1Tree {
245
- vfs: Vfs
246
- stats: Yarn1TreeStats
247
- installed: Yarn1Installed[]
176
+ /** The Vfs given, the tree mounted into it, or a new one */
177
+ vfs: Vfs;
178
+ stats: Yarn1TreeStats;
179
+ /** Each copy once per path, by path in code point order; no workspace, whose files the tree does not hold */
180
+ installed: Yarn1Installed[];
248
181
  }
249
182
 
250
- // The node_modules tree `yarn install --frozen-lockfile --ignore-scripts`
251
- // makes, with `production` --production too, with host.yarn's node_modules
252
- // linker, into a project with no node_modules yet: rooted at the lockfile's
253
- // directory, each package's files copied where yarn hoists it, and each
254
- // workspace linked where yarn hoists it, by a relative link to its
255
- // directory, with what yarn hoists beneath it in that directory's own
256
- // node_modules. The tree holds node_modules and nothing else of the
257
- // projects.
258
- //
259
- // The lockfile is resolved as yarn resolves it, in yarn's order, which
260
- // decides where a package goes: the resolutions' patterns, then the root's
261
- // dependencies, devDependencies and optionalDependencies, then the
262
- // workspaces, each request with all it leads to before the next, and
263
- // beneath one every request at once, as yarn's resolver runs them; each
264
- // package's peers looked for along the shortest chain of names that asked
265
- // for it, as yarn looks for them; and the tree laid out as yarn's hoister
266
- // lays it out, quirks and all. A resolution applies to a dependency by its
267
- // path, as yarn applies it, and not to one of the root's own; it resolves
268
- // to a semver range, or to the registry's own tarball or a directory of
269
- // the project, as below.
270
- //
271
- // With `production`, as --production has yarn install it: no workspace's
272
- // devDependencies are asked for, nor their entries read; the root's are
273
- // asked for all the same, resolved, fetched, checked and hoisted as without
274
- // it, but marked ignored, as yarn marks them, so each copy is installed only
275
- // where something else needs it, with what it alone needs left out. So a
276
- // devDependency of the root still takes the place it is hoisted to, which a
277
- // version another package needs is kept from, as without it; and one the
278
- // host cannot run fails as it does without it, though the tree leaves it
279
- // out.
280
- //
281
- // Scripts are always ignored, as `--ignore-scripts` has yarn ignore them,
282
- // whatever the settings say. No .bin is written, nor yarn's own
283
- // .yarn-integrity; but each bin's target is made executable, chmod 755, in
284
- // every copy of its package, as yarn's fetcher makes it in its cache,
285
- // whether yarn links the bin or not. Linking makes no file of the tree
286
- // executable that the fetcher has not: a bin in its package's own
287
- // node_modules, where yarn installs its dependencies, is refused, as
288
- // linking it would make the file there executable, and so is a package
289
- // with bins and a .bin file, where yarn fails to make a directory for
290
- // them; a workspace's bins are its own files, which the tree does not
291
- // hold. Each file's mode is the tarball's, with
292
- // read for all added and a umask of 0o022 taken off, as yarn unpacks it;
293
- // .bin, .yarn-metadata.json and .yarn-tarball.tgz in a package are left
294
- // out, as yarn's copy leaves them out.
295
- //
296
- // The lockfile is held to what the lockfile reader holds it to, with the
297
- // manifests, and to what a frozen install holds it to: every pattern
298
- // asked for has its entry, and each entry a version in the range of its
299
- // pattern, as yarn would otherwise resolve the pattern anew, frozen or not.
300
- // The root package.json's packageManager, where it has one, has to be
301
- // `yarn@` host.yarn exactly, as corepack would run the one it names.
302
- //
303
- // And to more than yarn holds it to, where a lockfile yarn writes, or a
304
- // package the registry serves, always holds: each tarball gzipped, every
305
- // file under one directory, none in the package's own node_modules, where
306
- // yarn installs its dependencies, no link or device in it, and a
307
- // package.json for exactly its name and version; each with the sha512
308
- // integrity the lockfile records, and the sha1 each of its entries does,
309
- // fetched or not. yarn writes a sha1 integrity alone where the registry had
310
- // no sha512 for the version: taken only for one the registry says was
311
- // published before 2018-08-05T14:58:16.253Z, since when it has made one for
312
- // every version as it was published, and held to that sha1 and to the
313
- // registry's own sha512. On macOS, two names in one
314
- // directory that differ only in case or normalization are refused, as
315
- // they would be one name there.
316
- //
317
- // Packages come from npm's registry, or from a directory of the project.
318
- // A registry entry's `resolved` has to be the registry's own URL of its
319
- // tarball, exactly as npm spells it,
320
- // https://registry.npmjs.org/<name>/-/<base>-<version>.tgz (a `#` and the
321
- // sha1 after it aside), or that same URL on yarn's mirror,
322
- // https://registry.yarnpkg.com/, which is taken for npm's; it is fetched
323
- // from npm's through @preventive/upstream. Each is asked for by a semver
324
- // range, an `npm:` alias, or a tag -- the last only where the project is
325
- // given, and a directory of the project of that name is not there, which
326
- // yarn would install instead. A request of a tag waits on the filesystem,
327
- // which answers in no set order, and each it answers resolves all beneath
328
- // it before the next: where two or more wait at once, only where that
329
- // order changes nothing, as no two would add a package or a pattern under
330
- // one name, and no resolution applies or directory is read beneath them.
331
- //
332
- // Or by the registry's own tarball URL, either of those above (no `#`
333
- // after it): the entry yarn writes for one has no integrity, so its
334
- // tarball is held to the sha1 after the `#` of its `resolved` and to the
335
- // registry's own sha512. Or, by the root or as what a resolution resolves
336
- // to, by a directory of the project, `file:<path>` or a path starting
337
- // `./`, within the project and not its root; beneath another package,
338
- // where yarn reads it in an order not modelled here, only one read
339
- // already, as the workspaces' aggregator asks for the root's again, which
340
- // yarn takes the first's package for, but not where a tag waits on the
341
- // filesystem beside it. yarn copies a
342
- // directory whole, whatever package.json's `files` and an ignore file
343
- // say, each file's mode as it is, each bin's target made executable, and
344
- // the tree copies it so, read from `project`, which has to be given for
345
- // it: all but each `.bin`, .yarn-metadata.json and .yarn-tarball.tgz in
346
- // it, as yarn's copy passes them over, empty directories kept. yarn reads
347
- // a directory's package.json anew at every install, frozen or not, and
348
- // installs whatever its version and dependencies say; so it has to be of
349
- // the name and version its lockfile entry has, with the dependencies and
350
- // optionalDependencies the entry lists. Refused: a link, device or a
351
- // node_modules of its own in it, a mode beyond 0o777, a directory two
352
- // patterns ask for, which yarn copies as two packages, and a tarball on
353
- // the project's disk, which yarn takes for any path ending in .tgz.
354
- //
355
- // Ranges and versions are read with npm's own semver, borrowed from the
356
- // npm beside node as @preventive/upstream borrows it, or with its semver
357
- // peer where there is no npm, without either of which this throws. yarn
358
- // 1.22 reads them with the semver 5.5.0 it bundles, which reads alike all
359
- // but the edges of what a range may spell.
360
- //
361
- // Nothing is left to a guess: a lockfile the lockfile reader refuses, a
362
- // setting this does not know or does not build for, a package from
363
- // anywhere but those above -- git, another tarball URL, a tarball on disk,
364
- // a directory by `link:` -- a range that is none of those above, a package
365
- // with bundled dependencies, another package manager, a check above that
366
- // fails -- each is refused with a DeptreeError or a LockfileError that says
367
- // where. A TypeError is thrown for options of the wrong type.
368
- export function buildYarn1Tree(options: Yarn1TreeOptions): Promise<Yarn1Tree>
183
+ /**
184
+ * The node_modules tree `yarn install --frozen-lockfile --ignore-scripts` makes with host.yarn into a
185
+ * project with no node_modules yet
186
+ *
187
+ * Each package's files are copied where yarn hoists it, and each workspace linked where yarn hoists it by
188
+ * a relative link, with what is hoisted beneath it in its own node_modules; nothing else of the projects is
189
+ * in the tree. The lockfile is resolved in yarn's order (the resolutions, the root's lists, then the
190
+ * workspaces, each request with all beneath it), peers looked for along the shortest chain of names that
191
+ * asked, and the tree laid out as yarn's hoister lays it out, quirks and all.
192
+ *
193
+ * Scripts never run, and no .bin or .yarn-integrity is written, but each bin's target is made 0o755 in every
194
+ * copy, as yarn's fetcher makes it. Each file's mode is the tarball's with read for all and a 0o022 umask
195
+ * taken off; .bin, .yarn-metadata.json and .yarn-tarball.tgz are left out, as yarn's copy leaves them.
196
+ *
197
+ * Held to the lockfile reader's checks and a frozen install's: every pattern has its entry, in its range,
198
+ * and the root's packageManager, where set, is `yarn@` host.yarn. And to what yarn's lockfiles and the
199
+ * registry always hold: each tarball gzipped, under one directory, with nothing in its own node_modules, no
200
+ * link or device, a package.json of its name and version, the lockfile's sha512 and sha1. A sha1 alone is
201
+ * taken only for a version published before 2018-08-05T14:58:16.253Z, and held to the registry's sha512
202
+ * too. On macOS, two names in a directory differing only in case or normalization are refused.
203
+ *
204
+ * Packages come from npm's registry, by its own tarball URL or that on yarn's mirror, asked for by a semver
205
+ * range, an `npm:` alias, the tarball URL, or a tag where the project is given and has no directory of
206
+ * that name; or from a directory of the project by `file:` or `./`, read from `project`, copied whole as
207
+ * yarn copies it, and held to its lockfile entry's name, version and lists. Tags that wait on the
208
+ * filesystem at once, which answers in no set order, are refused where that order could change anything.
209
+ * Ranges are read with the semver of the npm beside node, as @preventive/upstream borrows it.
210
+ *
211
+ * @param options - The files, the host and where the tree goes; `sizeEstimateOnly` or `lazy` is a TypeError
212
+ * @returns The tree
213
+ */
214
+ export function buildYarn1Tree(options: Yarn1TreeOptions): Promise<Yarn1Tree>;
369
215
 
370
- // The directories of the projects yarn finds in `project`, by which
371
- // buildYarn1Tree takes their package.json given: `.`, the root, first,
372
- // then each directory with a package.json that a glob of the root's
373
- // `workspaces` takes, outside node_modules, as yarn finds them, and as
374
- // buildYarn1Tree reads them from a project. Refused as buildYarn1Tree
375
- // refuses it: a link where the globs reach, a node_modules they would
376
- // take, a yarn.json; and a root with no package.json.
377
216
  export interface Yarn1WorkspacesOptions {
378
- project: Yarn1Project
217
+ project: Yarn1Project;
379
218
  }
380
219
 
381
- export function findYarn1Workspaces(options: Yarn1WorkspacesOptions): string[]
220
+ /**
221
+ * The directories of the projects yarn finds in `project`, by which buildYarn1Tree takes their
222
+ * package.json given; refused as buildYarn1Tree refuses them, as is a root with no package.json
223
+ *
224
+ * @returns `.` first, then each directory with a package.json a glob of the root's `workspaces` takes
225
+ */
226
+ export function findYarn1Workspaces(options: Yarn1WorkspacesOptions): string[];
382
227
 
383
- // `where` is what a refusal is about -- `.yarnrc:3`, `manifests["."]`, a
384
- // package's pattern -- or undefined for the call as a whole; the message
385
- // leads with it. `cause` is what a package beneath refused with, where one
386
- // did.
228
+ /** A refusal; `cause` is what a package beneath refused with, where one did */
387
229
  export class DeptreeError extends Error {
388
- constructor(detail: string, where?: string, options?: { cause?: unknown })
389
- where: string | undefined
230
+ constructor(detail: string, where?: string, options?: { cause?: unknown });
231
+ /** What it is about, which the message leads with (`.yarnrc:3`, `manifests["."]`, a pattern), or undefined */
232
+ where: string | undefined;
390
233
  }