@exodus/stasis 1.0.0-beta.15 → 1.0.0-beta.16
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/README.md +1 -1
- package/bin/stasis.js +19 -6
- package/package.json +10 -9
- package/src/audit-corrections.js +11 -42
- package/src/audit.js +113 -233
- package/src/babel.js +39 -122
- package/src/bundle-from-lockfile.js +9 -21
- package/src/bundle-reader.js +5 -9
- package/src/bundle.js +0 -3
- package/src/cmd/build.js +50 -166
- package/src/cmd/bundle-options.js +110 -167
- package/src/cmd/bundle.js +853 -1344
- package/src/cmd/diff.js +1 -4
- package/src/cmd/github-bundle.js +18 -22
- package/src/cmd/output.js +15 -12
- package/src/cmd/sbom.js +3 -8
- package/src/cmd/tokens.js +10 -23
- package/src/define.js +34 -97
- package/src/diff.js +72 -128
- package/src/esbuild.js +0 -4
- package/src/flow.js +10 -25
- package/src/installed.js +265 -0
- package/src/json-stream.js +4 -9
- package/src/loader-mock.js +3 -8
- package/src/loader.js +1 -5
- package/src/loaders/bash.js +41 -93
- package/src/loaders/cargo.js +298 -805
- package/src/loaders/foundry.js +109 -285
- package/src/loaders/paths.js +13 -13
- package/src/loaders/php.js +210 -489
- package/src/loaders/rust.js +507 -1430
- package/src/loaders/solidity-ownership.js +48 -128
- package/src/loaders/solidity.js +39 -122
- package/src/loaders/toml.js +7 -17
- package/src/lockfile.js +0 -3
- package/src/metro-assets.js +9 -33
- package/src/metro-resolver.js +20 -47
- package/src/metro-transformer.js +0 -5
- package/src/metro.js +0 -4
- package/src/mock.js +32 -80
- package/src/parse.js +2 -5
- package/src/prune.js +0 -3
- package/src/resolve-fields.js +90 -220
- package/src/resolve-node.js +27 -45
- package/src/resolve-typescript.js +109 -313
- package/src/rollup.js +0 -4
- package/src/run-installed.js +10 -0
- package/src/sbom.js +52 -128
- package/src/scan.js +136 -283
- package/src/sixel.js +18 -41
- package/src/table.js +14 -35
- package/src/validate-notes.d.ts +3 -2
- package/src/validate-notes.js +25 -19
- package/src/validate.d.ts +38 -11
- package/src/validate.js +478 -512
- package/src/vfs-bundle/entries.js +40 -57
- package/src/vfs-bundle/github.js +77 -121
- package/src/vfs-bundle/glob.js +4 -45
- package/src/vfs-bundle/lazy.js +27 -56
- package/src/vfs-bundle/prisma.js +167 -110
- package/src/vfs-bundle/soldeer.js +28 -49
- package/src/vfs-bundle/tree.js +295 -318
- package/src/vfs-bundle/yarnclean.js +10 -31
- package/src/vfs-bundle.js +23 -64
- package/src/webpack.js +0 -4
- package/src/why.js +75 -231
- package/src/installed-commits.js +0 -184
package/src/diff.js
CHANGED
|
@@ -1,53 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ATTESTED_METADATA, extSetsEqual, moduleFileKey, REPO_FIELDS, sameGithub, sortPaths, upsert } from '@exodus/stasis-core/util'
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// digest space: a lockfile already holds SRI digests; a bundle holds bytes, re-hashed via the
|
|
6
|
-
// injected `hash` — so a `hash` function is required whenever a bundle is an operand. Per-file
|
|
7
|
-
// encoding (resource:base64 vs text) is read from the bundle's `formats` map.
|
|
3
|
+
// Two parsed artifacts compared by module and file, never reading disk: each file as an SRI digest, a bundle's bytes
|
|
4
|
+
// re-hashed by the injected `hash`.
|
|
8
5
|
|
|
9
6
|
const KINDS = new Set(['lockfile', 'bundle'])
|
|
10
7
|
|
|
11
|
-
//
|
|
12
|
-
// bundle's are re-hashed, with a `resource:base64` file decoded to bytes first (others hash as text).
|
|
8
|
+
// One file's recorded value as an SRI digest: a bundle's re-hashed, a `resource:base64` file decoded first.
|
|
13
9
|
function digestOf(kind, format, value, hash) {
|
|
14
10
|
if (kind === 'lockfile') return value
|
|
15
11
|
if (typeof hash !== 'function') {
|
|
16
12
|
throw new Error('diff: a `hash` function is required to compare a bundle (its bytes are re-hashed into a lockfile-style digest)')
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
return hash(value)
|
|
14
|
+
return hash(format === 'resource:base64' ? Buffer.from(value, 'base64') : value)
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
// An artifact from before the `repo` field records none; `github` compares in any case.
|
|
18
|
+
const reposAgree = (a, b) => a === undefined || b === undefined ||
|
|
19
|
+
Object.keys(REPO_FIELDS).every((key) => (key === 'github' ? sameGithub(a.github, b.github) : a[key] === b[key]))
|
|
23
20
|
|
|
24
|
-
//
|
|
25
|
-
// files: Map<rel, digest> }>. `input` is { artifact, kind }; `hash` re-hashes bundle bytes only.
|
|
21
|
+
// `{ artifact, kind }` as scope + Map<dir, { name, version, ecosystem, repo, integrity, patch, files: Map<rel, digest> }>.
|
|
26
22
|
export function normalizeArtifact(input, { hash } = {}) {
|
|
27
23
|
const { artifact, kind } = input ?? {}
|
|
28
|
-
if (!artifact || !KINDS.has(kind)) {
|
|
29
|
-
throw new Error("diff: each input must be { artifact, kind } with kind 'lockfile' | 'bundle'")
|
|
30
|
-
}
|
|
24
|
+
if (!artifact || !KINDS.has(kind)) throw new Error("diff: each input must be { artifact, kind } with kind 'lockfile' | 'bundle'")
|
|
31
25
|
const formats = artifact.formats ?? new Map()
|
|
32
26
|
const modules = new Map()
|
|
33
|
-
for (const [dir, { name, version, ecosystem, repo, files }] of artifact.modules) {
|
|
34
|
-
const digests = new Map()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
// v0 bundles record no name/version; normalize undefined -> null for a single "unknown" sentinel.
|
|
39
|
-
modules.set(dir, { name: name ?? null, version: version ?? null, ecosystem: ecosystem ?? null, repo, files: digests })
|
|
27
|
+
for (const [dir, { name, version, ecosystem, repo, integrity, patch, files }] of artifact.modules) {
|
|
28
|
+
const digests = new Map(Object.entries(files).map(([rel, value]) => [rel, digestOf(kind, formats.get(moduleFileKey(dir, rel)), value, hash)]))
|
|
29
|
+
// v0 bundles record no name/version: null is the one "unknown".
|
|
30
|
+
modules.set(dir, { name: name ?? null, version: version ?? null, ecosystem: ecosystem ?? null, repo, integrity, patch, files: digests })
|
|
40
31
|
}
|
|
41
|
-
// `executable` decides
|
|
42
|
-
// an artifact produces even when every digest matches -- it has to be part of "did these differ?".
|
|
32
|
+
// `executable` decides what `stasis extract` chmods +x: the tree differs even where every digest matches.
|
|
43
33
|
return { scope: artifact.config?.scope ?? 'full', modules, executable: artifact.executable ?? new Set() }
|
|
44
34
|
}
|
|
45
35
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// reported once as an added/removed module, not per-file). A version/name/repo change is reported
|
|
49
|
-
// only when both sides record a non-null value (an artifact from before `repo` records none). `{ imports: true }` also diffs the resolution graphs
|
|
50
|
-
// (opt-in; verbose). `hash` is required only when a bundle is an operand.
|
|
36
|
+
// `left` the baseline. Files compare only within modules on BOTH sides (a one-sided module is reported once); a
|
|
37
|
+
// name/version/repo change only where both sides record one. `imports: true` also diffs the resolution graphs.
|
|
51
38
|
export function diffArtifacts(left, right, { imports = false, hash } = {}) {
|
|
52
39
|
const L = normalizeArtifact(left, { hash })
|
|
53
40
|
const R = normalizeArtifact(right, { hash })
|
|
@@ -60,37 +47,29 @@ export function diffArtifacts(left, right, { imports = false, hash } = {}) {
|
|
|
60
47
|
const filesDiffering = []
|
|
61
48
|
|
|
62
49
|
const summary = (dir, m) => ({ dir, name: m.name, version: m.version, ecosystem: m.ecosystem, files: m.files.size })
|
|
63
|
-
const
|
|
64
|
-
for (const dir of dirs) {
|
|
50
|
+
for (const dir of new Set([...L.modules.keys(), ...R.modules.keys()])) {
|
|
65
51
|
const l = L.modules.get(dir)
|
|
66
52
|
const r = R.modules.get(dir)
|
|
67
|
-
if (l
|
|
68
|
-
modulesRemoved.push(summary(dir, l))
|
|
69
|
-
continue
|
|
70
|
-
}
|
|
71
|
-
if (!l && r) {
|
|
72
|
-
modulesAdded.push(summary(dir, r))
|
|
53
|
+
if (!l || !r) {
|
|
54
|
+
(l ? modulesRemoved : modulesAdded).push(summary(dir, l ?? r))
|
|
73
55
|
continue
|
|
74
56
|
}
|
|
75
57
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
if (l.name !== null && r.name !== null && l.name !== r.name) {
|
|
81
|
-
change.nameChange = { from: l.name, to: r.name }
|
|
58
|
+
const changes = {}
|
|
59
|
+
for (const field of ['version', 'name']) {
|
|
60
|
+
if (l[field] !== null && r[field] !== null && l[field] !== r[field]) changes[`${field}Change`] = { from: l[field], to: r[field] }
|
|
82
61
|
}
|
|
83
62
|
// A dependency's repo picks the GitHub advisories audit asks, so a change to it is one to review.
|
|
84
|
-
if (!reposAgree(l.repo, r.repo)) {
|
|
85
|
-
|
|
63
|
+
if (!reposAgree(l.repo, r.repo)) changes.repoChange = { from: l.repo, to: r.repo }
|
|
64
|
+
for (const field of ATTESTED_METADATA) {
|
|
65
|
+
if (JSON.stringify(l[field]) !== JSON.stringify(r[field])) changes[`${field}Change`] = { from: l[field], to: r[field] }
|
|
86
66
|
}
|
|
87
|
-
if (
|
|
67
|
+
if (Object.keys(changes).length > 0) modulesChanged.push({ dir, name: r.name ?? l.name, ...changes })
|
|
88
68
|
|
|
89
|
-
const
|
|
90
|
-
for (const rel of rels) {
|
|
69
|
+
for (const rel of new Set([...l.files.keys(), ...r.files.keys()])) {
|
|
91
70
|
const lh = l.files.get(rel)
|
|
92
71
|
const rh = r.files.get(rel)
|
|
93
|
-
const path =
|
|
72
|
+
const path = moduleFileKey(dir, rel)
|
|
94
73
|
if (lh !== undefined && rh === undefined) filesRemoved.push(path)
|
|
95
74
|
else if (lh === undefined && rh !== undefined) filesAdded.push(path)
|
|
96
75
|
else if (lh !== rh) filesDiffering.push(path)
|
|
@@ -98,50 +77,28 @@ export function diffArtifacts(left, right, { imports = false, hash } = {}) {
|
|
|
98
77
|
}
|
|
99
78
|
|
|
100
79
|
const byDir = (a, b) => sortPaths(a.dir, b.dir)
|
|
101
|
-
|
|
102
|
-
modulesRemoved.sort(byDir)
|
|
103
|
-
modulesChanged.sort(byDir)
|
|
104
|
-
filesAdded.sort(sortPaths)
|
|
105
|
-
filesRemoved.sort(sortPaths)
|
|
106
|
-
filesDiffering.sort(sortPaths)
|
|
107
|
-
|
|
108
|
-
// Execute-bit changes, reported for every path either side marks (not just files in shared
|
|
109
|
-
// modules): gaining or losing +x is a real change to the extracted tree, whatever bucket it sits in.
|
|
80
|
+
// Of every path either side marks, not just files in shared modules.
|
|
110
81
|
const onlyIn = (a, b) => [...a.difference(b)].toSorted(sortPaths)
|
|
111
|
-
const executableAdded = onlyIn(R.executable, L.executable)
|
|
112
|
-
const executableRemoved = onlyIn(L.executable, R.executable)
|
|
113
|
-
|
|
114
82
|
const result = {
|
|
115
83
|
scope: { left: L.scope, right: R.scope },
|
|
116
|
-
modules: { added: modulesAdded, removed: modulesRemoved, changed: modulesChanged },
|
|
117
|
-
files: { added: filesAdded, removed: filesRemoved, differing: filesDiffering },
|
|
118
|
-
executable: { added:
|
|
84
|
+
modules: { added: modulesAdded.toSorted(byDir), removed: modulesRemoved.toSorted(byDir), changed: modulesChanged.toSorted(byDir) },
|
|
85
|
+
files: { added: filesAdded.toSorted(sortPaths), removed: filesRemoved.toSorted(sortPaths), differing: filesDiffering.toSorted(sortPaths) },
|
|
86
|
+
executable: { added: onlyIn(R.executable, L.executable), removed: onlyIn(L.executable, R.executable) },
|
|
119
87
|
}
|
|
120
88
|
if (imports) result.imports = diffImports(left, right)
|
|
121
89
|
return result
|
|
122
90
|
}
|
|
123
91
|
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
function attestedImports({ artifact }) {
|
|
127
|
-
return artifact.imports ?? null
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Collapse an imports map (conditions -> parent -> specifier -> target) to (parent, specifier) ->
|
|
131
|
-
// Set<target>, unioning over conditions: a static bundle keys every edge under "*" while a runtime
|
|
132
|
-
// lockfile uses precise sets, so keying on conditions would report identical resolutions as
|
|
133
|
-
// removed+added. Folding conditions away makes them compare equal.
|
|
92
|
+
// (parent, specifier) -> Set<target>, unioned over conditions: a static bundle keys every edge under "*", a runtime
|
|
93
|
+
// lockfile by precise sets, and the two must agree. A `--metro` target may be a { platform: file } map.
|
|
134
94
|
function resolutionsOf(imports) {
|
|
135
95
|
const byPair = new Map()
|
|
136
96
|
for (const [, byParent] of imports) {
|
|
137
97
|
for (const [parent, specifiers] of byParent) {
|
|
138
98
|
for (const [specifier, target] of specifiers) {
|
|
139
99
|
const key = JSON.stringify([parent, specifier])
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// A `--metro` edge target may be a { platform: file } map; fold each platform's file into the set.
|
|
143
|
-
if (target instanceof Map) for (const f of target.values()) entry.targets.add(f)
|
|
144
|
-
else entry.targets.add(target)
|
|
100
|
+
const { targets } = upsert(byPair, key, () => ({ parent, specifier, targets: new Set() }))
|
|
101
|
+
for (const f of target instanceof Map ? target.values() : [target]) targets.add(f)
|
|
145
102
|
}
|
|
146
103
|
}
|
|
147
104
|
}
|
|
@@ -151,15 +108,12 @@ function resolutionsOf(imports) {
|
|
|
151
108
|
const cmpStr = (a, b) => (a < b ? -1 : a > b ? 1 : 0)
|
|
152
109
|
const cmpPair = (a, b) => sortPaths(a.parent, b.parent) || cmpStr(a.specifier, b.specifier)
|
|
153
110
|
const sortedTargets = (set) => [...set].toSorted(sortPaths)
|
|
154
|
-
const sameTargets = (a, b) => a.size === b.size && a.isSubsetOf(b)
|
|
155
111
|
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const li = attestedImports(left)
|
|
162
|
-
const ri = attestedImports(right)
|
|
112
|
+
// Changed catches a redirect a byte diff can't see. A side attesting no imports (a lockfile predating attestation)
|
|
113
|
+
// skips the diff, `attested` saying which, rather than reporting the other whole graph as added/removed.
|
|
114
|
+
export function diffImports({ artifact: left }, { artifact: right }) {
|
|
115
|
+
const li = left.imports ?? null
|
|
116
|
+
const ri = right.imports ?? null
|
|
163
117
|
const attested = { left: li !== null, right: ri !== null }
|
|
164
118
|
if (li === null || ri === null) return { attested, added: [], removed: [], changed: [] }
|
|
165
119
|
|
|
@@ -173,22 +127,17 @@ export function diffImports(left, right) {
|
|
|
173
127
|
const r = R.get(key)
|
|
174
128
|
if (l && !r) removed.push({ parent: l.parent, specifier: l.specifier, from: sortedTargets(l.targets) })
|
|
175
129
|
else if (!l && r) added.push({ parent: r.parent, specifier: r.specifier, to: sortedTargets(r.targets) })
|
|
176
|
-
else if (!
|
|
130
|
+
else if (!extSetsEqual(l.targets, r.targets)) {
|
|
177
131
|
changed.push({ parent: l.parent, specifier: l.specifier, from: sortedTargets(l.targets), to: sortedTargets(r.targets) })
|
|
178
132
|
}
|
|
179
133
|
}
|
|
180
|
-
added.sort(cmpPair)
|
|
181
|
-
removed.sort(cmpPair)
|
|
182
|
-
changed.sort(cmpPair)
|
|
134
|
+
for (const list of [added, removed, changed]) list.sort(cmpPair)
|
|
183
135
|
return { attested, added, removed, changed }
|
|
184
136
|
}
|
|
185
137
|
|
|
186
|
-
//
|
|
187
|
-
//
|
|
138
|
+
// Scope alone doesn't count. Only the opt-in `imports` is guarded: a guard on the others would make a renamed facet
|
|
139
|
+
// read as "no differences" and quietly pass a review gate.
|
|
188
140
|
export function hasDifferences(diff) {
|
|
189
|
-
// `executable` is unguarded like modules/files -- diffArtifacts always sets it, and a shape guard
|
|
190
|
-
// here would make a renamed facet read as "no differences" and quietly pass a review gate.
|
|
191
|
-
// `imports` is genuinely opt-in (the `imports` option), so it keeps its guard.
|
|
192
141
|
const { modules, files, executable, imports } = diff
|
|
193
142
|
let n =
|
|
194
143
|
modules.added.length + modules.removed.length + modules.changed.length +
|
|
@@ -198,7 +147,6 @@ export function hasDifferences(diff) {
|
|
|
198
147
|
return n > 0
|
|
199
148
|
}
|
|
200
149
|
|
|
201
|
-
const KIND_LABEL = { lockfile: 'lockfile', bundle: 'bundle' }
|
|
202
150
|
const plural = (n) => (n === 1 ? '' : 's')
|
|
203
151
|
const ident = ({ name, version }) => (name ? (version ? `${name}@${version}` : name) : '')
|
|
204
152
|
|
|
@@ -210,11 +158,13 @@ const CHANGED = '*'
|
|
|
210
158
|
// `owner/name`, its commit and directory where recorded: `owner/name@0123abc (packages/x)`.
|
|
211
159
|
const repoLabel = ({ github, commit, directory }) => `${github ?? '?'}${commit ? `@${commit.slice(0, 7)}` : ''}${directory ? ` (${directory})` : ''}`
|
|
212
160
|
|
|
213
|
-
function describeModuleChange({ name, versionChange, nameChange, repoChange }) {
|
|
161
|
+
function describeModuleChange({ name, versionChange, nameChange, repoChange, integrityChange, patchChange }) {
|
|
214
162
|
const segs = []
|
|
215
163
|
if (versionChange) segs.push(`${versionChange.from} -> ${versionChange.to}`)
|
|
216
164
|
if (nameChange) segs.push(`name ${nameChange.from} -> ${nameChange.to}`)
|
|
217
165
|
if (repoChange) segs.push(`repo ${repoLabel(repoChange.from)} -> ${repoLabel(repoChange.to)}`)
|
|
166
|
+
if (integrityChange) segs.push(`integrity ${integrityChange.from ?? 'none'} -> ${integrityChange.to ?? 'none'}`)
|
|
167
|
+
if (patchChange) segs.push(`patch ${patchChange.from?.integrity ?? 'none'} -> ${patchChange.to?.integrity ?? 'none'}`)
|
|
218
168
|
return `${name ? `${name} ` : ''}${segs.join(', ')}`
|
|
219
169
|
}
|
|
220
170
|
|
|
@@ -223,44 +173,39 @@ const moduleLine = (mark, x) => {
|
|
|
223
173
|
return ` ${mark} ${x.dir}${id ? ` ${id}` : ''} (${x.files} file${plural(x.files)})`
|
|
224
174
|
}
|
|
225
175
|
|
|
226
|
-
// `parent 'specifier'` — an edge is identified by importer + specifier (conditions folded away).
|
|
227
176
|
const edgeLabel = (e) => `${e.parent} '${e.specifier}'`
|
|
228
|
-
const targetList = (files) => files.join(', ')
|
|
229
177
|
|
|
230
|
-
//
|
|
231
|
-
// when present); reports what changed, not the text. `labels` is { left, right, leftKind, rightKind }.
|
|
232
|
-
// Returns a string ending in a newline.
|
|
178
|
+
// The `--stat` summary: what changed, not the text.
|
|
233
179
|
export function formatDiffStat(diff, { left = '(left)', right = '(right)', leftKind, rightKind } = {}) {
|
|
234
180
|
const { modules: m, files: f, executable: ex, imports: im, scope } = diff
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
181
|
+
const label = (kind) => (kind ? `${kind}, ` : '')
|
|
182
|
+
const lines = [
|
|
183
|
+
'stasis diff --stat',
|
|
184
|
+
` ${REMOVED} ${left} (${label(leftKind)}scope=${scope.left})`,
|
|
185
|
+
` ${ADDED} ${right} (${label(rightKind)}scope=${scope.right})`,
|
|
186
|
+
]
|
|
187
|
+
const paths = (mark, list) => {
|
|
188
|
+
for (const p of list) lines.push(` ${mark} ${p}`)
|
|
189
|
+
}
|
|
239
190
|
if (scope.left !== scope.right) {
|
|
240
191
|
lines.push(` note: scopes differ (${scope.left} vs ${scope.right}); files only the full-scope artifact records show as removed/added`)
|
|
241
192
|
}
|
|
242
193
|
|
|
243
|
-
lines.push('')
|
|
244
|
-
lines.push(`Modules: ${m.added.length} added, ${m.removed.length} removed, ${m.changed.length} changed`)
|
|
194
|
+
lines.push('', `Modules: ${m.added.length} added, ${m.removed.length} removed, ${m.changed.length} changed`)
|
|
245
195
|
for (const x of m.removed) lines.push(moduleLine(REMOVED, x))
|
|
246
196
|
for (const x of m.added) lines.push(moduleLine(ADDED, x))
|
|
247
197
|
for (const x of m.changed) lines.push(` ${CHANGED} ${x.dir} ${describeModuleChange(x)}`)
|
|
248
198
|
|
|
249
|
-
lines.push('')
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
for (const p of f.removed) lines.push(` ${REMOVED} ${p}`)
|
|
254
|
-
for (const p of f.added) lines.push(` ${ADDED} ${p}`)
|
|
255
|
-
for (const p of f.differing) lines.push(` ${CHANGED} ${p}`)
|
|
199
|
+
lines.push('', `Files (within shared modules): ${f.added.length} added, ${f.removed.length} removed, ${f.differing.length} differing`)
|
|
200
|
+
paths(REMOVED, f.removed)
|
|
201
|
+
paths(ADDED, f.added)
|
|
202
|
+
paths(CHANGED, f.differing)
|
|
256
203
|
|
|
257
|
-
//
|
|
258
|
-
// and a permanent "0 added, 0 removed" line would be noise in every diff.
|
|
204
|
+
// A permanent "0 added, 0 removed" line would be noise in every diff.
|
|
259
205
|
if (ex.added.length > 0 || ex.removed.length > 0) {
|
|
260
|
-
lines.push('')
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
for (const p of ex.added) lines.push(` ${ADDED} ${p}`)
|
|
206
|
+
lines.push('', `Executable: ${ex.added.length} added, ${ex.removed.length} removed`)
|
|
207
|
+
paths(REMOVED, ex.removed)
|
|
208
|
+
paths(ADDED, ex.added)
|
|
264
209
|
}
|
|
265
210
|
|
|
266
211
|
if (im) {
|
|
@@ -272,13 +217,12 @@ export function formatDiffStat(diff, { left = '(left)', right = '(right)', leftK
|
|
|
272
217
|
lines.push(`Imports: ${which} resolutions; skipping import diff`)
|
|
273
218
|
} else {
|
|
274
219
|
lines.push(`Imports: ${im.added.length} added, ${im.removed.length} removed, ${im.changed.length} changed`)
|
|
275
|
-
for (const e of im.removed) lines.push(` ${REMOVED} ${edgeLabel(e)} -> ${
|
|
276
|
-
for (const e of im.added) lines.push(` ${ADDED} ${edgeLabel(e)} -> ${
|
|
277
|
-
for (const e of im.changed) lines.push(` ${CHANGED} ${edgeLabel(e)} ${
|
|
220
|
+
for (const e of im.removed) lines.push(` ${REMOVED} ${edgeLabel(e)} -> ${e.from.join(', ')}`)
|
|
221
|
+
for (const e of im.added) lines.push(` ${ADDED} ${edgeLabel(e)} -> ${e.to.join(', ')}`)
|
|
222
|
+
for (const e of im.changed) lines.push(` ${CHANGED} ${edgeLabel(e)} ${e.from.join(', ')} -> ${e.to.join(', ')}`)
|
|
278
223
|
}
|
|
279
224
|
}
|
|
280
225
|
|
|
281
|
-
lines.push('')
|
|
282
|
-
lines.push(hasDifferences(diff) ? 'Artifacts differ' : 'No differences')
|
|
226
|
+
lines.push('', hasDifferences(diff) ? 'Artifacts differ' : 'No differences')
|
|
283
227
|
return lines.join('\n') + '\n'
|
|
284
228
|
}
|
package/src/esbuild.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
// Public-export adapter: backs `@exodus/stasis/esbuild`. The plugin lives in
|
|
2
|
-
// @exodus/stasis-plugins (which depends on @exodus/stasis-core for State /
|
|
3
|
-
// resolvePluginState). Internal code uses `@exodus/stasis-plugins/esbuild` directly;
|
|
4
|
-
// this file exists only to back the package's `exports` map.
|
|
5
1
|
export * from '@exodus/stasis-plugins/esbuild'
|
package/src/flow.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
// --flow
|
|
2
|
-
//
|
|
3
|
-
// whatever else it holds, any other where the parser can't read it as it is. By flow-remove-types --
|
|
4
|
-
// stasis's own dependency, resolved from stasis itself (never from the project) and loaded lazily,
|
|
5
|
-
// only under --flow, which --metro turns on.
|
|
1
|
+
// --flow (which --metro turns on): Flow type syntax stripped as Metro's Babel (@react-native/babel-preset) strips it,
|
|
2
|
+
// by flow-remove-types -- stasis's own dependency, never the project's, loaded lazily.
|
|
6
3
|
import { createRequire } from 'node:module'
|
|
7
4
|
|
|
8
|
-
//
|
|
9
|
-
// corrupt TS-only constructs. .jsx is included (JS + JSX, which can carry Flow types like .js);
|
|
10
|
-
// flow-remove-types preserves JSX.
|
|
5
|
+
// The JS family alone: flow-remove-types would corrupt TS-only constructs. It preserves JSX.
|
|
11
6
|
export const FLOW_EXTS = new Set(['.js', '.cjs', '.mjs', '.jsx'])
|
|
12
7
|
|
|
13
|
-
//
|
|
14
|
-
// Babel preset finds it (/@flow/), to parse the file with hermes-parser, as Flow throughout: --flow
|
|
15
|
-
// strips such a file whether or not it parses as it is.
|
|
8
|
+
// Anywhere in the file, as React Native's Babel preset finds it (/@flow/), to parse the file as Flow throughout.
|
|
16
9
|
export const hasFlowPragma = (source) => source.includes('@flow')
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
// read (`f<T>(x)`, `a < b > (c)`) as JS (hermes-parser's `flow: 'detect'`), and none other; and
|
|
21
|
-
// what it leaves of it, the pragma blanked.
|
|
11
|
+
// In a file marked `@noflow`, flow-remove-types reads syntax both Flow and JS can read (`f<T>(x)`, `a < b > (c)`) as
|
|
12
|
+
// JS (hermes-parser's `flow: 'detect'`). NOFLOW_STRIPPED is what it leaves of the comment.
|
|
22
13
|
const NOFLOW = '\n/* @noflow */'
|
|
23
14
|
const NOFLOW_STRIPPED = `\n/* ${' '.repeat('@noflow'.length)} */`
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
// syntax JS can read too JS's (`a < b > (c)`, comparisons). flow-remove-types reads it so only in a
|
|
30
|
-
// file marked `@noflow`, so one not marked yet is, past its end, and cut off again.
|
|
31
|
-
// Types only: Flow syntax that is code -- `component` and `hook` declarations, `enum`s -- stays. An
|
|
32
|
-
// import listing types alone (`import { type A } from`) stays as `import {} from`, or with
|
|
33
|
-
// `removeEmptyImports` goes whole, as Babel's Flow transform drops it. Throws where flow-remove-types
|
|
34
|
-
// can't parse `source`.
|
|
16
|
+
let flowRemoveTypes
|
|
17
|
+
|
|
18
|
+
// `source` with its Flow types blanked in place (offsets kept): one marked `@flow` as Flow throughout (`f<T>(x)` a
|
|
19
|
+
// call), any other as a `@noflow` file, marked so past its end. Flow code (`enum`s) stays. Throws where it can't parse.
|
|
35
20
|
export function stripFlowTypes(source, { removeEmptyImports = false } = {}) {
|
|
36
21
|
flowRemoveTypes ??= createRequire(import.meta.url)('flow-remove-types')
|
|
37
22
|
if (hasFlowPragma(source)) return flowRemoveTypes(source, { all: true, removeEmptyImports }).toString()
|