@exodus/stasis 1.0.0-beta.8 → 1.0.0-rc.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.
Files changed (66) hide show
  1. package/README.md +7 -2
  2. package/bin/stasis.js +263 -446
  3. package/package.json +38 -13
  4. package/src/audit-corrections.js +11 -42
  5. package/src/audit.js +256 -212
  6. package/src/babel.js +119 -82
  7. package/src/bundle-from-lockfile.js +9 -21
  8. package/src/bundle-reader.js +24 -8
  9. package/src/bundle.js +0 -3
  10. package/src/cmd/build.js +211 -117
  11. package/src/cmd/bundle-options.js +347 -0
  12. package/src/cmd/bundle.js +1718 -908
  13. package/src/cmd/diff.js +1 -4
  14. package/src/cmd/github-bundle.js +48 -21
  15. package/src/cmd/output.js +24 -12
  16. package/src/cmd/sbom.js +6 -9
  17. package/src/cmd/tokens.js +60 -0
  18. package/src/define.js +218 -0
  19. package/src/diff.js +73 -129
  20. package/src/esbuild.js +0 -4
  21. package/src/flow.js +27 -0
  22. package/src/installed.js +265 -0
  23. package/src/json-stream.js +4 -9
  24. package/src/loader-mock.js +3 -8
  25. package/src/loader.js +1 -5
  26. package/src/loaders/bash.js +43 -120
  27. package/src/loaders/cargo.js +301 -808
  28. package/src/loaders/foundry.js +112 -290
  29. package/src/loaders/paths.js +15 -26
  30. package/src/loaders/php.js +221 -475
  31. package/src/loaders/rust.js +518 -1461
  32. package/src/loaders/solidity-ownership.js +51 -142
  33. package/src/loaders/solidity.js +42 -188
  34. package/src/loaders/toml.js +7 -17
  35. package/src/lockfile.js +0 -3
  36. package/src/metro-assets.js +41 -0
  37. package/src/metro-resolver.js +58 -133
  38. package/src/metro-transformer.js +0 -6
  39. package/src/metro.js +0 -4
  40. package/src/mock.js +32 -80
  41. package/src/parse.js +8 -7
  42. package/src/prune.js +0 -3
  43. package/src/resolve-fields.js +170 -235
  44. package/src/resolve-node.js +33 -46
  45. package/src/resolve-typescript.js +166 -298
  46. package/src/rollup.js +0 -4
  47. package/src/run-installed.js +10 -0
  48. package/src/sbom.js +70 -97
  49. package/src/scan.js +241 -278
  50. package/src/sixel.js +310 -0
  51. package/src/table.js +95 -0
  52. package/src/validate-notes.d.ts +19 -0
  53. package/src/validate-notes.js +72 -0
  54. package/src/validate.d.ts +159 -0
  55. package/src/validate.js +1315 -0
  56. package/src/vfs-bundle/entries.js +54 -46
  57. package/src/vfs-bundle/github.js +115 -92
  58. package/src/vfs-bundle/glob.js +379 -0
  59. package/src/vfs-bundle/lazy.js +99 -0
  60. package/src/vfs-bundle/prisma.js +235 -105
  61. package/src/vfs-bundle/soldeer.js +28 -49
  62. package/src/vfs-bundle/tree.js +434 -259
  63. package/src/vfs-bundle/yarnclean.js +79 -0
  64. package/src/vfs-bundle.js +25 -51
  65. package/src/webpack.js +0 -4
  66. package/src/why.js +79 -231
@@ -1,29 +1,22 @@
1
- // Who owns each file of a Solidity project -- the project or one of its dependencies -- decided by
2
- // where the file really is, for the import resolution (solidity.js), forge's config discovery
3
- // (foundry.js) and the bundler's --manifests. Dependencies are untrusted input: a link one plants
4
- // out of itself is never followed.
1
+ // Who owns each file of a Solidity project, by where it really is. Dependencies are untrusted input: a link
2
+ // one plants out of itself is never followed.
5
3
 
