@preventive/deptree 1.5.1 → 1.5.3

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.
Files changed (80) hide show
  1. package/bin/compare.js +10 -21
  2. package/bin/deptree.js +5 -10
  3. package/cargo.d.ts +139 -195
  4. package/cargo.js +0 -2
  5. package/cocoapods.d.ts +211 -381
  6. package/cocoapods.js +0 -2
  7. package/npm.d.ts +245 -369
  8. package/npm.js +4 -6
  9. package/package.json +2 -2
  10. package/pnpm.d.ts +258 -667
  11. package/pnpm.js +2 -4
  12. package/soldeer.d.ts +144 -215
  13. package/soldeer.js +0 -2
  14. package/src/cargo/crate.js +21 -46
  15. package/src/cargo/inputs.js +5 -8
  16. package/src/cargo/members.js +6 -12
  17. package/src/cargo/registry.js +5 -9
  18. package/src/cargo/tree.js +8 -13
  19. package/src/cargo/workspace.js +13 -26
  20. package/src/cocoapods/archive.js +19 -40
  21. package/src/cocoapods/clean.js +21 -45
  22. package/src/cocoapods/fnmatch.js +12 -27
  23. package/src/cocoapods/inputs.js +5 -11
  24. package/src/cocoapods/install.js +11 -24
  25. package/src/cocoapods/podspec.js +19 -40
  26. package/src/cocoapods/podtree.js +10 -19
  27. package/src/cocoapods/source.js +13 -30
  28. package/src/cocoapods/tree.js +17 -39
  29. package/src/cocoapods/unicode.js +3 -9
  30. package/src/github.js +12 -24
  31. package/src/glob.js +2 -4
  32. package/src/lazy.js +2 -4
  33. package/src/manifest.js +2 -4
  34. package/src/matcher.js +3 -5
  35. package/src/mount.js +7 -14
  36. package/src/npm/bins.js +3 -5
  37. package/src/npm/compat.js +3 -5
  38. package/src/npm/package.js +6 -12
  39. package/src/npm/ratio.js +3 -5
  40. package/src/npm/settings.js +3 -5
  41. package/src/npm/tree.js +6 -11
  42. package/src/npm/versions.js +3 -4
  43. package/src/npmrc.js +2 -4
  44. package/src/patch.js +8 -14
  45. package/src/pnpm/bins.js +16 -42
  46. package/src/pnpm/filename.js +2 -4
  47. package/src/pnpm/gitignore.js +2 -4
  48. package/src/pnpm/glob.js +3 -5
  49. package/src/pnpm/hoist.js +8 -16
  50. package/src/pnpm/hoisted.js +15 -44
  51. package/src/pnpm/hook.js +2 -4
  52. package/src/pnpm/install.js +5 -10
  53. package/src/pnpm/lazy.js +8 -23
  54. package/src/pnpm/local.js +2 -4
  55. package/src/pnpm/minimatch.js +8 -15
  56. package/src/pnpm/nm-hoist.js +5 -11
  57. package/src/pnpm/npm-packlist.js +3 -6
  58. package/src/pnpm/overrides.js +2 -4
  59. package/src/pnpm/package.js +10 -16
  60. package/src/pnpm/packlist.js +3 -7
  61. package/src/pnpm/patches.js +3 -4
  62. package/src/pnpm/production.js +9 -28
  63. package/src/pnpm/projects.js +2 -6
  64. package/src/pnpm/readers.js +2 -4
  65. package/src/pnpm/settings.js +2 -5
  66. package/src/pnpm/tree.js +14 -37
  67. package/src/pnpm/workspace.js +4 -7
  68. package/src/pnpm/write.js +1 -1
  69. package/src/soldeer/config.js +5 -9
  70. package/src/soldeer/tree.js +2 -4
  71. package/src/soldeer/zip.js +8 -17
  72. package/src/tarball.js +12 -29
  73. package/src/yarn1/compat.js +2 -4
  74. package/src/yarn1/hoist.js +3 -8
  75. package/src/yarn1/package.js +12 -23
  76. package/src/yarn1/resolve.js +6 -11
  77. package/src/yarn1/settings.js +5 -10
  78. package/src/yarn1/tree.js +9 -18
  79. package/yarn1.d.ts +203 -360
  80. package/yarn1.js +4 -6
