@preventive/deptree 1.3.2 → 1.4.0
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 +24 -6
- package/pnpm.d.ts +52 -75
- 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 +3 -6
- 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 +7 -16
- 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 +1 -2
- package/src/pnpm/patches.js +15 -13
- package/src/pnpm/production.js +1 -1
- 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 +34 -24
- package/src/pnpm/uptodate.js +12 -13
- package/src/pnpm/workspace.js +8 -79
- package/src/pnpm/write.js +2 -1
- 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/pnpm.d.ts
CHANGED
|
@@ -21,10 +21,9 @@ export { LockfileError, YamlError } from '@preventive/lockfile/pnpm.js'
|
|
|
21
21
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
22
22
|
|
|
23
23
|
// The machine pnpm would install on, which a tree depends on: `pnpm` is
|
|
24
|
-
// the version that installs, and has to be a
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// is refused. Left out, it is the one the root package.json's
|
|
24
|
+
// the version that installs, and has to be a 10.x, an 11.x or a 12.x
|
|
25
|
+
// from 12.8.1 on, the three built for, each as it differs from the
|
|
26
|
+
// others; an earlier 12.x installs otherwise in places, and is refused. Left out, it is the one the root package.json's
|
|
28
27
|
// packageManager pins, which pnpm switches to, and has to be given where
|
|
29
28
|
// that pins none. `node` is the Node it runs on,
|
|
30
29
|
// unless the settings name a nodeVersion or, for pnpm 11, the root
|
|
@@ -98,8 +97,9 @@ export interface PnpmProject {
|
|
|
98
97
|
// Each project is held to its importer as --frozen-lockfile holds it: its
|
|
99
98
|
// dependencies, devDependencies, optionalDependencies and, with
|
|
100
99
|
// autoInstallPeers, the peers it lists nowhere else, have to be what the
|
|
101
|
-
// importer records, and in the ranges they ask for
|
|
102
|
-
//
|
|
100
|
+
// importer records, and in the ranges they ask for, but `*`, which pnpm
|
|
101
|
+
// resolves to a prerelease `latest` too. The projects' names are what
|
|
102
|
+
// hoistWorkspacePackages hoists them by.
|
|
103
103
|
//
|
|
104
104
|
// Settings are read as `pnpm install` 10 reads them, each source over the
|
|
105
105
|
// one before: the .npmrc, then pnpm-workspace.yaml, then what the
|
|
@@ -113,12 +113,12 @@ export interface PnpmProject {
|
|
|
113
113
|
// is read only with `project` given, and only where the directory is
|
|
114
114
|
// under the lockfile's and holds a package.json there. pnpm links to it by a
|
|
115
115
|
// path alone or `link:`. By `file:` it installs it as a package, of the
|
|
116
|
-
// files its packlist picks -- npm-packlist 5.1.3 for pnpm
|
|
116
|
+
// files its packlist picks -- npm-packlist 5.1.3 for pnpm 10, 10.0.4
|
|
117
117
|
// for pnpm 11, and pnpm 12's own port of it -- which each is followed here
|
|
118
118
|
// as that version runs: by package.json's `files`, `main`, `bin` and, but
|
|
119
119
|
// for pnpm 12, `browser`; by the .npmignore and .gitignore files where it
|
|
120
120
|
// reads them; and by its own rules, case and all, odd steps among them,
|
|
121
|
-
// such as pnpm
|
|
121
|
+
// such as pnpm 10 keeping what a `files` glob takes that their rules
|
|
122
122
|
// leave out, or the minimatch pnpm 10 bundles from 10.31 matching `**`
|
|
123
123
|
// otherwise. Of glob syntax only `*`, `?` and `**` are followed, which all
|
|
124
124
|
// read alike: a pattern with braces, a class, an extglob or a backslash is
|
|
@@ -126,16 +126,16 @@ export interface PnpmProject {
|
|
|
126
126
|
// `files` that is not a list of strings, a file kept by a path a pattern
|
|
127
127
|
// spells with a `.` part, and a package.json with a byte order mark for
|
|
128
128
|
// pnpm 11 before 11.28, which fails on it. Refused too, where a pnpm may
|
|
129
|
-
// make too large a regexp of it, failing for pnpm
|
|
129
|
+
// make too large a regexp of it, failing for pnpm 10 and 11 and dropping
|
|
130
130
|
// it unread for 12, is a pattern of more than 4096 characters and, for pnpm
|
|
131
131
|
// 12, an ignore file or `files` of more than 16 KiB; and so are a pattern
|
|
132
|
-
// with more than 100 `**` parts for pnpm
|
|
132
|
+
// with more than 100 `**` parts for pnpm 10, and a directory nested
|
|
133
133
|
// more than 100 deep, for the time matching them takes. Matching takes
|
|
134
134
|
// time linear in the path and the pattern. pnpm hardlinks those files from
|
|
135
135
|
// the directory into each snapshot of the package, in their modes, which
|
|
136
136
|
// are refused but for a checkout's under umask 022 or 002: 0o644, 0o664,
|
|
137
137
|
// 0o755 and 0o775. So a file linking a bin makes executable -- 0o755 for
|
|
138
|
-
// pnpm
|
|
138
|
+
// pnpm 10, its mode with 0o111 added for 11 and 12 -- is made so in
|
|
139
139
|
// every snapshot and in the directory, which is not written here; a CRLF
|
|
140
140
|
// `#!` line it rewrites is rewritten as a file of that snapshot's own. Where it builds the package -- an install script, a
|
|
141
141
|
// binding.gyp, which pnpm 11 and 12 pass over with `gypfile: false`, or a
|
|
@@ -143,17 +143,24 @@ export interface PnpmProject {
|
|
|
143
143
|
// other than auto or hardlink, each snapshot has a copy of its own
|
|
144
144
|
// instead. One by `file:` to a tarball is refused, and so is a `file:`
|
|
145
145
|
// dependency no override names. One to the lockfile's own directory that
|
|
146
|
-
// the lockfile has as `file:` and an empty path, as pnpm
|
|
146
|
+
// the lockfile has as `file:` and an empty path, as pnpm 10 and 11
|
|
147
147
|
// write it, is refused for pnpm 12, which fails on that lockfile.
|
|
148
148
|
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
//
|
|
149
|
+
// Package extensions, `packageExtensions`, add to the package.json of each
|
|
150
|
+
// package a selector names, by its name and the versions in its range,
|
|
151
|
+
// before the overrides are read: the package.json's own entry in a field
|
|
152
|
+
// wins, and of two extensions the first. The lockfile is held to their
|
|
153
|
+
// checksum, as pnpm holds it: object-hash's sha256 of the setting, its
|
|
154
|
+
// names sorted by code point for pnpm 12. Only what pnpm 10, 11 and 12
|
|
155
|
+
// hash alike is taken: dependencies, optionalDependencies and
|
|
156
|
+
// peerDependencies of names to strings, and peerDependenciesMeta of names
|
|
157
|
+
// to `optional` alone. Refused too: a selector that names no package; an
|
|
158
|
+
// extension that names a project, whose package.json pnpm extends too;
|
|
159
|
+
// for pnpm 12, a range other than comparators and x-ranges joined by
|
|
160
|
+
// spaces and `||`, as it fails on some that npm's semver reads, and a name
|
|
161
|
+
// of digits alone, as it applies them in the order written; and, for pnpm
|
|
162
|
+
// 12 before 12.17.0, an extension of a directory a project depends on by
|
|
163
|
+
// `file:`, which that pnpm holds to its package.json without it.
|
|
157
164
|
//
|
|
158
165
|
// Of the .npmrc, only what pnpm reads for an install is read: its settings
|
|
159
166
|
// by their kebab-case names, those that can change the tree held to what
|
|
@@ -217,7 +224,7 @@ export interface PnpmProject {
|
|
|
217
224
|
// or is made, and every file and link is written where nothing is. The
|
|
218
225
|
// tree is built, and held to every check below, before any of it is
|
|
219
226
|
// written, so a refusal leaves the Vfs as it was. Nothing outside
|
|
220
|
-
// node_modules is written, though pnpm
|
|
227
|
+
// node_modules is written, though pnpm 10 makes the files a linked
|
|
221
228
|
// directory's bins run executable too.
|
|
222
229
|
//
|
|
223
230
|
// `metadata`, true unless given false, has each registry package's version
|
|
@@ -272,7 +279,7 @@ export interface PnpmProject {
|
|
|
272
279
|
// refused where that package is unpacked. Which of a package's bins pnpm
|
|
273
280
|
// links turns on the others' bins, and is read only where it could change
|
|
274
281
|
// the package's files: a bin pnpm would make executable, or whose CRLF `#!`
|
|
275
|
-
// line it would make LF; one that is a directory, which pnpm
|
|
282
|
+
// line it would make LF; one that is a directory, which pnpm 12 fails
|
|
276
283
|
// on; or any bin of a patched package. With the hoisted linker where any
|
|
277
284
|
// patch is configured, so does what pnpm's build pass does to a package it
|
|
278
285
|
// builds, patched or with an install script, which is read for every such
|
|
@@ -280,9 +287,9 @@ export interface PnpmProject {
|
|
|
280
287
|
// read from, but those unpacked already, which are read back from the
|
|
281
288
|
// tree, and keeps them: with the isolated linker, those the lockfile says
|
|
282
289
|
// have bins, those that bundle others, those whose bins pnpm reads whatever
|
|
283
|
-
// the lockfile says (a project's dependencies with pnpm
|
|
290
|
+
// the lockfile says (a project's dependencies with pnpm 10, their
|
|
284
291
|
// peers with pnpm 11 and 12, and those beside a dependency outside the tree
|
|
285
|
-
// with pnpm
|
|
292
|
+
// with pnpm 10 and 11), and directories, which are read with the tree; with
|
|
286
293
|
// the hoisted linker, those the lockfile says have bins, those that bundle
|
|
287
294
|
// others, and directories, and where a patch is configured, those patched
|
|
288
295
|
// and those that depend on one with bins, whose bins pnpm's build pass
|
|
@@ -308,8 +315,7 @@ export interface PnpmProject {
|
|
|
308
315
|
// those the rest reach, through dependencies, optionalDependencies and the
|
|
309
316
|
// projects they link to. The tree is laid out of those alone -- what the
|
|
310
317
|
// host cannot run left out as pnpm walks them, hoisted, its bins linked --
|
|
311
|
-
// as without it
|
|
312
|
-
// specifiers have, a devDependency's among them. Nothing else is fetched,
|
|
318
|
+
// as without it. Nothing else is fetched,
|
|
313
319
|
// nor its files checked; all else is held to the whole lockfile, as
|
|
314
320
|
// without it. From pnpm 11.28.0, and in pnpm 12, an edge to an optional
|
|
315
321
|
// peer, which the snapshot is linked to only as each project that reaches it
|
|
@@ -468,7 +474,7 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
468
474
|
|
|
469
475
|
// The node_modules tree `pnpm install --frozen-lockfile --ignore-scripts`,
|
|
470
476
|
// with `production` --prod too, makes with the isolated linker of
|
|
471
|
-
// host.pnpm,
|
|
477
|
+
// host.pnpm, 10, 11 or 12, or the hoisted one of pnpm 10 or 11, and no
|
|
472
478
|
// other install: whatever the settings say of frozen lockfiles, the install
|
|
473
479
|
// is frozen, which is also the only one that hoists by the lockfile's graph
|
|
474
480
|
// alone. It is rooted at the lockfile's directory: each package's
|
|
@@ -487,19 +493,6 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
487
493
|
// and a write that would replace anything with something else is refused;
|
|
488
494
|
// into a Vfs given, one that would replace anything at all.
|
|
489
495
|
//
|
|
490
|
-
// pnpm 9 makes its tree as pnpm 10 does but in places, each built as
|
|
491
|
-
// pnpm 9 makes it. It ends the name of a directory under
|
|
492
|
-
// node_modules/.pnpm it cuts short with 26 base32 characters of an MD5,
|
|
493
|
-
// not 32 hex of a SHA-256, and leaves a `#` in it. It hoists from the
|
|
494
|
-
// lockfile, not the graph: the snapshots of one depth in the order of
|
|
495
|
-
// their keys, not their directories', and an alias taken by a child left
|
|
496
|
-
// out, a `link:` or a project as well as by a snapshot hoisted, the root's
|
|
497
|
-
// all taken from the start as its specifiers spell them. It takes a bin's
|
|
498
|
-
// command by its name before it drops the scope, so links `@x/y z` as
|
|
499
|
-
// `y z`, and links a `bin` string, or a directories.bin, where it leads
|
|
500
|
-
// out of the package, which is refused; it fails on a bin that is a
|
|
501
|
-
// directory, which is refused, where pnpm 10 passes over it.
|
|
502
|
-
//
|
|
503
496
|
// pnpm 11 links bins otherwise in places -- npm owns `npx` and pnpm its
|
|
504
497
|
// aliases, a project's .bin takes the bins of the peers its dependencies
|
|
505
498
|
// require -- and each is built as the one given links them.
|
|
@@ -574,7 +567,9 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
574
567
|
// dependency to the catalog's version, a workspace package linked exactly
|
|
575
568
|
// where its version is in range, and a patch hash in a snapshot's peers to
|
|
576
569
|
// the patch; it lets an optional dependency the importer has no specifier
|
|
577
|
-
// for go unresolved, and takes two spellings of one git commit alike.
|
|
570
|
+
// for go unresolved, and takes two spellings of one git commit alike. From
|
|
571
|
+
// 11.28.7 it holds each directory snapshot a project reaches by `file:` (from
|
|
572
|
+
// 11.28.10, through a registry package too) to the directory's package.json. A
|
|
578
573
|
// devEngines.packageManager is refused unless its onFail, or pmOnFail, is
|
|
579
574
|
// to warn or ignore, as pnpm 11 installs with the pnpm the lockfile pins
|
|
580
575
|
// for it; and a root engines.runtime whose onFail is `error` has to take
|
|
@@ -590,25 +585,15 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
590
585
|
// or at host.pnpm for a range, with its package: pnpm 12 runs that one,
|
|
591
586
|
// and fails a frozen install where it is not there.
|
|
592
587
|
//
|
|
593
|
-
// pnpm 9 holds a lockfile to less than pnpm 10: neither to the catalogs
|
|
594
|
-
// nor to dedupePeers, nor a dependency's version to its range. It hashes a
|
|
595
|
-
// patch with MD5, in base32, and picks one for a package by `name@version`
|
|
596
|
-
// as spelled, else by `name`, never by a range. It overrides a peer in
|
|
597
|
-
// place, whatever the override. Where the root package.json's
|
|
598
|
-
// packageManager pins another pnpm, pnpm 9 installs with itself, unless
|
|
599
|
-
// managePackageManagerVersions has it switch to that one, or
|
|
600
|
-
// packageManagerStrict and packageManagerStrictVersion have it fail, each
|
|
601
|
-
// refused; and it fails on another package manager with
|
|
602
|
-
// packageManagerStrict, as it is by default, which is refused. It knows no
|
|
603
|
-
// runtime, and holds a project's os, cpu and libc to the host's own,
|
|
604
|
-
// whatever supportedArchitectures says.
|
|
605
|
-
//
|
|
606
588
|
// pnpm 12 makes none of pnpm 11's further checks of a lockfile, but holds
|
|
607
589
|
// a directory a project depends on by `file:` to it: each dependency the
|
|
608
590
|
// snapshot has is one its package.json, overridden, asks for, a peer among
|
|
609
|
-
// them
|
|
610
|
-
//
|
|
611
|
-
//
|
|
591
|
+
// them, an optional peer among its optional dependencies too; each it asks
|
|
592
|
+
// for is resolved as it asks, an optional one there or not, and one in both
|
|
593
|
+
// lists as optional at the dependency's range; and its peers, one only in
|
|
594
|
+
// peerDependenciesMeta at `*`, and which are optional, are what the lockfile
|
|
595
|
+
// records, but one that is a dependency too and that pnpm does not install
|
|
596
|
+
// itself. A project the lockfile has no importer for is held to none
|
|
612
597
|
// where it has no dependencies but peers, and refused otherwise. It checks
|
|
613
598
|
// of the projects only the root's engines.node, with engineStrict, and
|
|
614
599
|
// with engineStrict refuses whatever it installs that the host cannot run,
|
|
@@ -629,9 +614,13 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
629
614
|
// gzipped, every file under one directory, no link or device in it, and
|
|
630
615
|
// a package.json for exactly its name and version, whose os, cpu, libc,
|
|
631
616
|
// bins and bundled dependencies are what the lockfile recorded and whose
|
|
632
|
-
// every dependency the snapshot has
|
|
633
|
-
//
|
|
634
|
-
//
|
|
617
|
+
// every dependency the snapshot has, those package extensions add among
|
|
618
|
+
// them, but one its package.json also has as an optional peer where pnpm
|
|
619
|
+
// may leave that out: before 11.28.0 with autoInstallPeers, and in some
|
|
620
|
+
// graphs until 11.28.6 and 12.14.0; and, for any pnpm, each directory snapshot
|
|
621
|
+
// held so by every path, as no lockfile pnpm writes fails. On macOS, two names
|
|
622
|
+
// in one directory that differ only in case or normalization are refused, as
|
|
623
|
+
// they would be one name there.
|
|
635
624
|
//
|
|
636
625
|
// Packages come from https://registry.npmjs.org/ alone, fetched through
|
|
637
626
|
// @preventive/upstream, and each tarball is held to the lockfile's
|
|
@@ -642,7 +631,7 @@ export interface PnpmLazyTree extends PnpmTree {
|
|
|
642
631
|
// one of the env document pnpm 11 writes alone before anything is
|
|
643
632
|
// installed, a setting this does not know or does not build for, overrides
|
|
644
633
|
// pnpm cannot read, a lockfile not resolved with these settings, a package
|
|
645
|
-
// from anywhere but the registry, a pnpmfile, package extensions, an
|
|
634
|
+
// from anywhere but the registry, a pnpmfile, some package extensions, an
|
|
646
635
|
// injected dependency, a lockfile not up to date with a package.json,
|
|
647
636
|
// another package manager, a runtime to download, two projects of one
|
|
648
637
|
// name, a patch that does not hash or apply, a check above that fails,
|
|
@@ -679,17 +668,6 @@ export function buildPnpmTree(options: PnpmTreeOptions): Promise<PnpmTree>
|
|
|
679
668
|
// file, which is refused; and the projects come in the order of their
|
|
680
669
|
// paths by name, `a/b` before `a-b`.
|
|
681
670
|
//
|
|
682
|
-
// pnpm 9 finds them with fast-glob, otherwise again: past the names before
|
|
683
|
-
// a glob's first `**` it walks into every directory, one with a leading
|
|
684
|
-
// dot among them, though no `*` or `**` takes a project there; it walks
|
|
685
|
-
// from the top for every glob where one has a `*` in its first name; and
|
|
686
|
-
// it leaves out what a `!` glob takes, leading dots and all. It reads
|
|
687
|
-
// every manifest a project has, not the first, and fails on a glob that
|
|
688
|
-
// leads through a file, both refused. Where pnpm-workspace.yaml sets
|
|
689
|
-
// nothing, it finds projects everywhere, as `**` does; where it sets
|
|
690
|
-
// anything but no `packages`, it fails, which is refused; and it refuses
|
|
691
|
-
// no name for it but pnpm-workspace.yml.
|
|
692
|
-
//
|
|
693
671
|
// Refused: a root with no manifest, which pnpm takes for no project; a
|
|
694
672
|
// project, the root among them, whose manifest is package.json5 or
|
|
695
673
|
// package.yaml, which pnpm reads where there is no package.json, or is a
|
|
@@ -698,9 +676,8 @@ export function buildPnpmTree(options: PnpmTreeOptions): Promise<PnpmTree>
|
|
|
698
676
|
// project in a directory a lockfile could not key its importer by, with a
|
|
699
677
|
// control, bidirectional or backslash character in its path, or a drive
|
|
700
678
|
// letter; a node_modules pnpm walks into, which it does only under a
|
|
701
|
-
// directory with a leading dot, one a glob spells
|
|
702
|
-
//
|
|
703
|
-
// or 12.x; and a pnpm-workspace.yaml that is not YAML, is not a mapping,
|
|
679
|
+
// directory with a leading dot, or one a glob spells; a glob
|
|
680
|
+
// buildPnpmTree refuses, or a pnpm not 10.x, 11.x or 12.x; and a pnpm-workspace.yaml that is not YAML, is not a mapping,
|
|
704
681
|
// is not UTF-8, or is under another name pnpm refuses.
|
|
705
682
|
export interface PnpmProjectsOptions {
|
|
706
683
|
project: PnpmProject
|
package/soldeer.d.ts
CHANGED
|
@@ -186,7 +186,9 @@ export interface SoldeerTree {
|
|
|
186
186
|
// A git dependency Soldeer clones, `git clone` of the lockfile's `git`,
|
|
187
187
|
// then `git checkout` of its `rev`; here it is fetched from a GitHub
|
|
188
188
|
// repository alone, by `github`, as GitHub's tarball of the tree of that
|
|
189
|
-
// commit
|
|
189
|
+
// commit: the tree read off the commit's own object, which upstream's
|
|
190
|
+
// getCommitTree fetches from github.com as git fetches it and holds to the
|
|
191
|
+
// commit's id, and the tarball, which getRepoTreeTarball holds to it. A
|
|
190
192
|
// repository renamed or transferred since, which GitHub answers with a
|
|
191
193
|
// redirect that git's clone follows, is fetched by the name GitHub gives
|
|
192
194
|
// it now, as upstream's getRepo follows that redirect with
|
|
@@ -209,8 +211,9 @@ export interface SoldeerTree {
|
|
|
209
211
|
// `export-ignore`, `ident` or `working-tree-encoding`, from a repo set to
|
|
210
212
|
// include Git LFS objects in archives -- and where the tar reader of
|
|
211
213
|
// @preventive/archive/tar.js does, as for a symlink whose target climbs
|
|
212
|
-
// out of the tarball; so is a path
|
|
213
|
-
//
|
|
214
|
+
// out of the tarball; so is a path git refuses to check out, with a `.git`
|
|
215
|
+
// in it, or its short name `git~1`, in any case, dots and spaces after it,
|
|
216
|
+
// or a `:` after that. That the repository's branches and tags still
|
|
214
217
|
// reach the commit, without which Soldeer's clone does not have it, is not
|
|
215
218
|
// checked: GitHub answers for any commit it has.
|
|
216
219
|
//
|
package/src/cargo/members.js
CHANGED
|
@@ -21,8 +21,9 @@ export function checkLists(workspace) {
|
|
|
21
21
|
for (const [index, entry] of (workspace[key] ?? []).entries()) {
|
|
22
22
|
const where = `Cargo.toml: workspace.${key === 'defaultMembers' ? 'default-members' : key}[${index}]`
|
|
23
23
|
if (entry.startsWith('/') || UNSAFE.test(entry)) throw new DeptreeError(`${quote(entry)} is not a relative path within the project, which is all that is read`, where)
|
|
24
|
-
if (key
|
|
25
|
-
if (
|
|
24
|
+
if (key === 'exclude') continue
|
|
25
|
+
if (parts(entry).includes('..')) throw new DeptreeError(`${quote(entry)} leads out of the root, which is not read`, where)
|
|
26
|
+
if (/\*\*|\[/u.test(entry)) throw new DeptreeError(`${quote(entry)} has a \`**\` or a \`[\`, which is not supported`, where)
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
}
|
package/src/cargo/tree.js
CHANGED
|
@@ -78,11 +78,11 @@ function checkLock(lock, inputs, crates, vendored) {
|
|
|
78
78
|
for (const [dir, key] of keys) if (key in lock.packages) manifests[key] = inputs.packages.get(dir).manifest
|
|
79
79
|
const texts = new Map(crates.map((crate) => [crate.key, manifestOf(crate, vendored.get(crate.key))]))
|
|
80
80
|
for (const [key, { manifest }] of texts) manifests[key] = manifest
|
|
81
|
-
const members =
|
|
81
|
+
const members = inputs.packages.entries().filter(([dir, { member }]) => member && keys.has(dir)).map(([dir]) => keys.get(dir)).toArray()
|
|
82
82
|
checkPaths(linkCargo(lock, manifests, { workspace: inputs.root, members, config: inputs.config }), inputs.packages, keys)
|
|
83
83
|
const read = readCargoVendor(lock, Object.fromEntries(crates.map((crate) => [crate.directory, { manifest: texts.get(crate.key).text, checksum: vendored.get(crate.key).checksumText }])))
|
|
84
84
|
for (const crate of crates) if (read[crate.key].directory !== crate.directory) throw new Error(`unreachable: ${crate.key} read back from ${read[crate.key].directory}`)
|
|
85
|
-
return new Map(
|
|
85
|
+
return new Map(texts.entries().map(([key, { links }]) => [key, links]))
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Each crate's bytes are let go once its files are written, which copies them.
|
package/src/cargo/workspace.js
CHANGED
|
@@ -147,14 +147,11 @@ function loadMembers(context) {
|
|
|
147
147
|
// Each [patch] from a path, the root's from the root and the config's from
|
|
148
148
|
// the directory its .cargo is in, which is the root too.
|
|
149
149
|
function patchesOf(root, config) {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
...Object.entries(config.patch).map(([table, specs]) => ({ table, specs, file: config.file })),
|
|
153
|
-
]
|
|
154
|
-
return tables.flatMap(({ table, specs, file }) => Object.entries(specs).filter(([, spec]) => spec.source.type === 'path').map(([name, spec]) => {
|
|
150
|
+
const files = [[root.patch, 'Cargo.toml'], [config.patch, config.file]]
|
|
151
|
+
return files.flatMap(([patch, file]) => Object.entries(patch).flatMap(([table, specs]) => Object.entries(specs).filter(([, spec]) => spec.source.type === 'path').map(([name, spec]) => {
|
|
155
152
|
const where = `${file}: patch.${quote(table)}.${name}`
|
|
156
153
|
return { dir: resolvePath('.', spec.source.path, where), name: spec.package, where }
|
|
157
|
-
}))
|
|
154
|
+
})))
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
// `config` is what parseCargoConfig gives, with the `file` it was read from.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// An archive by :http as RemoteFile leaves it: saved as `file.<type>` in a
|
|
2
|
+
// directory, extracted there by `tar xf` or `unzip -d` under a umask of
|
|
3
|
+
// 0o022, then flattened where that is asked and it holds one directory.
|
|
4
|
+
|
|
5
|
+
import { decompress } from '@preventive/archive/compression.js'
|
|
6
|
+
import { ArchiveError, unpack } from '@preventive/archive/tar.js'
|
|
7
|
+
import { unzip } from '@preventive/archive/zip.js'
|
|
8
|
+
import { DeptreeError, quote } from '../error.js'
|
|
9
|
+
import { isGit } from '../soldeer/zip.js'
|
|
10
|
+
import { MAX_BYTES } from '../tarball.js'
|
|
11
|
+
|
|
12
|
+
const startsWith = (bytes, magic) => magic.every((byte, i) => bytes[i] === byte)
|
|
13
|
+
const GZIP = [0x1f, 0x8b]
|
|
14
|
+
// A zip, with an entry or empty.
|
|
15
|
+
const ZIPS = [[0x50, 0x4b, 0x03, 0x04], [0x50, 0x4b, 0x05, 0x06]]
|
|
16
|
+
// What `tar xf` decompresses by its magic too, and is not read here.
|
|
17
|
+
const OTHERS = [
|
|
18
|
+
['bzip2', [0x42, 0x5a, 0x68]], ['xz', [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]], ['zstd', [0x28, 0xb5, 0x2f, 0xfd]],
|
|
19
|
+
['compress', [0x1f, 0x9d]], ['lzip', [0x4c, 0x5a, 0x49, 0x50]], ['lzma', [0x5d, 0x00, 0x00]],
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
// The setuid, setgid and sticky bits.
|
|
23
|
+
const SPECIAL = 0o7000
|
|
24
|
+
const UMASK = 0o022
|
|
25
|
+
|
|
26
|
+
// The names at the archive's root, a directory's that only paths under it
|
|
27
|
+
// name among them.
|
|
28
|
+
const topsOf = ({ dirs, files, links }) => new Set([...dirs, ...files.keys(), ...links.keys()].map((path) => path.split('/')[0]))
|
|
29
|
+
|
|
30
|
+
const gitRefusal = (at) => new DeptreeError('a path with a .git in it, which CocoaPods 1.16 leaves out of its cache and those before keep', at)
|
|
31
|
+
const dirRefusal = (mode, at) => new DeptreeError(`a directory of mode ${mode.toString(8)}, which its owner cannot list and write in, as CocoaPods' cleaner has to`, at)
|
|
32
|
+
const fileRefusal = (mode, at) => new DeptreeError(`a file of mode ${mode.toString(8)}, which its owner cannot read, as CocoaPods' copy has to`, at)
|
|
33
|
+
|
|
34
|
+
async function tarOf(bytes, where) {
|
|
35
|
+
if (startsWith(bytes, GZIP)) return await decompress(bytes, 'gzip', { limit: MAX_BYTES })
|
|
36
|
+
if (ZIPS.some((magic) => startsWith(bytes, magic))) throw new DeptreeError('its archive is a zip, which bsdtar extracts for `tar xf` and GNU tar does not', where)
|
|
37
|
+
const other = OTHERS.find(([, magic]) => startsWith(bytes, magic))
|
|
38
|
+
if (other !== undefined) throw new DeptreeError(`its archive is compressed with ${other[0]}, which is not read here: only gzip is`, where)
|
|
39
|
+
return bytes
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Each entry as tar writes it out: a directory, a file with its bytes and
|
|
43
|
+
// its mode under the umask, a link to its target as stored. A hard link is
|
|
44
|
+
// a second name for what it links to, and is copied as rsync -a, which
|
|
45
|
+
// CocoaPods copies the download into its cache with, and FileUtils.cp_r
|
|
46
|
+
// copy one: a file of the same bytes and mode, or a link to the same
|
|
47
|
+
// target. What tar would make otherwise on one machine than on another is
|
|
48
|
+
// refused: a special bit; a directory its owner cannot list and write in,
|
|
49
|
+
// which the cleaner would leave files in; a file its owner cannot read,
|
|
50
|
+
// which the copy fails on; a name starting with `._`, which bsdtar on macOS
|
|
51
|
+
// makes an extended attribute of; a `.git`, which the copy into the cache
|
|
52
|
+
// leaves out from CocoaPods 1.16; a FIFO or a device.
|
|
53
|
+
function entriesOf(entries, where) {
|
|
54
|
+
const dirs = new Set()
|
|
55
|
+
const files = new Map()
|
|
56
|
+
const links = new Map()
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const { name, type } = entry
|
|
59
|
+
if (name === '.' || dirs.has(name) || files.has(name) || links.has(name)) continue
|
|
60
|
+
const at = `${where}: ${quote(name)}`
|
|
61
|
+
const segments = name.split('/')
|
|
62
|
+
if (segments.some(isGit)) throw gitRefusal(at)
|
|
63
|
+
if (segments.some((segment) => segment.startsWith('._'))) throw new DeptreeError('a name starting with `._`, which bsdtar on macOS reads as the extended attributes of another', at)
|
|
64
|
+
const mode = type === 'hardlink' ? undefined : entry.mode
|
|
65
|
+
if (mode !== undefined && type !== 'symlink' && (mode & SPECIAL) !== 0) throw new DeptreeError(`a mode of ${mode.toString(8)}, with a bit tar sets or drops by who extracts it`, at)
|
|
66
|
+
if (type === 'directory') {
|
|
67
|
+
if ((mode & 0o700) !== 0o700) throw dirRefusal(mode, at)
|
|
68
|
+
dirs.add(name)
|
|
69
|
+
} else if (type === 'file' || type === 'contiguous-file') {
|
|
70
|
+
if ((mode & 0o400) === 0) throw fileRefusal(mode, at)
|
|
71
|
+
files.set(name, { data: entry.data, mode: mode & 0o777 & ~UMASK })
|
|
72
|
+
} else if (type === 'symlink') {
|
|
73
|
+
links.set(name, entry.linkname)
|
|
74
|
+
} else if (type === 'hardlink') {
|
|
75
|
+
// The archive reader holds a hard link to an earlier entry.
|
|
76
|
+
if (files.has(entry.linkname)) files.set(name, { ...files.get(entry.linkname) })
|
|
77
|
+
else if (links.has(entry.linkname)) links.set(name, links.get(entry.linkname))
|
|
78
|
+
else throw new DeptreeError(`a hard link to ${quote(entry.linkname)}, which is no file or link`, at)
|
|
79
|
+
} else {
|
|
80
|
+
throw new DeptreeError(`a ${type}, which a pod's download cannot hold`, at)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { dirs, files, links }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function untarred(bytes, where) {
|
|
87
|
+
try {
|
|
88
|
+
return entriesOf(unpack(await tarOf(bytes, where), { trailingGlobal: true }), where)
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof ArchiveError) throw new DeptreeError(`its archive cannot be read: ${error.message}`, where, { cause: error })
|
|
91
|
+
throw error
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// What unzip 6.0 stops to ask about, which fails `pod install` with nothing
|
|
96
|
+
// on stdin.
|
|
97
|
+
const PKZIP_VERSION = 45
|
|
98
|
+
const VMS = 2
|
|
99
|
+
|
|
100
|
+
function checkVersion({ version }, at) {
|
|
101
|
+
const needed = version & 0xff
|
|
102
|
+
if (needed > PKZIP_VERSION) throw new DeptreeError(`needs PKZIP ${(needed / 10).toFixed(1)} to extract, past the 4.5 an unzip built without bzip2 takes`, at)
|
|
103
|
+
if (version >> 8 === VMS) throw new DeptreeError('marked as stored in VMS format, which unzip asks before extracting', at)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// A mode as unzip's mapattr() makes one: a Unix maker's as stored, any
|
|
107
|
+
// other's from the DOS bits under the umask, unless the Unix mode it stored
|
|
108
|
+
// agrees with them, as PKZip for Unix writes one; filtattr() then drops the
|
|
109
|
+
// special bits. A symlink is one by its mode, from a maker known to make them.
|
|
110
|
+
const UNIX_HOSTS = new Set([2, 3, 5, 12, 13, 16, 17, 30])
|
|
111
|
+
const SYMLINK_HOSTS = new Set([2, 3, 5, 16, 30])
|
|
112
|
+
const LABEL_HOSTS = new Set([0, 5, 6, 11])
|
|
113
|
+
const MODE_EXTRAS = new Set([0x756e, 0x000c]) // ASI Unix and PKWARE VMS, read where the attributes hold no mode
|
|
114
|
+
const S_IFMT = 0o170000
|
|
115
|
+
const S_IFLNK = 0o120000
|
|
116
|
+
const DOS_READONLY = 1
|
|
117
|
+
const DOS_LABEL = 8
|
|
118
|
+
const DOS_DIRECTORY = 0x10
|
|
119
|
+
const CONTROL_FIELDS = 4 // of the internal attributes: the external ones are then their low byte alone
|
|
120
|
+
|
|
121
|
+
function unzipAttributes({ system, internalAttributes, attributes, extra, storedName }, at) {
|
|
122
|
+
const host = Math.min(system, 31)
|
|
123
|
+
if (host === 1 || host === 18) throw new DeptreeError('made on Amiga or THEOS, whose attributes unzip reads by that system', at)
|
|
124
|
+
const external = internalAttributes & CONTROL_FIELDS ? attributes & 0xff : attributes
|
|
125
|
+
if ((external & DOS_LABEL) !== 0 && LABEL_HOSTS.has(host)) return { label: true }
|
|
126
|
+
let unix = 0
|
|
127
|
+
if (UNIX_HOSTS.has(host)) {
|
|
128
|
+
unix = external >>> 16
|
|
129
|
+
if (unix === 0 && extra.some(({ id }) => MODE_EXTRAS.has(id))) throw new DeptreeError('attributes with no mode, and an extra field unzip reads one from', at)
|
|
130
|
+
return { mode: unix, symlink: (unix & S_IFMT) === S_IFLNK && SYMLINK_HOSTS.has(host) }
|
|
131
|
+
}
|
|
132
|
+
if (host === 0) unix = external >>> 16
|
|
133
|
+
const dos = ((external & DOS_READONLY) === 0 ? 2 : 0) | ((external & DOS_DIRECTORY) !== 0 || storedName.endsWith('/') ? 1 : 0)
|
|
134
|
+
if ((unix & 0o700) === (0o400 | (dos << 6))) return { mode: unix, symlink: (unix & S_IFMT) === S_IFLNK && host === 0 }
|
|
135
|
+
return { mode: (0o444 | (dos << 6) | (dos << 3) | dos) & ~UMASK, symlink: false }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// What unzip's mapname() writes otherwise than the reader reads it.
|
|
139
|
+
const NON_ASCII = /[^\u0020-\u007E]/u
|
|
140
|
+
const VMS_VERSION = /;\d*$/u
|
|
141
|
+
|
|
142
|
+
function checkName({ storedName, type }, at) {
|
|
143
|
+
if (NON_ASCII.test(storedName)) throw new DeptreeError('a name with a character outside ASCII, which unzip writes by the machine\'s locale and its own build', at)
|
|
144
|
+
if (type === 'directory') return
|
|
145
|
+
const last = storedName.split('/').at(-1)
|
|
146
|
+
if (last === '.') throw new DeptreeError('a name ending in a `.` segment, which unzip writes as `_`', at)
|
|
147
|
+
if (VMS_VERSION.test(last)) throw new DeptreeError('a name ending in `;` and digits, which unzip takes for a VMS version and drops', at)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Each entry as unzip writes it out, in the central directory's order: a
|
|
151
|
+
// volume label skipped, a directory entry's mode counted only where unzip
|
|
152
|
+
// makes the directory for it.
|
|
153
|
+
async function unzipped(bytes, where) {
|
|
154
|
+
let entries
|
|
155
|
+
try {
|
|
156
|
+
entries = await unzip(bytes, { limit: MAX_BYTES })
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error instanceof ArchiveError) throw new DeptreeError(`its archive cannot be read: ${error.message}`, where, { cause: error })
|
|
159
|
+
throw error
|
|
160
|
+
}
|
|
161
|
+
if (entries.length === 0) throw new DeptreeError('an empty archive, which unzip warns of, and CocoaPods fails on the warning', where)
|
|
162
|
+
const dirs = new Set()
|
|
163
|
+
const files = new Map()
|
|
164
|
+
const links = new Map()
|
|
165
|
+
const made = new Set()
|
|
166
|
+
for (const entry of entries) {
|
|
167
|
+
const { name, type } = entry
|
|
168
|
+
if (name === '.') continue
|
|
169
|
+
const at = `${where}: ${quote(entry.storedName)}`
|
|
170
|
+
checkVersion(entry, at)
|
|
171
|
+
const { label, mode, symlink } = unzipAttributes(entry, at)
|
|
172
|
+
if (label) continue
|
|
173
|
+
checkName(entry, at)
|
|
174
|
+
const segments = name.split('/')
|
|
175
|
+
if (segments.some(isGit)) throw gitRefusal(at)
|
|
176
|
+
if (files.has(name) || links.has(name)) throw new DeptreeError('a name again, which unzip asks whether to replace', at)
|
|
177
|
+
if (symlink !== (type === 'symlink')) throw new DeptreeError('a symlink by the attributes of a maker that is not Unix, which unzip makes a link of', at)
|
|
178
|
+
const perms = mode & 0o777
|
|
179
|
+
for (let i = 1; i < segments.length; i++) made.add(segments.slice(0, i).join('/'))
|
|
180
|
+
if (type === 'directory') {
|
|
181
|
+
if (!made.has(name)) {
|
|
182
|
+
if ((perms & 0o700) !== 0o700) throw dirRefusal(perms, at)
|
|
183
|
+
made.add(name)
|
|
184
|
+
}
|
|
185
|
+
dirs.add(name)
|
|
186
|
+
} else if (type === 'symlink') {
|
|
187
|
+
links.set(name, entry.linkname)
|
|
188
|
+
} else {
|
|
189
|
+
if ((perms & 0o400) === 0) throw fileRefusal(perms, at)
|
|
190
|
+
files.set(name, { data: entry.data, mode: perms })
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return { dirs, files, links }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// RemoteFile#extract_with_type's flattening: where the directory holds one
|
|
197
|
+
// thing beside the download, and that is a directory, its contents moved
|
|
198
|
+
// up, by a move of it to its name and `.tmp` first. A link there, which
|
|
199
|
+
// Pathname#directory? would follow, is refused, and so is a name the moves
|
|
200
|
+
// would meet: a name ending in `.`, which Pathname#sub_ext reads otherwise
|
|
201
|
+
// than it ends, or something in it of the name it is moved to.
|
|
202
|
+
function flattened(contents, where) {
|
|
203
|
+
const tops = topsOf(contents)
|
|
204
|
+
if (tops.size !== 1) return contents
|
|
205
|
+
const [top] = tops
|
|
206
|
+
if (contents.files.has(top)) return contents
|
|
207
|
+
const at = `${where}: ${quote(top)}`
|
|
208
|
+
if (contents.links.has(top)) throw new DeptreeError('the one thing in the archive is a link, which flattening it would follow', at)
|
|
209
|
+
if (top.endsWith('.')) throw new DeptreeError('the one directory in the archive has a name ending in `.`, which flattening it reads otherwise', at)
|
|
210
|
+
const strip = (path) => path.slice(top.length + 1)
|
|
211
|
+
const inside = (path) => path.startsWith(`${top}/`)
|
|
212
|
+
const stripped = (map) => new Map([...map].map(([path, value]) => [strip(path), value]))
|
|
213
|
+
const moved = { dirs: new Set([...contents.dirs].filter(inside).map(strip)), files: stripped(contents.files), links: stripped(contents.links) }
|
|
214
|
+
if (topsOf(moved).has(`${top}.tmp`)) throw new DeptreeError(`the one directory in the archive holds ${quote(`${top}.tmp`)}, the name it is moved to while it is flattened`, at)
|
|
215
|
+
return moved
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// `source` is sourceOf's of :http; the contents are as writeFiles takes them.
|
|
219
|
+
export async function archiveOf(bytes, source, where) {
|
|
220
|
+
const contents = source.archive === 'zip' ? await unzipped(bytes, where) : await untarred(bytes, where)
|
|
221
|
+
if (topsOf(contents).has(source.file)) throw new DeptreeError(`the archive holds ${quote(source.file)}, the name RemoteFile downloads it under where it extracts it`, where)
|
|
222
|
+
return source.flatten ? flattened(contents, where) : contents
|
|
223
|
+
}
|