@exodus/stasis 1.0.0-beta.13 → 1.0.0-beta.15

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 (46) hide show
  1. package/README.md +5 -1
  2. package/bin/stasis.js +191 -149
  3. package/package.json +31 -7
  4. package/src/audit.js +224 -90
  5. package/src/babel.js +44 -37
  6. package/src/bundle-reader.js +24 -4
  7. package/src/cmd/build.js +218 -8
  8. package/src/cmd/bundle-options.js +31 -25
  9. package/src/cmd/bundle.js +1147 -311
  10. package/src/cmd/github-bundle.js +17 -9
  11. package/src/cmd/output.js +10 -3
  12. package/src/cmd/tokens.js +73 -0
  13. package/src/define.js +5 -0
  14. package/src/diff.js +2 -2
  15. package/src/flow.js +42 -0
  16. package/src/installed-commits.js +4 -2
  17. package/src/loaders/bash.js +2 -27
  18. package/src/loaders/cargo.js +6 -6
  19. package/src/loaders/foundry.js +4 -6
  20. package/src/loaders/paths.js +4 -15
  21. package/src/loaders/php.js +3 -5
  22. package/src/loaders/rust.js +19 -39
  23. package/src/loaders/solidity-ownership.js +4 -15
  24. package/src/loaders/solidity.js +4 -67
  25. package/src/metro-assets.js +65 -0
  26. package/src/metro-resolver.js +76 -123
  27. package/src/parse.js +7 -3
  28. package/src/resolve-fields.js +133 -366
  29. package/src/resolve-node.js +9 -7
  30. package/src/resolve-typescript.js +102 -30
  31. package/src/scan.js +154 -54
  32. package/src/sixel.js +333 -0
  33. package/src/table.js +116 -0
  34. package/src/validate-notes.d.ts +18 -0
  35. package/src/validate-notes.js +66 -0
  36. package/src/validate.d.ts +132 -0
  37. package/src/validate.js +1349 -0
  38. package/src/vfs-bundle/entries.js +5 -2
  39. package/src/vfs-bundle/github.js +68 -19
  40. package/src/vfs-bundle/glob.js +420 -0
  41. package/src/vfs-bundle/lazy.js +128 -0
  42. package/src/vfs-bundle/prisma.js +102 -29
  43. package/src/vfs-bundle/tree.js +238 -75
  44. package/src/vfs-bundle/yarnclean.js +100 -0
  45. package/src/vfs-bundle.js +16 -7
  46. package/src/why.js +9 -7
package/src/vfs-bundle.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { posix } from 'node:path'
2
2
 
3
3
  import { Vfs } from '@preventive/vfs'
4
+ import { installsDevDependencies } from './cmd/bundle.js'
4
5
  import { KINDS, checkAhead, defaultEntries } from './vfs-bundle/entries.js'
5
6
  import { suggestedRepoEntries } from './vfs-bundle/github.js'
6
7
  import { NODE_MODULES_MANAGERS, checkCache, checkTarget, checkVfs, detectPackageManager, loadTree, packageManagerFor, vfsHost } from './vfs-bundle/tree.js'
@@ -16,7 +17,9 @@ import { NODE_MODULES_MANAGERS, checkCache, checkTarget, checkVfs, detectPackage
16
17
  // dependency is GitHub's tarball of its commit, fetched through the `client` buildVfsBundle is given.
17
18
  // buildGitHubBundle builds one from a GitHub repo at a commit, or the one a tag names (the default
18
19
  // branch's head without either), its tree fetched from GitHub and held to its git tree id, cached
19
- // there the same way, and its Soldeer git dependencies through the same client.
20
+ // there the same way, and its Soldeer git dependencies through the same client. A pnpm or npm tree
21
+ // is lazy unless `lazy` is false or stasis.config.json's `lazyDependencies` is: laid out with nothing
22
+ // fetched, and each package fetched once the build reads it (vfs-bundle/lazy.js).
20
23
 
21
24
  export { buildVfsBundle } from './cmd/bundle.js'
22
25
  export { buildGitHubBundle } from './vfs-bundle/github.js'
@@ -31,9 +34,11 @@ export function createVfsHost(vfs) {
31
34
  }
32
35
 
33
36
  // -> { root, vfs, projects, host, stats, installed, packageManager, packageManagerVersion }, as
34
- // 'pnpm', 'yarn1' or 'npm' installs node_modules: the directory in the project's Vfs it installs cwd
35
- // from, which holds the lockfile; the Vfs the tree is laid out into, rooted there; the projects'
36
- // directories from there; the host reading the project through the tree; deptree's counts, and the
37
+ // 'pnpm', 'yarn1' or 'npm' installs node_modules, then cleaned by each .yarnclean in cwd and above
38
+ // it as `yarn autoclean` cleans Yarn's (vfs-bundle/yarnclean.js): the directory in the project's Vfs
39
+ // it installs cwd from, which holds the lockfile; the Vfs the tree is laid out into, rooted there;
40
+ // the projects' directories from there; the host reading the project through the tree; deptree's
41
+ // counts, and the
37
42
  // packages it installs (each by its `path` from there, with the `commit` its version document
38
43
  // names, where it names a full one); and the
39
44
  // package manager reproduced, at `packageManagerVersion` if given, else the one the root
@@ -45,7 +50,9 @@ export function createVfsHost(vfs) {
45
50
  // os, libc defaults to 'unknown'). Without a `packageManager`, it is the one of the three whose
46
51
  // lockfile installs cwd, where only one's does. `cache` is where the packages' tarballs and version
47
52
  // documents are kept, as @preventive/upstream's CacheOptions take it: left out, in setCacheDir's
48
- // cache; a store with `read` and `write`, in place of it; or false, nowhere.
53
+ // cache; a store with `read` and `write`, in place of it; or false, nowhere. Where the
54
+ // stasis.config.json in cwd sets `installDevDependencies` false, what devDependencies alone reach is
55
+ // left out, as buildVfsBundle's tree leaves it out.
49
56
  export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageManagerVersion, os, cpu, libc, cache } = {}) {
50
57
  checkVfs('loadNodeModules', vfs)
51
58
  checkTarget('loadNodeModules', { os, cpu, libc })
@@ -54,7 +61,8 @@ export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageM
54
61
  // A real path, as detection and the layout take it.
55
62
  cwd = project.realpath(posix.resolve('/', cwd))
56
63
  packageManager = packageManagerFor('loadNodeModules', project, cwd, { packageManager, packageManagerVersion, os }, NODE_MODULES_MANAGERS)
57
- return loadTree({ project, packageManager, cwd, packageManagerVersion, os, cpu, libc, cache })
64
+ const installDevDependencies = installsDevDependencies('loadNodeModules', cwd, project)
65
+ return loadTree({ project, packageManager, cwd, packageManagerVersion, os, cpu, libc, cache, installDevDependencies })
58
66
  }
