@exodus/stasis 1.0.0-beta.9 → 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 (67) hide show
  1. package/README.md +6 -2
  2. package/bin/stasis.js +222 -334
  3. package/package.json +38 -14
  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 +1664 -1001
  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 +211 -492
  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 +152 -249
  44. package/src/resolve-node.js +29 -45
  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 +240 -282
  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 +50 -46
  57. package/src/vfs-bundle/github.js +114 -94
  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 +418 -277
  63. package/src/vfs-bundle/yarnclean.js +79 -0
  64. package/src/vfs-bundle.js +24 -55
  65. package/src/webpack.js +0 -4
  66. package/src/why.js +79 -231
  67. package/src/installed-commits.js +0 -182
@@ -2,18 +2,14 @@ import { join } from 'node:path'
2
2
 
3
3
  import { isTomlTable, readToml } from '../loaders/toml.js'
4
4
 
5
- // What `soldeer install` (0.12.0) writes beside the dependencies folder after installing it
6
- // (soldeer-core's update_config_libs and edit_remappings with RemappingsAction::Update): the
7
- // remappings.txt it would write is written into the tree, which then serves it in place of the
8
- // project's; a foundry.toml it would edit is refused, as is what this can't tell it would leave as
9
- // it is. `view` is the project's root by paths from `/`, `root` its real path, for messages.
5
+ // What `soldeer install` 0.12.0 writes beside dependencies/: its remappings.txt goes into the tree; a foundry.toml edit is refused.
10
6
 
