@preventive/deptree 1.3.3 → 1.4.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 +5 -2
- package/bin/deptree.js +66 -19
- package/cocoapods.d.ts +372 -0
- package/cocoapods.js +6 -0
- package/package.json +23 -5
- package/pnpm.d.ts +64 -78
- package/soldeer.d.ts +6 -3
- package/src/cargo/members.js +3 -2
- package/src/cargo/tree.js +2 -2
- package/src/cargo/workspace.js +3 -6
- package/src/cocoapods/archive.js +223 -0
- package/src/cocoapods/clean.js +186 -0
- package/src/cocoapods/fnmatch.js +198 -0
- package/src/cocoapods/inputs.js +80 -0
- package/src/cocoapods/install.js +61 -0
- package/src/cocoapods/podspec.js +203 -0
- package/src/cocoapods/podtree.js +131 -0
- package/src/cocoapods/source.js +90 -0
- package/src/cocoapods/tree.js +184 -0
- package/src/cocoapods/unicode.js +17 -0
- package/src/github.js +92 -0
- package/src/glob.js +2 -1
- package/src/hash.js +1 -34
- package/src/matcher.js +2 -4
- package/src/mount.js +2 -5
- package/src/npm/compat.js +3 -4
- package/src/npm/manifests.js +1 -1
- package/src/npm/tree.js +9 -8
- package/src/patch.js +9 -5
- package/src/pnpm/bins.js +12 -11
- package/src/pnpm/commands.js +5 -15
- package/src/pnpm/directories.js +250 -0
- package/src/pnpm/extensions.js +76 -0
- package/src/pnpm/filename.js +4 -4
- package/src/pnpm/frozen.js +3 -2
- package/src/pnpm/glob.js +1 -1
- package/src/pnpm/graph.js +7 -9
- package/src/pnpm/hoist.js +0 -36
- package/src/pnpm/hoisted.js +3 -3
- package/src/pnpm/hook.js +13 -21
- package/src/pnpm/inputs.js +6 -18
- package/src/pnpm/install.js +3 -4
- package/src/pnpm/lazy.js +18 -18
- package/src/pnpm/local.js +29 -15
- package/src/pnpm/minimatch.js +2 -2
- package/src/pnpm/nm-hoist.js +1 -1
- package/src/pnpm/npm-packlist.js +1 -1
- package/src/pnpm/overrides.js +3 -4
- package/src/pnpm/package.js +17 -9
- package/src/pnpm/packlist.js +3 -2
- package/src/pnpm/patches.js +15 -13
- package/src/pnpm/production.js +41 -13
- package/src/pnpm/projects.js +14 -40
- package/src/pnpm/readers.js +6 -29
- package/src/pnpm/settings.js +14 -37
- package/src/pnpm/tree.js +36 -26
- package/src/pnpm/uptodate.js +12 -13
- package/src/pnpm/workspace.js +8 -79
- package/src/soldeer/tree.js +2 -2
- package/src/soldeer/zip.js +11 -42
- package/src/tarball.js +1 -3
- package/src/yarn1/hoist.js +4 -2
- package/src/yarn1/manifest.js +3 -2
- package/src/yarn1/requests.js +1 -1
- package/src/yarn1/resolve.js +16 -6
- package/src/yarn1/tree.js +12 -8
- package/src/soldeer/git.js +0 -67
package/src/pnpm/readers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Each setting pnpm reads, by its pnpm-workspace.yaml name, is either read
|
|
2
|
-
// and checked (READ,
|
|
3
|
-
// the tree as it is (IGNORED,
|
|
2
|
+
// and checked (READ, READ_11, READ_12) or passed over as leaving
|
|
3
|
+
// the tree as it is (IGNORED, IGNORED_11, IGNORED_12); any other is
|
|
4
4
|
// refused.
|
|
5
5
|
|
|
6
6
|
import { valid } from '@preventive/upstream/semver.js'
|
|
@@ -104,9 +104,8 @@ export const READ = {
|
|
|
104
104
|
filterProd: { kind: 'texts', check: never('every project is installed') },
|
|
105
105
|
useNodeVersion: { kind: 'text', check: never('the Node a tree is built for is the host\'s, or nodeVersion') },
|
|
106
106
|
globalPnpmfile: { kind: 'text', check: never('a pnpmfile\'s hooks are not run here') },
|
|
107
|
-
// [] loads none, not even the default one. An .npmrc's is passed over:
|
|
108
|
-
//
|
|
109
|
-
// puts its pnpmfileChecksum in the lockfile, which is refused (tree.js).
|
|
107
|
+
// [] loads none, not even the default one. An .npmrc's is passed over: a
|
|
108
|
+
// pnpmfile with hooks puts its pnpmfileChecksum in the lockfile, which is refused (tree.js).
|
|
110
109
|
pnpmfile: { kind: 'pnpmfile', check: (value, where) => (Array.isArray(value) && value.length === 0) || never('a pnpmfile\'s hooks are not run here')(value, where), rc: false },
|
|
111
110
|
registry: { kind: 'text', check: checkRegistry },
|
|
112
111
|
virtualStoreDirMaxLength: { kind: 'count' },
|
|
@@ -192,26 +191,6 @@ const UNRECOGNIZED_12 = new Set([
|
|
|
192
191
|
|
|
193
192
|
export const unrecognized12 = (where) => new DeptreeError('pnpm 12 does not know it, and fails on it where the root package.json pins the pnpm that runs', where)
|
|
194
193
|
|
|
195
|
-
// What pnpm 9 reads that pnpm 10 passes over: how it holds the root
|
|
196
|
-
// package.json's packageManager to the pnpm that runs (projects.js).
|
|
197
|
-
const READ_9 = {
|
|
198
|
-
__proto__: null,
|
|
199
|
-
nodeLinker: only('text', 'isolated', 'only the isolated node_modules layout is built for pnpm 9'),
|
|
200
|
-
managePackageManagerVersions: { kind: 'boolean' },
|
|
201
|
-
packageManagerStrict: { kind: 'boolean' },
|
|
202
|
-
packageManagerStrictVersion: { kind: 'boolean' },
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// What pnpm 10 reads that pnpm 9 has no setting for, and passes over.
|
|
206
|
-
const NOT_9 = new Set(['dedupePeers', 'enableGlobalVirtualStore', 'injectWorkspacePackages'])
|
|
207
|
-
|
|
208
|
-
// The keys of package.json's `pnpm` pnpm 9 reads, passing over any other.
|
|
209
|
-
export const MANIFEST_KEYS_9 = [
|
|
210
|
-
'allowNonAppliedPatches', 'allowedDeprecatedVersions', 'ignoredOptionalDependencies', 'neverBuiltDependencies',
|
|
211
|
-
'onlyBuiltDependencies', 'onlyBuiltDependenciesFile', 'overrides', 'packageExtensions', 'patchedDependencies',
|
|
212
|
-
'peerDependencyRules', 'supportedArchitectures',
|
|
213
|
-
]
|
|
214
|
-
|
|
215
194
|
// The keys of package.json's `pnpm` pnpm 10 reads, passing over any other.
|
|
216
195
|
export const MANIFEST_KEYS = [
|
|
217
196
|
'allowBuilds', 'allowNonAppliedPatches', 'allowUnusedPatches', 'allowedDeprecatedVersions', 'auditConfig',
|
|
@@ -278,11 +257,9 @@ function checkCatalogs(value, where) {
|
|
|
278
257
|
for (const [name, catalog] of Object.entries(value)) checkCatalog(readers.mapping(catalog, `${where}.${name}`), `${where}.${name}`)
|
|
279
258
|
}
|
|
280
259
|
|
|
281
|
-
// `{}` where a setting leaves the tree as it is
|
|
282
|
-
//
|
|
260
|
+
// `{}` where a setting leaves the tree as it is, undefined where not known
|
|
261
|
+
// here. pnpm 12 takes a pattern only as a list.
|
|
283
262
|
function lookup(name, major) {
|
|
284
|
-
if (major < 10 && name in READ_9) return { read: READ_9[name] }
|
|
285
|
-
if (major < 10 && NOT_9.has(name)) return {}
|
|
286
263
|
if (major >= 12 && UNRECOGNIZED_12.has(name)) return { unrecognized: true }
|
|
287
264
|
if (major >= 12 && name in READ_12) return { read: READ_12[name] }
|
|
288
265
|
if (major >= 11 && name in READ_11) return { read: READ_11[name] }
|
package/src/pnpm/settings.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// The settings an install reads. pnpm 10 reads the .npmrc beside the
|
|
2
2
|
// lockfile, pnpm-workspace.yaml and the root package.json's `pnpm` field,
|
|
3
|
-
// each over the one before; pnpm
|
|
4
|
-
// pnpm-workspace.yaml, and pnpm 11 and 12 read pnpm-workspace.yaml alone.
|
|
3
|
+
// each over the one before; pnpm 11 and 12 read pnpm-workspace.yaml alone.
|
|
5
4
|
// Settings from anywhere else (a user or global .npmrc, `npm_config_*`, the
|
|
6
5
|
// command line) are taken to be at their defaults.
|
|
7
6
|
|
|
@@ -9,7 +8,7 @@ import { valid, validRange } from '@preventive/upstream/semver.js'
|
|
|
9
8
|
import { DeptreeError, quote } from '../error.js'
|
|
10
9
|
import { parseNpmrc } from '../npmrc.js'
|
|
11
10
|
import { replaceReferences } from './overrides.js'
|
|
12
|
-
import { MANIFEST_KEYS,
|
|
11
|
+
import { MANIFEST_KEYS, READ, checkRegistry, known12, npmrcReader, readerOf, readers, unrecognized12 } from './readers.js'
|
|
13
12
|
|
|
14
13
|
// An .npmrc value can mean one thing only with no quote, escape, `;` or `#`.
|
|
15
14
|
const PLAIN = /^[^"'`;#\\]*$/u
|
|
@@ -62,8 +61,8 @@ function fromNpmrc(text, major) {
|
|
|
62
61
|
const earlier = settings.get(name)
|
|
63
62
|
if (earlier !== undefined && !(list && earlier.list)) throw new DeptreeError('set more than once', where)
|
|
64
63
|
if (list && read.kind !== 'texts') throw new DeptreeError('not a list', where)
|
|
65
|
-
const
|
|
66
|
-
settings.set(name, { value:
|
|
64
|
+
const given = plain(value, where)
|
|
65
|
+
settings.set(name, { value: list ? [...(earlier?.value ?? []), given] : given, list, where, read })
|
|
67
66
|
}
|
|
68
67
|
return { settings, environment }
|
|
69
68
|
}
|
|
@@ -72,7 +71,7 @@ function fromNpmrc(text, major) {
|
|
|
72
71
|
function fromManifest(manifest, major) {
|
|
73
72
|
const pnpm = manifest.pnpm === undefined ? {} : readers.mapping(manifest.pnpm, 'package.json: pnpm')
|
|
74
73
|
const settings = new Map()
|
|
75
|
-
for (const name of
|
|
74
|
+
for (const name of MANIFEST_KEYS) {
|
|
76
75
|
if (!Object.hasOwn(pnpm, name) || name === 'overrides') continue
|
|
77
76
|
const where = `package.json: pnpm.${name}`
|
|
78
77
|
noEnvironment(pnpm[name], where)
|
|
@@ -107,21 +106,11 @@ function fromWorkspace(workspace, major, pinned) {
|
|
|
107
106
|
return settings
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
// pnpm 9 passes over the rest of pnpm-workspace.yaml unread, a catalog of null
|
|
111
|
-
// among it.
|
|
112
|
-
function fromWorkspace9(workspace) {
|
|
113
|
-
readers.mapping(workspace, 'pnpm-workspace.yaml')
|
|
114
|
-
const names = ['packages', 'catalog', 'catalogs'].filter((name) => workspace[name] != null)
|
|
115
|
-
return new Map(names.map((name) => [name, { value: workspace[name], where: `pnpm-workspace.yaml: ${name}`, read: READ[name] }]))
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const PUBLIC_9 = ['*eslint*', '*prettier*']
|
|
119
|
-
|
|
120
109
|
// A hoist pattern left undefined is not hoisted to at all. Only on Windows,
|
|
121
110
|
// which checkHost refuses, is virtualStoreDirMaxLength 60 by default.
|
|
122
|
-
function derive(get
|
|
111
|
+
function derive(get) {
|
|
123
112
|
const shamefullyHoist = get('shamefullyHoist')
|
|
124
|
-
let publicHoistPattern = get('publicHoistPattern') ??
|
|
113
|
+
let publicHoistPattern = get('publicHoistPattern') ?? []
|
|
125
114
|
if (shamefullyHoist === true) publicHoistPattern = ['*']
|
|
126
115
|
else if (shamefullyHoist === false || (publicHoistPattern.length === 1 && publicHoistPattern[0] === '')) publicHoistPattern = undefined
|
|
127
116
|
return {
|
|
@@ -148,24 +137,15 @@ function derive(get, major) {
|
|
|
148
137
|
runtimeOnFail: get('runtimeOnFail'),
|
|
149
138
|
packageImportMethod: get('packageImportMethod') ?? 'auto',
|
|
150
139
|
nodeLinker: get('nodeLinker') ?? 'isolated',
|
|
151
|
-
...major < 10 ? {
|
|
152
|
-
packageManagerChecks: {
|
|
153
|
-
manage: get('managePackageManagerVersions') ?? false,
|
|
154
|
-
strict: get('packageManagerStrict') ?? true,
|
|
155
|
-
strictVersion: get('packageManagerStrictVersion') ?? false,
|
|
156
|
-
},
|
|
157
|
-
} : {},
|
|
158
140
|
}
|
|
159
141
|
}
|
|
160
142
|
|
|
161
143
|
function catalogsOf(catalog, catalogs = {}) {
|
|
162
|
-
if (catalog !== undefined && Object.hasOwn(catalogs, 'default'))
|
|
163
|
-
throw new DeptreeError('the default catalog is defined twice, as catalog and as catalogs.default', 'pnpm-workspace.yaml: catalog')
|
|
164
|
-
}
|
|
144
|
+
if (catalog !== undefined && Object.hasOwn(catalogs, 'default')) throw new DeptreeError('the default catalog is defined twice, as catalog and as catalogs.default', 'pnpm-workspace.yaml: catalog')
|
|
165
145
|
return Object.assign(Object.create(null), catalog === undefined ? {} : { default: catalog }, catalogs)
|
|
166
146
|
}
|
|
167
147
|
|
|
168
|
-
function settle(layers, manifest
|
|
148
|
+
function settle(layers, manifest) {
|
|
169
149
|
const values = new Map()
|
|
170
150
|
for (const layer of layers) {
|
|
171
151
|
for (const [name, { value, where, read: { kind, check } }] of layer) {
|
|
@@ -178,25 +158,22 @@ function settle(layers, manifest, major) {
|
|
|
178
158
|
values.set(name, read)
|
|
179
159
|
}
|
|
180
160
|
}
|
|
181
|
-
return derive((name) => values.get(name)
|
|
161
|
+
return derive((name) => values.get(name))
|
|
182
162
|
}
|
|
183
163
|
|
|
184
164
|
// Overrides that name nothing are none, and leave those below them.
|
|
185
165
|
export function readSettings({ workspace, npmrc, manifest, major = 10, pinned = false }) {
|
|
186
|
-
const fromYaml = () =>
|
|
187
|
-
if (workspace === undefined) return new Map()
|
|
188
|
-
return major < 10 ? fromWorkspace9(workspace) : fromWorkspace(workspace, major, pinned)
|
|
189
|
-
}
|
|
166
|
+
const fromYaml = () => (workspace === undefined ? new Map() : fromWorkspace(workspace, major, pinned))
|
|
190
167
|
if (major >= 11) {
|
|
191
168
|
if (npmrc !== undefined) checkNpmrcRegistries(npmrc)
|
|
192
|
-
const settings = settle([fromYaml()], manifest
|
|
169
|
+
const settings = settle([fromYaml()], manifest)
|
|
193
170
|
settings.runtimeNodeVersion = runtimeNode(manifest, settings.runtimeOnFail)
|
|
194
171
|
return settings
|
|
195
172
|
}
|
|
196
173
|
const rc = npmrc === undefined ? { settings: new Map(), environment: false } : fromNpmrc(npmrc, major)
|
|
197
174
|
const rest = [fromYaml(), fromManifest(manifest, major)]
|
|
198
|
-
const settings = settle([rc.settings, ...rest], manifest
|
|
199
|
-
if (rc.environment && JSON.stringify(settings) !== JSON.stringify(settle(rest, manifest
|
|
175
|
+
const settings = settle([rc.settings, ...rest], manifest)
|
|
176
|
+
if (rc.environment && JSON.stringify(settings) !== JSON.stringify(settle(rest, manifest))) {
|
|
200
177
|
throw new DeptreeError('a line takes a value from the environment, which pnpm drops the whole file for where it is unset, and the file sets what would change the tree', '.npmrc')
|
|
201
178
|
}
|
|
202
179
|
return settings
|
package/src/pnpm/tree.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The node_modules tree pnpm
|
|
1
|
+
// The node_modules tree pnpm 10, 11 or 12 installs from a frozen lockfile
|
|
2
2
|
// with the isolated linker and --ignore-scripts, in a Vfs rooted at the
|
|
3
3
|
// lockfile's directory; patched still, as pnpm patches before scripts. Bins are
|
|
4
4
|
// not linked, though what linking does to their files is (bins.js). With
|
|
@@ -25,8 +25,10 @@ import { checkNoneDropped, hoistedBuilds, hoistedLayout, hoistedModules, mayDrop
|
|
|
25
25
|
import { checkLocalOverrides, createFreshnessCheck, readDirectoryPackage, readLinked } from './local.js'
|
|
26
26
|
import { createPatchedCheck, skippedSnapshots } from './install.js'
|
|
27
27
|
import { lazyUnpacker } from './lazy.js'
|
|
28
|
-
import { checkFetched, fetchPackage } from './package.js'
|
|
28
|
+
import { checkFetched, createPeerDrop, fetchPackage } from './package.js'
|
|
29
29
|
import { checkLinks, checkOptional } from './checks.js'
|
|
30
|
+
import { createDirectoryCheck } from './directories.js'
|
|
31
|
+
import { listExtensions } from './extensions.js'
|
|
30
32
|
import { createHook } from './hook.js'
|
|
31
33
|
import { productionLockfile } from './production.js'
|
|
32
34
|
import { listOverrides } from './overrides.js'
|
|
@@ -89,25 +91,27 @@ async function fetchAll(nodes, project, host, fetching) {
|
|
|
89
91
|
return fetching.sizeEstimateOnly ? { ...got, size: bytesOf(got.files) } : got
|
|
90
92
|
}
|
|
91
93
|
await eachConcurrently(packages, async ([id, pkg]) => {
|
|
92
|
-
if (pkg.resolution.type === 'directory')
|
|
93
|
-
|
|
94
|
+
if (pkg.resolution.type === 'directory') {
|
|
95
|
+
fetched.set(id, read(pkg, quote(id)))
|
|
96
|
+
} else if (!fetching.lazy) {
|
|
97
|
+
fetched.set(id, await fetch(pkg, quote(id)))
|
|
98
|
+
}
|
|
94
99
|
}, ([id]) => quote(id))
|
|
95
100
|
return fetched
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
// With `lazy`, a registry package's snapshots have no files yet, and are held
|
|
99
|
-
// to them as each is unpacked; `checks` are what that takes, of
|
|
100
|
-
//
|
|
101
|
-
async function fetchNodes(nodes,
|
|
104
|
+
// to them as each is unpacked; `checks` are what that takes, of the whole
|
|
105
|
+
// lockfile.
|
|
106
|
+
async function fetchNodes(nodes, checks, project, host, fetching) {
|
|
102
107
|
const fetched = await fetchAll(nodes, project, host, fetching)
|
|
103
|
-
const checks = { lockfile: checked, hook, fresh: createFreshnessCheck(checked, host.major) }
|
|
104
108
|
const byDir = new Map()
|
|
105
109
|
for (const node of nodes.values()) {
|
|
106
110
|
const got = fetched.get(packageKeyOf(node.key))
|
|
107
111
|
if (got !== undefined) checkFetched(node, got, checks)
|
|
108
112
|
byDir.set(node.dir, { ...node, files: got?.files, manifest: got?.manifest, about: got?.about ?? NO_ABOUT, size: got?.size })
|
|
109
113
|
}
|
|
110
|
-
return { byDir, tarballs: [...fetched.values()].filter((got) => !got.local).length
|
|
114
|
+
return { byDir, tarballs: [...fetched.values()].filter((got) => !got.local).length }
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
// pnpm hardlinks a directory package's files into each of its snapshots, so a
|
|
@@ -188,8 +192,8 @@ const COPYING = new Set(['copy', 'clone', 'clone-or-copy'])
|
|
|
188
192
|
// followed, nor with `lazy` but where a package unpacked needs them. `builds`
|
|
189
193
|
// tells, where any patch is configured, what the build pass builds; `reads`
|
|
190
194
|
// the packages the fixes read the files of (hoistedBinReads). `lockfile` is
|
|
191
|
-
// the one the tree is laid out from, and `
|
|
192
|
-
async function buildHoisted({ lockfile,
|
|
195
|
+
// the one the tree is laid out from, and `checks` hold it to the whole one.
|
|
196
|
+
async function buildHoisted({ lockfile, checks, settings, host, project, installed, manifests, names, patched, skipped, fetching }) {
|
|
193
197
|
const { major } = host
|
|
194
198
|
const since = (version) => compareVersions(host.pnpm, version) >= 0
|
|
195
199
|
if (!COPYING.has(settings.packageImportMethod)) {
|
|
@@ -205,7 +209,7 @@ async function buildHoisted({ lockfile, checked, settings, host, project, hook,
|
|
|
205
209
|
const keepsModules = since('11.25.0')
|
|
206
210
|
const dropping = building && hardlinks && !keepsModules ? mayDrop(placed) : new Map()
|
|
207
211
|
if (fetching.sizeEstimateOnly) checkNoneDropped(dropping, host.pnpm)
|
|
208
|
-
const { byDir, tarballs
|
|
212
|
+
const { byDir, tarballs } = await fetchNodes(placed, checks, project, host, fetching)
|
|
209
213
|
const linked = readLinked(links, byDir, manifests, project)
|
|
210
214
|
const prod = prodPackages(lockfile, skipped, directories)
|
|
211
215
|
const dev = (node) => !prod.has(packageIdOf(node.key, node.pkg, directories))
|
|
@@ -220,17 +224,17 @@ async function buildHoisted({ lockfile, checked, settings, host, project, hook,
|
|
|
220
224
|
}
|
|
221
225
|
// With lazy, those that may drop a node_modules are fetched with the tree.
|
|
222
226
|
const early = dropping.size === 0 ? undefined : { nodes: [...byDir.values()].filter((node) => dropping.has(node.key)), check: () => builtOf((node) => dropping.has(node.key) && builds(node)) }
|
|
223
|
-
return { byDir, links, fixes, reads: () => hoistedBinReads({ nodes: byDir, building, packages: lockfile.packages }), builds, early, tarballs, dev
|
|
227
|
+
return { byDir, links, fixes, reads: () => hoistedBinReads({ nodes: byDir, building, packages: lockfile.packages }), builds, early, tarballs, dev }
|
|
224
228
|
}
|
|
225
229
|
|
|
226
230
|
// The isolated layout: each package in node_modules/.pnpm, linked from what
|
|
227
231
|
// needs it and where it is hoisted; `fixes` as buildHoisted's, and `reads`
|
|
228
232
|
// the packages they read the files of (binReads).
|
|
229
|
-
async function buildIsolated({ lockfile,
|
|
233
|
+
async function buildIsolated({ lockfile, checks, settings, host, project, installed, manifests, names, skipped, fetching }) {
|
|
230
234
|
const { major } = host
|
|
231
235
|
const { nodes, direct, hoisting } = await buildGraph(lockfile, skipped, settings.virtualStoreDirMaxLength, major)
|
|
232
236
|
for (const node of nodes.values()) checkSource(node, installed)
|
|
233
|
-
const { byDir, tarballs
|
|
237
|
+
const { byDir, tarballs } = await fetchNodes(nodes, checks, project, host, fetching)
|
|
234
238
|
const links = linksOf(byDir, direct, settings, names, major, hoisting)
|
|
235
239
|
const linked = readLinked(links, byDir, manifests, project)
|
|
236
240
|
const prod = reachedInProd(lockfile.importers, nodes, byDir)
|
|
@@ -249,14 +253,15 @@ async function buildIsolated({ lockfile, checked, settings, host, project, hook,
|
|
|
249
253
|
const targets = binTargets(linking)
|
|
250
254
|
return { targets, executable: executableElsewhere(byDir, targets, settings.packageImportMethod, major) }
|
|
251
255
|
}
|
|
252
|
-
return { byDir, links, fixes, reads: () => binReads(linking), tarballs, dev
|
|
256
|
+
return { byDir, links, fixes, reads: () => binReads(linking), tarballs, dev }
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
export async function buildPnpmTree(options) {
|
|
256
|
-
const
|
|
260
|
+
const opts = options ?? {}
|
|
261
|
+
const { project, host: given, vfs: into } = opts
|
|
257
262
|
if (into !== undefined && !(into instanceof Vfs)) throw new TypeError('vfs must be a Vfs, or left out')
|
|
258
|
-
const fetching = fetchingOf(
|
|
259
|
-
const production = productionOf(
|
|
263
|
+
const fetching = fetchingOf(opts, into)
|
|
264
|
+
const production = productionOf(opts)
|
|
260
265
|
if (project !== undefined) checkProject(project)
|
|
261
266
|
const machine = checkHost(given)
|
|
262
267
|
const folded = machine.os === 'darwin'
|
|
@@ -275,22 +280,27 @@ export async function buildPnpmTree(options) {
|
|
|
275
280
|
// pins, which leaves the tree as it is.
|
|
276
281
|
if (env !== undefined && major < 11) throw new DeptreeError('the env document pnpm 11 writes is not supported', 'env')
|
|
277
282
|
if (env !== undefined && Object.keys(env.importers['.'].configDependencies).length > 0) throw new DeptreeError('config dependencies are not supported', 'env.importers["."].configDependencies')
|
|
278
|
-
// As pnpm
|
|
283
|
+
// As pnpm 10 and 11 write the lockfile's own directory.
|
|
279
284
|
const empty = major >= 12 ? Object.keys(lockfile.packages).find((key) => packageKeyOf(key).endsWith('@file:')) : undefined
|
|
280
285
|
if (empty !== undefined) throw new DeptreeError('pnpm 12 refuses as broken a lockfile with `file:` and an empty path', quote(empty))
|
|
281
286
|
const settings = readSettings({ workspace, npmrc: inputs.npmrc, manifest: manifests.get('.'), major, pinned: pinsPnpm(manifests.get('.'), host.pnpm) })
|
|
282
287
|
checkWorkspace(Object.keys(lockfile.importers), settings.packages, major)
|
|
283
288
|
const overrides = listOverrides(settings.overrides, settings.catalogs, major)
|
|
289
|
+
const extensions = listExtensions(settings.packageExtensions, major)
|
|
284
290
|
const installed = checkLocalOverrides(overrides, project)
|
|
285
|
-
const patched = await checkUpToDate(lockfile, settings, overrides, patchesOf(inputs, settings.patchedDependencies), major)
|
|
286
|
-
const hook = createHook({ overrides, ignored: settings.ignoredOptionalDependencies, major })
|
|
287
|
-
|
|
291
|
+
const patched = await checkUpToDate(lockfile, settings, { overrides, extensions }, patchesOf(inputs, settings.patchedDependencies), major)
|
|
292
|
+
const hook = createHook({ overrides, extensions, ignored: settings.ignoredOptionalDependencies, major })
|
|
293
|
+
const fresh = createFreshnessCheck(lockfile, host, extensions, settings.autoInstallPeers)
|
|
294
|
+
const drops = createPeerDrop(host, settings.autoInstallPeers)
|
|
295
|
+
const directories = createDirectoryCheck(lockfile, { host, hook, project, installed, settings, fresh, drops })
|
|
296
|
+
checkProjects(lockfile, manifests, { hook, extensions, host, settings, env, directories })
|
|
288
297
|
checkOptional(lockfile)
|
|
289
298
|
const names = settings.hoistWorkspacePackages ? workspaceNames(manifests) : new Map()
|
|
290
|
-
const
|
|
291
|
-
const { skipped, incompatible } =
|
|
299
|
+
const skippedOf = (walked) => skippedSnapshots(walked, { host, settings })
|
|
300
|
+
const { installing, skipped, incompatible } = production ? productionLockfile(lockfile, { ...host, resolvePeersFromWorkspaceRoot: settings.resolvePeersFromWorkspaceRoot }, skippedOf) : { installing: lockfile, ...skippedOf(lockfile) }
|
|
292
301
|
const hoisted = settings.nodeLinker === 'hoisted'
|
|
293
|
-
const
|
|
302
|
+
const checks = { lockfile, hook, fresh, drops }
|
|
303
|
+
const { byDir, links, fixes, reads, builds, early, tarballs, dev } = await (hoisted ? buildHoisted : buildIsolated)({ lockfile: installing, checks, settings, host, project, installed, manifests, names, patched, skipped, fetching })
|
|
294
304
|
const laidOut = fetching.sizeEstimateOnly || fetching.lazy
|
|
295
305
|
const { targets, executable } = laidOut ? { targets: new Map(), executable: new Map() } : fixes()
|
|
296
306
|
|
package/src/pnpm/uptodate.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Refuses a lockfile a frozen install would refuse as out of date with the
|
|
2
2
|
// settings (@pnpm/lockfile.settings-checker's getOutdatedLockfileSetting),
|
|
3
|
-
// naming the setting as pnpm names it.
|
|
4
|
-
// catalogs nor dedupePeers.
|
|
3
|
+
// naming the setting as pnpm names it.
|
|
5
4
|
|
|
6
5
|
import { normalize } from '@preventive/vfs/path.js'
|
|
7
6
|
import { DeptreeError, difference, quote } from '../error.js'
|
|
8
|
-
import {
|
|
7
|
+
import { sha256Hex } from '../hash.js'
|
|
8
|
+
import { extensionsChecksum } from './extensions.js'
|
|
9
9
|
import { sameSpecifier } from './frozen.js'
|
|
10
10
|
import { catalogEntry } from './overrides.js'
|
|
11
11
|
import { checkPatchUse, checkPeerPatches } from './patches.js'
|
|
@@ -15,7 +15,7 @@ const outdated = (name, detail) => new DeptreeError(`${detail}, which a frozen i
|
|
|
15
15
|
const SIDES = ['the lockfile', 'the settings']
|
|
16
16
|
|
|
17
17
|
// `hashes` is { hash, path } by selector, `byHash` { text, path } by hash.
|
|
18
|
-
async function hashPatches(configured, given
|
|
18
|
+
async function hashPatches(configured, given) {
|
|
19
19
|
const texts = new Map()
|
|
20
20
|
for (const [key, text] of given) {
|
|
21
21
|
const path = normalize(key)
|
|
@@ -32,7 +32,7 @@ async function hashPatches(configured, given, major) {
|
|
|
32
32
|
const text = texts.get(path)
|
|
33
33
|
const normalized = text.replaceAll('\r\n', '\n')
|
|
34
34
|
const where = `patches[${quote(path)}]`
|
|
35
|
-
const hash =
|
|
35
|
+
const hash = await sha256Hex(normalized, where)
|
|
36
36
|
hashes[selector] = { hash, path }
|
|
37
37
|
if (!byHash.has(hash)) byHash.set(hash, { text, path })
|
|
38
38
|
}
|
|
@@ -49,9 +49,9 @@ function checkPatches(locked, hashes, major) {
|
|
|
49
49
|
if (detail !== undefined) throw outdated('patchedDependencies', `the patches differ: ${detail}`)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export async function checkUpToDate(lockfile, settings, overrides, given, major) {
|
|
53
|
-
const { hashes, byHash } = await hashPatches(settings.patchedDependencies, given
|
|
54
|
-
for (const [name, catalog] of
|
|
52
|
+
export async function checkUpToDate(lockfile, settings, { overrides, extensions }, given, major) {
|
|
53
|
+
const { hashes, byHash } = await hashPatches(settings.patchedDependencies, given)
|
|
54
|
+
for (const [name, catalog] of Object.entries(lockfile.catalogs)) {
|
|
55
55
|
for (const [alias, { specifier }] of Object.entries(catalog)) {
|
|
56
56
|
const configured = catalogEntry(settings.catalogs, name, alias)
|
|
57
57
|
if (!sameSpecifier(specifier, configured, major)) throw outdated('catalogs', `${quote(alias)} is ${quote(specifier)} in the lockfile's catalog ${quote(name)}, and ${configured === undefined ? 'nothing' : quote(configured)} in the settings`)
|
|
@@ -59,17 +59,16 @@ export async function checkUpToDate(lockfile, settings, overrides, given, major)
|
|
|
59
59
|
}
|
|
60
60
|
const overridden = difference(lockfile.overrides, Object.fromEntries(overrides.map(({ selector, spec }) => [selector, spec])), SIDES)
|
|
61
61
|
if (overridden !== undefined) throw outdated('overrides', `the overrides differ: ${overridden}`)
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
if (lockfile.packageExtensionsChecksum !== undefined) throw outdated('packageExtensionsChecksum', 'the lockfile was resolved with package extensions, and the settings have none')
|
|
62
|
+
const extended = await extensionsChecksum(extensions, major)
|
|
63
|
+
if (lockfile.packageExtensionsChecksum !== extended) throw outdated('packageExtensionsChecksum', extended === undefined ? 'the lockfile was resolved with package extensions, and the settings have none' : 'the package extensions in the settings are not those the lockfile was resolved with')
|
|
65
64
|
const ignored = (list) => JSON.stringify([...list].sort())
|
|
66
65
|
if (ignored(lockfile.ignoredOptionalDependencies) !== ignored(settings.ignoredOptionalDependencies)) throw outdated('ignoredOptionalDependencies', 'the optional dependencies left out differ')
|
|
67
66
|
checkPatches(lockfile.patchedDependencies, hashes, major)
|
|
68
67
|
const locked = lockfile.settings
|
|
69
68
|
if (locked.autoInstallPeers !== undefined && locked.autoInstallPeers !== settings.autoInstallPeers) throw outdated('settings.autoInstallPeers', `autoInstallPeers is ${locked.autoInstallPeers} in the lockfile`)
|
|
70
|
-
if (
|
|
69
|
+
if (Boolean(locked.dedupePeers) !== settings.dedupePeers) throw outdated('settings.dedupePeers', `dedupePeers is ${Boolean(locked.dedupePeers)} in the lockfile`)
|
|
71
70
|
if ((locked.peersSuffixMaxLength ?? 1000) !== settings.peersSuffixMaxLength) throw outdated('settings.peersSuffixMaxLength', `peersSuffixMaxLength is ${locked.peersSuffixMaxLength ?? 'left at 1000'} in the lockfile`)
|
|
72
|
-
checkPatchUse(lockfile, hashes
|
|
71
|
+
checkPatchUse(lockfile, hashes)
|
|
73
72
|
if (major >= 11) checkPeerPatches(lockfile, hashes)
|
|
74
73
|
return byHash
|
|
75
74
|
}
|
package/src/pnpm/workspace.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The directories pnpm takes for a workspace's projects: the root, and each
|
|
2
2
|
// whose package.json a glob of pnpm-workspace.yaml's `packages` takes, as
|
|
3
|
-
// @pnpm/fs.find-packages globs for them with tinyglobby
|
|
3
|
+
// @pnpm/fs.find-packages globs for them with tinyglobby, or
|
|
4
4
|
// as pnpm 12 walks (wax). pnpm 11 matches `!` globs with micromatch, dotted
|
|
5
5
|
// names and all.
|
|
6
6
|
|
|
@@ -47,7 +47,6 @@ function enters({ names: glob, dot }, names) {
|
|
|
47
47
|
// find-packages ignores; pnpm 12 drops it whatever the globs say. `wild` is
|
|
48
48
|
// whether a glob with a `*` takes it (manifestOf).
|
|
49
49
|
function compileAll(packages, major) {
|
|
50
|
-
if (major < 10) return compile9(packages)
|
|
51
50
|
const twelve = major >= 12
|
|
52
51
|
const [enters_, ignored_, dropped] = twelve ? [enters12, underLeftOut, underLeftOut] : [enters, ignored, () => false]
|
|
53
52
|
const include = []
|
|
@@ -61,78 +60,15 @@ function compileAll(packages, major) {
|
|
|
61
60
|
walked: (names) => include.some((glob) => enters_(glob, names)) && !ignored_(names),
|
|
62
61
|
taken: takenBy(include, exclude, dropped),
|
|
63
62
|
wild: (names) => include.some((glob) => glob.wild && takes(glob, names)),
|
|
64
|
-
manifests: MANIFESTS,
|
|
65
|
-
through: [],
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
const takenBy = (include, exclude, dropped) => (names) => include.some((glob) => takes(glob, names)) && !exclude.some((glob) => takes(glob, names)) && !dropped(names)
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// fast-glob's partial matcher: past the names before its first `**`, any.
|
|
74
|
-
function partial({ names: glob, raw }, names) {
|
|
75
|
-
const star = raw.indexOf('**')
|
|
76
|
-
if (star === -1 && glob.length <= names.length) return false
|
|
77
|
-
if (star !== -1 && names.length > star) return true
|
|
78
|
-
return names.every((name, i) => glob[i].test(name))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const isDynamic = (glob) => glob.raw.some((name) => name.includes('*'))
|
|
82
|
-
|
|
83
|
-
// pnpm 9 globs with fast-glob 3: a glob with no `*` it looks up where it
|
|
84
|
-
// leads, and one with a `*` it walks for from the names before that
|
|
85
|
-
// (`base`), from the top for all of them where one has none there. Under
|
|
86
|
-
// a base it walks into every directory its globs may reach (`partial`),
|
|
87
|
-
// those with a leading dot among them, but where the ignore globs take it
|
|
88
|
-
// with `**` taking no leading dot, or where a `!` glob takes it whole;
|
|
89
|
-
// and takes a manifest a glob takes and no `!` glob, nor an ignore glob,
|
|
90
|
-
// with `**` and `*` taking leading dots. It reads every manifest a
|
|
91
|
-
// directory has, so one but package.json is the one refused (MANIFESTS_9),
|
|
92
|
-
// and fails on a glob that leads through a file (`through`).
|
|
93
|
-
function compile9(packages) {
|
|
94
|
-
const where = 'pnpm-workspace.yaml: packages'
|
|
95
|
-
const include = []
|
|
96
|
-
const exclude = []
|
|
97
|
-
const excludeWhole = []
|
|
98
|
-
for (const glob of packages ?? []) {
|
|
99
|
-
if (glob.startsWith('!')) {
|
|
100
|
-
exclude.push(compile(glob.slice(1), where, true))
|
|
101
|
-
excludeWhole.push(compile(glob.slice(1), where, false))
|
|
102
|
-
} else include.push(compile(glob, where, false))
|
|
103
|
-
}
|
|
104
|
-
const dynamic = include.filter(isDynamic)
|
|
105
|
-
const baseOf = (glob) => glob.raw.slice(0, glob.raw.findIndex((name) => name.includes('*')))
|
|
106
|
-
const groups = Map.groupBy(dynamic, (glob) => baseOf(glob).join('/'))
|
|
107
|
-
const tasks = groups.has('') ? [{ base: [], globs: dynamic }] : [...groups.values()].map((globs) => ({ base: baseOf(globs[0]), globs }))
|
|
108
|
-
const skipped = (names) => ignored(names) || (MANIFESTS.includes(names.at(-1)) && excludeWhole.some((glob) => takes(glob, [...names.slice(0, -1), 'package.json'])))
|
|
109
|
-
// A task walks into a directory only where it walked into its parent; each
|
|
110
|
-
// answer is kept for the walk.
|
|
111
|
-
const reacher = ({ base, globs }) => {
|
|
112
|
-
const known = new Map()
|
|
113
|
-
const reaches = (names) => {
|
|
114
|
-
if (names.length <= base.length) return names.length === base.length && startsWith(names, base)
|
|
115
|
-
const key = names.join('/')
|
|
116
|
-
if (!known.has(key)) known.set(key, reaches(names.slice(0, -1)) && globs.some((glob) => partial(glob, names)) && !skipped(names))
|
|
117
|
-
return known.get(key)
|
|
118
|
-
}
|
|
119
|
-
return reaches
|
|
120
|
-
}
|
|
121
|
-
const reachers = tasks.map(reacher)
|
|
122
|
-
const through = [...tasks.map((task) => task.base), ...include.filter((glob) => !isDynamic(glob)).map((glob) => glob.raw.slice(0, -1))]
|
|
123
|
-
return {
|
|
124
|
-
walked: (names) => through.some((path) => startsWith(path, names)) || reachers.some((reaches) => reaches(names)),
|
|
125
|
-
taken: takenBy(include, exclude, underLeftOut),
|
|
126
|
-
wild: () => false,
|
|
127
|
-
manifests: MANIFESTS_9,
|
|
128
|
-
through,
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// The first of `globs.manifests` that is a file; pnpm 12 reads the first there
|
|
68
|
+
// The first of MANIFESTS that is a file; pnpm 12 reads the first there
|
|
133
69
|
// where a `wild` glob takes the directory, failing where it is not a file.
|
|
134
70
|
function manifestOf(project, globs, names, entries) {
|
|
135
|
-
for (const name of
|
|
71
|
+
for (const name of MANIFESTS) {
|
|
136
72
|
if (!entries.includes(name)) continue
|
|
137
73
|
const type = typeOf(project, `/${[...names, name].join('/')}`)
|
|
138
74
|
if (type === 'file') return name
|
|
@@ -150,8 +86,8 @@ function byNames(a, b) {
|
|
|
150
86
|
}
|
|
151
87
|
|
|
152
88
|
// find-packages leaves out what is under these, by globs whose `**`, as
|
|
153
|
-
// tinyglobby reads them, takes no name with a leading dot;
|
|
154
|
-
//
|
|
89
|
+
// tinyglobby reads them, takes no name with a leading dot; pnpm 12 drops
|
|
90
|
+
// whatever is under them (underLeftOut).
|
|
155
91
|
const LEFT_OUT = ['node_modules', 'bower_components']
|
|
156
92
|
const IGNORED = LEFT_OUT.map((name) => ({ names: ['**', compileName(name, false), '**'], dot: false }))
|
|
157
93
|
const ignored = (names) => IGNORED.some((glob) => takes(glob, names))
|
|
@@ -181,20 +117,14 @@ export function checkProjectId(id, where) {
|
|
|
181
117
|
|
|
182
118
|
export const linkedManifest = (file) => new DeptreeError('a link pnpm would read a project\'s manifest through is not supported', quote(file))
|
|
183
119
|
|
|
184
|
-
// pnpm reads the first of these a project has
|
|
185
|
-
// package.json is named first.
|
|
120
|
+
// pnpm reads the first of these a project has.
|
|
186
121
|
const MANIFESTS = ['package.json', 'package.json5', 'package.yaml']
|
|
187
|
-
const MANIFESTS_9 = ['package.json5', 'package.yaml', 'package.json']
|
|
188
122
|
|
|
189
123
|
// Every directory tinyglobby walks into is read, and no other. It walks into
|
|
190
124
|
// a node_modules only under a directory with a leading dot, which is
|
|
191
125
|
// refused, as what is installed there is no project buildPnpmTree builds.
|
|
192
126
|
export function findProjects(project, packages, major = 10) {
|
|
193
127
|
const globs = compileAll(packages, major)
|
|
194
|
-
for (const path of globs.through) {
|
|
195
|
-
const end = path.findIndex((_, i) => typeOf(project, `/${path.slice(0, i + 1).join('/')}`) === 'file')
|
|
196
|
-
if (end !== -1) throw new DeptreeError('a glob leads through this file, which pnpm 9 fails on', quote(path.slice(0, end + 1).join('/')))
|
|
197
|
-
}
|
|
198
128
|
const ids = []
|
|
199
129
|
const pending = [{ names: [] }]
|
|
200
130
|
while (pending.length > 0) {
|
|
@@ -221,9 +151,8 @@ export function findProjects(project, packages, major = 10) {
|
|
|
221
151
|
const linked = type === 'symlink' && typeOf(project, `/${path}`) === 'directory'
|
|
222
152
|
if (type !== 'directory' && !linked) continue
|
|
223
153
|
if (entry === 'node_modules') throw new DeptreeError('pnpm-workspace.yaml\'s packages walk into this node_modules, which is not supported', quote(path))
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
else throw new DeptreeError(`a link to a directory in one tinyglobby follows, ${quote(path)}, is not supported`, quote(link))
|
|
154
|
+
if (linked && link !== undefined) throw new DeptreeError(`a link to a directory in one tinyglobby follows, ${quote(path)}, is not supported`, quote(link))
|
|
155
|
+
pending.push({ names: at, link: linked ? path : link })
|
|
227
156
|
}
|
|
228
157
|
}
|
|
229
158
|
return ['.', ...major >= 12 ? ids.sort(byNames) : ids.sort()]
|
package/src/soldeer/tree.js
CHANGED
|
@@ -8,7 +8,7 @@ import { eachConcurrently } from '../concurrent.js'
|
|
|
8
8
|
import { DeptreeError, quote } from '../error.js'
|
|
9
9
|
import { checkNoDir, fold, makeDirs, mount, writeFiles } from '../mount.js'
|
|
10
10
|
import { configOf } from './config.js'
|
|
11
|
-
import { checkoutOf, githubRepoOf } from '
|
|
11
|
+
import { checkoutOf, githubRepoOf } from '../github.js'
|
|
12
12
|
import { checkHost, inputsOf } from './inputs.js'
|
|
13
13
|
import { extractZip } from './zip.js'
|
|
14
14
|
|
|
@@ -62,7 +62,7 @@ async function fetchAll(dependencies, github) {
|
|
|
62
62
|
export async function buildSoldeerTree(options) {
|
|
63
63
|
const { host: given, vfs: into, github } = options ?? {}
|
|
64
64
|
if (into !== undefined && !(into instanceof Vfs)) throw new TypeError('vfs must be a Vfs, or left out')
|
|
65
|
-
if (github !== undefined &&
|
|
65
|
+
if (github !== undefined && ['getCommitTree', 'getRepoTreeTarball', 'getRepo'].some((method) => typeof github?.[method] !== 'function')) throw new TypeError(GITHUB)
|
|
66
66
|
const inputs = inputsOf(options ?? {})
|
|
67
67
|
const folded = checkHost(given).os === 'darwin'
|
|
68
68
|
// Refused before anything is fetched; mount checks again.
|