59
67
 
60
68
  // -> the entries buildGitHubBundle takes where none are given, as paths from the project's
@@ -66,7 +74,8 @@ export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageM
66
74
  // for Soldeer, its .sol entry points by name and layout (solidityEntries). The options are checked
67
75
  // as the build checks them, and `os`, the one the build is for, detects the package manager as
68
76
  // there. Of the project held in `vfs`, from `cwd`; or of a GitHub repo, `{ github, sha, tag,
69
- // directory, client }` as buildGitHubBundle takes them, downloaded as it downloads them.
77
+ // directory | path, client }` as buildGitHubBundle takes them, downloaded as it downloads them: of a
78
+ // `path` to a file, that file.
70
79
  export async function suggestedEntries({ vfs, cwd = '/', packageManager, conditions, mainFields, metro, platforms, jsx, typescript, os, ...repo } = {}) {
71
80
  checkTarget('suggestedEntries', { os })
72
81
  const resolution = { conditions, mainFields, metro, platforms, jsx, typescript }
package/src/why.js CHANGED
@@ -138,9 +138,10 @@ function bucketGraphs(edges, fileToDir, dirInfo, fileReasons) {
138
138
  return graphs
139
139
  }
140
140
 
141
- // Invert the reason map to file -> Set(consumer). null when the artifact carries
142
- // no reason map (single-consumer bundle / lockfile) -> chains render bare.
143
- export function invertReason(reason) {
141
+ // Invert the reason map to file -> Set(consumer), each consumer by `name(consumer)` (as it is, by
142
+ // default). null when the artifact carries no reason map (single-consumer bundle / lockfile) ->
143
+ // chains render bare.
144
+ export function invertReason(reason, name = (consumer) => consumer) {
144
145
  if (!reason) return null
145
146
  const byFile = new Map()
146
147
  for (const [consumer, list] of Object.entries(reason)) {
@@ -148,7 +149,7 @@ export function invertReason(reason) {
148
149
  for (const f of list) {
149
150
  let set = byFile.get(f)
150
151
  if (set === undefined) byFile.set(f, (set = new Set()))
151
- set.add(consumer)
152
+ set.add(name(consumer))
152
153
  }
153
154
  }
154
155
  return byFile
@@ -344,8 +345,9 @@ function dropSuffixed(chains) {
344
345
  // `full` (--why-full) -- then every surviving chain is spelled out with no `...`
345
346
  // collapse, in the same shortest-first order. The flags compose: deep + full is
346
347
  // the complete raw listing. Artifacts without a resolution graph (`imports`)
347
- // contribute nothing.
348
- export function collectWhy(files, targetKeys, reasonFilter = null, { deep = false, full = false } = {}) {
348
+ // contribute nothing. Each consumer is `consumerName(consumer)` (as it is, by default),
349
+ // which `reasonFilter` names it by too.
350
+ export function collectWhy(files, targetKeys, reasonFilter = null, { deep = false, full = false, consumerName } = {}) {
349
351
  // key -> reason bucket ('' = unattributed) -> Map(chainKey -> node-name array)
350
352
  const acc = new Map()
351
353
  const truncatedKeys = new Set()
@@ -367,7 +369,7 @@ export function collectWhy(files, targetKeys, reasonFilter = null, { deep = fals
367
369
 
368
370
  const { fileToDir, dirInfo, dirFiles } = moduleIndex(artifact)
369
371
  const edges = fileEdges(imports)
370
- const fileReasons = invertReason(artifact.reason)
372
+ const fileReasons = invertReason(artifact.reason, consumerName)
371
373
  const graphs = bucketGraphs(edges, fileToDir, dirInfo, fileReasons)
372
374
  const dirReasons = dirReasonsIndex(dirFiles, fileReasons)
373
375
  // Terminal packages end a chain regardless of what imports them.