11
7
  const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*)?(?:\+[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*)?$/u
12
8
  // A requirement Soldeer takes as exact: a bare version (its `^` made `=`), or one written `=`.
13
9
  const EXACT = /^=?\s*(\S+)$/u
14
10
  const withoutBuild = (version) => version.replace(/\+.*$/u, '')
15
11
 
16
- // A file's text as Soldeer reads it (a byte order mark kept), or undefined.
12
+ // A byte order mark kept, as Soldeer reads it.
17
13
  function textOf(view, path) {
18
14
  try {
19
15
  return view.stat(path).type === 'file' ? view.readFile(path).toString('utf8') : undefined
@@ -22,17 +18,13 @@ function textOf(view, path) {
22
18
  }
23
19
  }
24
20
 
25
- // Rust's `Path::components` of a remapping's target, `.` kept only at the start.
21
+ // Rust's `Path::components`, `.` kept only at the start.
26
22
  function components(path) {
27
- const out = path.startsWith('/') ? ['/'] : []
28
- for (const [i, part] of path.split('/').entries()) {
29
- if (part !== '' && (part !== '.' || i === 0)) out.push(part)
30
- }
31
- return out
23
+ const parts = path.split('/').filter((part, i) => part !== '' && (part !== '.' || i === 0))
24
+ return path.startsWith('/') ? ['/', ...parts] : parts
32
25
  }
33
26
 
34
- // Whether the folder `name` of a remapping's target (its dependencies folder and the one in it) is
35
- // `dep`'s, as soldeer's path_matches tells, or null where only Rust's semver could tell.
27
+ // As soldeer's path_matches tells, or null where only Rust's semver could tell.
36
28
  function folderMatches(dep, name) {
37
29
  if (!name.startsWith(`${dep.name}-`)) return false
38
30
  const version = name.slice(dep.name.length + 1)
@@ -43,37 +35,27 @@ function folderMatches(dep, name) {
43
35
  return null
44
36
  }
45
37
 
46
- // The remappings Soldeer's update leaves, of `existing` (`[name, target]` pairs) and the config's
47
- // dependencies, sorted as it sorts them (by their UTF-8 bytes).
48
38
  function updatedRemappings(existing, deps, { regenerate, where }) {
49
- const items = deps.map((dep) => ({ dep, line: `${dep.remapped}=dependencies/${dep.folder}/` }))
50
- let lines
51
- if (regenerate || existing.length === 0) {
52
- lines = items.map(({ line }) => line)
53
- } else {
54
- lines = []
55
- let rest = existing
56
- for (const { dep, line } of items) {
57
- let found = false
58
- rest = rest.filter(([name, target]) => {
59
- const path = components(target).slice(0, 2)
60
- const folder = path.at(-1)
61
- const matches = folder === undefined || ['/', '.', '..'].includes(folder) ? false : folderMatches(dep, folder)
62
- if (matches === null) throw new Error(`${where}: "${name}=${target}" names ${folder}, which \`soldeer install\` may rewrite to dependencies/${dep.folder}`)
63
- if (!matches) return true
64
- lines.push(`${name}=${target.replaceAll(path.join('/').replace(/^\/\//u, '/'), `dependencies/${dep.folder}`)}`)
65
- found = true
66
- return false
67
- })
68
- if (!found) lines.push(line)
69
- }
70
- lines.push(...rest.map(([name, target]) => `${name}=${target}`))
39
+ const lines = []
40
+ let rest = regenerate ? [] : existing
41
+ for (const dep of deps) {
42
+ let found = false
43
+ rest = rest.filter(([name, target]) => {
44
+ const path = components(target).slice(0, 2)
45
+ const folder = path.at(-1)
46
+ const matches = folder === undefined || ['/', '.', '..'].includes(folder) ? false : folderMatches(dep, folder)
47
+ if (matches === null) throw new Error(`${where}: "${name}=${target}" names ${folder}, which \`soldeer install\` may rewrite to dependencies/${dep.folder}`)
48
+ if (!matches) return true
49
+ lines.push(`${name}=${target.replaceAll(path.join('/').replace(/^\/\//u, '/'), `dependencies/${dep.folder}`)}`)
50
+ found = true
51
+ return false
52
+ })
53
+ if (!found) lines.push(`${dep.remapped}=dependencies/${dep.folder}/`)
71
54
  }
55
+ lines.push(...rest.map(([name, target]) => `${name}=${target}`))
72
56
  return lines.toSorted((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b)))
73
57
  }
74
58
 
75
- // `[name, target]` of each remapping in `lines`, as Soldeer reads them: split at the first `=`, any
76
- // line without one passed over.
77
59
  const pairs = (lines) => lines.flatMap((line) => {
78
60
  const at = line.indexOf('=')
79
61
  return at === -1 ? [] : [[line.slice(0, at), line.slice(at + 1)]]
@@ -82,15 +64,12 @@ const pairs = (lines) => lines.flatMap((line) => {
82
64
  export function settleSoldeer(view, vfs, root) {
83
65
  const foundryText = textOf(view, '/foundry.toml')
84
66
  const foundry = foundryText === undefined ? undefined : readToml(foundryText)
85
- const configFile = isTomlTable(foundry?.dependencies) ? 'foundry.toml' : 'soldeer.toml'
86
- const config = configFile === 'foundry.toml' ? foundry : readToml(textOf(view, '/soldeer.toml') ?? '')
67
+ const inFoundry = isTomlTable(foundry?.dependencies)
68
+ const config = inFoundry ? foundry : readToml(textOf(view, '/soldeer.toml') ?? '')
87
69
  const where = (file) => join(root, file)
88
-
89
- if (configFile === 'foundry.toml') {
90
- const libs = foundry.profile?.default?.libs
91
- if (!Array.isArray(libs) || !libs.includes('dependencies')) {
92
- throw new Error(`${where('foundry.toml')}: [profile.default] libs holds no "dependencies", which \`soldeer install\` adds`)
93
- }
70
+ const libs = foundry?.profile?.default?.libs
71
+ if (inFoundry && !(Array.isArray(libs) && libs.includes('dependencies'))) {
72
+ throw new Error(`${where('foundry.toml')}: [profile.default] libs holds no "dependencies", which \`soldeer install\` adds`)
94
73
  }
95
74
 
96
75
  const settings = { remappings_generate: true, remappings_regenerate: false, remappings_version: true, remappings_prefix: '', remappings_location: 'txt', ...config.soldeer }
@@ -104,7 +83,7 @@ export function settleSoldeer(view, vfs, root) {
104
83
  })
105
84
 
106
85
  const remappingsTxt = textOf(view, '/remappings.txt')
107
- if (configFile === 'foundry.toml' && settings.remappings_location === 'config') {
86
+ if (inFoundry && settings.remappings_location === 'config') {
108
87
  if (remappingsTxt !== undefined) throw new Error(`${where('remappings.txt')}: \`soldeer install\` removes it, as remappings_location is "config"`)
109
88
  for (const [name, profile] of Object.entries(isTomlTable(foundry.profile) ? foundry.profile : {})) {
110
89
  const current = Array.isArray(profile?.remappings) ? profile.remappings : undefined