@preventive/deptree 1.0.0-alpha.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/compare.js +123 -0
- package/bin/deptree.js +217 -0
- package/bin/npmrc.js +21 -0
- package/cargo.d.ts +221 -0
- package/cargo.js +6 -0
- package/npm.d.ts +87 -17
- package/package.json +26 -6
- package/pnpm.d.ts +102 -28
- package/soldeer.d.ts +36 -33
- package/src/cargo/crate.js +183 -0
- package/src/cargo/inputs.js +81 -0
- package/src/cargo/members.js +90 -0
- package/src/cargo/registry.js +65 -0
- package/src/cargo/tree.js +125 -0
- package/src/cargo/workspace.js +177 -0
- package/src/concurrent.js +9 -0
- package/src/error.js +4 -2
- package/src/hash.js +14 -30
- package/src/manifest.js +1 -1
- package/src/matcher.js +1 -1
- package/src/mount.js +10 -0
- package/src/npm/package.js +20 -5
- package/src/npm/tree.js +25 -10
- package/src/patch.js +2 -3
- package/src/pnpm/gitignore.js +2 -3
- package/src/pnpm/hoisted.js +15 -0
- package/src/pnpm/package.js +11 -5
- package/src/pnpm/packlist.js +2 -2
- package/src/pnpm/tree.js +53 -27
- package/src/project.js +4 -5
- package/src/soldeer/config.js +6 -1
- package/src/soldeer/git.js +16 -1
- package/src/soldeer/tree.js +6 -12
- package/src/soldeer/zip.js +3 -4
- package/src/tarball.js +53 -38
- package/src/yarn1/package.js +51 -6
- package/src/yarn1/resolve.js +58 -11
- package/src/yarn1/tree.js +27 -15
- package/yarn1.d.ts +69 -26
package/src/yarn1/resolve.js
CHANGED
|
@@ -131,6 +131,11 @@ class Resolver {
|
|
|
131
131
|
return this.rules.find((rule) => rule.name === name && matchesGlob(rule.glob, path))
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// The package a request of `name` and `range` finds resolved already.
|
|
135
|
+
resolvedOf(name, range, info) {
|
|
136
|
+
return info.kind === 'directory' ? this.copyOf(name, info.dir) : this.exactMatch(name, validRange(range) ? info.version : range)
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
exactMatch(name, version) {
|
|
135
140
|
return this.byName.get(name)?.map((pattern) => this.patterns.get(pattern)).find((ref) => ref.version === version)
|
|
136
141
|
}
|
|
@@ -141,8 +146,7 @@ class Resolver {
|
|
|
141
146
|
// the last of which its pattern names.
|
|
142
147
|
check(request, info) {
|
|
143
148
|
const { name, range } = splitPattern(request.pattern)
|
|
144
|
-
|
|
145
|
-
if (found !== undefined) {
|
|
149
|
+
if (this.resolvedOf(name, range, info) !== undefined) {
|
|
146
150
|
this.delayed.push(request)
|
|
147
151
|
return []
|
|
148
152
|
}
|
|
@@ -187,17 +191,60 @@ class Resolver {
|
|
|
187
191
|
return { request, info, left: info.tag ? Infinity : TURNS[info.kind] }
|
|
188
192
|
}
|
|
189
193
|
|
|
194
|
+
// The names a request would add a package or a pattern under, through all
|
|
195
|
+
// it would resolve that is not resolved already; undefined where a
|
|
196
|
+
// resolution or a directory may come in, or something is refused.
|
|
197
|
+
namesOf(request) {
|
|
198
|
+
const names = new Set()
|
|
199
|
+
const seen = new Set()
|
|
200
|
+
const queue = [request]
|
|
201
|
+
try {
|
|
202
|
+
while (queue.length > 0) {
|
|
203
|
+
const next = queue.pop()
|
|
204
|
+
if (seen.has(next.pattern)) continue
|
|
205
|
+
seen.add(next.pattern)
|
|
206
|
+
const { name, range } = splitPattern(next.pattern)
|
|
207
|
+
if (this.rules.some((rule) => rule.name === name)) return undefined
|
|
208
|
+
const info = this.infoOf(next)
|
|
209
|
+
const deps = asked(info, quote(next.pattern))
|
|
210
|
+
if (info.kind === 'directory') return undefined
|
|
211
|
+
names.add(name).add(info.name)
|
|
212
|
+
if (this.resolvedOf(name, range, info) === undefined) queue.push(...deps)
|
|
213
|
+
}
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (error instanceof DeptreeError) return undefined
|
|
216
|
+
throw error
|
|
217
|
+
}
|
|
218
|
+
return names
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// A tag waits on the filesystem, and each it answers resolves all beneath
|
|
222
|
+
// it before the next: in an order not set, which changes nothing where no
|
|
223
|
+
// two would add under one name, and no resolution or directory comes in.
|
|
224
|
+
apart(waiting) {
|
|
225
|
+
if (this.late.length > 0) return false
|
|
226
|
+
const taken = new Set()
|
|
227
|
+
for (const { request } of waiting) {
|
|
228
|
+
const names = this.namesOf(request)
|
|
229
|
+
if (names === undefined || !names.isDisjointFrom(taken)) return false
|
|
230
|
+
for (const name of names) taken.add(name)
|
|
231
|
+
}
|
|
232
|
+
return true
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Where none is a directory of the project, the first goes on.
|
|
190
236
|
answer(waiting) {
|
|
191
237
|
const reading = [...waiting.map(({ request }) => request), ...this.late]
|
|
192
|
-
if (reading.length > 1) throw new DeptreeError(`yarn resolves these in the order the filesystem answers it, which is not set: ${reading.map(({ pattern }) => quote(pattern)).join(', ')}`)
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
238
|
+
if (reading.length > 1 && !this.apart(waiting)) throw new DeptreeError(`yarn resolves these in the order the filesystem answers it, which is not set: ${reading.map(({ pattern }) => quote(pattern)).join(', ')}`)
|
|
239
|
+
for (const { request } of waiting) {
|
|
240
|
+
const where = quote(request.pattern)
|
|
241
|
+
const { range } = splitPattern(request.pattern)
|
|
242
|
+
const found = this.isDirectory(range)
|
|
243
|
+
if (found === undefined) throw new DeptreeError(`yarn installs the directory ${quote(range)} for it where the project has one, which is known only with the project read`, where)
|
|
244
|
+
if (found) throw new DeptreeError(`yarn installs the directory ${quote(range)} for it, which is not supported`, where)
|
|
245
|
+
}
|
|
246
|
+
waiting[0].left = 1
|
|
247
|
+
return waiting
|
|
201
248
|
}
|
|
202
249
|
|
|
203
250
|
// A microtask turn: the requests a check makes start where it stood.
|
package/src/yarn1/tree.js
CHANGED
|
@@ -10,12 +10,13 @@ import { eachConcurrently } from '../concurrent.js'
|
|
|
10
10
|
import { DeptreeError, quote } from '../error.js'
|
|
11
11
|
import { checkNoModules, isInside, makeDirs, mount, writeFiles, writeLink } from '../mount.js'
|
|
12
12
|
import { typeOf } from '../project.js'
|
|
13
|
+
import { fetchingOf } from '../tarball.js'
|
|
13
14
|
import { checkBinLinks } from './bins.js'
|
|
14
15
|
import { incompatibility } from './compat.js'
|
|
15
16
|
import { Hoister } from './hoist.js'
|
|
16
17
|
import { checkHost, inputsOf } from './inputs.js'
|
|
17
18
|
import { checkRoot, fixLists } from './manifest.js'
|
|
18
|
-
import { fetchYarnPackage, readYarnDirectory, registryTarball } from './package.js'
|
|
19
|
+
import { checkSha1, checkShared, fetchYarnPackage, readYarnDirectory, registryTarball } from './package.js'
|
|
19
20
|
import { resolvePeers } from './peers.js'
|
|
20
21
|
import { AGGREGATOR, aggregatorOf, rulesOf, topRequests, workspacesOf } from './requests.js'
|
|
21
22
|
import { resolve, splitPattern } from './resolve.js'
|
|
@@ -31,12 +32,18 @@ function fetchedName(ref) {
|
|
|
31
32
|
return range.startsWith('npm:') ? splitPattern(range.slice(4)).name : ref.name
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// The first of each place in `first` is fetched, and every entry held to it.
|
|
36
|
+
async function fetchAll(refs, first, fetching) {
|
|
35
37
|
const fetched = new Map()
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const times = new Map()
|
|
39
|
+
const tarballs = new Map(refs.map((ref) => [ref, registryTarball(ref.entry, fetchedName(ref), whereOf(ref))]))
|
|
40
|
+
await eachConcurrently([...first.values()], async (ref) => {
|
|
41
|
+
fetched.set(ref, await fetchYarnPackage(tarballs.get(ref), whereOf(ref), times, fetching))
|
|
42
|
+
}, whereOf)
|
|
43
|
+
for (const ref of refs) {
|
|
44
|
+
const head = first.get(ref.loc)
|
|
45
|
+
if (head !== ref) await checkShared(tarballs.get(ref), fetched.get(head), whereOf(ref), times)
|
|
46
|
+
}
|
|
40
47
|
return fetched
|
|
41
48
|
}
|
|
42
49
|
|
|
@@ -79,20 +86,20 @@ function resolveProject(inputs, host) {
|
|
|
79
86
|
// its resolver hands them over. Of two its cache keeps in one place, only the
|
|
80
87
|
// first is fetched; the rest keep their lockfile entry as package.json, with
|
|
81
88
|
// no peers, bins, platforms or engines, and the first's files, and their
|
|
82
|
-
//
|
|
83
|
-
async function fetchChecked(resolved, host, settings, project) {
|
|
89
|
+
// hashes are held to the first's tarball.
|
|
90
|
+
async function fetchChecked(resolved, host, settings, project, fetching) {
|
|
84
91
|
const order = [...new Set(resolved.patterns.values())]
|
|
92
|
+
const registry = order.filter((ref) => ref.kind === 'registry')
|
|
85
93
|
const first = new Map()
|
|
86
|
-
for (const ref of
|
|
87
|
-
const fetched = await fetchAll(
|
|
94
|
+
for (const ref of registry) if (!first.has(ref.loc)) first.set(ref.loc, ref)
|
|
95
|
+
const fetched = await fetchAll(registry, first, fetching)
|
|
88
96
|
const directories = readDirectories(order, project, fetched)
|
|
89
97
|
const manifestOf = new Map()
|
|
90
98
|
for (const ref of order) {
|
|
91
99
|
let manifest = ref.workspace?.manifest
|
|
92
100
|
if (ref.kind === 'registry') {
|
|
93
101
|
const head = first.get(ref.loc)
|
|
94
|
-
|
|
95
|
-
if (sha1 !== undefined && fetched.get(head).sha1 !== sha1) throw new DeptreeError(`the tarball's sha1 is not ${sha1}`, whereOf(ref))
|
|
102
|
+
checkSha1(ref.entry.resolution.sha1, fetched.get(head).sha1, whereOf(ref))
|
|
96
103
|
fetched.set(ref, fetched.get(head))
|
|
97
104
|
ref.hasBins = head === ref && fetched.get(ref).hasBins
|
|
98
105
|
manifest = head === ref ? fixLists(fetched.get(ref).manifest) : { name: ref.name, version: ref.version }
|
|
@@ -170,13 +177,16 @@ function writeTree(placed, fetched) {
|
|
|
170
177
|
return { vfs, links, locations, copies, ...counted }
|
|
171
178
|
}
|
|
172
179
|
|
|
180
|
+
// What a version document says, but what it does not.
|
|
181
|
+
const said = (about) => Object.fromEntries(Object.entries(about).filter(([, value]) => value !== undefined))
|
|
182
|
+
|
|
173
183
|
function listInstalled(copies, fetched, asked, hoister) {
|
|
174
184
|
const prod = hoister.reachedBut('dev', asked)
|
|
175
185
|
const required = hoister.reachedBut('optional', asked)
|
|
176
186
|
return [...copies].map(([path, places]) => {
|
|
177
187
|
const { ref } = places[0]
|
|
178
|
-
const { manifest, integrity } = fetched.get(ref)
|
|
179
|
-
const from = ref.kind === 'directory' ? { directory: ref.dir } : { integrity }
|
|
188
|
+
const { manifest, integrity, about } = fetched.get(ref)
|
|
189
|
+
const from = ref.kind === 'directory' ? { directory: ref.dir } : { integrity, ...said(about) }
|
|
180
190
|
return { path, name: manifest.name, version: manifest.version, ...from, dev: !places.some((info) => prod.has(info)), optional: !places.some((info) => required.has(info)) }
|
|
181
191
|
}).sort((a, b) => compareNames(a.path, b.path))
|
|
182
192
|
}
|
|
@@ -184,6 +194,8 @@ function listInstalled(copies, fetched, asked, hoister) {
|
|
|
184
194
|
export async function buildYarn1Tree(options) {
|
|
185
195
|
const { host: given, vfs: into } = options ?? {}
|
|
186
196
|
if (into !== undefined && !(into instanceof Vfs)) throw new TypeError('vfs must be a Vfs, or left out')
|
|
197
|
+
const fetching = fetchingOf(options ?? {})
|
|
198
|
+
if (fetching.sizeEstimateOnly) throw new TypeError('sizeEstimateOnly is not taken for yarn 1, which hoists and leaves out packages by what their package.json says, which only their tarballs hold')
|
|
187
199
|
const inputs = inputsOf(options ?? {})
|
|
188
200
|
const host = checkHost(given, inputs.manifests.get('.'))
|
|
189
201
|
const folded = host.os === 'darwin'
|
|
@@ -191,7 +203,7 @@ export async function buildYarn1Tree(options) {
|
|
|
191
203
|
if (into !== undefined) checkNoModules(into, folded)
|
|
192
204
|
checkRoot(inputs.manifests.get('.'))
|
|
193
205
|
const { workspaces, asked, resolved } = resolveProject(inputs, host)
|
|
194
|
-
const { packages, fetched, manifestOf } = await fetchChecked(resolved, host, inputs.settings, inputs.project)
|
|
206
|
+
const { packages, fetched, manifestOf } = await fetchChecked(resolved, host, inputs.settings, inputs.project, fetching)
|
|
195
207
|
const { placed, hoister } = layout({ resolved, manifestOf, asked, workspaces })
|
|
196
208
|
const { vfs, links, locations, copies, files, bytes } = writeTree(placed, fetched)
|
|
197
209
|
checkBinLinks({ placed, patterns: resolved.patterns, locations, realOf: (path) => realOf(links, path) })
|
package/yarn1.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { CacheOptions, PackageBugs, PackageRepository } from '@preventive/upstream/npm.js'
|
|
3
2
|
import type { NodeType, Vfs } from '@preventive/vfs'
|
|
4
3
|
|
|
5
4
|
export { LockfileError } from '@preventive/lockfile/yarn1.js'
|
|
@@ -7,7 +6,7 @@ export { LockfileError } from '@preventive/lockfile/yarn1.js'
|
|
|
7
6
|
// Where @preventive/upstream caches what it fetches, tarballs among them.
|
|
8
7
|
// Tarballs are fetched through it, and that is the one place anything here
|
|
9
8
|
// touches a filesystem. Before the network, it takes a tarball from npm's
|
|
10
|
-
// cache
|
|
9
|
+
// cache -- under $npm_config_cache, or ~/.npm -- from ~/.audit/cache/tgz, or
|
|
11
10
|
// from its own default cache directory or stasis's, where one there has the
|
|
12
11
|
// lockfile's integrity, and writes none of them; then from its own cache,
|
|
13
12
|
// where one is set, which is where it writes each tarball it fetches:
|
|
@@ -22,7 +21,7 @@ export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
|
22
21
|
// one the root package.json's packageManager pins, which corepack runs,
|
|
23
22
|
// and has to be given where that pins none, and to be that one where it
|
|
24
23
|
// does. `node` is the Node yarn runs on, an exact version; `os` and `cpu`
|
|
25
|
-
// as Node names them
|
|
24
|
+
// as Node names them -- `linux`, `x64`. Windows is refused: yarn links bins
|
|
26
25
|
// there with shims, and workspaces with junctions.
|
|
27
26
|
// A package whose os, cpu or engines the machine does not take is left
|
|
28
27
|
// out where it is optional, and refused where it is not, as yarn fails
|
|
@@ -82,8 +81,8 @@ export interface Yarn1Project {
|
|
|
82
81
|
// reads as a manifest too; and a .yarnrc.yml, whose yarnPath yarn 1.22
|
|
83
82
|
// runs in its stead.
|
|
84
83
|
//
|
|
85
|
-
// Settings from anywhere else
|
|
86
|
-
// in the home directory, the environment, the command line
|
|
84
|
+
// Settings from anywhere else -- a .yarnrc or .npmrc above the project or
|
|
85
|
+
// in the home directory, the environment, the command line -- are not read,
|
|
87
86
|
// and are taken to be at their defaults.
|
|
88
87
|
//
|
|
89
88
|
// Of the .yarnrc and the .npmrc, as yarn 1.22 reads them: yarn reads an
|
|
@@ -91,18 +90,18 @@ export interface Yarn1Project {
|
|
|
91
90
|
// a `--` line of the .yarnrc as a flag on its command line. Two settings
|
|
92
91
|
// are followed as yarn follows them: ignore-engines, by the flag
|
|
93
92
|
// `--ignore-engines true` or `--install.ignore-engines true`, or by the
|
|
94
|
-
// option where it is truthy as yarn reads it
|
|
93
|
+
// option where it is truthy as yarn reads it -- a quoted "false" is; and
|
|
95
94
|
// ignore-platform, by its flag alone, as yarn does not act on the option.
|
|
96
|
-
// Options yarn reads that change what it installs are refused
|
|
95
|
+
// Options yarn reads that change what it installs are refused --
|
|
97
96
|
// ignore-optional, production, bin-links, workspaces-experimental and the
|
|
98
|
-
// like
|
|
97
|
+
// like -- and so is yarn-path, which has another yarn run, and
|
|
99
98
|
// global-folder, which, where it is the project's own directory, has yarn
|
|
100
99
|
// read its package.json files otherwise; any other option
|
|
101
100
|
// is passed over, as yarn reads it only for where it fetches from, how,
|
|
102
101
|
// and what it keeps, which the tree is held to the lockfile's integrities
|
|
103
102
|
// against whatever serves it, or for no install at all, as with most of
|
|
104
|
-
// npm's own. A flag is passed over where it does not change the tree
|
|
105
|
-
// --registry, --frozen-lockfile, --network-timeout and the like
|
|
103
|
+
// npm's own. A flag is passed over where it does not change the tree --
|
|
104
|
+
// --registry, --frozen-lockfile, --network-timeout and the like -- and
|
|
106
105
|
// refused where it may or is not known here: --production, --flat,
|
|
107
106
|
// --modules-folder, --ignore-optional, --no-bin-links, --no-lockfile,
|
|
108
107
|
// which has yarn read no yarn.lock, --global-folder, --cwd and the rest. A .yarnrc line indented under another, which yarn reads into it,
|
|
@@ -110,13 +109,13 @@ export interface Yarn1Project {
|
|
|
110
109
|
// or false, or for the .yarnrc's option a quoted string.
|
|
111
110
|
//
|
|
112
111
|
// A workspace project is the root, marked private, and every directory its
|
|
113
|
-
// `workspaces` globs take
|
|
114
|
-
// them
|
|
112
|
+
// `workspaces` globs take -- `*`, `?` and `**`, as the lockfile reader takes
|
|
113
|
+
// them -- with a package.json that has a name and a version. `nohoist`,
|
|
115
114
|
// Plug'n'Play, and a root package.json's `flat` are refused.
|
|
116
115
|
//
|
|
117
116
|
// `vfs` is a Vfs to mount the tree into, at its root, which is taken to
|
|
118
117
|
// be the lockfile's directory, beside whatever it holds, such as the
|
|
119
|
-
// projects themselves
|
|
118
|
+
// projects themselves -- it may be `project` too; without one, a new Vfs
|
|
120
119
|
// holds the tree alone. Nothing the tree is built from is read from it. A
|
|
121
120
|
// Vfs that holds a node_modules anywhere, or on macOS a name that is one
|
|
122
121
|
// there, is refused before anything is fetched: kept beside the tree, Node
|
|
@@ -126,6 +125,30 @@ export interface Yarn1Project {
|
|
|
126
125
|
// tree is built, and held to every check below, before any of it is
|
|
127
126
|
// written, so a refusal leaves the Vfs as it was.
|
|
128
127
|
//
|
|
128
|
+
// `metadata`, true unless given false, has each registry package's version
|
|
129
|
+
// document asked for beside its tarball, through getMeta of
|
|
130
|
+
// @preventive/upstream given the lockfile's dist: the one `cache` keeps,
|
|
131
|
+
// where its dist is that one, else the registry's, a request for each name
|
|
132
|
+
// and version. Its dist has to be the lockfile's, the tarball
|
|
133
|
+
// the registry's own URL and the integrity the lockfile's sha512, compared
|
|
134
|
+
// as text, with nothing hashed again, as the lockfile copies the
|
|
135
|
+
// registry's; and its gitHead, repository, homepage and bugs are the
|
|
136
|
+
// package's. False fetches none, and gives none of them, but for a package
|
|
137
|
+
// whose sha512 the lockfile does not record, whose document is fetched for
|
|
138
|
+
// the registry's either way, and gives them.
|
|
139
|
+
//
|
|
140
|
+
// `cache` is where each registry package's tarball and version document
|
|
141
|
+
// are kept, as @preventive/upstream's CacheOptions take it: in setCacheDir's
|
|
142
|
+
// cache where it is left out; in a store of the caller's, with `read` and
|
|
143
|
+
// `write`, in place of it; or with false, nowhere, though setCacheDir's
|
|
144
|
+
// cache is read all the same. Other tools' caches are read for tarballs
|
|
145
|
+
// whatever it is. A TypeError is thrown for anything else.
|
|
146
|
+
//
|
|
147
|
+
// `sizeEstimateOnly`, which buildPnpmTree and buildNpmTree take for a tree's
|
|
148
|
+
// directories and links alone, is not taken, as yarn hoists and leaves out
|
|
149
|
+
// packages by what their package.json says, which only their tarballs
|
|
150
|
+
// hold: a TypeError is thrown for it given true.
|
|
151
|
+
//
|
|
129
152
|
// The two ways the files come, one or the other: given, with `lockfile`
|
|
130
153
|
// and `manifests`; or read, with `project` and none of them. `project`
|
|
131
154
|
// given with `lockfile` is read only to tell whether a tag a top-level
|
|
@@ -140,6 +163,8 @@ export interface Yarn1TreeGiven {
|
|
|
140
163
|
project?: Yarn1Project
|
|
141
164
|
host: Yarn1Host
|
|
142
165
|
vfs?: Vfs
|
|
166
|
+
metadata?: boolean
|
|
167
|
+
cache?: CacheOptions['cache']
|
|
143
168
|
}
|
|
144
169
|
|
|
145
170
|
export interface Yarn1TreeRead {
|
|
@@ -150,6 +175,8 @@ export interface Yarn1TreeRead {
|
|
|
150
175
|
project: Yarn1Project
|
|
151
176
|
host: Yarn1Host
|
|
152
177
|
vfs?: Vfs
|
|
178
|
+
metadata?: boolean
|
|
179
|
+
cache?: CacheOptions['cache']
|
|
153
180
|
}
|
|
154
181
|
|
|
155
182
|
// What buildYarn1Tree counts, all of it plain numbers: `packages` the
|
|
@@ -169,12 +196,18 @@ export interface Yarn1TreeStats {
|
|
|
169
196
|
|
|
170
197
|
// A copy of a package in the tree, as an SBOM would list it: `path` is
|
|
171
198
|
// where its files really are, from the lockfile's directory, which is `/`
|
|
172
|
-
// of the Vfs
|
|
199
|
+
// of the Vfs -- node_modules/<alias>, or beneath a workspace, in that
|
|
173
200
|
// workspace's own node_modules. `name` and `version` are the package's
|
|
174
201
|
// own, which its package.json is held to, whatever alias it is installed
|
|
175
202
|
// as; `integrity` the sha512 its tarball is held to, for a registry
|
|
176
203
|
// package, and `directory` the directory of the project it is copied
|
|
177
|
-
// from, for one by `file:`, in place of an integrity.
|
|
204
|
+
// from, for one by `file:`, in place of an integrity. For a registry
|
|
205
|
+
// package alone, where its version document is fetched: `commit` is its
|
|
206
|
+
// gitHead, where that is a full commit id, the commit npm read off the
|
|
207
|
+
// checkout it published from; `repository`, `homepage` and `bugs` the
|
|
208
|
+
// document's, as getMeta of @preventive/upstream reads them; each left out
|
|
209
|
+
// where there is none, and all of it the publisher's word, held to no
|
|
210
|
+
// repository. `dev` is
|
|
178
211
|
// whether dev dependencies alone reach this copy, the root's and the
|
|
179
212
|
// workspaces' devDependencies: nothing else does, each dependency, and
|
|
180
213
|
// each peer yarn finds, looked for from where what asks for it is, as Node
|
|
@@ -188,6 +221,10 @@ export interface Yarn1Installed {
|
|
|
188
221
|
version: string
|
|
189
222
|
integrity?: string
|
|
190
223
|
directory?: string
|
|
224
|
+
commit?: string
|
|
225
|
+
repository?: string | PackageRepository
|
|
226
|
+
homepage?: string
|
|
227
|
+
bugs?: string | PackageBugs
|
|
191
228
|
dev: boolean
|
|
192
229
|
optional: boolean
|
|
193
230
|
}
|
|
@@ -250,7 +287,11 @@ export interface Yarn1Tree {
|
|
|
250
287
|
// yarn installs its dependencies, no link or device in it, and a
|
|
251
288
|
// package.json for exactly its name and version; each with the sha512
|
|
252
289
|
// integrity the lockfile records, and the sha1 each of its entries does,
|
|
253
|
-
// fetched or not.
|
|
290
|
+
// fetched or not. yarn writes a sha1 integrity alone where the registry had
|
|
291
|
+
// no sha512 for the version: taken only for one the registry says was
|
|
292
|
+
// published before 2018-08-05T14:58:16.253Z, since when it has made one for
|
|
293
|
+
// every version as it was published, and held to that sha1 and to the
|
|
294
|
+
// registry's own sha512. On macOS, two names in one
|
|
254
295
|
// directory that differ only in case or normalization are refused, as
|
|
255
296
|
// they would be one name there.
|
|
256
297
|
//
|
|
@@ -261,11 +302,13 @@ export interface Yarn1Tree {
|
|
|
261
302
|
// sha1 after it aside), or that same URL on yarn's mirror,
|
|
262
303
|
// https://registry.yarnpkg.com/, which is taken for npm's; it is fetched
|
|
263
304
|
// from npm's through @preventive/upstream. Each is asked for by a semver
|
|
264
|
-
// range, an `npm:` alias, or a tag
|
|
305
|
+
// range, an `npm:` alias, or a tag -- the last only where the project is
|
|
265
306
|
// given, and a directory of the project of that name is not there, which
|
|
266
|
-
// yarn would install instead
|
|
267
|
-
//
|
|
268
|
-
//
|
|
307
|
+
// yarn would install instead. A request of a tag waits on the filesystem,
|
|
308
|
+
// which answers in no set order, and each it answers resolves all beneath
|
|
309
|
+
// it before the next: where two or more wait at once, only where that
|
|
310
|
+
// order changes nothing, as no two would add a package or a pattern under
|
|
311
|
+
// one name, and no resolution applies or directory is read beneath them.
|
|
269
312
|
//
|
|
270
313
|
// Or by the registry's own tarball URL, either of those above (no `#`
|
|
271
314
|
// after it): the entry yarn writes for one has no integrity, so its
|
|
@@ -298,10 +341,10 @@ export interface Yarn1Tree {
|
|
|
298
341
|
//
|
|
299
342
|
// Nothing is left to a guess: a lockfile the lockfile reader refuses, a
|
|
300
343
|
// setting this does not know or does not build for, a package from
|
|
301
|
-
// anywhere but those above
|
|
302
|
-
// a directory by `link:`
|
|
344
|
+
// anywhere but those above -- git, another tarball URL, a tarball on disk,
|
|
345
|
+
// a directory by `link:` -- a range that is none of those above, a package
|
|
303
346
|
// with bundled dependencies, another package manager, a check above that
|
|
304
|
-
// fails
|
|
347
|
+
// fails -- each is refused with a DeptreeError or a LockfileError that says
|
|
305
348
|
// where. A TypeError is thrown for options of the wrong type.
|
|
306
349
|
export function buildYarn1Tree(options: Yarn1TreeOptions): Promise<Yarn1Tree>
|
|
307
350
|
|
|
@@ -318,8 +361,8 @@ export interface Yarn1WorkspacesOptions {
|
|
|
318
361
|
|
|
319
362
|
export function findYarn1Workspaces(options: Yarn1WorkspacesOptions): string[]
|
|
320
363
|
|
|
321
|
-
// `where` is what a refusal is about
|
|
322
|
-
// package's pattern
|
|
364
|
+
// `where` is what a refusal is about -- `.yarnrc:3`, `manifests["."]`, a
|
|
365
|
+
// package's pattern -- or undefined for the call as a whole; the message
|
|
323
366
|
// leads with it. `cause` is what a package beneath refused with, where one
|
|
324
367
|
// did.
|
|
325
368
|
export class DeptreeError extends Error {
|