@preventive/deptree 1.0.0-alpha.6 → 1.0.0-alpha.8
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/npm.d.ts +9 -8
- package/package.json +11 -7
- package/pnpm.d.ts +66 -18
- package/soldeer.d.ts +74 -21
- package/src/hash.js +2 -6
- package/src/matcher.js +3 -2
- package/src/mount.js +22 -2
- package/src/npm/bins.js +2 -19
- package/src/npm/compat.js +11 -6
- package/src/npm/inputs.js +4 -9
- package/src/npm/manifests.js +4 -12
- package/src/npmrc.js +1 -2
- package/src/patch.js +4 -13
- package/src/pnpm/bins.js +129 -37
- package/src/pnpm/commands.js +4 -10
- package/src/pnpm/frozen.js +3 -6
- package/src/pnpm/gitignore.js +3 -1
- package/src/pnpm/glob.js +3 -3
- package/src/pnpm/hoist.js +3 -6
- package/src/pnpm/hoisted.js +234 -0
- package/src/pnpm/inputs.js +24 -34
- package/src/pnpm/install.js +17 -20
- package/src/pnpm/local.js +15 -3
- package/src/pnpm/minimatch.js +6 -15
- package/src/pnpm/nm-hoist-graph.js +299 -0
- package/src/pnpm/nm-hoist.js +149 -0
- package/src/pnpm/npm-packlist.js +7 -11
- package/src/pnpm/overrides.js +1 -2
- package/src/pnpm/package.js +6 -3
- package/src/pnpm/packlist.js +5 -4
- package/src/pnpm/readers.js +26 -29
- package/src/pnpm/settings.js +9 -8
- package/src/pnpm/tree.js +73 -30
- package/src/pnpm/workspace.js +2 -2
- package/src/project.js +22 -6
- package/src/soldeer/git.js +52 -0
- package/src/soldeer/inputs.js +4 -11
- package/src/soldeer/tree.js +36 -22
- package/src/soldeer/zip.js +4 -5
- package/src/tarball.js +68 -11
- package/src/yarn1/bins.js +1 -1
- package/src/yarn1/inputs.js +4 -11
- package/src/yarn1/package.js +61 -9
- package/src/yarn1/requests.js +7 -5
- package/src/yarn1/resolve.js +62 -13
- package/src/yarn1/settings.js +1 -2
- package/src/yarn1/tree.js +29 -9
- package/yarn1.d.ts +62 -29
package/src/yarn1/resolve.js
CHANGED
|
@@ -7,8 +7,12 @@ import { DeptreeError, quote } from '../error.js'
|
|
|
7
7
|
import { matchesGlob } from '../glob.js'
|
|
8
8
|
|
|
9
9
|
// Beneath a top-level request, all run at once, each taking these microtask
|
|
10
|
-
// turns, by its resolver, before it checks for a package of its version
|
|
11
|
-
|
|
10
|
+
// turns, by its resolver, before it checks for a package of its version: a
|
|
11
|
+
// tarball URL as many as the registry. A directory is read at the top level
|
|
12
|
+
// alone, where nothing runs beside it; beneath, only one read already is
|
|
13
|
+
// asked for again, which yarn reads once all else has run, and takes the
|
|
14
|
+
// first's package for.
|
|
15
|
+
const TURNS = { registry: 5, workspace: 3, directory: 1 }
|
|
12
16
|
|
|
13
17
|
// yarn's normalizePattern.
|
|
14
18
|
export function splitPattern(pattern) {
|
|
@@ -19,13 +23,37 @@ export function splitPattern(pattern) {
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
// yarn's normalizeRange: any range but a semver range or one with a `:`,
|
|
22
|
-
// such as an `npm:` alias, is a tag.
|
|
26
|
+
// such as an `npm:` alias, is a tag. Of the sources getExoticResolver takes,
|
|
27
|
+
// in its order, a tarball first, where a path ends in .tgz: the registry's
|
|
28
|
+
// own tarball by its URL, on npm's registry or yarn's mirror; and a
|
|
29
|
+
// directory, by `file:` or a path.
|
|
23
30
|
const TAG = /^[\w~-][\w.~-]*$/u
|
|
24
|
-
|
|
31
|
+
const TARBALL = /^https?:\/\/|^[^@]*\.(?:tgz|tar\.gz)$/u
|
|
32
|
+
const REGISTRY_TARBALL = /^https:\/\/registry\.(?:npmjs\.org|yarnpkg\.com)\/[^#?]+\.tgz$/u
|
|
33
|
+
const DIRECTORY = /^(?:file:|\.{1,2}\/|\/)/u
|
|
34
|
+
export function kindOf(range, where) {
|
|
25
35
|
if (validRange(range)) return 'range'
|
|
26
36
|
if (range.startsWith('npm:')) return 'alias'
|
|
27
|
-
if (
|
|
28
|
-
|
|
37
|
+
if (TARBALL.test(range)) {
|
|
38
|
+
if (REGISTRY_TARBALL.test(range)) return 'tarball'
|
|
39
|
+
} else if (DIRECTORY.test(range)) return 'directory'
|
|
40
|
+
else if (TAG.test(range)) return 'tag'
|
|
41
|
+
throw new DeptreeError('only a semver range, an npm: alias, a tag, a file: directory or the registry\'s own tarball URL is supported', where)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The directory a `file:` range names, as yarn resolves it from the
|
|
45
|
+
// lockfile's: one within the project, which it is read from.
|
|
46
|
+
function directoryOf(range, where) {
|
|
47
|
+
const path = range.replace(/^file:/u, '')
|
|
48
|
+
const segments = []
|
|
49
|
+
for (const segment of path.split('/')) {
|
|
50
|
+
if (segment === '..') {
|
|
51
|
+
if (segments.pop() === undefined) throw new DeptreeError(`${quote(path)} is outside the project, which is not supported`, where)
|
|
52
|
+
} else if (segment !== '' && segment !== '.') segments.push(segment)
|
|
53
|
+
}
|
|
54
|
+
if (path.startsWith('/')) throw new DeptreeError(`${quote(path)} is an absolute path, which is not supported`, where)
|
|
55
|
+
if (segments.length === 0) throw new DeptreeError('the project\'s own directory is not supported', where)
|
|
56
|
+
return segments.join('/')
|
|
29
57
|
}
|
|
30
58
|
|
|
31
59
|
// What a package asks for, in yarn's order. A lockfile entry's are patterns;
|
|
@@ -43,8 +71,9 @@ function asked(info, where) {
|
|
|
43
71
|
// Where yarn's cache keeps a package (generateModuleCachePath), which is
|
|
44
72
|
// what its hoister tells two references apart by: two of one package, as
|
|
45
73
|
// a tag or an alias asked for twice makes, are one there.
|
|
46
|
-
function locOf({ kind, name, version, entry }) {
|
|
74
|
+
function locOf({ kind, name, version, entry, dir }) {
|
|
47
75
|
if (kind === 'workspace') return `workspace\n${name}`
|
|
76
|
+
if (kind === 'directory') return `copy\n${dir}`
|
|
48
77
|
const { uid } = entry
|
|
49
78
|
const { sha1, integrity } = entry.resolution ?? {}
|
|
50
79
|
return `npm\n${name}\n${version}\n${uid !== undefined && uid !== version ? uid : sha1 ?? ''}\n${integrity ? 'integrity' : ''}`
|
|
@@ -56,6 +85,7 @@ class Resolver {
|
|
|
56
85
|
this.patterns = new Map()
|
|
57
86
|
this.byName = new Map()
|
|
58
87
|
this.delayed = []
|
|
88
|
+
this.late = []
|
|
59
89
|
this.diverted = []
|
|
60
90
|
}
|
|
61
91
|
|
|
@@ -74,13 +104,23 @@ class Resolver {
|
|
|
74
104
|
const workspace = this.workspaces.get(name)
|
|
75
105
|
if (workspace !== undefined && satisfies(workspace.version, range, { loose: true })) return { kind: 'workspace', name: workspace.name, version: workspace.version, workspace }
|
|
76
106
|
const where = quote(request.pattern)
|
|
77
|
-
const
|
|
107
|
+
const kind = kindOf(range, where)
|
|
78
108
|
const entry = this.lockfile.packages[request.pattern]
|
|
79
109
|
if (entry === undefined) throw new DeptreeError('yarn would resolve this pattern anew: the lockfile has no entry for it', where)
|
|
80
110
|
if (hasVersion && validRange(range) && !satisfies(entry.version, range)) {
|
|
81
111
|
throw new DeptreeError(`yarn would resolve this pattern anew: the lockfile has ${entry.version}, which the range does not take`, where)
|
|
82
112
|
}
|
|
83
|
-
return { kind: 'registry', name, version: entry.version, entry, tag }
|
|
113
|
+
if (kind !== 'directory') return { kind: 'registry', name, version: entry.version, entry, tag: kind === 'tag' }
|
|
114
|
+
const dir = directoryOf(range, where)
|
|
115
|
+
if (request.parentNames !== undefined && this.copyOf(name, dir) === undefined) {
|
|
116
|
+
throw new DeptreeError('a file: directory asked for beneath the top level, and not by the root or a resolution first, is not supported', where)
|
|
117
|
+
}
|
|
118
|
+
return { kind, name, version: entry.version, entry, dir }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// exoticRangeMatch: the package of `name` copied from `dir` already.
|
|
122
|
+
copyOf(name, dir) {
|
|
123
|
+
return this.byName.get(name)?.map((pattern) => this.patterns.get(pattern)).find((ref) => ref.kind === 'directory' && ref.dir === dir)
|
|
84
124
|
}
|
|
85
125
|
|
|
86
126
|
// No resolution applies to a top-level request.
|
|
@@ -101,8 +141,8 @@ class Resolver {
|
|
|
101
141
|
// the last of which its pattern names.
|
|
102
142
|
check(request, info) {
|
|
103
143
|
const { name, range } = splitPattern(request.pattern)
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
144
|
+
const found = info.kind === 'directory' ? this.copyOf(name, info.dir) : this.exactMatch(name, validRange(range) ? info.version : range)
|
|
145
|
+
if (found !== undefined) {
|
|
106
146
|
this.delayed.push(request)
|
|
107
147
|
return []
|
|
108
148
|
}
|
|
@@ -113,6 +153,7 @@ class Resolver {
|
|
|
113
153
|
kind: info.kind,
|
|
114
154
|
entry: info.entry,
|
|
115
155
|
workspace: info.workspace,
|
|
156
|
+
dir: info.dir,
|
|
116
157
|
patterns: [],
|
|
117
158
|
requests: [request],
|
|
118
159
|
asked: asked(info, quote(request.pattern)),
|
|
@@ -139,11 +180,16 @@ class Resolver {
|
|
|
139
180
|
return undefined
|
|
140
181
|
}
|
|
141
182
|
const info = this.infoOf(request)
|
|
183
|
+
if (info.kind === 'directory' && request.parentNames !== undefined) {
|
|
184
|
+
this.late.push(request)
|
|
185
|
+
return undefined
|
|
186
|
+
}
|
|
142
187
|
return { request, info, left: info.tag ? Infinity : TURNS[info.kind] }
|
|
143
188
|
}
|
|
144
189
|
|
|
145
190
|
answer(waiting) {
|
|
146
|
-
|
|
191
|
+
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(', ')}`)
|
|
147
193
|
const [strand] = waiting
|
|
148
194
|
const where = quote(strand.request.pattern)
|
|
149
195
|
const { range } = splitPattern(strand.request.pattern)
|
|
@@ -170,13 +216,16 @@ class Resolver {
|
|
|
170
216
|
if (strands.every((strand) => strand.left === Infinity)) strands = this.answer(strands)
|
|
171
217
|
strands = this.turn(strands)
|
|
172
218
|
}
|
|
219
|
+
this.delayed.push(...this.late)
|
|
220
|
+
this.late = []
|
|
173
221
|
}
|
|
174
222
|
|
|
175
223
|
// yarn's resolveToExistingVersion for the delayed, then the diverted.
|
|
176
224
|
settle() {
|
|
177
225
|
for (const request of this.delayed) {
|
|
178
226
|
const { name } = splitPattern(request.pattern)
|
|
179
|
-
const
|
|
227
|
+
const info = this.infoOf(request)
|
|
228
|
+
const ref = info.kind === 'directory' ? this.copyOf(name, info.dir) : this.exactMatch(name, info.version)
|
|
180
229
|
ref.requests.push(request)
|
|
181
230
|
this.addPattern(request.pattern, ref)
|
|
182
231
|
if (!request.optional) ref.optional = false
|
package/src/yarn1/settings.js
CHANGED
|
@@ -63,8 +63,7 @@ function readYarnrc(text) {
|
|
|
63
63
|
const tokens = line.match(TOKEN) ?? []
|
|
64
64
|
if (tokens.join(' ') !== line.replace(/\s+/gu, ' ') || tokens.length > 2) throw new DeptreeError('expected a setting and its value', where)
|
|
65
65
|
const [key, value] = tokens.map((token) => (token.startsWith('"') ? unquote(token, 'a setting', where) : token))
|
|
66
|
-
|
|
67
|
-
settings.set(key, { value: bare ? BARE.get(value) : value, where })
|
|
66
|
+
settings.set(key, { value: tokens[1]?.startsWith('"') === false ? BARE.get(value) : value, where })
|
|
68
67
|
}
|
|
69
68
|
return settings
|
|
70
69
|
}
|
package/src/yarn1/tree.js
CHANGED
|
@@ -15,7 +15,7 @@ import { incompatibility } from './compat.js'
|
|
|
15
15
|
import { Hoister } from './hoist.js'
|
|
16
16
|
import { checkHost, inputsOf } from './inputs.js'
|
|
17
17
|
import { checkRoot, fixLists } from './manifest.js'
|
|
18
|
-
import { fetchYarnPackage, registryTarball } from './package.js'
|
|
18
|
+
import { fetchYarnPackage, readYarnDirectory, registryTarball } from './package.js'
|
|
19
19
|
import { resolvePeers } from './peers.js'
|
|
20
20
|
import { AGGREGATOR, aggregatorOf, rulesOf, topRequests, workspacesOf } from './requests.js'
|
|
21
21
|
import { resolve, splitPattern } from './resolve.js'
|
|
@@ -35,11 +35,25 @@ async function fetchAll(refs) {
|
|
|
35
35
|
const fetched = new Map()
|
|
36
36
|
const tarballs = refs.map((ref) => ({ ref, tarball: registryTarball(ref.entry, fetchedName(ref), whereOf(ref)) }))
|
|
37
37
|
await eachConcurrently(tarballs, async ({ ref, tarball }) => {
|
|
38
|
-
fetched.set(ref,
|
|
38
|
+
fetched.set(ref, await fetchYarnPackage(tarball, whereOf(ref)))
|
|
39
39
|
}, ({ ref }) => whereOf(ref))
|
|
40
40
|
return fetched
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// Each file: directory, read from the project. yarn copies one into a place
|
|
44
|
+
// of its cache of its own each time it is asked for, as another package.
|
|
45
|
+
function readDirectories(order, project, fetched) {
|
|
46
|
+
const read = new Set()
|
|
47
|
+
for (const ref of order) {
|
|
48
|
+
if (ref.kind !== 'directory') continue
|
|
49
|
+
if (project === undefined) throw new DeptreeError('a file: directory is read from the project, which is not given', whereOf(ref))
|
|
50
|
+
if (read.has(ref.dir)) throw new DeptreeError(`${quote(ref.dir)} is asked for by another pattern too, which yarn copies as another package, and which is not supported`, whereOf(ref))
|
|
51
|
+
read.add(ref.dir)
|
|
52
|
+
fetched.set(ref, readYarnDirectory(project, ref, whereOf(ref)))
|
|
53
|
+
}
|
|
54
|
+
return read.size
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
// Under the aggregator, a package goes in its workspace's node_modules.
|
|
44
58
|
function locationOf(names, workspaces) {
|
|
45
59
|
if (names[0] === AGGREGATOR) return `${workspaces.get(names[1]).dir}/node_modules/${names.slice(2).join('/node_modules/')}`
|
|
@@ -66,11 +80,12 @@ function resolveProject(inputs, host) {
|
|
|
66
80
|
// first is fetched; the rest keep their lockfile entry as package.json, with
|
|
67
81
|
// no peers, bins, platforms or engines, and the first's files, and their
|
|
68
82
|
// URL's sha1 is held to the first's tarball.
|
|
69
|
-
async function fetchChecked(resolved, host, settings) {
|
|
83
|
+
async function fetchChecked(resolved, host, settings, project) {
|
|
70
84
|
const order = [...new Set(resolved.patterns.values())]
|
|
71
85
|
const first = new Map()
|
|
72
86
|
for (const ref of order) if (ref.kind === 'registry' && !first.has(ref.loc)) first.set(ref.loc, ref)
|
|
73
87
|
const fetched = await fetchAll([...first.values()])
|
|
88
|
+
const directories = readDirectories(order, project, fetched)
|
|
74
89
|
const manifestOf = new Map()
|
|
75
90
|
for (const ref of order) {
|
|
76
91
|
let manifest = ref.workspace?.manifest
|
|
@@ -81,6 +96,9 @@ async function fetchChecked(resolved, host, settings) {
|
|
|
81
96
|
fetched.set(ref, fetched.get(head))
|
|
82
97
|
ref.hasBins = head === ref && fetched.get(ref).hasBins
|
|
83
98
|
manifest = head === ref ? fixLists(fetched.get(ref).manifest) : { name: ref.name, version: ref.version }
|
|
99
|
+
} else if (ref.kind === 'directory') {
|
|
100
|
+
ref.hasBins = fetched.get(ref).hasBins
|
|
101
|
+
manifest = fixLists(fetched.get(ref).manifest)
|
|
84
102
|
}
|
|
85
103
|
const bundled = manifest.bundleDependencies ?? manifest.bundledDependencies
|
|
86
104
|
if (bundled && !(Array.isArray(bundled) && bundled.length === 0)) throw new DeptreeError('a package with bundled dependencies is not supported', whereOf(ref))
|
|
@@ -92,7 +110,7 @@ async function fetchChecked(resolved, host, settings) {
|
|
|
92
110
|
if (!ref.optional) throw new DeptreeError(`${reason}, and it is not optional, which yarn fails on`, whereOf(ref))
|
|
93
111
|
ref.incompatible = true
|
|
94
112
|
}
|
|
95
|
-
return { packages: first.size, fetched, manifestOf }
|
|
113
|
+
return { packages: first.size + directories, fetched, manifestOf }
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
// Sorted as yarn's linker sorts its absolute paths, all under one directory,
|
|
@@ -124,7 +142,7 @@ function writeTree(placed, fetched) {
|
|
|
124
142
|
const copies = new Map()
|
|
125
143
|
const left = new Map()
|
|
126
144
|
for (const { info: { ref } } of placed) {
|
|
127
|
-
if (ref.kind
|
|
145
|
+
if (ref.kind !== 'workspace') left.set(fetched.get(ref), (left.get(fetched.get(ref)) ?? 0) + 1)
|
|
128
146
|
}
|
|
129
147
|
const letGo = (pkg) => Object.assign(pkg, { files: undefined, dirs: undefined })
|
|
130
148
|
for (const pkg of new Set(fetched.values())) if (!left.has(pkg)) letGo(pkg)
|
|
@@ -156,8 +174,10 @@ function listInstalled(copies, fetched, asked, hoister) {
|
|
|
156
174
|
const prod = hoister.reachedBut('dev', asked)
|
|
157
175
|
const required = hoister.reachedBut('optional', asked)
|
|
158
176
|
return [...copies].map(([path, places]) => {
|
|
159
|
-
const {
|
|
160
|
-
|
|
177
|
+
const { ref } = places[0]
|
|
178
|
+
const { manifest, integrity } = fetched.get(ref)
|
|
179
|
+
const from = ref.kind === 'directory' ? { directory: ref.dir } : { integrity }
|
|
180
|
+
return { path, name: manifest.name, version: manifest.version, ...from, dev: !places.some((info) => prod.has(info)), optional: !places.some((info) => required.has(info)) }
|
|
161
181
|
}).sort((a, b) => compareNames(a.path, b.path))
|
|
162
182
|
}
|
|
163
183
|
|
|
@@ -171,14 +191,14 @@ export async function buildYarn1Tree(options) {
|
|
|
171
191
|
if (into !== undefined) checkNoModules(into, folded)
|
|
172
192
|
checkRoot(inputs.manifests.get('.'))
|
|
173
193
|
const { workspaces, asked, resolved } = resolveProject(inputs, host)
|
|
174
|
-
const { packages, fetched, manifestOf } = await fetchChecked(resolved, host, inputs.settings)
|
|
194
|
+
const { packages, fetched, manifestOf } = await fetchChecked(resolved, host, inputs.settings, inputs.project)
|
|
175
195
|
const { placed, hoister } = layout({ resolved, manifestOf, asked, workspaces })
|
|
176
196
|
const { vfs, links, locations, copies, files, bytes } = writeTree(placed, fetched)
|
|
177
197
|
checkBinLinks({ placed, patterns: resolved.patterns, locations, realOf: (path) => realOf(links, path) })
|
|
178
198
|
const stats = {
|
|
179
199
|
packages,
|
|
180
200
|
skipped: [...manifestOf.keys()].filter((ref) => ref.incompatible).length,
|
|
181
|
-
installed: placed.filter(({ info }) => info.ref.kind
|
|
201
|
+
installed: placed.filter(({ info }) => info.ref.kind !== 'workspace').length,
|
|
182
202
|
files,
|
|
183
203
|
bytes,
|
|
184
204
|
links: links.size,
|
package/yarn1.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export { LockfileError } from '@preventive/lockfile/yarn1.js'
|
|
|
7
7
|
// Where @preventive/upstream caches what it fetches, tarballs among them.
|
|
8
8
|
// Tarballs are fetched through it, and that is the one place anything here
|
|
9
9
|
// touches a filesystem. Before the network, it takes a tarball from npm's
|
|
10
|
-
// cache — under $npm_config_cache, or ~/.npm —
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
10
|
+
// cache — under $npm_config_cache, or ~/.npm — from ~/.audit/cache/tgz, or
|
|
11
|
+
// from its own default cache directory or stasis's, where one there has the
|
|
12
|
+
// lockfile's integrity, and writes none of them; then from its own cache,
|
|
13
|
+
// where one is set, which is where it writes each tarball it fetches:
|
|
14
|
+
// setCacheDir() sets the default one, and setCacheDir(false) unsets it.
|
|
15
|
+
// Unset, which it is until set, it writes nothing. yarn's own cache is
|
|
16
|
+
// never read. The project is read only through the view given as
|
|
17
|
+
// `project`, and the tree built in a Vfs.
|
|
16
18
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
17
19
|
|
|
18
20
|
// The machine yarn would install on, which a tree depends on: `yarn` is
|
|
@@ -44,13 +46,13 @@ export interface Yarn1Host {
|
|
|
44
46
|
// A view of the lockfile's directory, by paths from `/`: a Vfs, or
|
|
45
47
|
// anything with its readdir, lstat, stat and readFile, such as one of a
|
|
46
48
|
// directory on disk, of which only this is read: the names in a
|
|
47
|
-
// directory; what a path is, `file`, `directory` or `symlink`,
|
|
48
|
-
// and what it leads to with stat; and a file's bytes.
|
|
49
|
-
// whose `code` is ENOENT, ENOTDIR or ELOOP for a path
|
|
50
|
-
// Nothing is written to it.
|
|
49
|
+
// directory; what a path is, `file`, `directory` or `symlink`, and its
|
|
50
|
+
// mode, with lstat, and what it leads to with stat; and a file's bytes.
|
|
51
|
+
// Each throws an error whose `code` is ENOENT, ENOTDIR or ELOOP for a path
|
|
52
|
+
// that leads nowhere. Nothing is written to it.
|
|
51
53
|
export interface Yarn1Project {
|
|
52
54
|
readdir(path: string): string[]
|
|
53
|
-
lstat(path: string): { type: NodeType }
|
|
55
|
+
lstat(path: string): { type: NodeType, mode: number }
|
|
54
56
|
stat(path: string): { type: NodeType }
|
|
55
57
|
readFile(path: string): Uint8Array
|
|
56
58
|
}
|
|
@@ -151,7 +153,8 @@ export interface Yarn1TreeRead {
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
// What buildYarn1Tree counts, all of it plain numbers: `packages` the
|
|
154
|
-
//
|
|
156
|
+
// packages yarn resolves, each fetched from the registry or read from a
|
|
157
|
+
// directory of the project; `skipped` the optional
|
|
155
158
|
// ones left out, as the host cannot run them; `installed` the copies of
|
|
156
159
|
// them in the tree; `files` and `bytes` what is written; `links` the
|
|
157
160
|
// workspaces linked.
|
|
@@ -164,12 +167,14 @@ export interface Yarn1TreeStats {
|
|
|
164
167
|
links: number
|
|
165
168
|
}
|
|
166
169
|
|
|
167
|
-
// A copy of a
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
170
|
+
// A copy of a package in the tree, as an SBOM would list it: `path` is
|
|
171
|
+
// where its files really are, from the lockfile's directory, which is `/`
|
|
172
|
+
// of the Vfs — node_modules/<alias>, or beneath a workspace, in that
|
|
173
|
+
// workspace's own node_modules. `name` and `version` are the package's
|
|
174
|
+
// own, which its package.json is held to, whatever alias it is installed
|
|
175
|
+
// as; `integrity` the sha512 its tarball is held to, for a registry
|
|
176
|
+
// package, and `directory` the directory of the project it is copied
|
|
177
|
+
// from, for one by `file:`, in place of an integrity. `dev` is
|
|
173
178
|
// whether dev dependencies alone reach this copy, the root's and the
|
|
174
179
|
// workspaces' devDependencies: nothing else does, each dependency, and
|
|
175
180
|
// each peer yarn finds, looked for from where what asks for it is, as Node
|
|
@@ -181,7 +186,8 @@ export interface Yarn1Installed {
|
|
|
181
186
|
path: string
|
|
182
187
|
name: string
|
|
183
188
|
version: string
|
|
184
|
-
integrity
|
|
189
|
+
integrity?: string
|
|
190
|
+
directory?: string
|
|
185
191
|
dev: boolean
|
|
186
192
|
optional: boolean
|
|
187
193
|
}
|
|
@@ -212,7 +218,9 @@ export interface Yarn1Tree {
|
|
|
212
218
|
// package's peers looked for along the shortest chain of names that asked
|
|
213
219
|
// for it, as yarn looks for them; and the tree laid out as yarn's hoister
|
|
214
220
|
// lays it out, quirks and all. A resolution applies to a dependency by its
|
|
215
|
-
// path, as yarn applies it, and not to one of the root's own
|
|
221
|
+
// path, as yarn applies it, and not to one of the root's own; it resolves
|
|
222
|
+
// to a semver range, or to the registry's own tarball or a directory of
|
|
223
|
+
// the project, as below.
|
|
216
224
|
//
|
|
217
225
|
// Scripts are always ignored, as `--ignore-scripts` has yarn ignore them,
|
|
218
226
|
// whatever the settings say. No .bin is written, nor yarn's own
|
|
@@ -246,10 +254,11 @@ export interface Yarn1Tree {
|
|
|
246
254
|
// directory that differ only in case or normalization are refused, as
|
|
247
255
|
// they would be one name there.
|
|
248
256
|
//
|
|
249
|
-
// Packages come from npm's registry
|
|
250
|
-
// `resolved` has to be the registry's own URL of its
|
|
251
|
-
// npm spells it,
|
|
252
|
-
// (a `#` and the
|
|
257
|
+
// Packages come from npm's registry, or from a directory of the project.
|
|
258
|
+
// A registry entry's `resolved` has to be the registry's own URL of its
|
|
259
|
+
// tarball, exactly as npm spells it,
|
|
260
|
+
// https://registry.npmjs.org/<name>/-/<base>-<version>.tgz (a `#` and the
|
|
261
|
+
// sha1 after it aside), or that same URL on yarn's mirror,
|
|
253
262
|
// https://registry.yarnpkg.com/, which is taken for npm's; it is fetched
|
|
254
263
|
// from npm's through @preventive/upstream. Each is asked for by a semver
|
|
255
264
|
// range, an `npm:` alias, or a tag — the last only where the project is
|
|
@@ -258,15 +267,39 @@ export interface Yarn1Tree {
|
|
|
258
267
|
// requests of tags wait on the filesystem at once, which it answers in no
|
|
259
268
|
// set order.
|
|
260
269
|
//
|
|
270
|
+
// Or by the registry's own tarball URL, either of those above (no `#`
|
|
271
|
+
// after it): the entry yarn writes for one has no integrity, so its
|
|
272
|
+
// tarball is held to the sha1 after the `#` of its `resolved` and to the
|
|
273
|
+
// registry's own sha512. Or, by the root or as what a resolution resolves
|
|
274
|
+
// to, by a directory of the project, `file:<path>` or a path starting
|
|
275
|
+
// `./`, within the project and not its root; beneath another package,
|
|
276
|
+
// where yarn reads it in an order not modelled here, only one read
|
|
277
|
+
// already, as the workspaces' aggregator asks for the root's again, which
|
|
278
|
+
// yarn takes the first's package for, but not where a tag waits on the
|
|
279
|
+
// filesystem beside it. yarn copies a
|
|
280
|
+
// directory whole, whatever package.json's `files` and an ignore file
|
|
281
|
+
// say, each file's mode as it is, each bin's target made executable, and
|
|
282
|
+
// the tree copies it so, read from `project`, which has to be given for
|
|
283
|
+
// it: all but each `.bin`, .yarn-metadata.json and .yarn-tarball.tgz in
|
|
284
|
+
// it, as yarn's copy passes them over, empty directories kept. yarn reads
|
|
285
|
+
// a directory's package.json anew at every install, frozen or not, and
|
|
286
|
+
// installs whatever its version and dependencies say; so it has to be of
|
|
287
|
+
// the name and version its lockfile entry has, with the dependencies and
|
|
288
|
+
// optionalDependencies the entry lists. Refused: a link, device or a
|
|
289
|
+
// node_modules of its own in it, a mode beyond 0o777, a directory two
|
|
290
|
+
// patterns ask for, which yarn copies as two packages, and a tarball on
|
|
291
|
+
// the project's disk, which yarn takes for any path ending in .tgz.
|
|
292
|
+
//
|
|
261
293
|
// Ranges and versions are read with npm's own semver, borrowed from the
|
|
262
|
-
// npm beside node as @preventive/upstream borrows it,
|
|
263
|
-
//
|
|
264
|
-
// reads
|
|
294
|
+
// npm beside node as @preventive/upstream borrows it, or with its semver
|
|
295
|
+
// peer where there is no npm, without either of which this throws. yarn
|
|
296
|
+
// 1.22 reads them with the semver 5.5.0 it bundles, which reads alike all
|
|
297
|
+
// but the edges of what a range may spell.
|
|
265
298
|
//
|
|
266
299
|
// Nothing is left to a guess: a lockfile the lockfile reader refuses, a
|
|
267
300
|
// setting this does not know or does not build for, a package from
|
|
268
|
-
// anywhere but
|
|
269
|
-
//
|
|
301
|
+
// anywhere but those above — git, another tarball URL, a tarball on disk,
|
|
302
|
+
// a directory by `link:` — a range that is none of those above, a package
|
|
270
303
|
// with bundled dependencies, another package manager, a check above that
|
|
271
304
|
// fails — each is refused with a DeptreeError or a LockfileError that says
|
|
272
305
|
// where. A TypeError is thrown for options of the wrong type.
|