package/bin/compare.js CHANGED
@@ -1,7 +1,5 @@
1
- // The two sides `deptree compare` sets beside each other, what is on disk
2
- // and what deptree builds, each a map from a path under the folders an
3
- // install makes to its type, mode, and bytes or link target; and how they
4
- // differ: files and links as @preventive/compare tells them, the rest here.
1
+ // What is on disk and what deptree builds, each a map from a path under the install's folders to its type,
2
+ // mode, and bytes or target; and how they differ, files and links as @preventive/compare tells them
5
3
 
6
4
  import { Buffer } from 'node:buffer'
7
5
  import { lstatSync, readFileSync, readdirSync, readlinkSync, statSync } from 'node:fs'
@@ -29,17 +27,12 @@ export function projectView(root) {
29
27
  }
30
28
  }
31
29
 
32
- // What deptree never builds: the .bin directories, each package manager's
33
- // record of its install and pnpm 11's unread package map, the .git of a
34
- // dependency Soldeer clones, and what CocoaPods generates in Pods beside the
35
- // pods but its record, Manifest.lock: the podspecs of pods by :path, headers,
36
- // support files and the projects.
30
+ // What deptree never builds: .bin, each manager's record of its install and pnpm 11's unread package map,
31
+ // a Soldeer clone's .git, and what CocoaPods generates in Pods but Manifest.lock
37
32
  const NOT_BUILT = /(?:^|\/)node_modules\/(?:\.bin|\.modules\.yaml|\.pnpm-workspace-state(?:-v\d+)?\.json|\.pnpm\/lock\.yaml|\.package-lock\.json|\.package-map\.json|\.yarn-integrity)(?:\/|$)|^dependencies\/[^/]+\/\.git(?:\/|$)|^Pods\/(?:Local Podspecs|Headers|Target Support Files|\.project_cache|[^/]+\.xcodeproj)(?:\/|$)/u
38
33
 