6
4
  import { realpathSync } from 'node:fs'
7
5
  import { isAbsolute, join, parse, posix, relative, resolve, sep } from 'node:path'
8
6
 
9
7
  import { utf8toString } from '@exodus/bytes/utf8.js'
10
8
  import { LockfileError, parseGitmodules } from '@preventive/lockfile/foundry.js'
11
- import { NO_ENTRY, readRegularFileOrNull } from '@exodus/stasis-core/bundle-util'
9
+ import { NO_ENTRY, lexists, readRegularFileOrNull } from '@exodus/stasis-core/bundle-util'
12
10
  import { diskHost } from '@exodus/stasis-core/host'
13
- import { hasNodeModulesSegment } from '@exodus/stasis-core/util'
11
+ import { hasNodeModulesSegment, memoized, nestedMap, relativeEscapes, upsert } from '@exodus/stasis-core/util'
14
12
  import { isDir } from '../resolve-typescript.js'
15
13
 
16
- // `/`-separated, as the loader's paths are: only Windows' separator is converted (on POSIX a `\\` is
17
- // part of a name, and must not read as a directory boundary).
14
+ // Only Windows' separator: on POSIX a `\\` is part of a name, and must not read as a directory boundary.
18
15
  const toSlashes = (p) => (sep === '\\' ? p.replaceAll('\\', '/') : p)
19
16
 
20
- // --- Reading --------------------------------------------------------------------------------
21
-
22
- // `p`'s real path as `host` resolves it, which throws when it can't: on disk, as the OS does
23
- // (realpath(3): the filesystem's own spelling, which Node's realpathSync doesn't give).
17
+ // On disk as the OS resolves it (realpath(3): the filesystem's own spelling, which Node's realpathSync doesn't give).
24
18
  const realpathIn = (host, p) => (host === diskHost ? realpathSync.native(p) : host.realpath(p))
25
19
 
