@preventive/deptree 1.0.0-alpha.1 → 1.0.0-alpha.10
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/LICENSE-APACHE +202 -0
- package/bin/compare.js +132 -0
- package/bin/deptree.js +211 -0
- package/bin/npmrc.js +21 -0
- package/cargo.d.ts +223 -0
- package/cargo.js +6 -0
- package/npm.d.ts +321 -0
- package/npm.js +7 -0
- package/package.json +92 -11
- package/pnpm.d.ts +401 -81
- package/pnpm.js +4 -9
- package/soldeer.d.ts +235 -0
- package/soldeer.js +6 -0
- 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 +32 -0
- package/src/error.js +8 -10
- package/src/glob.js +55 -0
- package/src/hash.js +51 -16
- package/src/manifest.js +52 -0
- package/src/matcher.js +60 -10
- package/src/mount.js +124 -42
- package/src/npm/bins.js +54 -0
- package/src/npm/compat.js +97 -0
- package/src/npm/dev-engines.js +52 -0
- package/src/npm/graph.js +68 -0
- package/src/npm/inputs.js +75 -0
- package/src/npm/manifests.js +130 -0
- package/src/npm/package.js +57 -0
- package/src/npm/ratio.js +34 -0
- package/src/npm/settings.js +67 -0
- package/src/npm/tree.js +139 -0
- package/src/npm/versions.js +20 -0
- package/src/npmrc.js +24 -0
- package/src/patch.js +26 -45
- package/src/pnpm/bins.js +202 -322
- package/src/pnpm/checks.js +8 -35
- package/src/pnpm/commands.js +230 -0
- package/src/pnpm/filename.js +19 -16
- package/src/pnpm/frozen.js +29 -73
- package/src/pnpm/gitignore.js +138 -0
- package/src/pnpm/glob.js +65 -0
- package/src/pnpm/graph.js +26 -34
- package/src/pnpm/hoist.js +96 -59
- package/src/pnpm/hoisted.js +234 -0
- package/src/pnpm/hook.js +26 -31
- package/src/pnpm/inputs.js +177 -0
- package/src/pnpm/install.js +123 -124
- package/src/pnpm/local.js +95 -40
- package/src/pnpm/minimatch.js +319 -0
- package/src/pnpm/nm-hoist-graph.js +299 -0
- package/src/pnpm/nm-hoist.js +149 -0
- package/src/pnpm/npm-packlist.js +217 -0
- package/src/pnpm/overrides.js +11 -51
- package/src/pnpm/package.js +123 -0
- package/src/pnpm/packlist.js +176 -81
- package/src/pnpm/patches.js +18 -25
- package/src/pnpm/projects.js +132 -89
- package/src/pnpm/readers.js +122 -77
- package/src/pnpm/settings.js +74 -95
- package/src/pnpm/tree.js +216 -237
- package/src/pnpm/uptodate.js +16 -28
- package/src/pnpm/workspace.js +152 -126
- package/src/project.js +56 -0
- package/src/soldeer/config.js +63 -0
- package/src/soldeer/git.js +52 -0
- package/src/soldeer/inputs.js +30 -0
- package/src/soldeer/tree.js +83 -0
- package/src/soldeer/zip.js +121 -0
- package/src/tarball.js +123 -131
- package/src/yarn1/bins.js +28 -0
- package/src/yarn1/compat.js +67 -0
- package/src/yarn1/hoist.js +249 -0
- package/src/yarn1/inputs.js +83 -0
- package/src/yarn1/manifest.js +64 -0
- package/src/yarn1/package.js +206 -0
- package/src/yarn1/peers.js +51 -0
- package/src/yarn1/requests.js +74 -0
- package/src/yarn1/resolve.js +289 -0
- package/src/yarn1/settings.js +95 -0
- package/src/yarn1/tree.js +219 -0
- package/yarn1.d.ts +368 -0
- package/yarn1.js +7 -0
- package/src/pnpm/npmrc.js +0 -31
- /package/{LICENSE → LICENSE-MIT} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// A node_modules tree as `yarn install --frozen-lockfile --ignore-scripts`
|
|
2
|
+
// makes it in a directory with no node_modules yet. Not written:
|
|
3
|
+
// node_modules/.bin, yarn's .yarn-integrity, and anything a script builds.
|
|
4
|
+
|
|
5
|
+
import { parseYarn1Lockfile } from '@preventive/lockfile/yarn1.js'
|
|
6
|
+
import { Vfs } from '@preventive/vfs'
|
|
7
|
+
import { compareNames, dirname, relative } from '@preventive/vfs/path.js'
|
|
8
|
+
import { clean, satisfies, valid, validRange } from '@preventive/upstream/semver.js'
|
|
9
|
+
import { eachConcurrently } from '../concurrent.js'
|
|
10
|
+
import { DeptreeError, quote } from '../error.js'
|
|
11
|
+
import { checkNoModules, isInside, makeDirs, mount, writeFiles, writeLink } from '../mount.js'
|
|
12
|
+
import { typeOf } from '../project.js'
|
|
13
|
+
import { fetchingOf } from '../tarball.js'
|
|
14
|
+
import { checkBinLinks } from './bins.js'
|
|
15
|
+
import { incompatibility } from './compat.js'
|
|
16
|
+
import { Hoister } from './hoist.js'
|
|
17
|
+
import { checkHost, inputsOf } from './inputs.js'
|
|
18
|
+
import { checkRoot, fixLists } from './manifest.js'
|
|
19
|
+
import { checkSha1, checkShared, fetchYarnPackage, readYarnDirectory, registryTarball } from './package.js'
|
|
20
|
+
import { resolvePeers } from './peers.js'
|
|
21
|
+
import { AGGREGATOR, aggregatorOf, rulesOf, topRequests, workspacesOf } from './requests.js'
|
|
22
|
+
import { resolve, splitPattern } from './resolve.js'
|
|
23
|
+
|
|
24
|
+
const whereOf = (ref) => quote(ref.patterns[0])
|
|
25
|
+
|
|
26
|
+
// The basenames yarn's copy passes over, wherever they are in a package.
|
|
27
|
+
const IGNORED = new Set(['.bin', '.yarn-metadata.json', '.yarn-tarball.tgz'])
|
|
28
|
+
const skipped = (path) => path.split('/').some((segment) => IGNORED.has(segment))
|
|
29
|
+
|
|
30
|
+
function fetchedName(ref) {
|
|
31
|
+
const { range } = splitPattern(ref.patterns[0])
|
|
32
|
+
return range.startsWith('npm:') ? splitPattern(range.slice(4)).name : ref.name
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The first of each place in `first` is fetched, and every entry held to it.
|
|
36
|
+
async function fetchAll(refs, first, fetching) {
|
|
37
|
+
const fetched = new Map()
|
|
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
|
+
}
|
|
47
|
+
return fetched
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Each file: directory, read from the project. yarn copies one into a place
|
|
51
|
+
// of its cache of its own each time it is asked for, as another package.
|
|
52
|
+
function readDirectories(order, project, fetched) {
|
|
53
|
+
const read = new Set()
|
|
54
|
+
for (const ref of order) {
|
|
55
|
+
if (ref.kind !== 'directory') continue
|
|
56
|
+
if (project === undefined) throw new DeptreeError('a file: directory is read from the project, which is not given', whereOf(ref))
|
|
57
|
+
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))
|
|
58
|
+
read.add(ref.dir)
|
|
59
|
+
fetched.set(ref, readYarnDirectory(project, ref, whereOf(ref)))
|
|
60
|
+
}
|
|
61
|
+
return read.size
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Under the aggregator, a package goes in its workspace's node_modules.
|
|
65
|
+
function locationOf(names, workspaces) {
|
|
66
|
+
if (names[0] === AGGREGATOR) return `${workspaces.get(names[1]).dir}/node_modules/${names.slice(2).join('/node_modules/')}`
|
|
67
|
+
return `node_modules/${names.join('/node_modules/')}`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resolveProject(inputs, host) {
|
|
71
|
+
const lockfile = parseYarn1Lockfile(inputs.lockfile, { manifests: Object.fromEntries(inputs.manifests), semver: { clean, satisfies, valid, validRange } })
|
|
72
|
+
const manifests = new Map([...inputs.manifests].map(([dir, manifest]) => [dir, fixLists(manifest)]))
|
|
73
|
+
const root = manifests.get('.')
|
|
74
|
+
const workspaces = workspacesOf(manifests)
|
|
75
|
+
if (workspaces.size > 0) workspaces.set(AGGREGATOR, aggregatorOf(root, workspaces))
|
|
76
|
+
const rules = rulesOf(root)
|
|
77
|
+
const { requests, asked } = topRequests(root, workspaces, rules)
|
|
78
|
+
const reason = incompatibility(root, host, 'manifests["."]', inputs.settings)
|
|
79
|
+
if (reason !== undefined) throw new DeptreeError(reason, 'manifests["."]')
|
|
80
|
+
const { project } = inputs
|
|
81
|
+
const isDirectory = project === undefined ? () => undefined : (tag) => typeOf(project, `/${tag}/package.json`) !== undefined
|
|
82
|
+
return { workspaces, asked, resolved: resolve({ lockfile, workspaces, rules, top: requests, isDirectory }) }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// As in yarn, every package is fetched before any is checked, in the order
|
|
86
|
+
// its resolver hands them over. Of two its cache keeps in one place, only the
|
|
87
|
+
// first is fetched; the rest keep their lockfile entry as package.json, with
|
|
88
|
+
// no peers, bins, platforms or engines, and the first's files, and their
|
|
89
|
+
// hashes are held to the first's tarball.
|
|
90
|
+
async function fetchChecked(resolved, host, settings, project, fetching) {
|
|
91
|
+
const order = [...new Set(resolved.patterns.values())]
|
|
92
|
+
const registry = order.filter((ref) => ref.kind === 'registry')
|
|
93
|
+
const first = new Map()
|
|
94
|
+
for (const ref of registry) if (!first.has(ref.loc)) first.set(ref.loc, ref)
|
|
95
|
+
const fetched = await fetchAll(registry, first, fetching)
|
|
96
|
+
const directories = readDirectories(order, project, fetched)
|
|
97
|
+
const manifestOf = new Map()
|
|
98
|
+
for (const ref of order) {
|
|
99
|
+
let manifest = ref.workspace?.manifest
|
|
100
|
+
if (ref.kind === 'registry') {
|
|
101
|
+
const head = first.get(ref.loc)
|
|
102
|
+
checkSha1(ref.entry.resolution.sha1, fetched.get(head).sha1, whereOf(ref))
|
|
103
|
+
fetched.set(ref, fetched.get(head))
|
|
104
|
+
ref.hasBins = head === ref && fetched.get(ref).hasBins
|
|
105
|
+
manifest = head === ref ? fixLists(fetched.get(ref).manifest) : { name: ref.name, version: ref.version }
|
|
106
|
+
} else if (ref.kind === 'directory') {
|
|
107
|
+
ref.hasBins = fetched.get(ref).hasBins
|
|
108
|
+
manifest = fixLists(fetched.get(ref).manifest)
|
|
109
|
+
}
|
|
110
|
+
const bundled = manifest.bundleDependencies ?? manifest.bundledDependencies
|
|
111
|
+
if (bundled && !(Array.isArray(bundled) && bundled.length === 0)) throw new DeptreeError('a package with bundled dependencies is not supported', whereOf(ref))
|
|
112
|
+
manifestOf.set(ref, manifest)
|
|
113
|
+
}
|
|
114
|
+
for (const ref of order) {
|
|
115
|
+
const reason = incompatibility(manifestOf.get(ref), host, whereOf(ref), settings)
|
|
116
|
+
if (reason === undefined) continue
|
|
117
|
+
if (!ref.optional) throw new DeptreeError(`${reason}, and it is not optional, which yarn fails on`, whereOf(ref))
|
|
118
|
+
ref.incompatible = true
|
|
119
|
+
}
|
|
120
|
+
return { packages: first.size + directories, fetched, manifestOf }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Sorted as yarn's linker sorts its absolute paths, all under one directory,
|
|
124
|
+
// by localeCompare in Node's locale; that changes nothing written, as a link
|
|
125
|
+
// sorts before what is beneath it in any locale.
|
|
126
|
+
function layout({ resolved, manifestOf, asked, workspaces }) {
|
|
127
|
+
resolvePeers(resolved, manifestOf)
|
|
128
|
+
for (const ref of manifestOf.keys()) ref.dependencies = ref.asked.map(({ pattern }) => pattern)
|
|
129
|
+
const hoister = new Hoister(resolved.patterns, (ref) => Object.keys(manifestOf.get(ref)?.peerDependencies ?? {}))
|
|
130
|
+
hoister.seed(asked.map(({ pattern }) => pattern))
|
|
131
|
+
const flat = hoister.flatten(workspaces.size > 0 ? AGGREGATOR : undefined)
|
|
132
|
+
const placed = flat.map(({ names, info }) => ({ loc: locationOf(names, workspaces), info }))
|
|
133
|
+
return { placed: placed.sort((a, b) => a.loc.localeCompare(b.loc)), hoister }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Where `path` really is, through each link in `links`, in the order made.
|
|
137
|
+
function realOf(links, path) {
|
|
138
|
+
for (const [link, target] of links) if (path === link || path.startsWith(`${link}/`)) path = target + path.slice(link.length)
|
|
139
|
+
return path
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// A package beneath a workspace's link is copied through it, so two of the
|
|
143
|
+
// hoister's places may be one real path, which `copies` maps to both.
|
|
144
|
+
function writeTree(placed, fetched) {
|
|
145
|
+
const vfs = new Vfs()
|
|
146
|
+
makeDirs(vfs, 'node_modules')
|
|
147
|
+
const links = new Map()
|
|
148
|
+
const locations = new Map()
|
|
149
|
+
const copies = new Map()
|
|
150
|
+
const left = new Map()
|
|
151
|
+
for (const { info: { ref } } of placed) {
|
|
152
|
+
if (ref.kind !== 'workspace') left.set(fetched.get(ref), (left.get(fetched.get(ref)) ?? 0) + 1)
|
|
153
|
+
}
|
|
154
|
+
const letGo = (pkg) => Object.assign(pkg, { files: undefined, dirs: undefined })
|
|
155
|
+
for (const pkg of new Set(fetched.values())) if (!left.has(pkg)) letGo(pkg)
|
|
156
|
+
const counted = { files: 0, bytes: 0 }
|
|
157
|
+
for (const { loc, info } of placed) {
|
|
158
|
+
const { ref } = info
|
|
159
|
+
const dest = realOf(links, loc)
|
|
160
|
+
if (!locations.has(ref)) locations.set(ref, [])
|
|
161
|
+
if (!locations.get(ref).includes(dest)) locations.get(ref).push(dest)
|
|
162
|
+
if (ref.kind === 'workspace') {
|
|
163
|
+
// readManifests has each workspace in the project.
|
|
164
|
+
if (!isInside(ref.workspace.dir)) throw new DeptreeError('links out of the project', whereOf(ref))
|
|
165
|
+
links.set(dest, ref.workspace.dir)
|
|
166
|
+
writeLink(vfs, dest, relative(`/${dirname(dest)}`, `/${ref.workspace.dir}`) || '.')
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
const pkg = fetched.get(ref)
|
|
170
|
+
const earlier = copies.get(dest)
|
|
171
|
+
if (earlier?.[0].ref === ref) earlier.push(info)
|
|
172
|
+
else copies.set(dest, [info])
|
|
173
|
+
writeFiles(vfs, dest, pkg, counted, skipped)
|
|
174
|
+
left.set(pkg, left.get(pkg) - 1)
|
|
175
|
+
if (left.get(pkg) === 0) letGo(pkg)
|
|
176
|
+
}
|
|
177
|
+
return { vfs, links, locations, copies, ...counted }
|
|
178
|
+
}
|
|
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
|
+
|
|
183
|
+
function listInstalled(copies, fetched, asked, hoister) {
|
|
184
|
+
const prod = hoister.reachedBut('dev', asked)
|
|
185
|
+
const required = hoister.reachedBut('optional', asked)
|
|
186
|
+
return [...copies].map(([path, places]) => {
|
|
187
|
+
const { ref } = places[0]
|
|
188
|
+
const { manifest, integrity, about } = fetched.get(ref)
|
|
189
|
+
const from = ref.kind === 'directory' ? { directory: ref.dir } : { integrity, ...said(about) }
|
|
190
|
+
return { path, name: manifest.name, version: manifest.version, ...from, dev: !places.some((info) => prod.has(info)), optional: !places.some((info) => required.has(info)) }
|
|
191
|
+
}).sort((a, b) => compareNames(a.path, b.path))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function buildYarn1Tree(options) {
|
|
195
|
+
const { host: given, vfs: into } = options ?? {}
|
|
196
|
+
if (into !== undefined && !(into instanceof Vfs)) throw new TypeError('vfs must be a Vfs, or left out')
|
|
197
|
+
const fetching = fetchingOf(options ?? {})
|
|
198
|
+
const inputs = inputsOf(options ?? {})
|
|
199
|
+
const host = checkHost(given, inputs.manifests.get('.'))
|
|
200
|
+
const folded = host.os === 'darwin'
|
|
201
|
+
// Refused before anything is fetched; mount checks again.
|
|
202
|
+
if (into !== undefined) checkNoModules(into, folded)
|
|
203
|
+
checkRoot(inputs.manifests.get('.'))
|
|
204
|
+
const { workspaces, asked, resolved } = resolveProject(inputs, host)
|
|
205
|
+
const { packages, fetched, manifestOf } = await fetchChecked(resolved, host, inputs.settings, inputs.project, fetching)
|
|
206
|
+
const { placed, hoister } = layout({ resolved, manifestOf, asked, workspaces })
|
|
207
|
+
const { vfs, links, locations, copies, files, bytes } = writeTree(placed, fetched)
|
|
208
|
+
checkBinLinks({ placed, patterns: resolved.patterns, locations, realOf: (path) => realOf(links, path) })
|
|
209
|
+
const stats = {
|
|
210
|
+
packages,
|
|
211
|
+
skipped: [...manifestOf.keys()].filter((ref) => ref.incompatible).length,
|
|
212
|
+
installed: placed.filter(({ info }) => info.ref.kind !== 'workspace').length,
|
|
213
|
+
files,
|
|
214
|
+
bytes,
|
|
215
|
+
links: links.size,
|
|
216
|
+
}
|
|
217
|
+
const installed = listInstalled(copies, fetched, asked, hoister)
|
|
218
|
+
return { vfs: mount(vfs, into, folded), stats, installed }
|
|
219
|
+
}
|
package/yarn1.d.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// Hand-written against yarn1.js; a change to either belongs with the other.
|
|
2
|
+
|
|
3
|
+
import type { CacheOptions, PackageBugs, PackageRepository } from '@preventive/upstream/npm.js'
|
|
4
|
+
import type { NodeType, Vfs } from '@preventive/vfs'
|
|
5
|
+
|
|
6
|
+
export { LockfileError } from '@preventive/lockfile/yarn1.js'
|
|
7
|
+
|
|
8
|
+
// Where @preventive/upstream caches what it fetches, tarballs among them.
|
|
9
|
+
// Tarballs are fetched through it, and that is the one place anything here
|
|
10
|
+
// touches a filesystem. Before the network, it takes a tarball from npm's
|
|
11
|
+
// cache — under $npm_config_cache, or ~/.npm — from ~/.audit/cache/tgz, or
|
|
12
|
+
// from its own default cache directory or stasis's, where one there has the
|
|
13
|
+
// lockfile's integrity, and writes none of them; then from its own cache,
|
|
14
|
+
// where one is set, which is where it writes each tarball it fetches:
|
|
15
|
+
// setCacheDir() sets the default one, and setCacheDir(false) unsets it.
|
|
16
|
+
// Unset, which it is until set, it writes nothing. yarn's own cache is
|
|
17
|
+
// never read. The project is read only through the view given as
|
|
18
|
+
// `project`, and the tree built in a Vfs.
|
|
19
|
+
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
20
|
+
|
|
21
|
+
// The machine yarn would install on, which a tree depends on: `yarn` is
|
|
22
|
+
// the version that installs, and has to be a 1.22.x; left out, it is the
|
|
23
|
+
// one the root package.json's packageManager pins, which corepack runs,
|
|
24
|
+
// and has to be given where that pins none, and to be that one where it
|
|
25
|
+
// does. `node` is the Node yarn runs on, an exact version; `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.
|
|
40
|
+
export interface Yarn1Host {
|
|
41
|
+
yarn?: string
|
|
42
|
+
node: string
|
|
43
|
+
os: string
|
|
44
|
+
cpu: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// A view of the lockfile's directory, by paths from `/`: a Vfs, or
|
|
48
|
+
// anything with its readdir, lstat, stat and readFile, such as one of a
|
|
49
|
+
// directory on disk, of which only this is read: the names in a
|
|
50
|
+
// directory; what a path is, `file`, `directory` or `symlink`, and its
|
|
51
|
+
// mode, with lstat, and what it leads to with stat; and a file's bytes.
|
|
52
|
+
// Each throws an error whose `code` is ENOENT, ENOTDIR or ELOOP for a path
|
|
53
|
+
// that leads nowhere. Nothing is written to it.
|
|
54
|
+
export interface Yarn1Project {
|
|
55
|
+
readdir(path: string): string[]
|
|
56
|
+
lstat(path: string): { type: NodeType, mode: number }
|
|
57
|
+
stat(path: string): { type: NodeType }
|
|
58
|
+
readFile(path: string): Uint8Array
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// The files an install reads: yarn.lock; the package.json of the root and
|
|
62
|
+
// of every workspace; and the .yarnrc and the .npmrc, where there are any.
|
|
63
|
+
//
|
|
64
|
+
// With `lockfile`, they are given as text: `manifests` by the project's
|
|
65
|
+
// directory relative to the lockfile's (`.` for the root, then each
|
|
66
|
+
// workspace's, as findYarn1Workspaces lists them: a directory under the
|
|
67
|
+
// lockfile's, with no `.`, `..` or empty segment). Every workspace yarn
|
|
68
|
+
// would find has to be given, which buildYarn1Tree cannot check where it
|
|
69
|
+
// is given them, as it is not given the directories; and the lockfile
|
|
70
|
+
// reader refuses a manifest of any directory the root's `workspaces` do
|
|
71
|
+
// not take.
|
|
72
|
+
//
|
|
73
|
+
// Without it, they are read from `project`, as yarn reads them there, and
|
|
74
|
+
// none of them may be given: yarn.lock, which has to be there; the root
|
|
75
|
+
// package.json, which has to be there too; the package.json of every
|
|
76
|
+
// directory the root's `workspaces` globs take, as yarn globs for them,
|
|
77
|
+
// outside node_modules; the .yarnrc and the .npmrc. Each is read as UTF-8,
|
|
78
|
+
// and refused where it is not; a byte order mark is dropped, as yarn drops
|
|
79
|
+
// it. A refusal names each as it would given: `manifests["packages/x"]`.
|
|
80
|
+
// Refused there: a link anywhere the globs reach, which node-glob follows
|
|
81
|
+
// or not by where it is; a node_modules the globs would take, whose
|
|
82
|
+
// package.json yarn would read as a workspace; a yarn.json, which yarn
|
|
83
|
+
// reads as a manifest too; and a .yarnrc.yml, whose yarnPath yarn 1.22
|
|
84
|
+
// runs in its stead.
|
|
85
|
+
//
|
|
86
|
+
// Settings from anywhere else — a .yarnrc or .npmrc above the project or
|
|
87
|
+
// in the home directory, the environment, the command line — are not read,
|
|
88
|
+
// and are taken to be at their defaults.
|
|
89
|
+
//
|
|
90
|
+
// Of the .yarnrc and the .npmrc, as yarn 1.22 reads them: yarn reads an
|
|
91
|
+
// option by its name from the .yarnrc, or else from the .npmrc, and takes
|
|
92
|
+
// a `--` line of the .yarnrc as a flag on its command line. Two settings
|
|
93
|
+
// are followed as yarn follows them: ignore-engines, by the flag
|
|
94
|
+
// `--ignore-engines true` or `--install.ignore-engines true`, or by the
|
|
95
|
+
// option where it is truthy as yarn reads it — a quoted "false" is; and
|
|
96
|
+
// ignore-platform, by its flag alone, as yarn does not act on the option.
|
|
97
|
+
// Options yarn reads that change what it installs are refused —
|
|
98
|
+
// ignore-optional, production, bin-links, workspaces-experimental and the
|
|
99
|
+
// like — and so is yarn-path, which has another yarn run, and
|
|
100
|
+
// global-folder, which, where it is the project's own directory, has yarn
|
|
101
|
+
// read its package.json files otherwise; any other option
|
|
102
|
+
// is passed over, as yarn reads it only for where it fetches from, how,
|
|
103
|
+
// and what it keeps, which the tree is held to the lockfile's integrities
|
|
104
|
+
// against whatever serves it, or for no install at all, as with most of
|
|
105
|
+
// npm's own. A flag is passed over where it does not change the tree —
|
|
106
|
+
// --registry, --frozen-lockfile, --network-timeout and the like — and
|
|
107
|
+
// refused where it may or is not known here: --production, --flat,
|
|
108
|
+
// --modules-folder, --ignore-optional, --no-bin-links, --no-lockfile,
|
|
109
|
+
// 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
|
+
// is refused too, and so is a value of those two followed that is not true
|
|
111
|
+
// or false, or for the .yarnrc's option a quoted string.
|
|
112
|
+
//
|
|
113
|
+
// A workspace project is the root, marked private, and every directory its
|
|
114
|
+
// `workspaces` globs take — `*`, `?` and `**`, as the lockfile reader takes
|
|
115
|
+
// them — with a package.json that has a name and a version. `nohoist`,
|
|
116
|
+
// Plug'n'Play, and a root package.json's `flat` are refused.
|
|
117
|
+
//
|
|
118
|
+
// `vfs` is a Vfs to mount the tree into, at its root, which is taken to
|
|
119
|
+
// be the lockfile's directory, beside whatever it holds, such as the
|
|
120
|
+
// projects themselves — it may be `project` too; without one, a new Vfs
|
|
121
|
+
// holds the tree alone. Nothing the tree is built from is read from it. A
|
|
122
|
+
// Vfs that holds a node_modules anywhere, or on macOS a name that is one
|
|
123
|
+
// there, is refused before anything is fetched: kept beside the tree, Node
|
|
124
|
+
// would read it as the tree's, and removed, it would be the caller's lost.
|
|
125
|
+
// Nothing there is written over: each directory the tree has is one there
|
|
126
|
+
// or is made, and every file and link is written where nothing is. The
|
|
127
|
+
// tree is built, and held to every check below, before any of it is
|
|
128
|
+
// written, so a refusal leaves the Vfs as it was.
|
|
129
|
+
//
|
|
130
|
+
// `metadata`, true unless given false, has each registry package's version
|
|
131
|
+
// document asked for beside its tarball, through getMeta of
|
|
132
|
+
// @preventive/upstream given the lockfile's dist: the one `cache` keeps,
|
|
133
|
+
// where its dist is that one, else the registry's, a request for each name
|
|
134
|
+
// and version. Its dist has to be the lockfile's, the tarball
|
|
135
|
+
// the registry's own URL and the integrity the lockfile's sha512, compared
|
|
136
|
+
// as text, with nothing hashed again, as the lockfile copies the
|
|
137
|
+
// registry's; and its gitHead, repository, homepage and bugs are the
|
|
138
|
+
// package's. False fetches none, and gives none of them, but for a package
|
|
139
|
+
// whose sha512 the lockfile does not record, whose document is fetched for
|
|
140
|
+
// the registry's either way, and gives them.
|
|
141
|
+
//
|
|
142
|
+
// `cache` is where each registry package's tarball and version document
|
|
143
|
+
// are kept, as @preventive/upstream's CacheOptions take it: in setCacheDir's
|
|
144
|
+
// cache where it is left out; in a store of the caller's, with `read` and
|
|
145
|
+
// `write`, in place of it; or with false, nowhere, though setCacheDir's
|
|
146
|
+
// cache is read all the same. Other tools' caches are read for tarballs
|
|
147
|
+
// whatever it is. A TypeError is thrown for anything else.
|
|
148
|
+
//
|
|
149
|
+
// The two ways the files come, one or the other: given, with `lockfile`
|
|
150
|
+
// and `manifests`; or read, with `project` and none of them. `project`
|
|
151
|
+
// given with `lockfile` is read only to tell whether a tag a top-level
|
|
152
|
+
// dependency asks for is a directory, which yarn would install instead.
|
|
153
|
+
export type Yarn1TreeOptions = Yarn1TreeGiven | Yarn1TreeRead
|
|
154
|
+
|
|
155
|
+
export interface Yarn1TreeGiven {
|
|
156
|
+
lockfile: string
|
|
157
|
+
manifests: Record<string, string> | Map<string, string>
|
|
158
|
+
yarnrc?: string
|
|
159
|
+
npmrc?: string
|
|
160
|
+
project?: Yarn1Project
|
|
161
|
+
host: Yarn1Host
|
|
162
|
+
vfs?: Vfs
|
|
163
|
+
metadata?: boolean
|
|
164
|
+
cache?: CacheOptions['cache']
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface Yarn1TreeRead {
|
|
168
|
+
lockfile?: undefined
|
|
169
|
+
manifests?: undefined
|
|
170
|
+
yarnrc?: undefined
|
|
171
|
+
npmrc?: undefined
|
|
172
|
+
project: Yarn1Project
|
|
173
|
+
host: Yarn1Host
|
|
174
|
+
vfs?: Vfs
|
|
175
|
+
metadata?: boolean
|
|
176
|
+
cache?: CacheOptions['cache']
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// What buildYarn1Tree counts, all of it plain numbers: `packages` the
|
|
180
|
+
// packages yarn resolves, each fetched from the registry or read from a
|
|
181
|
+
// directory of the project; `skipped` the optional
|
|
182
|
+
// ones left out, as the host cannot run them; `installed` the copies of
|
|
183
|
+
// them in the tree; `files` and `bytes` what is written; `links` the
|
|
184
|
+
// workspaces linked.
|
|
185
|
+
export interface Yarn1TreeStats {
|
|
186
|
+
packages: number
|
|
187
|
+
skipped: number
|
|
188
|
+
installed: number
|
|
189
|
+
files: number
|
|
190
|
+
bytes: number
|
|
191
|
+
links: number
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// A copy of a package in the tree, as an SBOM would list it: `path` is
|
|
195
|
+
// where its files really are, from the lockfile's directory, which is `/`
|
|
196
|
+
// of the Vfs — node_modules/<alias>, or beneath a workspace, in that
|
|
197
|
+
// workspace's own node_modules. `name` and `version` are the package's
|
|
198
|
+
// own, which its package.json is held to, whatever alias it is installed
|
|
199
|
+
// as; `integrity` the sha512 its tarball is held to, for a registry
|
|
200
|
+
// package, and `directory` the directory of the project it is copied
|
|
201
|
+
// from, for one by `file:`, in place of an integrity. For a registry
|
|
202
|
+
// package alone, where its version document is fetched: `commit` is its
|
|
203
|
+
// gitHead, where that is a full commit id, the commit npm read off the
|
|
204
|
+
// checkout it published from; `repository`, `homepage` and `bugs` the
|
|
205
|
+
// document's, as getMeta of @preventive/upstream reads them; each left out
|
|
206
|
+
// where there is none, and all of it the publisher's word, held to no
|
|
207
|
+
// repository. `dev` is
|
|
208
|
+
// whether dev dependencies alone reach this copy, the root's and the
|
|
209
|
+
// workspaces' devDependencies: nothing else does, each dependency, and
|
|
210
|
+
// each peer yarn finds, looked for from where what asks for it is, as Node
|
|
211
|
+
// finds it and yarn marks what an install requires, past what the host
|
|
212
|
+
// cannot run. Two copies of one package may differ: one beneath a
|
|
213
|
+
// devDependency that only it needs is dev. `optional` is whether optional
|
|
214
|
+
// dependencies alone reach this copy, so.
|
|
215
|
+
export interface Yarn1Installed {
|
|
216
|
+
path: string
|
|
217
|
+
name: string
|
|
218
|
+
version: string
|
|
219
|
+
integrity?: string
|
|
220
|
+
directory?: string
|
|
221
|
+
commit?: string
|
|
222
|
+
repository?: string | PackageRepository
|
|
223
|
+
homepage?: string
|
|
224
|
+
bugs?: string | PackageBugs
|
|
225
|
+
dev: boolean
|
|
226
|
+
optional: boolean
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// `vfs` is the one given, the tree mounted into it, or a new one.
|
|
230
|
+
// `installed` is each copy in the tree, once for each path, by path in
|
|
231
|
+
// the order of its code points, whatever the locale; a workspace, whose
|
|
232
|
+
// files the tree does not hold, is not among them.
|
|
233
|
+
export interface Yarn1Tree {
|
|
234
|
+
vfs: Vfs
|
|
235
|
+
stats: Yarn1TreeStats
|
|
236
|
+
installed: Yarn1Installed[]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// The node_modules tree `yarn install --frozen-lockfile --ignore-scripts`
|
|
240
|
+
// makes, with host.yarn's node_modules linker, into a project with no
|
|
241
|
+
// node_modules yet: rooted at the lockfile's directory, each package's
|
|
242
|
+
// files copied where yarn hoists it, and each workspace linked where yarn
|
|
243
|
+
// hoists it, by a relative link to its directory, with what yarn hoists
|
|
244
|
+
// beneath it in that directory's own node_modules. The tree holds
|
|
245
|
+
// node_modules and nothing else of the projects.
|
|
246
|
+
//
|
|
247
|
+
// The lockfile is resolved as yarn resolves it, in yarn's order, which
|
|
248
|
+
// decides where a package goes: the resolutions' patterns, then the root's
|
|
249
|
+
// dependencies, devDependencies and optionalDependencies, then the
|
|
250
|
+
// workspaces, each request with all it leads to before the next, and
|
|
251
|
+
// beneath one every request at once, as yarn's resolver runs them; each
|
|
252
|
+
// package's peers looked for along the shortest chain of names that asked
|
|
253
|
+
// for it, as yarn looks for them; and the tree laid out as yarn's hoister
|
|
254
|
+
// lays it out, quirks and all. A resolution applies to a dependency by its
|
|
255
|
+
// path, as yarn applies it, and not to one of the root's own; it resolves
|
|
256
|
+
// to a semver range, or to the registry's own tarball or a directory of
|
|
257
|
+
// the project, as below.
|
|
258
|
+
//
|
|
259
|
+
// Scripts are always ignored, as `--ignore-scripts` has yarn ignore them,
|
|
260
|
+
// whatever the settings say. No .bin is written, nor yarn's own
|
|
261
|
+
// .yarn-integrity; but each bin's target is made executable, chmod 755, in
|
|
262
|
+
// every copy of its package, as yarn's fetcher makes it in its cache,
|
|
263
|
+
// whether yarn links the bin or not. Linking makes no file of the tree
|
|
264
|
+
// executable that the fetcher has not: a bin in its package's own
|
|
265
|
+
// node_modules, where yarn installs its dependencies, is refused, as
|
|
266
|
+
// linking it would make the file there executable, and so is a package
|
|
267
|
+
// with bins and a .bin file, where yarn fails to make a directory for
|
|
268
|
+
// them; a workspace's bins are its own files, which the tree does not
|
|
269
|
+
// hold. Each file's mode is the tarball's, with
|
|
270
|
+
// read for all added and a umask of 0o022 taken off, as yarn unpacks it;
|
|
271
|
+
// .bin, .yarn-metadata.json and .yarn-tarball.tgz in a package are left
|
|
272
|
+
// out, as yarn's copy leaves them out.
|
|
273
|
+
//
|
|
274
|
+
// The lockfile is held to what the lockfile reader holds it to, with the
|
|
275
|
+
// manifests, and to what a frozen install holds it to: every pattern
|
|
276
|
+
// asked for has its entry, and each entry a version in the range of its
|
|
277
|
+
// pattern, as yarn would otherwise resolve the pattern anew, frozen or not.
|
|
278
|
+
// The root package.json's packageManager, where it has one, has to be
|
|
279
|
+
// `yarn@` host.yarn exactly, as corepack would run the one it names.
|
|
280
|
+
//
|
|
281
|
+
// And to more than yarn holds it to, where a lockfile yarn writes, or a
|
|
282
|
+
// package the registry serves, always holds: each tarball gzipped, every
|
|
283
|
+
// file under one directory, none in the package's own node_modules, where
|
|
284
|
+
// yarn installs its dependencies, no link or device in it, and a
|
|
285
|
+
// package.json for exactly its name and version; each with the sha512
|
|
286
|
+
// integrity the lockfile records, and the sha1 each of its entries does,
|
|
287
|
+
// fetched or not. yarn writes a sha1 integrity alone where the registry had
|
|
288
|
+
// no sha512 for the version: taken only for one the registry says was
|
|
289
|
+
// published before 2018-08-05T14:58:16.253Z, since when it has made one for
|
|
290
|
+
// every version as it was published, and held to that sha1 and to the
|
|
291
|
+
// registry's own sha512. On macOS, two names in one
|
|
292
|
+
// directory that differ only in case or normalization are refused, as
|
|
293
|
+
// they would be one name there.
|
|
294
|
+
//
|
|
295
|
+
// Packages come from npm's registry, or from a directory of the project.
|
|
296
|
+
// A registry entry's `resolved` has to be the registry's own URL of its
|
|
297
|
+
// tarball, exactly as npm spells it,
|
|
298
|
+
// https://registry.npmjs.org/<name>/-/<base>-<version>.tgz (a `#` and the
|
|
299
|
+
// sha1 after it aside), or that same URL on yarn's mirror,
|
|
300
|
+
// https://registry.yarnpkg.com/, which is taken for npm's; it is fetched
|
|
301
|
+
// from npm's through @preventive/upstream. Each is asked for by a semver
|
|
302
|
+
// range, an `npm:` alias, or a tag — the last only where the project is
|
|
303
|
+
// given, and a directory of the project of that name is not there, which
|
|
304
|
+
// yarn would install instead. A request of a tag waits on the filesystem,
|
|
305
|
+
// which answers in no set order, and each it answers resolves all beneath
|
|
306
|
+
// it before the next: where two or more wait at once, only where that
|
|
307
|
+
// order changes nothing, as no two would add a package or a pattern under
|
|
308
|
+
// one name, and no resolution applies or directory is read beneath them.
|
|
309
|
+
//
|
|
310
|
+
// Or by the registry's own tarball URL, either of those above (no `#`
|
|
311
|
+
// after it): the entry yarn writes for one has no integrity, so its
|
|
312
|
+
// tarball is held to the sha1 after the `#` of its `resolved` and to the
|
|
313
|
+
// registry's own sha512. Or, by the root or as what a resolution resolves
|
|
314
|
+
// to, by a directory of the project, `file:<path>` or a path starting
|
|
315
|
+
// `./`, within the project and not its root; beneath another package,
|
|
316
|
+
// where yarn reads it in an order not modelled here, only one read
|
|
317
|
+
// already, as the workspaces' aggregator asks for the root's again, which
|
|
318
|
+
// yarn takes the first's package for, but not where a tag waits on the
|
|
319
|
+
// filesystem beside it. yarn copies a
|
|
320
|
+
// directory whole, whatever package.json's `files` and an ignore file
|
|
321
|
+
// say, each file's mode as it is, each bin's target made executable, and
|
|
322
|
+
// the tree copies it so, read from `project`, which has to be given for
|
|
323
|
+
// it: all but each `.bin`, .yarn-metadata.json and .yarn-tarball.tgz in
|
|
324
|
+
// it, as yarn's copy passes them over, empty directories kept. yarn reads
|
|
325
|
+
// a directory's package.json anew at every install, frozen or not, and
|
|
326
|
+
// installs whatever its version and dependencies say; so it has to be of
|
|
327
|
+
// the name and version its lockfile entry has, with the dependencies and
|
|
328
|
+
// optionalDependencies the entry lists. Refused: a link, device or a
|
|
329
|
+
// node_modules of its own in it, a mode beyond 0o777, a directory two
|
|
330
|
+
// patterns ask for, which yarn copies as two packages, and a tarball on
|
|
331
|
+
// the project's disk, which yarn takes for any path ending in .tgz.
|
|
332
|
+
//
|
|
333
|
+
// Ranges and versions are read with npm's own semver, borrowed from the
|
|
334
|
+
// npm beside node as @preventive/upstream borrows it, or with its semver
|
|
335
|
+
// peer where there is no npm, without either of which this throws. yarn
|
|
336
|
+
// 1.22 reads them with the semver 5.5.0 it bundles, which reads alike all
|
|
337
|
+
// but the edges of what a range may spell.
|
|
338
|
+
//
|
|
339
|
+
// Nothing is left to a guess: a lockfile the lockfile reader refuses, a
|
|
340
|
+
// setting this does not know or does not build for, a package from
|
|
341
|
+
// anywhere but those above — git, another tarball URL, a tarball on disk,
|
|
342
|
+
// a directory by `link:` — a range that is none of those above, a package
|
|
343
|
+
// with bundled dependencies, another package manager, a check above that
|
|
344
|
+
// fails — each is refused with a DeptreeError or a LockfileError that says
|
|
345
|
+
// where. A TypeError is thrown for options of the wrong type.
|
|
346
|
+
export function buildYarn1Tree(options: Yarn1TreeOptions): Promise<Yarn1Tree>
|
|
347
|
+
|
|
348
|
+
// The directories of the projects yarn finds in `project`, by which
|
|
349
|
+
// buildYarn1Tree takes their package.json given: `.`, the root, first,
|
|
350
|
+
// then each directory with a package.json that a glob of the root's
|
|
351
|
+
// `workspaces` takes, outside node_modules, as yarn finds them, and as
|
|
352
|
+
// buildYarn1Tree reads them from a project. Refused as buildYarn1Tree
|
|
353
|
+
// refuses it: a link where the globs reach, a node_modules they would
|
|
354
|
+
// take, a yarn.json; and a root with no package.json.
|
|
355
|
+
export interface Yarn1WorkspacesOptions {
|
|
356
|
+
project: Yarn1Project
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function findYarn1Workspaces(options: Yarn1WorkspacesOptions): string[]
|
|
360
|
+
|
|
361
|
+
// `where` is what a refusal is about — `.yarnrc:3`, `manifests["."]`, a
|
|
362
|
+
// package's pattern — or undefined for the call as a whole; the message
|
|
363
|
+
// leads with it. `cause` is what a package beneath refused with, where one
|
|
364
|
+
// did.
|
|
365
|
+
export class DeptreeError extends Error {
|
|
366
|
+
constructor(detail: string, where?: string, options?: { cause?: unknown })
|
|
367
|
+
where: string | undefined
|
|
368
|
+
}
|
package/yarn1.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// A node_modules tree built in memory from a yarn.lock, as yarn 1.22
|
|
2
|
+
// installs it with its node_modules linker; see yarn1.d.ts.
|
|
3
|
+
export { buildYarn1Tree } from './src/yarn1/tree.js'
|
|
4
|
+
export { findYarn1Workspaces } from './src/yarn1/inputs.js'
|
|
5
|
+
export { DeptreeError } from './src/error.js'
|
|
6
|
+
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
7
|
+
export { LockfileError } from '@preventive/lockfile/yarn1.js'
|
package/src/pnpm/npmrc.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// An .npmrc read as the `ini` package reads it for npm and pnpm, as far as
|
|
2
|
-
// a key and the text after its `=` go: a line per setting, `#` or `;` in
|
|
3
|
-
// front for a comment, `key[]` to add to a list, and a key with no `=`
|
|
4
|
-
// set to true. What a value means is left to the setting that reads it,
|
|
5
|
-
// which takes it only in a form with one reading (settings.js); a value
|
|
6
|
-
// ini would unquote, unescape, cut at a `;` or `#`, or fill in from the
|
|
7
|
-
// environment is refused there rather than read two ways. A section, which
|
|
8
|
-
// npm reads under a prefix no setting here has, is refused outright.
|
|
9
|
-
|
|
10
|
-
import { DeptreeError } from '../error.js'
|
|
11
|
-
|
|
12
|
-
// Each setting in the order written: `line` counts from one, and `list`
|
|
13
|
-
// says the key was written with `[]`, which is dropped from it.
|
|
14
|
-
export function parseNpmrc(text) {
|
|
15
|
-
const settings = []
|
|
16
|
-
const lines = text.split(/\r\n|\r|\n/u)
|
|
17
|
-
for (const [index, raw] of lines.entries()) {
|
|
18
|
-
const line = raw.trim()
|
|
19
|
-
const where = `.npmrc:${index + 1}`
|
|
20
|
-
if (line === '' || line.startsWith('#') || line.startsWith(';')) continue
|
|
21
|
-
if (line.startsWith('[')) throw new DeptreeError('a section is not supported', where)
|
|
22
|
-
const eq = line.indexOf('=')
|
|
23
|
-
let key = (eq === -1 ? line : line.slice(0, eq)).trim()
|
|
24
|
-
const value = eq === -1 ? 'true' : line.slice(eq + 1).trim()
|
|
25
|
-
const list = key.length > 2 && key.endsWith('[]')
|
|
26
|
-
if (list) key = key.slice(0, -2)
|
|
27
|
-
if (key === '') throw new DeptreeError('a setting has no name', where)
|
|
28
|
-
settings.push({ key, value, list, line: index + 1 })
|
|
29
|
-
}
|
|
30
|
-
return settings
|
|
31
|
-
}
|
/package/{LICENSE → LICENSE-MIT}
RENAMED
|
File without changes
|