39
- // Everything under each of `dirs` as `view` has it, the disk's projectView
40
- // or the tree's Vfs: links not followed, every file read whole, and a
41
- // folder not there left out. A directory deptree never builds is one entry,
42
- // not entered, as only it is ever listed.
34
+ // Everything under each of `dirs` as `view` has it, links not followed and files read whole; a directory
35
+ // deptree never builds is one entry, not entered
43
36
  export function readSide(view, dirs) {
44
37
  const entries = new Map()
45
38
  const stack = dirs.filter((dir) => typeOf(view, dir, false) !== undefined)
@@ -55,10 +48,8 @@ export function readSide(view, dirs) {
55
48
  return entries
56
49
  }
57
50
 
58
- // The paths on disk alone that hold nothing Node resolves: what deptree never
59
- // builds, and directories of nothing else, as pnpm leaves a node_modules of a
60
- // .bin of links to what it removed, a scope once its last package goes, or
61
- // the hoisted linker's .pnpm of its state alone.
51
+ // The paths on disk alone that hold nothing Node resolves: what deptree never builds, and directories of
52
+ // nothing else, as pnpm leaves a .bin of links to what it removed, or an emptied scope
62
53
  export function leftOut(changes, disk) {
63
54
  const left = new Set(changes.filter(({ mark }) => mark === '-').map(({ path }) => path))
64
55
  for (const [path, { type }] of disk) {
@@ -105,10 +96,8 @@ function changeOf({ status, old: disk, new: tree }) {
105
96
  return { mark: '~', type: tree.type, what: what.join('; '), content }
106
97
  }
107
98
 
108
- // How the disk differs from the tree, in walk order, each file or link with
109
- // compare's `status` of it, as formatPatch takes it. Nothing is listed under
110
- // a path only one side has, or of another type on each, as only a directory
111
- // has anything in it; a directory's own mode is the umask's, not compared.
99
+ // How the disk differs from the tree, in walk order, each file or link with compare's `status` of it.
100
+ // Nothing under a path one side lacks or types otherwise is listed; a directory's mode is not compared.
112
101
  export function difference(disk, tree) {
113
102
  const shown = (path) => disk.get(dirname(path))?.type === tree.get(dirname(path))?.type
114
103
  const changes = []
package/bin/deptree.js CHANGED
@@ -92,13 +92,11 @@ const OPTIONS = {
92
92
  help: { type: 'boolean', short: 'h' },
93
93
  }
94
94
 
95
- // Each package manager by its version flag: its lockfile, the folder it
96
- // installs into in each project it finds, and the version where the flag is
97
- // left out and nothing pins one, or, `pinned`, what the project pins, or,
98
- // `unpinned`, that the flag is needed; `development`, that it installs every
99
- // dependency, there being no other kind.
100
95
  const github = () => createClient({ token: process.env.GITHUB_TOKEN || process.env.GH_TOKEN || null })
101
96
 
97
+ // Each manager by its version flag: its lockfile, the folder it installs into, and the version where the
98
+ // flag is left out: `pinned` takes what the project pins, `unpinned` needs the flag. `development` is a
99
+ // manager that installs every dependency, there being no other kind.
102
100
  const MANAGERS = {
103
101
  pnpm: { lockfile: 'pnpm-lock.yaml', folder: 'node_modules', projects: findPnpmProjects, build: buildPnpmTree },
104
102
  yarn: { lockfile: 'yarn.lock', folder: 'node_modules', projects: findYarn1Workspaces, build: buildYarn1Tree },
@@ -241,11 +239,8 @@ function size(bytes) {
241
239
  return unit === 0 ? `${bytes} B` : `${(bytes / 1024 ** unit).toFixed(1)} ${UNITS[unit]}`
242
240
  }
243
241
 
244
- // A refusal says what and where: deptree's or its lockfile reader's,
245
- // compare's of a side that is no tree it can hold (a link to nothing, say),
246
- // the system's on a call it names, parseArgs's of an option, or a host
247
- // deptree takes no version of from what is there. Anything else is a bug,
248
- // and shows its stack, though Node gave it a code.
242
+ // A refusal says what and where: deptree's, its readers', compare's, the system's on a call it names,
243
+ // parseArgs's, or of a host version deptree cannot take. Anything else is a bug, and shows its stack.
249
244
  const REFUSALS = [DeptreeError, LockfileError, TomlError, CompareError]
250
245
  const refused = (error) => REFUSALS.some((type) => error instanceof type) || typeof error?.syscall === 'string' || String(error?.code).startsWith('ERR_PARSE_ARGS_') || (error instanceof TypeError && error.message.startsWith('host.'))
251
246
  function describe(error) {
package/cargo.d.ts CHANGED
@@ -1,221 +1,165 @@
1
- import type { NodeType, Vfs } from '@preventive/vfs'
1
+ /**
2
+ * The vendor directory `cargo vendor` makes from a Cargo.lock, built in memory
3
+ *
4
+ * ```js
5
+ * import { buildCargoTree } from '@preventive/deptree/cargo.js'
6
+ * ```
7
+ *
8
+ * Each .crate is fetched through `@preventive/upstream`: from cargo's own cache ($CARGO_HOME/registry/cache)
9
+ * where one there has the lockfile's checksum, which is never written, else its own (`setCacheDir`). That
10
+ * is the one place a filesystem is touched. Nothing is left to a guess: what cargo would read otherwise,
11
+ * or what this cannot reproduce exactly, is refused.
12
+ *
13
+ * @module @preventive/deptree/cargo.js
14
+ */
2
15
 
3
- export { LockfileError, TomlError } from '@preventive/lockfile/cargo.js'
16
+ import type { NodeType, Vfs } from '@preventive/vfs';
4
17
 
5
- // Where @preventive/upstream caches what it fetches, .crate files among
6
- // them. Each .crate is fetched through it, and that is the one place
7
- // anything here touches a filesystem. Before the network, it takes one from
8
- // cargo's own cache -- each registry's under $CARGO_HOME/registry/cache, or
9
- // ~/.cargo where that is unset -- where one there has the lockfile's
10
- // checksum, and writes none of it; then from its own cache, where one is
11
- // set, which is where it writes each .crate it fetches: setCacheDir() sets
12
- // the default one, and setCacheDir(false) unsets it. Unset, which it is
13
- // until set, it writes nothing. The project is read only through the view
14
- // given as `project`, and the tree built in a Vfs.
15
- export { setCacheDir } from '@preventive/upstream/npm.js'
18
+ export { LockfileError, TomlError } from '@preventive/lockfile/cargo.js';
16
19
 
17
- // The machine cargo would vendor on: `cargo` is the version that vendors,
18
- // exact, 1.94.0 to 1.99.x, which unpack a .crate alike, those from 1.97 on
19
- // writing a `$comment` in each .cargo-checksum.json that those before do
20
- // not; `os` as Node names it -- `linux`, `darwin`. Windows is refused:
21
- // cargo unpacks and names files otherwise there.
20
+ // Where `@preventive/upstream` caches .crate files: setCacheDir() the default, false none, as until set
21
+ export { setCacheDir } from '@preventive/upstream/npm.js';
22
+
23
+ /** The machine cargo would vendor on */
22
24
  export interface CargoHost {
23
- cargo: string
24
- os: string
25
+ /** The exact cargo that vendors, 1.94.0 to 1.99.x; from 1.97 each .cargo-checksum.json has a `$comment` */
26
+ cargo: string;
27
+ /** As Node names it, `linux` or `darwin`; Windows is refused, as cargo unpacks and names files otherwise there */
28
+ os: string;
25
29
  }
26
30
 
27
- // A view of the project's root, by paths from `/`: a Vfs, or anything with
28
- // its readdir, lstat, stat and readFile, such as one of a directory on
29
- // disk, of which only this is read: Cargo.lock; the Cargo.toml of every
30
- // path package cargo reads, as below, and of each directory between one and
31
- // the root, as cargo looks there for a workspace's root; the directories
32
- // workspace.members takes; and .cargo/config, or else .cargo/config.toml.
33
- // Each is read as UTF-8, and refused where it is not. A link where cargo
34
- // looks for members, or at or on the way to any file it reads -- Cargo.lock,
35
- // the config, a Cargo.toml -- is refused, so that nothing is read from
36
- // outside the view. Each throws an error
37
- // whose `code` is ENOENT, ENOTDIR or ELOOP for a path that leads nowhere.
38
- // Nothing is written to it.
31
+ /**
32
+ * The project's root, by paths from `/`: a Vfs, or anything with these methods, such as a view of a
33
+ * directory on disk. Read as UTF-8: Cargo.lock, the Cargo.toml of every path package cargo reads and of
34
+ * each directory between one and the root, the directories workspace.members takes, and .cargo/config or
35
+ * .cargo/config.toml. A link at or on the way to any of them is refused; nothing is written.
36
+ */
39
37
  export interface CargoProject {
40
- readdir(path: string): string[]
41
- lstat(path: string): { type: NodeType }
42
- stat(path: string): { type: NodeType }
43
- readFile(path: string): Uint8Array
38
+ readdir(path: string): string[];
39
+ lstat(path: string): { type: NodeType };
40
+ stat(path: string): { type: NodeType };
41
+ /** Throws with `code` ENOENT, ENOTDIR or ELOOP for a path that leads nowhere */
42
+ readFile(path: string): Uint8Array;
44
43
  }
45
44
 
46
- // The files `cargo vendor` reads, run at the project's root, which is taken
47
- // to be the workspace's, with no workspace above it: Cargo.lock; the
48
- // Cargo.toml of the root and of every other path package cargo reads; and
49
- // the project's .cargo/config.toml, where there is one.
50
- //
51
- // The path packages are the members -- the root's package, each directory
52
- // workspace.members takes and workspace.exclude does not, and each path
53
- // dependency of a member that is in the root and not excluded -- and every
54
- // other package cargo reads from a path: each path dependency of a member
55
- // that is not one, each [patch] from a path, and each normal or build path
56
- // dependency of those, which cargo resolves where it resolves their
57
- // dev-dependencies for members alone. Each inherits from the root's
58
- // [workspace] where cargo has it inherit: where it is in the root and not
59
- // excluded, or its package.workspace points to the root.
60
- //
61
- // With `lockfile`, they are given as text: `manifests` by directory, `.`
62
- // for the root and each other's path from it, with no `.`, `..` or empty
63
- // segment; and `config`, where there is one. They stand for the project, so
64
- // that a directory none of them is in is taken not to be there, and every
65
- // one cargo reads has to be given, and none else. Without it, they are read
66
- // from `project`, and none of them may be given. A refusal names each by
67
- // its path from the root: `crates/a/Cargo.toml`.
68
- //
69
- // Of a workspace, what cargo reads otherwise than this is refused: a glob
70
- // in workspace.members or default-members with a `**` or a `[`, a path in
71
- // one of the three lists or in a manifest that is absolute, leads out of
72
- // the project or has a `..` after a name; a package.workspace that points
73
- // elsewhere than the root, or a root's at all; a [workspace] between a
74
- // package and the root. What cargo refuses of one is refused too: a glob
75
- // that takes nothing, a member with no Cargo.toml or with a [workspace] of
76
- // its own, a root excluded from its own workspace, a default member that is
77
- // no member, a path dependency or [patch] that leads to no package or to
78
- // another of the name. Settings from anywhere else -- a config above the
79
- // project or in cargo's home, the environment, the command line -- are not
80
- // read, and are taken to be at their defaults. Of the config, [patch] is
81
- // read, as cargo resolves with it; `paths` and `include` are refused; the
82
- // rest is passed over, as it bears on where packages are fetched from and
83
- // not on what is vendored: `cargo vendor` replaces no source unless told
84
- // to with --respect-source-config.
85
- //
86
- // `vfs` is a Vfs to mount the tree into, at its root, which is taken to be
87
- // the project's -- it may be `project` too; without one, a new Vfs holds
88
- // the tree alone. A Vfs that holds a `vendor` at its root, or on macOS a
89
- // name that is one there, is refused before anything is fetched: cargo
90
- // would remove what is in it. Nothing there is written over: each
91
- // directory the tree has is one there or is made, and every file is written
92
- // where nothing is. The tree is built, and held to every check below,
93
- // before any of it is written, so a refusal leaves the Vfs as it was.
94
- export type CargoTreeOptions = CargoTreeGiven | CargoTreeRead
45
+ /**
46
+ * The files `cargo vendor` reads at the project's root, taken to be the workspace's, with no workspace
47
+ * above it: given as text (`lockfile`, `manifests` and `config`) or read from `project`
48
+ *
49
+ * The path packages are the members (the root's, each directory workspace.members takes and exclude does
50
+ * not, each path dependency of a member in the root and not excluded), and every other package cargo reads
51
+ * from a path: path dependencies of members, each `[patch]` from a path, and their normal and build path
52
+ * dependencies. Each inherits from the root's `[workspace]` where cargo has it inherit.
53
+ *
54
+ * Refused, as cargo reads it otherwise: a `**` or `[` in a members glob, a path that is absolute, leads
55
+ * out of the project or has a `..` after a name, a package.workspace pointing elsewhere than the root,
56
+ * and a `[workspace]` between a package and the root. Refused, as cargo refuses it: a glob that takes
57
+ * nothing, a member without a Cargo.toml or with a `[workspace]`, a root excluded from its workspace, a
58
+ * default member that is no member, and a path dependency or `[patch]` to no package or another of the
59
+ * name. Of the config, `[patch]` is read and `paths` and `include` refused; settings from anywhere else
60
+ * are taken to be at their defaults.
61
+ */
62
+ export type CargoTreeOptions = CargoTreeGiven | CargoTreeRead;
63
+
64
+ interface CargoTreeCommon {
65
+ host: CargoHost;
66
+ /**
67
+ * A Vfs to mount the tree into, at the project's root (it may be `project`), or a new one. One that
68
+ * holds a `vendor` (on macOS, a name that is one there) is refused before anything is fetched. Nothing
69
+ * there is written over, and a refusal leaves it as it was.
70
+ */
71
+ vfs?: Vfs;
72
+ }
95
73
 
96
- export interface CargoTreeGiven {
97
- lockfile: string
98
- manifests: Record<string, string> | Map<string, string>
99
- config?: string
100
- project?: undefined
101
- host: CargoHost
102
- vfs?: Vfs
74
+ export interface CargoTreeGiven extends CargoTreeCommon {
75
+ lockfile: string;
76
+ /**
77
+ * Each Cargo.toml cargo reads, and none else, by directory: `.` for the root, and each other's path
78
+ * from it with no `.`, `..` or empty segment
79
+ */
80
+ manifests: Record<string, string> | Map<string, string>;
81
+ /** .cargo/config.toml */
82
+ config?: string;
83
+ project?: undefined;
103
84
  }
104
85
 
105
- export interface CargoTreeRead {
106
- lockfile?: undefined
107
- manifests?: undefined
108
- config?: undefined
109
- project: CargoProject
110
- host: CargoHost
111
- vfs?: Vfs
86
+ export interface CargoTreeRead extends CargoTreeCommon {
87
+ lockfile?: undefined;
88
+ manifests?: undefined;
89
+ config?: undefined;
90
+ project: CargoProject;
112
91
  }
113
92
 
114
- // What buildCargoTree counts, all of it plain numbers: `packages` the
115
- // lockfile's; `vendored` those copied into vendor/, each a .crate fetched;
116
- // `files` and `bytes` what is written, each .cargo-checksum.json among it.
93
+ /** What was vendored */
117
94
  export interface CargoTreeStats {
118
- packages: number
119
- vendored: number
120
- files: number
121
- bytes: number
95
+ /** The lockfile's packages */
96
+ packages: number;
97
+ /** Those copied into vendor/, each a .crate fetched */
98
+ vendored: number;
99
+ /** Files written, each .cargo-checksum.json among them */
100
+ files: number;
101
+ /** Bytes written */
102
+ bytes: number;
122
103
  }
123
104
 
124
- // A package in the tree, as an SBOM would list it: `path` is its
125
- // directory, from the project's root, which is `/` of the Vfs --
126
- // vendor/<name>, or vendor/<name>-<version> for all but the greatest
127
- // version of a name; `name`, `version` and `source` the lockfile's;
128
- // `checksum` the hex sha256 its .crate is held to; `commit` the commit its
129
- // .cargo_vcs_info.json names, as `cargo package` writes one where it packs
130
- // from a git checkout, where that is a full commit id and the checkout was
131
- // not dirty, and undefined elsewhere; `repository` and `homepage` those its
132
- // Cargo.toml's [package] gives, as cargo packed it, each undefined where it
133
- // gives none. All of it is the publisher's word, held to no repository.
105
+ /** A package as an SBOM would list it; all of it the publisher's word, held to no repository */
134
106
  export interface CargoInstalled {
135
- path: string
136
- name: string
137
- version: string
138
- source: string
139
- checksum: string
140
- commit: string | undefined
141
- repository: string | undefined
142
- homepage: string | undefined
107
+ /** `vendor/<name>`, or `vendor/<name>-<version>` for all but the greatest version of a name */
108
+ path: string;
109
+ name: string;
110
+ version: string;
111
+ source: string;
112
+ /** The hex sha256 its .crate is held to */
113
+ checksum: string;
114
+ /** The full commit its .cargo_vcs_info.json names, where `cargo package` packed a clean checkout */
115
+ commit: string | undefined;
116
+ /** Its packed Cargo.toml's */
117
+ repository: string | undefined;
118
+ /** Its packed Cargo.toml's */
119
+ homepage: string | undefined;
143
120
  }
144
121
 
145
- // `vfs` is the one given, the tree mounted into it, or a new one.
146
- // `installed` is each package vendored, in the lockfile's order.
147
122
  export interface CargoTree {
148
- vfs: Vfs
149
- stats: CargoTreeStats
150
- installed: CargoInstalled[]
123
+ /** The one given, the tree mounted into it, or a new one */
124
+ vfs: Vfs;
125
+ stats: CargoTreeStats;
126
+ /** In the lockfile's order */
127
+ installed: CargoInstalled[];
151
128
  }
152
129
 
153
- // The vendor directory `cargo vendor` makes from the lockfile, with
154
- // host.cargo and none of its options, in a project with no vendor directory
155
- // yet: rooted at the project's root, it holds vendor/<directory> for each
156
- // package of the lockfile but a path one, and nothing else of the project;
157
- // none at all where every package is a path one. Each package's directory
158
- // is its name, or `<name>-<version>` for all but the greatest version of
159
- // that name, by the semver crate's order. What cargo writes or prints
160
- // beside it -- the config that reads from it, the lockfile again -- is not
161
- // written.
162
- //
163
- // The lockfile is held to the manifests, as cargo would resolve anew one
164
- // that is out of date with them and vendor what that comes to: every
165
- // package's, a vendored one's from its .crate, laid over it with
166
- // @preventive/lockfile/cargo.js's linkCargo, with what that refuses, and
167
- // each path dependency to the package in the directory it leads to. Every
168
- // path package of the lockfile has to be one cargo reads, and every member
169
- // one of the lockfile's.
170
- //
171
- // Each .crate is fetched from crates.io and held to the lockfile's checksum,
172
- // its sha256. It is unpacked as cargo unpacks it into vendor/: every entry
173
- // under the directory `<name>-<version>`, that directory taken off; of what
174
- // is under it, anything under a `.git`, a .gitattributes or .gitignore,
175
- // and a .cargo-ok, passed over, and a directory none but such entries are
176
- // in not made. Each directory is 0o755, or its own entry's mode where it has
177
- // one; each file its mode within 0o777; both as a umask of 0o022 leaves
178
- // them. Each directory then gets a .cargo-checksum.json, 0o644, as cargo
179
- // writes it: the sha256 of each file and of the .crate, as serde_json
180
- // writes them.
181
- //
182
- // What the archive readers refuse is refused: @preventive/archive's
183
- // compression.js and tar.js refuse a name with a backslash, a control or
184
- // formatting character, an empty or `..` segment, or a drive letter, two
185
- // entries of one name that differ, an entry inside one that is not a
186
- // directory, a sparse entry -- where cargo would take some of it. What cargo
187
- // reads otherwise than the readers is refused:
188
- // a .crate of more than one gzip member, of which cargo reads the first
189
- // alone; a gzip header CRC or reserved flag; a pax size, which cargo 1.94.0
190
- // reads otherwise. What cargo refuses or fails on is refused: a .crate that
191
- // unpacks to more than 512 MiB, or twenty times its size where that is
192
- // more; an entry not under `<name>-<version>`, an entry not a file or
193
- // directory, a .crate's own .cargo-checksum.json, which cargo lists and
194
- // writes over so that it cannot build from it. So is what cargo fails on or
195
- // reads otherwise as any user but root: a file whose mode lacks the owner's
196
- // read, which cargo cannot checksum; a directory with anything in it whose
197
- // mode lacks the owner's read or search, whose files cargo leaves out of
198
- // .cargo-checksum.json; and one whose mode lacks the owner's write where
199
- // anything is written into it after its own entry, as .cargo-checksum.json
200
- // always is into the package's. A directory with nothing in it may have any
201
- // mode. On macOS, two names in one directory that differ only in case
202
- // or normalization are refused, as they would be one name there.
203
- //
204
- // Packages come from crates.io alone: one from git, which cargo vendor
205
- // checks out with git, or from another registry, is refused.
206
- //
207
- // Nothing is left to a guess: a lockfile or manifest the lockfile reader
208
- // refuses, a workspace this does not read as cargo reads it, a package from
209
- // anywhere but crates.io, a check above that fails -- each is refused with a
210
- // DeptreeError, a LockfileError or a TomlError that says where. A TypeError
211
- // is thrown for options of the wrong type.
212
- export function buildCargoTree(options: CargoTreeOptions): Promise<CargoTree>
130
+ /**
131
+ * The vendor directory `cargo vendor` makes, with `host.cargo` and none of its options, in a project
132
+ * with no vendor directory yet: `vendor/<directory>` for each package but path ones, and nothing else
133
+ *
134
+ * A package's directory is its name, or `<name>-<version>` for all but the greatest version of the name
135
+ * by the semver crate's order. The lockfile is held to the manifests, as cargo resolves anew one out of
136
+ * date with them: every package's (a vendored one's from its .crate) laid over it by `linkCargo`, each
137
+ * path dependency to the package its path leads to, every path package of it one cargo reads, and every
138
+ * member in it.
139
+ *
140
+ * Each .crate is fetched from crates.io, held to the lockfile's sha256, and unpacked as cargo unpacks
141
+ * it: `<name>-<version>/` taken off; anything under a `.git`, a .gitattributes, .gitignore or .cargo-ok
142
+ * passed over; directories 0o755 or their own entry's mode, files their mode within 0o777, as a 0o022
143
+ * umask leaves them; then a .cargo-checksum.json, 0o644, as cargo writes it. Refused:
144
+ * - what `@preventive/archive`'s readers refuse, such as a `..` name or two entries of one name that differ
145
+ * - what cargo reads otherwise: more than one gzip member, a gzip header CRC or reserved flag, a pax size
146
+ * - what cargo refuses: past 512 MiB unpacked (or twenty times the .crate), an entry not under
147
+ * `<name>-<version>` or not a file or directory, a .crate's own .cargo-checksum.json
148
+ * - what cargo fails on as any user but root: a file without its owner's read, a directory with anything
149
+ * in it without its owner's read and search, or written into after its entry without its owner's write
150
+ * - on macOS, two names that are one there
151
+ *
152
+ * A package from git, or from a registry but crates.io, is refused.
153
+ *
154
+ * @param options - The files and where to build
155
+ * @returns The tree, what it holds, and its packages
156
+ * @throws DeptreeError, LockfileError or TomlError saying where; TypeError for options of the wrong type
157
+ */
158
+ export function buildCargoTree(options: CargoTreeOptions): Promise<CargoTree>;
213
159
 
214
- // `where` is what a refusal is about -- `crates/a/Cargo.toml`,
215
- // `packages["serde 1.0.0 (registry+...)"]`, an entry of a .crate -- or
216
- // undefined for the call as a whole; the message leads with it. `cause` is
217
- // what a package beneath refused with, where one did.
160
+ /** A refusal */
218
161
  export class DeptreeError extends Error {
219
- constructor(detail: string, where?: string, options?: { cause?: unknown })
220
- where: string | undefined
162
+ constructor(detail: string, where?: string, options?: { cause?: unknown });
163
+ /** What it is about, such as `crates/a/Cargo.toml`, which the message leads with; undefined for the call */
164
+ where: string | undefined;
221
165
  }
package/cargo.js CHANGED
@@ -1,5 +1,3 @@
1
- // The vendor directory built in memory from a Cargo.lock, as `cargo vendor`
2
- // makes it; see cargo.d.ts.
3
1
  export { buildCargoTree } from './src/cargo/tree.js'
4
2
  export { DeptreeError } from './src/error.js'
5
3
  export { setCacheDir } from '@preventive/upstream/npm.js'