26
- // `p`'s real path (realpathIn), or null.
27
20
  export function realpathOrNull(p, host = diskHost) {
28
21
  try {
29
22
  return realpathIn(host, p)
@@ -32,16 +25,10 @@ export function realpathOrNull(p, host = diskHost) {
32
25
  }
33
26
  }
34
27
 
35
- // A path relative to a dir (slashes) that stays inside it.
36
- const inRoot = (rel) => rel !== '..' && !rel.startsWith('../') && !isAbsolute(rel)
28
+ const inRoot = (rel) => !relativeEscapes(rel)
37
29
 
38
- // `abs`, a file the resolution read, relative to the project `root` (slashes): as spelled when that
39
- // lies inside it with no `..` to resolve (a linked lib's files keep the lib's path), else by real
40
- // paths -- where the read went (an absolute or `/proc/self/cwd` lib; a `..` after a symlink) --
41
- // `../` when outside the project. One whose real path the OS can't give (past PATH_MAX) is never
42
- // normalized, which could name another file: it keeps the path it was read by, `..` and all, from
43
- // the root however that's spelled (as given or by its real path), for solidityOwnership to refuse,
44
- // or else stays absolute, a name --manifests refuses as unresolvable. Real paths are `host`'s.
30
+ // As spelled inside `root` with no `..` to resolve, else by real paths. One with no real path is never normalized,
31
+ // which could name another file: it keeps its `..`s, for solidityOwnership to refuse.
45
32
  export function projectRelative(root, abs, host = diskHost) {
46
33
  const rel = toSlashes(relative(root, abs))
47
34
  if (inRoot(rel) && !toSlashes(abs).split('/').includes('..')) return rel
@@ -51,8 +38,6 @@ export function projectRelative(root, abs, host = diskHost) {
51
38
  return below(resolve(root), abs) ?? (realRoot === null ? null : below(realRoot, abs)) ?? toSlashes(abs)
52
39
  }
53
40
 
54
- // `abs` from `dir`, component by component as spelled (empty and `.` ones dropped, `..` kept), or
55
- // null when it doesn't start with `dir`'s components.
56
41
  function below(dir, abs) {
57
42
  const parts = (p) => toSlashes(p).split('/').filter((c) => c !== '' && c !== '.')
58
43
  const d = parts(dir)
@@ -60,10 +45,8 @@ function below(dir, abs) {
60
45
  return d.length < a.length && d.every((c, i) => a[i] === c) ? a.slice(d.length).join('/') : null
61
46
  }
62
47
 
63
- // realpathIn `host` of `p`: `{ real }`, or `{ real: null, missing }`, `missing` only when nothing
64
- // is there at all. The OS may fail to resolve what is there -- a real path past PATH_MAX, a loop, a
65
- // link whose end it can't name (`/proc/self/fd/0` on a pipe), a dir it may not search -- and a
66
- // read may still get through.
48
+ // `missing` only when nothing is there at all: the OS may fail to resolve what is there (past PATH_MAX, a loop,
49
+ // `/proc/self/fd/0` on a pipe, a dir it may not search), and a read may still get through.
67
50
  function osRealpath(p, host) {
68
51
  try {
69
52
  return { real: realpathIn(host, p), missing: false }
@@ -72,20 +55,8 @@ function osRealpath(p, host) {
72
55
  }
73
56
  }
74
57
 
75
- // Whether anything is at `p` itself, a link not followed (`host.readlink` throws when nothing is).
76
- function lexists(p, host) {
77
- try {
78
- host.readlink(p)
79
- return true
80
- } catch (err) {
81
- if (NO_ENTRY.has(err.code)) return false
82
- throw err
83
- }
84
- }
85
-
86
- // `bytes` as UTF-8 text, a byte-order mark kept. Bytes that aren't UTF-8 throw, naming them
87
- // `label`, rather than read with U+FFFD in their place: forge, solc and git refuse such a file, and
88
- // the text bundled or read must be the file's own.
58
+ // A BOM kept. Bytes that aren't UTF-8 throw rather than read with U+FFFD in their place: forge, solc and git
59
+ // refuse such a file, and the text bundled or read must be the file's own.
89
60
  export function decodeUtf8(bytes, label) {
90
61
  try {
91
62
  return utf8toString(bytes)
@@ -94,22 +65,12 @@ export function decodeUtf8(bytes, label) {
94
65
  }
95
66
  }
96
67
 
97
- // A config file's text (decodeUtf8), or null when there's no file (readRegularFileOrNull: a regular
98
- // file only, read through `host`). Errors name it `label`.
99
68
  export function readUtf8OrNull(file, label, host = diskHost) {
100
69
  const buf = readRegularFileOrNull(file, label, host)
101
70
  return buf === null ? null : decodeUtf8(buf, label)
102
71
  }
103
72
 
104
- // --- .gitmodules ------------------------------------------------------------------------------
105
-
106
- // The submodules of the project at `baseDir`, `{ path, url, branch }` (`url` and `branch` when set),
107
- // from its `.gitmodules` as @preventive/lockfile reads it (as git does). A url is taken as written
108
- // (`checkUrls: false`): relative to the superproject's remote, a path or none, as it only names a
109
- // GitHub submodule's bucket. A file the library refuses -- something git reads two ways, or that it
110
- // doesn't check (`update = none`, `active`, a `[core]` section) -- never fails the bundle: it's
111
- // warned about and read submodule by submodule (gitmodulesLeniently). One git itself refuses is an
112
- // error: read past what git can't, a submodule's section would be lost, and its directory with it.
73
+ // One the library refuses is warned about and read submodule by submodule; one git itself refuses is an error.
113
74
  export function readGitmodules(baseDir, host = diskHost) {
114
75
  const text = readUtf8OrNull(join(baseDir, '.gitmodules'), '.gitmodules', host)
115
76
  if (text === null) return []
@@ -124,20 +85,12 @@ export function readGitmodules(baseDir, host = diskHost) {
124
85
  }
125
86
  }
126
87
 
127
- // The keys a submodule is read for; past `path`, they're dropped in this order to read the rest.
88
+ // Past `path`, they're dropped in this order to read the rest.
128
89
  const SUBMODULE_KEYS = new Set(['path', 'url', 'branch'])
129
90
  const DROPPABLE = ['branch', 'url']
130
91
 
131
- // `.gitmodules` text the library refused as a whole, read as git reads it (readGitConfig) a
132
- // submodule at a time: a key of `submodule.<name>.<key>`, from `[submodule "name"]` or
133
- // `[submodule.name]`, its last `path`, `url` and `branch` (the sections of one name merged), as git
134
- // reads the checkout's .gitmodules -- a value replaces an earlier one, but for a path or url git
135
- // ignores, one starting with `-` -- each submodule then read by the library alone. One that still
136
- // doesn't read loses its branch, then its url; one whose path doesn't read fails closed: its
137
- // directory, when the path names one inside the repository (`./lib/x`, `lib/x/`), is still a
138
- // dependency, just unnamed, and else the submodule is skipped. Every other path given it is a
139
- // dependency too: git reads the first of two where it reads .gitmodules from a commit, so no path a
140
- // submodule is given may name the project's own code. `notes` say what was dropped.
92
+ // Each submodule's last `path`, `url` and `branch` read by the library alone, dropping its branch, then url,
93
+ // until it reads; failing closed: every path given it a dependency, if unnamed.
141
94
  function gitmodulesLeniently(text) {
142
95
  const sections = new Map() // a submodule's name -> Map<key, its entry>
143
96
  const paths = new Map() // a submodule's name -> every `path` given it
@@ -147,8 +100,8 @@ function gitmodulesLeniently(text) {
147
100
  if (!variable?.startsWith('submodule.')) continue
148
101
  const name = variable.slice('submodule.'.length)
149
102
  if (section !== 'submodule') notes.push(`${header}, a section git reads as [submodule "${name}"]; reading it as that`)
150
- const kept = sections.get(name) ?? sections.set(name, new Map()).get(name)
151
- const given = paths.get(name) ?? paths.set(name, []).get(name)
103
+ const kept = nestedMap(sections, name)
104
+ const given = upsert(paths, name, () => [])
152
105
  for (const entry of keys) {
153
106
  if (!SUBMODULE_KEYS.has(entry.key)) continue
154
107
  if (entry.key === 'path') given.push(entry.value)
@@ -198,27 +151,20 @@ function gitmodulesLeniently(text) {
198
151
  return { submodules, notes }
199
152
  }
200
153
 
201
- // A `path`'s value -> the directory it names, normalized, when that lies inside the repository (else
202
- // null): `./lib/x` and `lib/x/` are lib/x.
203
154
  function normalSubmodulePath(value) {
204
155
  if (typeof value !== 'string') return null
205
156
  const path = posix.normalize(value).replace(/\/+$/u, '')
206
157
  return path !== '' && path !== '.' && inRoot(path) ? path : null
207
158
  }
208
159
 
209
- // git's ctype, ASCII alone: only these are space, and a key is letters, digits and `-`, starting with
210
- // a letter.
160
+ // git's ctype, ASCII alone.
211
161
  const GIT_SPACE = new Set([' ', '\t', '\n', '\r'])
212
162
  const isGitAlpha = (char) => /^[A-Za-z]$/u.test(char)
213
163
  const isGitKeyChar = (char) => /^[\dA-Za-z-]$/u.test(char)
214
164
  const GIT_ESCAPES = { __proto__: null, t: '\t', b: '\b', n: '\n', '\\': '\\', '"': '"' }
215
165
 
216
- // `.gitmodules` text as git's config.c reads a config file, to the character, refusing what git
217
- // refuses ("bad config line") and nothing more: its sections in order, each `{ section, subsection,
218
- // header, keys }` -- the name lowercased, the subsection with a backslash's character for it, the
219
- // header as written -- and each key `{ key, value, text }`: its name lowercased, its value (null for
220
- // a key alone) and its text, from the key to the end of its value. Keys before any header are in a
221
- // first section with no name.
166
+ // As git's config.c reads it, refusing what git refuses and nothing more; keys before any header in a first,
167
+ // unnamed section, a key's `text` from the key to its value's end.
222
168
  function readGitConfig(text) {
223
169
  const src = text.startsWith('\uFEFF') ? text.slice(1) : text // a byte-order mark git skips
224
170
  let pos = 0
@@ -242,7 +188,7 @@ function readGitConfig(text) {
242
188
  }
243
189
  const refuse = (what) => new Error(`.gitmodules: ${what} at line ${at}; git refuses such a file`)
244
190
 
245
- // git's get_base_var and get_extended_base_var: `[name]` or `[name "subsection"]`.
191
+ // git's get_base_var and get_extended_base_var.
246
192
  const readHeader = () => {
247
193
  let section = ''
248
194
  for (;;) {
@@ -272,8 +218,7 @@ function readGitConfig(text) {
272
218
  if (next() !== ']') throw refuse('a subsection with no "]" right after it')
273
219
  return subsection
274
220
  }
275
- // git's parse_value: quotes, escapes, a `\` that runs the value on, a comment outside quotes, and
276
- // space outside quotes trimmed at both ends.
221
+ // git's parse_value.
277
222
  const readValue = () => {
278
223
  let value = ''
279
224
  let quoted = false
@@ -310,7 +255,7 @@ function readGitConfig(text) {
310
255
  }
311
256
  }
312
257
  }
313
- // git's get_value: a key, and `=` and its value or nothing.
258
+ // git's get_value.
314
259
  const readKey = (first, start) => {
315
260
  let key = first.toLowerCase()
316
261
  let char = next()
@@ -347,8 +292,6 @@ function readGitConfig(text) {
347
292
  }
348
293
  }
349
294
 
350
- // --- Ownership --------------------------------------------------------------------------------
351
-
352
295
  const readdirOrEmpty = (dir, host) => {
353
296
  try {
354
297
  return host.readdir(dir)
@@ -361,27 +304,8 @@ const NOTHING = { abs: null, escape: null }
361
304
  // A link target's separators, as the OS reads them (a `\\` is part of a name on POSIX).
362
305
  const TARGET_SEPARATORS = sep === '\\' ? /[\\/]/u : /\//u
363
306
 
364
- // Who owns each project-relative path, decided from how it resolves on disk. The dependencies are
365
- // every `node_modules/<pkg>` (`@scope/<pkg>`), each entry of the `dirs` (forge's libs, Soldeer's
366
- // `dependencies/`; a linked entry is the dependency where it points, as a symlinked
367
- // `lib/forge-std`), and the `packages` (git submodules). `assert(path)` throws for a path `of`
368
- // refuses; `of(path)` gives `{ real, outside, dependency, escape }`:
369
- // - `real`: the real path, spelled as the filesystem spells it (project-relative; null when
370
- // nothing is there), `outside` when it's out of the root;
371
- // - `dependency`: the real path lies in a dependency, however the path got there (a project's
372
- // `src/vendor -> ../lib/dep/src` holds the dependency's code);
373
- // - `escape`: `{ link, root, why }` (and `reason`, saying so) when the path may not be read: it
374
- // crosses a symlink that no one trusted placed -- one planted inside the dependency `root` that
375
- // leads out of it to anything but another dependency (`lib/evil/src/Evil.sol -> ../../../.env`),
376
- // or one outside the project (`root` null) that leads back into it (a dependency linked from
377
- // elsewhere: `lib/evil -> ../../shared/evil` holding `Evil.sol -> ../../proj/.env`) -- or
378
- // (`why: 'unresolved'`) the walk below can't vouch for it: it resolves the path link by link, and
379
- // where that doesn't land where the OS's realpath does (a link target it can't read as the OS
380
- // does, one that isn't UTF-8), or the OS can't resolve it at all (a real path past PATH_MAX), the
381
- // path is refused rather than trusted. `real` null with no `escape` means nothing is there. A
382
- // link the project placed (a workspace package in node_modules, a linked `lib/` entry) may lead
383
- // anywhere in the root, and so may one on the path the project was named by (a symlinked
384
- // checkout, macOS's `/tmp`). The project is read through `host`.
307
+ // The dependencies are every `node_modules/<pkg>`, each entry of `dirs` and the `packages`. An `escape` is a link
308
+ // a dependency planted out of itself, one from outside back in, or one the walk can't vouch for.
385
309
  export function solidityOwnership(baseDir, { dirs = [], packages = [], host = diskHost } = {}) {
386
310
  const realBase = realpathIn(host, baseDir)
387
311
  const realOf = (p) => realpathOrNull(p, host)
@@ -392,14 +316,13 @@ export function solidityOwnership(baseDir, { dirs = [], packages = [], host = di
392
316
  const under = (rel, dir) => rel === dir || rel.startsWith(`${dir}/`)
393
317
  const clean = (d) => posix.normalize(toSlashes(d)).replace(/\/+$/u, '')
394
318
 
395
- // Dirs whose entries are dependencies, and dependency dirs themselves; each by its real path too.
319
+ // Dirs whose entries are dependencies, and dependency dirs themselves, each by its real path too.
396
320
  const holders = new Set()
397
321
  const roots = new Set()
398
322
  const addReal = (set, rel) => {
399
323
  const real = realOf(join(baseDir, rel))
400
324
  if (real !== null && inside(toRel(real))) set.add(toRel(real))
401
325
  }
402
- // A dir as the project names it: relative to the root, or (an absolute lib) by its real path.
403
326
  const projectDir = (d) => {
404
327
  if (!isAbsolute(d)) return clean(d)
405
328
  const real = realOf(d)
@@ -417,7 +340,6 @@ export function solidityOwnership(baseDir, { dirs = [], packages = [], host = di
417
340
  }
418
341
  const dependencyDirs = [...holders, ...roots]
419
342
  const inDependency = (rel) => inside(rel) && (hasNodeModulesSegment(rel) || dependencyDirs.some((d) => under(rel, d)))
420
- // The innermost dependency holding `rel`, a real path.
421
343
  const rootOf = (rel) => {
422
344
  if (!inside(rel)) return null
423
345
  const parts = rel.split('/')
@@ -434,10 +356,8 @@ export function solidityOwnership(baseDir, { dirs = [], packages = [], host = di
434
356
  return best
435
357
  }
436
358
 
437
- // Resolve `parts` from the real dir `start` as realpath does, checking each symlink crossed
438
- // (and those its target crosses): `{ abs, escape }`, `abs` null when nothing is there, and
439
- // spelled as given past the last link. A link's dir and target take the filesystem's spelling (a
440
- // case-insensitive one finds `lib` for `LIB`) before their owners are judged.
359
+ // As realpath resolves `parts`, checking each symlink crossed. A link's dir and target take the filesystem's
360
+ // spelling (a case-insensitive one finds `lib` for `LIB`) before their owners are judged.
441
361
  const walk = (start, parts, depth) => {
442
362
  let cur = start
443
363
  for (const part of parts) {
@@ -478,35 +398,27 @@ export function solidityOwnership(baseDir, { dirs = [], packages = [], host = di
478
398
  return { abs: cur, escape: null }
479
399
  }
480
400
 
481
- const owners = new Map()
482
- const of = (rel) => {
483
- let owner = owners.get(rel)
484
- if (owner === undefined) {
485
- // As given, not normalized: the OS resolves a `..` after a link from where the link leads.
486
- const path = rel === '' ? realBase : `${realBase}${sep}${rel}`
487
- let { abs, escape } = walk(realBase, rel.split('/'), 0)
488
- if (escape === null) {
489
- // The OS's answer is the one a read gets: the walk must agree with it, or the path is
490
- // refused, as it is when the OS can't resolve it at all, though a read may still get through.
491
- // (Past its last link the walk's path is spelled as given; with none, it's `path` itself.)
492
- const { real: os, missing } = osRealpath(path, host)
493
- const walked = abs === null ? null : abs === path ? os : realOf(abs)
494
- if (walked !== os || (os === null && !missing)) escape = { link: rel, root: null, why: 'unresolved' }
495
- abs = os
496
- }
497
- const real = abs === null ? null : toRel(abs)
498
- owner = {
499
- real,
500
- outside: real !== null && !inRoot(real),
501
- dependency: real !== null && inDependency(real),
502
- escape,
503
- reason: escape && escapeReason(rel, escape),
504
- }
505
- owners.set(rel, owner)
401
+ const of = memoized((rel) => {
402
+ // As given, not normalized: the OS resolves a `..` after a link from where the link leads.
403
+ const path = rel === '' ? realBase : `${realBase}${sep}${rel}`
404
+ let { abs, escape } = walk(realBase, rel.split('/'), 0)
405
+ if (escape === null) {
406
+ // The OS's answer is the one a read gets: the walk must agree with it, or the path is refused, as it is
407
+ // when the OS can't resolve it at all.
408
+ const { real: os, missing } = osRealpath(path, host)
409
+ const walked = abs === null ? null : abs === path ? os : realOf(abs)
410
+ if (walked !== os || (os === null && !missing)) escape = { link: rel, root: null, why: 'unresolved' }
411
+ abs = os
506
412
  }
507
- return owner
508
- }
509
- // Throws, saying why, for a path `of` refuses; `what` names it (`'entry '`).
413
+ const real = abs === null ? null : toRel(abs)
414
+ return {
415
+ real,
416
+ outside: real !== null && !inRoot(real),
417
+ dependency: real !== null && inDependency(real),
418
+ escape,
419
+ reason: escape && escapeReason(rel, escape),
420
+ }
421
+ })
510
422
  const assert = (rel, what = '') => {
511
423
  const { reason } = of(rel)
512
424
  if (reason) throw new Error(`Refusing ${what}${rel}: ${reason}`)
@@ -514,16 +426,13 @@ export function solidityOwnership(baseDir, { dirs = [], packages = [], host = di
514
426
  return { of, assert }
515
427
  }
516
428
 
517
- // The ownership of the project at `baseDir` given its lib dirs (`soldeer`: forge's `dependencies/`
518
- // holds dependencies too), with its git submodules, which it keeps as `submodules` (readGitmodules),
519
- // read through `host`.
429
+ // `soldeer`: forge's `dependencies/` holds dependencies too.
520
430
  export function projectOwnership(baseDir, libs, { soldeer = false, host = diskHost } = {}) {
521
431
  const submodules = readGitmodules(baseDir, host)
522
432
  const dirs = [...libs, ...(soldeer ? ['dependencies'] : [])]
523
433
  return { ...solidityOwnership(baseDir, { dirs, packages: submodules.map((s) => s.path), host }), submodules }
524
434
  }
525
435
 
526
- // Why a path is refused (see solidityOwnership).
527
436
  function escapeReason(path, { link, root, why }) {
528
437
  if (why === 'unresolved') return `${path} crosses a link stasis can't follow the way the filesystem does`
529
438
  const what = root === null ? 'a link from outside the project root back into it' : `a link out of the dependency ${root}`