@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.
- package/bin/compare.js +10 -21
- package/bin/deptree.js +5 -10
- package/cargo.d.ts +139 -195
- package/cargo.js +0 -2
- package/cocoapods.d.ts +211 -381
- package/cocoapods.js +0 -2
- package/npm.d.ts +245 -369
- package/npm.js +4 -6
- package/package.json +2 -2
- package/pnpm.d.ts +258 -667
- package/pnpm.js +2 -4
- package/soldeer.d.ts +144 -215
- package/soldeer.js +0 -2
- package/src/cargo/crate.js +21 -46
- package/src/cargo/inputs.js +5 -8
- package/src/cargo/members.js +6 -12
- package/src/cargo/registry.js +5 -9
- package/src/cargo/tree.js +8 -13
- package/src/cargo/workspace.js +13 -26
- package/src/cocoapods/archive.js +19 -40
- package/src/cocoapods/clean.js +21 -45
- package/src/cocoapods/fnmatch.js +12 -27
- package/src/cocoapods/inputs.js +5 -11
- package/src/cocoapods/install.js +11 -24
- package/src/cocoapods/podspec.js +19 -40
- package/src/cocoapods/podtree.js +10 -19
- package/src/cocoapods/source.js +13 -30
- package/src/cocoapods/tree.js +17 -39
- package/src/cocoapods/unicode.js +3 -9
- package/src/github.js +12 -24
- package/src/glob.js +2 -4
- package/src/lazy.js +2 -4
- package/src/manifest.js +2 -4
- package/src/matcher.js +3 -5
- package/src/mount.js +7 -14
- package/src/npm/bins.js +3 -5
- package/src/npm/compat.js +3 -5
- package/src/npm/package.js +6 -12
- package/src/npm/ratio.js +3 -5
- package/src/npm/settings.js +3 -5
- package/src/npm/tree.js +6 -11
- package/src/npm/versions.js +3 -4
- package/src/npmrc.js +2 -4
- package/src/patch.js +8 -14
- package/src/pnpm/bins.js +16 -42
- package/src/pnpm/filename.js +2 -4
- package/src/pnpm/gitignore.js +2 -4
- package/src/pnpm/glob.js +3 -5
- package/src/pnpm/hoist.js +8 -16
- package/src/pnpm/hoisted.js +15 -44
- package/src/pnpm/hook.js +2 -4
- package/src/pnpm/install.js +5 -10
- package/src/pnpm/lazy.js +8 -23
- package/src/pnpm/local.js +2 -4
- package/src/pnpm/minimatch.js +8 -15
- package/src/pnpm/nm-hoist.js +5 -11
- package/src/pnpm/npm-packlist.js +3 -6
- package/src/pnpm/overrides.js +2 -4
- package/src/pnpm/package.js +10 -16
- package/src/pnpm/packlist.js +3 -7
- package/src/pnpm/patches.js +3 -4
- package/src/pnpm/production.js +9 -28
- package/src/pnpm/projects.js +2 -6
- package/src/pnpm/readers.js +2 -4
- package/src/pnpm/settings.js +2 -5
- package/src/pnpm/tree.js +14 -37
- package/src/pnpm/workspace.js +4 -7
- package/src/pnpm/write.js +1 -1
- package/src/soldeer/config.js +5 -9
- package/src/soldeer/tree.js +2 -4
- package/src/soldeer/zip.js +8 -17
- package/src/tarball.js +12 -29
- package/src/yarn1/compat.js +2 -4
- package/src/yarn1/hoist.js +3 -8
- package/src/yarn1/package.js +12 -23
- package/src/yarn1/resolve.js +6 -11
- package/src/yarn1/settings.js +5 -10
- package/src/yarn1/tree.js +9 -18
- package/yarn1.d.ts +203 -360
- package/yarn1.js +4 -6
package/pnpm.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// A node_modules tree built in memory from a pnpm lockfile, as pnpm 9, 10,
|
|
2
|
-
// 11 or 12 installs it with the isolated linker; see pnpm.d.ts.
|
|
3
|
-
export { buildPnpmTree } from './src/pnpm/tree.js'
|
|
4
|
-
export { findPnpmProjects } from './src/pnpm/inputs.js'
|
|
5
1
|
export { DeptreeError } from './src/error.js'
|
|
2
|
+
export { findPnpmProjects } from './src/pnpm/inputs.js'
|
|
3
|
+
export { buildPnpmTree } from './src/pnpm/tree.js'
|
|
6
4
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
|
7
5
|
export { LockfileError, YamlError } from '@preventive/lockfile/pnpm.js'
|
package/soldeer.d.ts
CHANGED
|
@@ -1,240 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
1
|
+
/**
|
|
2
|
+
* The dependencies folder `soldeer install` makes from a soldeer.lock, built in memory
|
|
3
|
+
*
|
|
4
|
+
* ```js
|
|
5
|
+
* import { buildSoldeerTree } from '@preventive/deptree/soldeer.js'
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Everything is fetched through `@preventive/upstream`, whose cache (`setCacheDir`) is the one place
|
|
9
|
+
* a filesystem is touched; Soldeer's own folders are never read. Nothing is left to a guess: what
|
|
10
|
+
* Soldeer would read otherwise, or what this cannot reproduce exactly, is refused.
|
|
11
|
+
*
|
|
12
|
+
* @module @preventive/deptree/soldeer.js
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { Client } from '@preventive/upstream/github.js';
|
|
16
|
+
import type { NodeType, Vfs } from '@preventive/vfs';
|
|
17
|
+
|
|
18
|
+
export { LockfileError, TomlError } from '@preventive/lockfile/soldeer.js';
|
|
19
|
+
|
|
20
|
+
// Where `@preventive/upstream` caches zips and GitHub's tarballs: setCacheDir() the default, false none, as until set
|
|
21
|
+
export { setCacheDir } from '@preventive/upstream/npm.js';
|
|
22
|
+
|
|
23
|
+
/** The machine Soldeer would install on */
|
|
21
24
|
export interface SoldeerHost {
|
|
22
|
-
soldeer
|
|
23
|
-
|
|
25
|
+
/** The Soldeer that installs, alone or as `forge soldeer`: 0.12.0, which extracts zips otherwise than 0.11 */
|
|
26
|
+
soldeer: string;
|
|
27
|
+
/** As Node names it, `linux` or `darwin`; Windows is refused, as Soldeer names folders otherwise there */
|
|
28
|
+
os: string;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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. Only soldeer.lock, foundry.toml and, without that, soldeer.toml are read, as
|
|
34
|
+
* UTF-8; nothing is written.
|
|
35
|
+
*/
|
|
31
36
|
export interface SoldeerProject {
|
|
32
|
-
readdir(path: string): string[]
|
|
33
|
-
lstat(path: string): { type: NodeType }
|
|
34
|
-
stat(path: string): { type: NodeType }
|
|
35
|
-
readFile(path: string): Uint8Array
|
|
37
|
+
readdir(path: string): string[];
|
|
38
|
+
lstat(path: string): { type: NodeType };
|
|
39
|
+
stat(path: string): { type: NodeType };
|
|
40
|
+
readFile(path: string): Uint8Array;
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// leaves the Vfs as it was.
|
|
70
|
-
//
|
|
71
|
-
// `github` is the client from @preventive/upstream/github.js's createClient
|
|
72
|
-
// each git dependency is fetched through, with whatever token it was made
|
|
73
|
-
// with, or none. It is needed only where the lockfile has a git dependency,
|
|
74
|
-
// and there it is a TypeError to leave it out, before anything is fetched.
|
|
75
|
-
export type SoldeerTreeOptions = SoldeerTreeGiven | SoldeerTreeRead
|
|
76
|
-
|
|
77
|
-
export interface SoldeerTreeGiven {
|
|
78
|
-
lockfile: string
|
|
79
|
-
foundry?: string
|
|
80
|
-
soldeer?: string
|
|
81
|
-
project?: undefined
|
|
82
|
-
host: SoldeerHost
|
|
83
|
-
vfs?: Vfs
|
|
84
|
-
github?: Client
|
|
43
|
+
/**
|
|
44
|
+
* The files an install reads, given as text (`lockfile`, and `foundry` and `soldeer` where there) or
|
|
45
|
+
* read from `project`
|
|
46
|
+
*
|
|
47
|
+
* The config is foundry.toml where it has a `[dependencies]` table, else soldeer.toml where there is
|
|
48
|
+
* no foundry.toml; otherwise Soldeer asks which file to make its config, which is refused. Refused too:
|
|
49
|
+
* - in foundry.toml, a profile or profile.default that is not a table, or libs that are not an array,
|
|
50
|
+
* which Soldeer fails on as it adds `dependencies` to them
|
|
51
|
+
* - in `[soldeer]`, a value of a type Soldeer fails on, `recursive_deps = true`, and a setting Soldeer
|
|
52
|
+
* 0.12 does not have, as a later Soldeer may install otherwise by it
|
|
53
|
+
* - an inline `dependencies`, which Soldeer reads none from
|
|
54
|
+
*/
|
|
55
|
+
export type SoldeerTreeOptions = SoldeerTreeGiven | SoldeerTreeRead;
|
|
56
|
+
|
|
57
|
+
interface SoldeerTreeCommon {
|
|
58
|
+
host: SoldeerHost;
|
|
59
|
+
/**
|
|
60
|
+
* A Vfs to mount the tree into, at the project's root (it may be `project`), or a new one. One that
|
|
61
|
+
* holds a `dependencies` (on macOS, a name that is one there) is refused before anything is fetched.
|
|
62
|
+
* Nothing there is written over, and a refusal leaves it as it was.
|
|
63
|
+
*/
|
|
64
|
+
vfs?: Vfs;
|
|
65
|
+
/** From upstream's `createClient`, for each git dependency; a TypeError where one needs it and it is missing */
|
|
66
|
+
github?: Client;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface SoldeerTreeGiven extends SoldeerTreeCommon {
|
|
70
|
+
lockfile: string;
|
|
71
|
+
foundry?: string;
|
|
72
|
+
soldeer?: string;
|
|
73
|
+
project?: undefined;
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
export interface SoldeerTreeRead {
|
|
88
|
-
lockfile?: undefined
|
|
89
|
-
foundry?: undefined
|
|
90
|
-
soldeer?: undefined
|
|
91
|
-
project: SoldeerProject
|
|
92
|
-
host: SoldeerHost
|
|
93
|
-
vfs?: Vfs
|
|
94
|
-
github?: Client
|
|
76
|
+
export interface SoldeerTreeRead extends SoldeerTreeCommon {
|
|
77
|
+
lockfile?: undefined;
|
|
78
|
+
foundry?: undefined;
|
|
79
|
+
soldeer?: undefined;
|
|
80
|
+
project: SoldeerProject;
|
|
95
81
|
}
|
|
96
82
|
|
|
97
|
-
|
|
98
|
-
// those installed, each a zip or a tarball fetched; `files` and `bytes`
|
|
99
|
-
// what is written, and `links` the symlinks, which git dependencies alone
|
|
100
|
-
// have, as a zip's are written as files.
|
|
83
|
+
/** What was installed */
|
|
101
84
|
export interface SoldeerTreeStats {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
/** Dependencies installed, each a zip or a tarball fetched */
|
|
86
|
+
dependencies: number;
|
|
87
|
+
/** Files written */
|
|
88
|
+
files: number;
|
|
89
|
+
/** Bytes written */
|
|
90
|
+
bytes: number;
|
|
91
|
+
/** Symlinks, which git dependencies alone have: a zip's are written as files */
|
|
92
|
+
links: number;
|
|
106
93
|
}
|
|
107
94
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// dependencies/<name>-<version>; `name` and `version` the lockfile's, as
|
|
111
|
-
// the registry has them, or for a git dependency, the config's. From the
|
|
112
|
-
// registry, `checksum` is the hex sha256 its zip is held to; from git,
|
|
113
|
-
// `git` is the repository's URL and `rev` the commit, as the lockfile has
|
|
114
|
-
// them, and `commit` that commit again, as the other trees name one.
|
|
115
|
-
export type SoldeerInstalled = SoldeerInstalledZip | SoldeerInstalledGit
|
|
95
|
+
/** A dependency as an SBOM would list it */
|
|
96
|
+
export type SoldeerInstalled = SoldeerInstalledZip | SoldeerInstalledGit;
|
|
116
97
|
|
|
117
98
|
export interface SoldeerInstalledZip {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
99
|
+
/** `dependencies/<name>-<version>`, from the project's root */
|
|
100
|
+
path: string;
|
|
101
|
+
name: string;
|
|
102
|
+
version: string;
|
|
103
|
+
/** The hex sha256 its zip is held to */
|
|
104
|
+
checksum: string;
|
|
122
105
|
}
|
|
123
106
|
|
|
124
107
|
export interface SoldeerInstalledGit {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
/** `dependencies/<name>-<version>`, from the project's root */
|
|
109
|
+
path: string;
|
|
110
|
+
/** The config's */
|
|
111
|
+
name: string;
|
|
112
|
+
/** The config's */
|
|
113
|
+
version: string;
|
|
114
|
+
/** The repository's URL, as the lockfile has it */
|
|
115
|
+
git: string;
|
|
116
|
+
/** The commit, as the lockfile has it */
|
|
117
|
+
rev: string;
|
|
118
|
+
/** `rev` again, as the other trees name a commit */
|
|
119
|
+
commit: string;
|
|
131
120
|
}
|
|
132
121
|
|
|
133
|
-
// `vfs` is the one given, the tree mounted into it, or a new one.
|
|
134
|
-
// `installed` is each dependency, in the lockfile's order.
|
|
135
122
|
export interface SoldeerTree {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
123
|
+
/** The one given, the tree mounted into it, or a new one */
|
|
124
|
+
vfs: Vfs;
|
|
125
|
+
stats: SoldeerTreeStats;
|
|
126
|
+
/** In the lockfile's order */
|
|
127
|
+
installed: SoldeerInstalled[];
|
|
139
128
|
}
|
|
140
129
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// and what the zip crate reads otherwise than the archive reader is
|
|
177
|
-
// refused: a name with a byte past ASCII that is not flagged UTF-8, which
|
|
178
|
-
// it reads as CP437, and an AES or a Unicode comment extra field. What
|
|
179
|
-
// Soldeer fails on is refused: a name with a `:` in it, an NTFS extra
|
|
180
|
-
// field or an extended timestamp the zip crate does not read. A folder
|
|
181
|
-
// Soldeer downloads another dependency's zip into, `<folder>.zip`, is
|
|
182
|
-
// refused. On macOS, two names in one directory that differ only in case
|
|
183
|
-
// or normalization are refused, as they would be one name there, and so
|
|
184
|
-
// is a folder that is one there with another dependency's zip.
|
|
185
|
-
//
|
|
186
|
-
// A git dependency Soldeer clones, `git clone` of the lockfile's `git`,
|
|
187
|
-
// then `git checkout` of its `rev`; here it is fetched from a GitHub
|
|
188
|
-
// repository alone, by `github`, as GitHub's tarball of the tree of that
|
|
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
|
|
192
|
-
// repository renamed or transferred since, which GitHub answers with a
|
|
193
|
-
// redirect that git's clone follows, is fetched by the name GitHub gives
|
|
194
|
-
// it now, as upstream's getRepo follows that redirect with
|
|
195
|
-
// `followRedirect`; any other redirect is refused. It is written as a
|
|
196
|
-
// checkout with no git config and a umask of 0o022 writes it: each
|
|
197
|
-
// directory 0o755, each file 0o644, or 0o755 where git has it executable;
|
|
198
|
-
// each symlink a symlink to its target, as git has it; a submodule an
|
|
199
|
-
// empty directory, as Soldeer leaves it without recursive_deps; a file the
|
|
200
|
-
// tree's .gitattributes mark `eol=crlf` with CRLF, as upstream reads them.
|
|
201
|
-
// The .git a clone has is not written, so nothing of the repository's
|
|
202
|
-
// history is there; nor is what git config on the machine would change,
|
|
203
|
-
// `core.autocrlf` or a filter such as Git LFS's. Its folder is the
|
|
204
|
-
// config's name and version, which Soldeer's sanitize_filename has to
|
|
205
|
-
// leave as they are. The `git` is the repository's URL over https or ssh,
|
|
206
|
-
// as git takes it -- `https://github.com/<owner>/<name>`,
|
|
207
|
-
// `ssh://git@github.com/<owner>/<name>` or
|
|
208
|
-
// `git@github.com:<owner>/<name>`, `.git` after or not; git's http and git
|
|
209
|
-
// protocols, which Soldeer has git refuse, are refused. GitHub's tarball
|
|
210
|
-
// is refused where upstream refuses it -- a tree with files marked
|
|
211
|
-
// `export-ignore`, `ident` or `working-tree-encoding`, from a repo set to
|
|
212
|
-
// include Git LFS objects in archives -- and where the tar reader of
|
|
213
|
-
// @preventive/archive/tar.js does, as for a symlink whose target climbs
|
|
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
|
|
217
|
-
// reach the commit, without which Soldeer's clone does not have it, is not
|
|
218
|
-
// checked: GitHub answers for any commit it has.
|
|
219
|
-
//
|
|
220
|
-
// Dependencies come from Soldeer's registry, each by a name and a version
|
|
221
|
-
// the registry takes, or from GitHub: one from another git host, from a
|
|
222
|
-
// URL the config gives, or one the registry keeps private, which it hands
|
|
223
|
-
// out to those signed in alone, is refused.
|
|
224
|
-
//
|
|
225
|
-
// Nothing is left to a guess: a lockfile the lockfile reader refuses, a
|
|
226
|
-
// config this does not read as Soldeer reads it, a dependency from
|
|
227
|
-
// anywhere but the registry or GitHub, a check above that fails -- each is
|
|
228
|
-
// refused with a DeptreeError, a LockfileError or a TomlError that says
|
|
229
|
-
// where. A TypeError is thrown for options of the wrong type, and for a
|
|
230
|
-
// git dependency without `github`.
|
|
231
|
-
export function buildSoldeerTree(options: SoldeerTreeOptions): Promise<SoldeerTree>
|
|
232
|
-
|
|
233
|
-
// `where` is what a refusal is about -- `foundry.toml: profile.default`,
|
|
234
|
-
// `dependencies["forge-std"]`, an entry of a zip -- or undefined for the
|
|
235
|
-
// call as a whole; the message leads with it. `cause` is what a package
|
|
236
|
-
// beneath refused with, where one did.
|
|
130
|
+
/**
|
|
131
|
+
* The dependencies folder `soldeer install` makes, with `host.soldeer`, in a project with no
|
|
132
|
+
* dependencies folder yet: `dependencies/<name>-<version>` for each dependency, and nothing else
|
|
133
|
+
*
|
|
134
|
+
* What Soldeer writes beside it (the lockfile again, remappings, foundry.toml's libs) is not written.
|
|
135
|
+
* The lockfile is held to the config, each dependency to have its entry and each entry a dependency.
|
|
136
|
+
*
|
|
137
|
+
* A registry dependency's zip is fetched anew from Soldeer's registry, as 0.12 does, held to the
|
|
138
|
+
* lockfile's sha256, and extracted as the zip crate extracts it: no root folder taken off; of two
|
|
139
|
+
* entries of one name the later, where the first was; anything under a `.git` (as Windows reads the
|
|
140
|
+
* name) passed over; a symlink written as a file of its target. Directories are 0o755, a file its Unix
|
|
141
|
+
* mode as the zip crate reads it, or 0o644 where it reads none, as a 0o022 umask leaves them. Refused:
|
|
142
|
+
* - what `@preventive/archive/zip.js` refuses, such as a `..` or absolute name, zip64 or encryption
|
|
143
|
+
* - what the zip crate reads otherwise: a name past ASCII not flagged UTF-8, an AES or Unicode comment
|
|
144
|
+
* extra field
|
|
145
|
+
* - what Soldeer fails on: a `:` in a name, an NTFS field or extended timestamp the zip crate does not read
|
|
146
|
+
* - a folder another dependency's zip is downloaded into, `<folder>.zip`
|
|
147
|
+
* - on macOS, two names that are one there
|
|
148
|
+
*
|
|
149
|
+
* A git dependency is fetched from GitHub alone, by `github`, as the tarball of the commit's tree (held
|
|
150
|
+
* to the commit's id), and written as a checkout with no git config under a 0o022 umask: files 0o644,
|
|
151
|
+
* or 0o755 where git has them executable, symlinks as symlinks, a submodule an empty directory, a file
|
|
152
|
+
* `.gitattributes` marks `eol=crlf` with CRLF. Its URL is GitHub's over https or ssh, and its folder one
|
|
153
|
+
* Soldeer's sanitize_filename leaves as it is. Refused: what upstream refuses of the tarball (such as
|
|
154
|
+
* `export-ignore` or Git LFS), and a path git refuses to check out (a `.git` or `git~1` in it).
|
|
155
|
+
*
|
|
156
|
+
* A dependency from another git host, a URL of its own, or a private one is refused.
|
|
157
|
+
*
|
|
158
|
+
* @param options - The files and where to build
|
|
159
|
+
* @returns The tree, what it holds, and its dependencies
|
|
160
|
+
* @throws DeptreeError, LockfileError or TomlError saying where; TypeError for options of the wrong type
|
|
161
|
+
*/
|
|
162
|
+
export function buildSoldeerTree(options: SoldeerTreeOptions): Promise<SoldeerTree>;
|
|
163
|
+
|
|
164
|
+
/** A refusal */
|
|
237
165
|
export class DeptreeError extends Error {
|
|
238
|
-
constructor(detail: string, where?: string, options?: { cause?: unknown })
|
|
239
|
-
|
|
166
|
+
constructor(detail: string, where?: string, options?: { cause?: unknown });
|
|
167
|
+
/** What it is about, such as `dependencies["forge-std"]`, which the message leads with; undefined for the call */
|
|
168
|
+
where: string | undefined;
|
|
240
169
|
}
|
package/soldeer.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// The dependencies folder built in memory from a soldeer.lock, as Soldeer
|
|
2
|
-
// 0.12 installs it; see soldeer.d.ts.
|
|
3
1
|
export { buildSoldeerTree } from './src/soldeer/tree.js'
|
|
4
2
|
export { DeptreeError } from './src/error.js'
|
|
5
3
|
export { setCacheDir } from '@preventive/upstream/npm.js'
|
package/src/cargo/crate.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// A .crate as `cargo vendor`
|
|
2
|
-
//
|
|
3
|
-
// reader takes and cargo would read otherwise is refused. As a 0o022 umask
|
|
4
|
-
// leaves them, each directory is 0o755 unless its own entry gives a mode, and
|
|
5
|
-
// each file its mode within 0o777, both without group and other write bits.
|
|
1
|
+
// A .crate as `cargo vendor` 1.94 to 1.99 unpacks it (registry/mod.rs's unpack, vendor.rs's vendor_this),
|
|
2
|
+
// under a 0o022 umask; what the archive reader takes and cargo would read otherwise is refused
|
|
6
3
|
|
|
7
4
|
import { crc32 } from '@exodus/bytes/crc.js'
|
|
8
5
|
import { utf8fromString, utf8toString } from '@exodus/bytes/utf8.js'
|
|
@@ -13,13 +10,11 @@ import { DeptreeError, quote } from '../error.js'
|
|
|
13
10
|
import { bytesSha256Hex } from '../hash.js'
|
|
14
11
|
import { own } from '../manifest.js'
|
|
15
12
|
|
|
16
|
-
// Cargo's bound on what a .crate unpacks to: 512 MiB, or twenty times the
|
|
17
|
-
// .crate where that is more.
|
|
13
|
+
// Cargo's bound on what a .crate unpacks to: 512 MiB, or twenty times the .crate where that is more
|
|
18
14
|
const unpackLimit = (bytes) => Math.max(512 * 1024 * 1024, bytes.length * 20)
|
|
19
15
|
const [FTEXT, FEXTRA, FNAME, FCOMMENT] = [0x01, 0x04, 0x08, 0x10]
|
|
20
16
|
|
|
21
|
-
// Where the
|
|
22
|
-
// or a reserved flag, which a reader may take or not, is refused.
|
|
17
|
+
// Where the deflate data starts; a header CRC or a reserved flag, which a reader may take or not, is refused
|
|
23
18
|
function deflateStart(bytes, where) {
|
|
24
19
|
if (bytes.length < 18 || bytes[0] !== 0x1f || bytes[1] !== 0x8b || bytes[2] !== 0x08) throw new DeptreeError('the .crate is not gzipped', where)
|
|
25
20
|
const flags = bytes[3]
|
|
@@ -35,22 +30,15 @@ function deflateStart(bytes, where) {
|
|
|
35
30
|
return at
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
// flate2's GzDecoder
|
|
39
|
-
//
|
|
40
|
-
// so the first has to be all of it. Its deflate data has to end where its
|
|
41
|
-
// eight-byte trailer starts, which deflate-raw holds it to, refusing what
|
|
42
|
-
// follows; and the trailer has to be the data's CRC-32 and length, as flate2
|
|
43
|
-
// checks them.
|
|
33
|
+
// flate2's GzDecoder reads the first gzip member alone, where the platform reads on, so it has to be all
|
|
34
|
+
// of it: deflate-raw holds its data to end at the trailer, which has to be its CRC-32 and length
|
|
44
35
|
async function gunzip(bytes, where) {
|
|
45
36
|
const start = deflateStart(bytes, where)
|
|
46
37
|
const limit = unpackLimit(bytes)
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
tar = await decompress(bytes.subarray(start, bytes.length - 8), 'deflate-raw', { limit })
|
|
50
|
-
} catch (error) {
|
|
38
|
+
const tar = await decompress(bytes.subarray(start, bytes.length - 8), 'deflate-raw', { limit }).catch((error) => {
|
|
51
39
|
if (!(error instanceof CompressionError)) throw error
|
|
52
40
|
throw new DeptreeError(error.limited ? `the .crate unpacks to more than ${limit} bytes, which cargo refuses` : 'the .crate is not one gzip member, which cargo reads the first of alone', where, { cause: error })
|
|
53
|
-
}
|
|
41
|
+
})
|
|
54
42
|
const trailer = new DataView(bytes.buffer, bytes.byteOffset + bytes.length - 8, 8)
|
|
55
43
|
if (trailer.getUint32(0, true) !== crc32(tar) || trailer.getUint32(4, true) !== tar.length >>> 0) throw new DeptreeError('the .crate\'s gzip trailer does not match its data', where)
|
|
56
44
|
return tar
|
|
@@ -65,20 +53,16 @@ function entriesOf(tar, where) {
|
|
|
65
53
|
}
|
|
66
54
|
}
|
|
67
55
|
|
|
68
|
-
// vendor_this
|
|
69
|
-
//
|
|
70
|
-
// looked at, unlike unpack's own .cargo-ok anywhere, after it.
|
|
56
|
+
// vendor_this passes over a `.git` anywhere on the way, a .gitattributes or .gitignore, and .cargo-ok at
|
|
57
|
+
// the root, before the type is looked at, unlike unpack's own .cargo-ok anywhere, after it
|
|
71
58
|
const vendored = (segments, last) => !segments.includes('.git') && last !== '.gitattributes' && last !== '.gitignore' && segments.join('/') !== '.cargo-ok'
|
|
72
59
|
|
|
73
60
|
const modeOf = (entry) => entry.mode & 0o777 & ~0o022
|
|
74
61
|
const unsupported = (entry, why, here) => new DeptreeError(`mode ${entry.mode.toString(8)}, which keeps cargo from ${why} as any user but root, is not supported`, here)
|
|
75
62
|
|
|
76
|
-
// As any user but root, cargo reads back no file without its owner's read
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// nothing into one without its write bit once its entry has set it, `after`.
|
|
80
|
-
// A directory nothing is in may have any mode. The package's always has
|
|
81
|
-
// something written into it last, its .cargo-checksum.json.
|
|
63
|
+
// As any user but root, cargo reads back no file without its owner's read, lists nothing in a directory
|
|
64
|
+
// without its owner's read and search, and writes nothing into one without its write once its entry has
|
|
65
|
+
// set it (`after`), as .cargo-checksum.json always is into the package's
|
|
82
66
|
function fileMode(entry, here) {
|
|
83
67
|
const mode = modeOf(entry)
|
|
84
68
|
if (!(mode & 0o400)) throw unsupported(entry, 'reading it back to checksum it', here)
|
|
@@ -91,9 +75,7 @@ function dirMode({ entry, here, after }, content) {
|
|
|
91
75
|
return mode
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
// The directory
|
|
95
|
-
// strip_prefix reads a path: by its components, so `./` or `/` before it
|
|
96
|
-
// is not it.
|
|
78
|
+
// The directory every entry has to be in, by components as Rust's strip_prefix reads them: not `./` or `/` it
|
|
97
79
|
function segmentsOf(entry, prefix, here) {
|
|
98
80
|
const [first, ...rest] = entry.name.split('/')
|
|
99
81
|
if (entry.storedName.startsWith('/') || entry.storedName.startsWith('./') || first !== prefix) throw new DeptreeError(`not under ${quote(prefix)}, which cargo refuses`, here)
|
|
@@ -102,8 +84,7 @@ function segmentsOf(entry, prefix, here) {
|
|
|
102
84
|
return rest
|
|
103
85
|
}
|
|
104
86
|
|
|
105
|
-
// `root` is the
|
|
106
|
-
// under it to its mode, 0o755 where no entry of its own gives one.
|
|
87
|
+
// `root` is the package's directory's mode, `dirs` each under it, 0o755 where no entry of its own gives one
|
|
107
88
|
function vendorEntries(entries, prefix, where) {
|
|
108
89
|
const dirs = new Map()
|
|
109
90
|
const files = new Map()
|
|
@@ -140,8 +121,7 @@ function vendorEntries(entries, prefix, where) {
|
|
|
140
121
|
|
|
141
122
|
const COMMENT = 'This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.'
|
|
142
123
|
|
|
143
|
-
// vendor.rs's, as serde_json writes it: compact,
|
|
144
|
-
// byte order, `$comment` from cargo 1.97 on.
|
|
124
|
+
// vendor.rs's, as serde_json writes it: compact, keys in UTF-8 byte order, `$comment` from cargo 1.97 on
|
|
145
125
|
async function checksumFile(files, checksum, comment) {
|
|
146
126
|
const paths = [...files.keys()].sort(compareNames)
|
|
147
127
|
const sums = await Promise.all(paths.map((path) => bytesSha256Hex(files.get(path).data)))
|
|
@@ -149,15 +129,11 @@ async function checksumFile(files, checksum, comment) {
|
|
|
149
129
|
return `{${comment ? `"$comment":${JSON.stringify(COMMENT)},` : ''}"files":{${listed}},"package":${JSON.stringify(checksum)}}`
|
|
150
130
|
}
|
|
151
131
|
|
|
152
|
-
// A full commit id
|
|
153
|
-
// repository of SHA-256 objects.
|
|
132
|
+
// A full commit id: 40 lowercase hex digits, or 64 in a repository of SHA-256 objects
|
|
154
133
|
const COMMIT = /^(?:[\da-f]{40}|[\da-f]{64})$/u
|
|
155
134
|
|
|
156
|
-
// The commit .cargo_vcs_info.json
|
|
157
|
-
// it
|
|
158
|
-
// the files are then not that commit's, nor where it names anything but a
|
|
159
|
-
// full id. Cargo reads none of it, so one that is not JSON names none, and
|
|
160
|
-
// is vendored all the same.
|
|
135
|
+
// The commit `cargo package` wrote in .cargo_vcs_info.json, none where the checkout was dirty or it is not
|
|
136
|
+
// a full id. Cargo reads none of it, so one that is not JSON names none and is vendored all the same.
|
|
161
137
|
function vcsCommitOf(file) {
|
|
162
138
|
if (file === undefined) return undefined
|
|
163
139
|
try {
|
|
@@ -170,9 +146,8 @@ function vcsCommitOf(file) {
|
|
|
170
146
|
}
|
|
171
147
|
}
|
|
172
148
|
|
|
173
|
-
// What vendor/<directory> holds
|
|
174
|
-
//
|
|
175
|
-
// again where it is unpacked.
|
|
149
|
+
// What vendor/<directory> holds, .cargo-checksum.json among it. getCrate has held the .crate to its
|
|
150
|
+
// checksum; it is held to it again where it is unpacked.
|
|
176
151
|
export async function vendorCrate(bytes, { name, version, checksum }, comment, where) {
|
|
177
152
|
if (await bytesSha256Hex(bytes) !== checksum) throw new DeptreeError(`its .crate's sha256 is not ${checksum}`, where)
|
|
178
153
|
const { root, dirs, files } = vendorEntries(entriesOf(await gunzip(bytes, where), where), `${name}-${version}`, where)
|
package/src/cargo/inputs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// What buildCargoTree takes, as text or read from the project's root
|
|
2
|
-
//
|
|
3
|
-
// one way.
|
|
1
|
+
// What buildCargoTree takes, as text or read from the project's root; texts given are laid out as the
|
|
2
|
+
// project they stand for, so both are read one way
|
|
4
3
|
|
|
5
4
|
import { Vfs } from '@preventive/vfs'
|
|
6
5
|
import { DeptreeError, quote } from '../error.js'
|
|
@@ -18,9 +17,8 @@ export function checkHost(host) {
|
|
|
18
17
|
return { cargo: host.cargo, os: host.os, comment: Number(minor) >= 97 }
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
// A file cargo reads,
|
|
22
|
-
//
|
|
23
|
-
// is read from outside the project's view.
|
|
20
|
+
// A file cargo reads, or undefined where there is none: a link at or on the way to it is refused, so
|
|
21
|
+
// nothing is read from outside the project's view
|
|
24
22
|
export function readUnlinked(project, file, what) {
|
|
25
23
|
const segments = file.split('/')
|
|
26
24
|
for (let i = 1; i <= segments.length; i++) {
|
|
@@ -61,8 +59,7 @@ function given(manifests) {
|
|
|
61
59
|
|
|
62
60
|
const LOCKFILE = 'lockfile must be the Cargo.lock text, or left out where project is given'
|
|
63
61
|
|
|
64
|
-
// `
|
|
65
|
-
// of those given, which have to be those read.
|
|
62
|
+
// `given` are the directories of the manifests given, which have to be those read
|
|
66
63
|
export function inputsOf(options) {
|
|
67
64
|
const { lockfile, manifests, config, project } = options
|
|
68
65
|
if (lockfile === undefined) {
|