@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.
- package/README.md +7 -2
- package/bin/stasis.js +263 -446
- package/package.json +38 -13
- package/src/audit-corrections.js +11 -42
- package/src/audit.js +256 -212
- package/src/babel.js +119 -82
- package/src/bundle-from-lockfile.js +9 -21
- package/src/bundle-reader.js +24 -8
- package/src/bundle.js +0 -3
- package/src/cmd/build.js +211 -117
- package/src/cmd/bundle-options.js +347 -0
- package/src/cmd/bundle.js +1718 -908
- package/src/cmd/diff.js +1 -4
- package/src/cmd/github-bundle.js +48 -21
- package/src/cmd/output.js +24 -12
- package/src/cmd/sbom.js +6 -9
- package/src/cmd/tokens.js +60 -0
- package/src/define.js +218 -0
- package/src/diff.js +73 -129
- package/src/esbuild.js +0 -4
- package/src/flow.js +27 -0
- 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 +43 -120
- package/src/loaders/cargo.js +301 -808
- package/src/loaders/foundry.js +112 -290
- package/src/loaders/paths.js +15 -26
- package/src/loaders/php.js +221 -475
- package/src/loaders/rust.js +518 -1461
- package/src/loaders/solidity-ownership.js +51 -142
- package/src/loaders/solidity.js +42 -188
- package/src/loaders/toml.js +7 -17
- package/src/lockfile.js +0 -3
- package/src/metro-assets.js +41 -0
- package/src/metro-resolver.js +58 -133
- package/src/metro-transformer.js +0 -6
- package/src/metro.js +0 -4
- package/src/mock.js +32 -80
- package/src/parse.js +8 -7
- package/src/prune.js +0 -3
- package/src/resolve-fields.js +170 -235
- package/src/resolve-node.js +33 -46
- package/src/resolve-typescript.js +166 -298
- package/src/rollup.js +0 -4
- package/src/run-installed.js +10 -0
- package/src/sbom.js +70 -97
- package/src/scan.js +241 -278
- package/src/sixel.js +310 -0
- package/src/table.js +95 -0
- package/src/validate-notes.d.ts +19 -0
- package/src/validate-notes.js +72 -0
- package/src/validate.d.ts +159 -0
- package/src/validate.js +1315 -0
- package/src/vfs-bundle/entries.js +54 -46
- package/src/vfs-bundle/github.js +115 -92
- package/src/vfs-bundle/glob.js +379 -0
- package/src/vfs-bundle/lazy.js +99 -0
- package/src/vfs-bundle/prisma.js +235 -105
- package/src/vfs-bundle/soldeer.js +28 -49
- package/src/vfs-bundle/tree.js +434 -259
- package/src/vfs-bundle/yarnclean.js +79 -0
- package/src/vfs-bundle.js +25 -51
- package/src/webpack.js +0 -4
- package/src/why.js +79 -231
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { posix } from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { loadMinimatch } from './glob.js'
|
|
4
|
+
|
|
5
|
+
// Yarn 1.22.22's .yarnclean (autoclean's sortFilter and matchesFilter), on minimatch, for any package manager's tree:
|
|
6
|
+
// each path matched from the node_modules holding its package, as Yarn hoists it (.pnpm/x@1/node_modules/x/a as x/a).
|
|
7
|
+
|
|
8
|
+
export const YARNCLEAN = '.yarnclean'
|
|
9
|
+
|
|
10
|
+
const patternLines = (lines) => lines.filter((line) => !(line === '!' || line[0] === '#' || /^\s*$/u.test(line)))
|
|
11
|
+
|
|
12
|
+
// `regex` as micromatch's makeRe makes it for Yarn (trimmed, dot, nocase), `plain` as its isMatch does by default.
|
|
13
|
+
const NONE = /(?!)/u
|
|
14
|
+
function filterOf(line, { makeRe }) {
|
|
15
|
+
const negation = line[0] === '!'
|
|
16
|
+
const pattern = (negation ? line.slice(1) : line).replace(/\/$/u, '')
|
|
17
|
+
return { negation, regex: makeRe(pattern.trim(), { dot: true, nocase: true }) || NONE, plain: makeRe(pattern) || NONE }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const matches = ({ regex, plain }, loc) => regex.test(loc) || regex.test(`/${loc}`) || regex.test(posix.basename(loc)) || plain.test(loc)
|
|
21
|
+
|
|
22
|
+
// Null for a node_modules itself or a dot-named entry of one: the package manager's own.
|
|
23
|
+
function packagePath(dir, path) {
|
|
24
|
+
const segments = path.slice(dir.length + 1).split('/')
|
|
25
|
+
const tail = segments.slice(segments.lastIndexOf('node_modules') + 1)
|
|
26
|
+
return tail.length === 0 || tail[0].startsWith('.') ? null : tail.join('/')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Its `keeps`: whether a `!` pattern keeps paths, so that what is cleaned of one package turns on what the others hold.
|
|
30
|
+
export function yarnclean(host, cwd) {
|
|
31
|
+
const lines = []
|
|
32
|
+
for (let dir = cwd; ; dir = posix.dirname(dir)) {
|
|
33
|
+
const file = posix.join(dir, YARNCLEAN)
|
|
34
|
+
if (host.stat(file)?.isFile()) lines.push(...patternLines(host.readFile(file).toString('utf8').split('\n')))
|
|
35
|
+
if (dir === '/') break
|
|
36
|
+
}
|
|
37
|
+
if (lines.length === 0) return null
|
|
38
|
+
const minimatch = loadMinimatch(`A ${YARNCLEAN}, which cleans the node_modules a lockfile lays out,`)
|
|
39
|
+
const filters = lines.map((line) => filterOf(line, minimatch))
|
|
40
|
+
const negations = filters.filter((filter) => filter.negation)
|
|
41
|
+
const positives = filters.filter((filter) => !filter.negation)
|
|
42
|
+
return Object.assign((vfs, dir) => {
|
|
43
|
+
if (!vfs.isDirectory(dir)) return
|
|
44
|
+
const entries = [...vfs.walk(dir)].slice(1).map(({ path, type }) => ({ path, type, loc: packagePath(dir, path) })).filter(({ loc }) => loc !== null)
|
|
45
|
+
// A path a `!` filter matches is kept, and so is every directory holding one.
|
|
46
|
+
const kept = new Set()
|
|
47
|
+
const holdingKept = new Set()
|
|
48
|
+
const keep = (path) => {
|
|
49
|
+
kept.add(path)
|
|
50
|
+
for (let up = posix.dirname(path); up !== dir; up = posix.dirname(up)) holdingKept.add(up)
|
|
51
|
+
}
|
|
52
|
+
for (const { path, loc } of negations.length === 0 ? [] : entries) if (negations.some((filter) => matches(filter, loc))) keep(path)
|
|
53
|
+
// So is a link to either: pnpm links each package into its store, where Yarn's hoisted layout holds the package.
|
|
54
|
+
const leadsToKept = (path) => {
|
|
55
|
+
try {
|
|
56
|
+
const real = vfs.realpath(path)
|
|
57
|
+
return kept.has(real) || holdingKept.has(real)
|
|
58
|
+
} catch {
|
|
59
|
+
return false // a link to nothing, or a loop
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const { path, type } of kept.size === 0 ? [] : entries) if (type === 'symlink' && leadsToKept(path)) keep(path)
|
|
63
|
+
// Any other a filter matches goes, with everything below it, but a directory holding a kept path stays with that.
|
|
64
|
+
const matched = new Set()
|
|
65
|
+
const matchedAbove = (path) => {
|
|
66
|
+
for (let up = posix.dirname(path); up !== dir; up = posix.dirname(up)) if (matched.has(up)) return true
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
let gone = null
|
|
70
|
+
for (const { path, loc } of entries) {
|
|
71
|
+
if ((gone !== null && path.startsWith(gone)) || kept.has(path)) continue
|
|
72
|
+
if (positives.some((filter) => matches(filter, loc))) matched.add(path)
|
|
73
|
+
else if (!matchedAbove(path)) continue
|
|
74
|
+
if (holdingKept.has(path)) continue
|
|
75
|
+
vfs.rm(path, { recursive: true })
|
|
76
|
+
gone = `${path}/`
|
|
77
|
+
}
|
|
78
|
+
}, { keeps: negations.length > 0 })
|
|
79
|
+
}
|
package/src/vfs-bundle.js
CHANGED
|
@@ -1,75 +1,49 @@
|
|
|
1
1
|
import { posix } from 'node:path'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { configuredLockfiles, installsDevDependencies } from './cmd/bundle.js'
|
|
4
|
+
import { checkAhead, defaultEntries } from './vfs-bundle/entries.js'
|
|
5
5
|
import { suggestedRepoEntries } from './vfs-bundle/github.js'
|
|
6
|
-
import { NODE_MODULES_MANAGERS, checkTarget, checkVfs, detectPackageManager, loadTree, packageManagerFor, vfsHost } from './vfs-bundle/tree.js'
|
|
6
|
+
import { NODE_MODULES_MANAGERS, checkCache, checkTarget, checkVfs, detectPackageManager, loadTree, lockfilesManagers, packageManagerFor, vfsHost } from './vfs-bundle/tree.js'
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
// dependencies its package manager would install (`packageManager`: 'pnpm', pnpm 9, 10, 11 or 12;
|
|
10
|
-
// 'yarn1', yarn 1.22; 'npm', npm 10.9 or 11; or 'soldeer', Soldeer 0.12; without one, the one whose
|
|
11
|
-
// lockfile installs the project, where only one's does), over the project held in a Vfs, which is
|
|
12
|
-
// only read. The tree is laid out by @preventive/deptree into a Vfs of its own, and nothing is read
|
|
13
|
-
// from disk or written there but the tarballs and zips: fetched from registry.npmjs.org and
|
|
14
|
-
// Soldeer's registry, or read from npm's cache or ~/.audit's where one holds them, every copy held
|
|
15
|
-
// to the lockfile's integrity before it is used; cached only where setCacheDir says. A Soldeer git
|
|
16
|
-
// dependency is GitHub's tarball of its commit, fetched through the `client` buildVfsBundle is given.
|
|
17
|
-
// buildGitHubBundle builds one from a GitHub repo at a commit, or the one a tag names (the default
|
|
18
|
-
// 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.
|
|
8
|
+
// Nothing touches disk but the tarballs and zips, each held to the lockfile's integrity, cached where setCacheDir says.
|
|
20
9
|
|
|
21
10
|
export { buildVfsBundle } from './cmd/bundle.js'
|
|
22
11
|
export { buildGitHubBundle } from './vfs-bundle/github.js'
|
|
23
12
|
export { setCacheDir } from '@preventive/deptree/pnpm.js'
|
|
24
|
-
export { Vfs }
|
|
13
|
+
export { Vfs } from '@preventive/vfs'
|
|
25
14
|
|
|
26
|
-
//
|
|
27
|
-
// at each call.
|
|
15
|
+
// Reading `vfs` as it is at each call.
|
|
28
16
|
export function createVfsHost(vfs) {
|
|
29
17
|
checkVfs('createVfsHost', vfs)
|
|
30
18
|
return vfsHost(vfs, { cache: false })
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// pins: npm reads no packageManager). The host caches what it reads, of the project's Vfs too, so
|
|
40
|
-
// neither is to change while it is used.
|
|
41
|
-
// `os`, `cpu` and `libc` ('glibc', 'musl' or 'unknown', pnpm's and npm's, which takes 'unknown' for
|
|
42
|
-
// none) are the machine packages are matched against: this one's but for what is given (for another
|
|
43
|
-
// os, libc defaults to 'unknown'). Without a `packageManager`, it is the one of the three whose
|
|
44
|
-
// lockfile installs cwd, where only one's does.
|
|
45
|
-
export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageManagerVersion, os, cpu, libc } = {}) {
|
|
46
|
-
checkVfs('loadNodeModules', vfs)
|
|
47
|
-
checkTarget('loadNodeModules', { os, cpu, libc })
|
|
21
|
+
// The host caches what it reads, so neither Vfs is to change meanwhile.
|
|
22
|
+
export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageManagerVersion, os, cpu, libc, cache } = {}) {
|
|
23
|
+
const name = 'loadNodeModules'
|
|
24
|
+
checkVfs(name, vfs)
|
|
25
|
+
checkTarget(name, { os, cpu, libc })
|
|
26
|
+
checkCache(name, cache)
|
|
48
27
|
const project = vfsHost(vfs)
|
|
49
|
-
// A real path, as detection and the layout take it.
|
|
50
28
|
cwd = project.realpath(posix.resolve('/', cwd))
|
|
51
|
-
packageManager = packageManagerFor(
|
|
52
|
-
|
|
29
|
+
packageManager = packageManagerFor(name, project, cwd, { packageManager, packageManagerVersion, os }, NODE_MODULES_MANAGERS)
|
|
30
|
+
const installDevDependencies = installsDevDependencies(name, cwd, project)
|
|
31
|
+
return loadTree({ project, packageManager, cwd, packageManagerVersion, os, cpu, libc, cache, installDevDependencies })
|
|
53
32
|
}
|
|
54
33
|
|
|
55
|
-
// -> the entries buildGitHubBundle takes where none are given, as paths from the project's
|
|
56
|
-
// directory, of the kind its package manager builds: `packageManager` if given, else the one
|
|
57
|
-
// detected as the build detects it. For pnpm and yarn 1, the entry points its package.json names,
|
|
58
|
-
// resolved as the build resolves them with the same `conditions`, `mainFields`, `metro`,
|
|
59
|
-
// `platforms` and `typescript` (packageEntries); for Soldeer, its .sol entry points by name
|
|
60
|
-
// and layout (solidityEntries). The options are checked as the build checks them, and `os`, the
|
|
61
|
-
// one the build is for, detects the package manager as there. Of the project held in `vfs`, from
|
|
62
|
-
// `cwd`; or of a GitHub repo, `{ github, sha, tag, directory, client }` as buildGitHubBundle takes
|
|
63
|
-
// them, downloaded as it downloads them.
|
|
64
34
|
export async function suggestedEntries({ vfs, cwd = '/', packageManager, conditions, mainFields, metro, platforms, jsx, typescript, os, ...repo } = {}) {
|
|
65
|
-
|
|
35
|
+
const name = 'suggestedEntries'
|
|
36
|
+
checkTarget(name, { os })
|
|
66
37
|
const resolution = { conditions, mainFields, metro, platforms, jsx, typescript }
|
|
67
|
-
if (vfs === undefined && repo.github === undefined) throw new Error(
|
|
68
|
-
if (vfs !== undefined && repo.github !== undefined) throw new Error(
|
|
38
|
+
if (vfs === undefined && repo.github === undefined) throw new Error(`${name}: a vfs or a github repo is required`)
|
|
39
|
+
if (vfs !== undefined && repo.github !== undefined) throw new Error(`${name}: takes a vfs or a github repo, not both`)
|
|
69
40
|
if (vfs === undefined) return suggestedRepoEntries({ ...repo, packageManager }, { ...resolution, os })
|
|
70
|
-
checkVfs(
|
|
41
|
+
checkVfs(name, vfs)
|
|
71
42
|
const host = vfsHost(vfs)
|
|
72
43
|
const at = posix.resolve('/', cwd)
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
// As the build lays them out: a tree of each lockfile stasis.config.json names, none detected.
|
|
45
|
+
const lockfiles = packageManager === undefined ? configuredLockfiles(name, at, host) : undefined
|
|
46
|
+
const one = lockfiles === undefined ? packageManager ?? detectPackageManager(name, host, at, { os }) : undefined
|
|
47
|
+
checkAhead(name, one, resolution)
|
|
48
|
+
return defaultEntries(name, host, at, lockfiles === undefined ? [one] : lockfilesManagers(name, lockfiles), resolution).entries
|
|
75
49
|
}
|
package/src/webpack.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
// Public-export adapter: backs `@exodus/stasis/webpack`. The plugin lives in
|
|
2
|
-
// @exodus/stasis-plugins (which depends on @exodus/stasis-core for State /
|
|
3
|
-
// resolvePluginState). Internal code uses `@exodus/stasis-plugins/webpack` directly;
|
|
4
|
-
// this file exists only to back the package's `exports` map.
|
|
5
1
|
export * from '@exodus/stasis-plugins/webpack'
|