@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
|
@@ -2,24 +2,14 @@ import { posix } from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import { loadMinimatch } from './glob.js'
|
|
4
4
|
|
|
5
|
-
// Yarn 1's .yarnclean
|
|
6
|
-
//
|
|
7
|
-
// keep, `#` a comment. Here every .yarnclean in the directory installed or above it cleans the tree
|
|
8
|
-
// a package manager lays out, whichever it is, as Yarn 1.22.22's autoclean cleans its own
|
|
9
|
-
// (sortFilter and matchesFilter, src/util/filter.js), on minimatch with the options Yarn gives
|
|
10
|
-
// micromatch. A path is matched from the node_modules directory holding its package, as Yarn's
|
|
11
|
-
// hoisted layout has it (pnpm's .pnpm/x@1/node_modules/x/README.md as x/README.md), and none of the
|
|
12
|
-
// package manager's own (.bin, .pnpm, .modules.yaml) is.
|
|
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).
|
|
13
7
|
|
|
14
8
|
export const YARNCLEAN = '.yarnclean'
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
const patternLines = (lines) => lines.filter((line) => !(line === '' || line === '!' || line[0] === '#' || /^\s+$/u.test(line)))
|
|
10
|
+
const patternLines = (lines) => lines.filter((line) => !(line === '!' || line[0] === '#' || /^\s*$/u.test(line)))
|
|
18
11
|
|
|
19
|
-
//
|
|
20
|
-
// its trimmed spelling as micromatch's makeRe makes one for Yarn, dotfiles and all, case aside, and
|
|
21
|
-
// `plain`, of the pattern as micromatch's isMatch takes it, by default; never matching where the
|
|
22
|
-
// pattern makes none.
|
|
12
|
+
// `regex` as micromatch's makeRe makes it for Yarn (trimmed, dot, nocase), `plain` as its isMatch does by default.
|
|
23
13
|
const NONE = /(?!)/u
|
|
24
14
|
function filterOf(line, { makeRe }) {
|
|
25
15
|
const negation = line[0] === '!'
|
|
@@ -27,23 +17,16 @@ function filterOf(line, { makeRe }) {
|
|
|
27
17
|
return { negation, regex: makeRe(pattern.trim(), { dot: true, nocase: true }) || NONE, plain: makeRe(pattern) || NONE }
|
|
28
18
|
}
|
|
29
19
|
|
|
30
|
-
// matchesFilter: a path from the node_modules directory holding its package, by its whole spelling,
|
|
31
|
-
// from `/`, or by its name.
|
|
32
20
|
const matches = ({ regex, plain }, loc) => regex.test(loc) || regex.test(`/${loc}`) || regex.test(posix.basename(loc)) || plain.test(loc)
|
|
33
21
|
|
|
34
|
-
//
|
|
35
|
-
// null for the package manager's own: a dot-named entry of one, or that directory itself.
|
|
22
|
+
// Null for a node_modules itself or a dot-named entry of one: the package manager's own.
|
|
36
23
|
function packagePath(dir, path) {
|
|
37
24
|
const segments = path.slice(dir.length + 1).split('/')
|
|
38
25
|
const tail = segments.slice(segments.lastIndexOf('node_modules') + 1)
|
|
39
26
|
return tail.length === 0 || tail[0].startsWith('.') ? null : tail.join('/')
|
|
40
27
|
}
|
|
41
28
|
|
|
42
|
-
//
|
|
43
|
-
// cleaning the node_modules directory at a path of a Vfs as sortFilter cleans one, or null where
|
|
44
|
-
// none holds a pattern; its `keeps`, whether a `!` pattern keeps paths, which turns what is cleaned
|
|
45
|
-
// of one package on what the others hold. minimatch is loaded here, where one does: before anything
|
|
46
|
-
// is installed.
|
|
29
|
+
// Its `keeps`: whether a `!` pattern keeps paths, so that what is cleaned of one package turns on what the others hold.
|
|
47
30
|
export function yarnclean(host, cwd) {
|
|
48
31
|
const lines = []
|
|
49
32
|
for (let dir = cwd; ; dir = posix.dirname(dir)) {
|
|
@@ -67,21 +50,17 @@ export function yarnclean(host, cwd) {
|
|
|
67
50
|
for (let up = posix.dirname(path); up !== dir; up = posix.dirname(up)) holdingKept.add(up)
|
|
68
51
|
}
|
|
69
52
|
for (const { path, loc } of negations.length === 0 ? [] : entries) if (negations.some((filter) => matches(filter, loc))) keep(path)
|
|
70
|
-
// So is a link to
|
|
71
|
-
// links each package (under its scope's directory) into its store, where Yarn's hoisted layout
|
|
72
|
-
// holds the package itself.
|
|
53
|
+
// So is a link to either: pnpm links each package into its store, where Yarn's hoisted layout holds the package.
|
|
73
54
|
const leadsToKept = (path) => {
|
|
74
|
-
let real
|
|
75
55
|
try {
|
|
76
|
-
real = vfs.realpath(path)
|
|
56
|
+
const real = vfs.realpath(path)
|
|
57
|
+
return kept.has(real) || holdingKept.has(real)
|
|
77
58
|
} catch {
|
|
78
59
|
return false // a link to nothing, or a loop
|
|
79
60
|
}
|
|
80
|
-
return kept.has(real) || holdingKept.has(real)
|
|
81
61
|
}
|
|
82
62
|
for (const { path, type } of kept.size === 0 ? [] : entries) if (type === 'symlink' && leadsToKept(path)) keep(path)
|
|
83
|
-
// Any other a filter matches goes,
|
|
84
|
-
// it, but a directory holding a kept path: it stays with that, and what else is below it goes.
|
|
63
|
+
// Any other a filter matches goes, with everything below it, but a directory holding a kept path stays with that.
|
|
85
64
|
const matched = new Set()
|
|
86
65
|
const matchedAbove = (path) => {
|
|
87
66
|
for (let up = posix.dirname(path); up !== dir; up = posix.dirname(up)) if (matched.has(up)) return true
|
package/src/vfs-bundle.js
CHANGED
|
@@ -1,90 +1,49 @@
|
|
|
1
1
|
import { posix } from 'node:path'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { KINDS, checkAhead, defaultEntries } from './vfs-bundle/entries.js'
|
|
3
|
+
import { configuredLockfiles, installsDevDependencies } from './cmd/bundle.js'
|
|
4
|
+
import { checkAhead, defaultEntries } from './vfs-bundle/entries.js'
|
|
6
5
|
import { suggestedRepoEntries } from './vfs-bundle/github.js'
|
|
7
|
-
import { NODE_MODULES_MANAGERS, checkCache, 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'
|
|
8
7
|
|
|
9
|
-
//
|
|
10
|
-
// dependencies its package manager would install (`packageManager`: 'pnpm', pnpm 9, 10, 11 or 12;
|
|
11
|
-
// 'yarn1', yarn 1.22; 'npm', npm 10.9 or 11; or 'soldeer', Soldeer 0.12; without one, the one whose
|
|
12
|
-
// lockfile installs the project, where only one's does), over the project held in a Vfs, which is
|
|
13
|
-
// only read. The tree is laid out by @preventive/deptree into a Vfs of its own, and nothing is read
|
|
14
|
-
// from disk or written there but the tarballs and zips: fetched from registry.npmjs.org and
|
|
15
|
-
// Soldeer's registry, or read from npm's cache or ~/.audit's where one holds them, every copy held
|
|
16
|
-
// to the lockfile's integrity before it is used; cached only where setCacheDir says. A Soldeer git
|
|
17
|
-
// dependency is GitHub's tarball of its commit, fetched through the `client` buildVfsBundle is given.
|
|
18
|
-
// buildGitHubBundle builds one from a GitHub repo at a commit, or the one a tag names (the default
|
|
19
|
-
// branch's head without either), its tree fetched from GitHub and held to its git tree id, cached
|
|
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).
|
|
8
|
+
// Nothing touches disk but the tarballs and zips, each held to the lockfile's integrity, cached where setCacheDir says.
|
|
23
9
|
|
|
24
10
|
export { buildVfsBundle } from './cmd/bundle.js'
|
|
25
11
|
export { buildGitHubBundle } from './vfs-bundle/github.js'
|
|
26
12
|
export { setCacheDir } from '@preventive/deptree/pnpm.js'
|
|
27
|
-
export { Vfs }
|
|
13
|
+
export { Vfs } from '@preventive/vfs'
|
|
28
14
|
|
|
29
|
-
//
|
|
30
|
-
// at each call.
|
|
15
|
+
// Reading `vfs` as it is at each call.
|
|
31
16
|
export function createVfsHost(vfs) {
|
|
32
17
|
checkVfs('createVfsHost', vfs)
|
|
33
18
|
return vfsHost(vfs, { cache: false })
|
|
34
19
|
}
|
|
35
20
|
|
|
36
|
-
//
|
|
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
|
|
42
|
-
// packages it installs (each by its `path` from there, with the `commit` its version document
|
|
43
|
-
// names, where it names a full one); and the
|
|
44
|
-
// package manager reproduced, at `packageManagerVersion` if given, else the one the root
|
|
45
|
-
// package.json's packageManager pins, else pnpm 10.33.4, yarn 1.22.22 or npm 11.21.0 (which nothing
|
|
46
|
-
// pins: npm reads no packageManager). The host caches what it reads, of the project's Vfs too, so
|
|
47
|
-
// neither is to change while it is used.
|
|
48
|
-
// `os`, `cpu` and `libc` ('glibc', 'musl' or 'unknown', pnpm's and npm's, which takes 'unknown' for
|
|
49
|
-
// none) are the machine packages are matched against: this one's but for what is given (for another
|
|
50
|
-
// os, libc defaults to 'unknown'). Without a `packageManager`, it is the one of the three whose
|
|
51
|
-
// lockfile installs cwd, where only one's does. `cache` is where the packages' tarballs and version
|
|
52
|
-
// documents are kept, as @preventive/upstream's CacheOptions take it: left out, in setCacheDir's
|
|
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.
|
|
21
|
+
// The host caches what it reads, so neither Vfs is to change meanwhile.
|
|
56
22
|
export async function loadNodeModules({ vfs, packageManager, cwd = '/', packageManagerVersion, os, cpu, libc, cache } = {}) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
const name = 'loadNodeModules'
|
|
24
|
+
checkVfs(name, vfs)
|
|
25
|
+
checkTarget(name, { os, cpu, libc })
|
|
26
|
+
checkCache(name, cache)
|
|
60
27
|
const project = vfsHost(vfs)
|
|
61
|
-
// A real path, as detection and the layout take it.
|
|
62
28
|
cwd = project.realpath(posix.resolve('/', cwd))
|
|
63
|
-
packageManager = packageManagerFor(
|
|
64
|
-
const installDevDependencies = installsDevDependencies(
|
|
29
|
+
packageManager = packageManagerFor(name, project, cwd, { packageManager, packageManagerVersion, os }, NODE_MODULES_MANAGERS)
|
|
30
|
+
const installDevDependencies = installsDevDependencies(name, cwd, project)
|
|
65
31
|
return loadTree({ project, packageManager, cwd, packageManagerVersion, os, cpu, libc, cache, installDevDependencies })
|
|
66
32
|
}
|
|
67
33
|
|
|
68
|
-
// -> the entries buildGitHubBundle takes where none are given, as paths from the project's
|
|
69
|
-
// directory: those its stasis.config.json's `entries` names, where it has `entries` (none of an
|
|
70
|
-
// empty one), checked with the options as the build checks them; else of the kind its package
|
|
71
|
-
// manager builds: `packageManager` if given, else the one detected as the build detects it. For
|
|
72
|
-
// pnpm and yarn 1, the entry points its package.json names, resolved as the build resolves them
|
|
73
|
-
// with the same `conditions`, `mainFields`, `metro`, `platforms` and `typescript` (packageEntries);
|
|
74
|
-
// for Soldeer, its .sol entry points by name and layout (solidityEntries). The options are checked
|
|
75
|
-
// as the build checks them, and `os`, the one the build is for, detects the package manager as
|
|
76
|
-
// there. Of the project held in `vfs`, from `cwd`; or of a GitHub repo, `{ github, sha, tag,
|
|
77
|
-
// directory | path, client }` as buildGitHubBundle takes them, downloaded as it downloads them: of a
|
|
78
|
-
// `path` to a file, that file.
|
|
79
34
|
export async function suggestedEntries({ vfs, cwd = '/', packageManager, conditions, mainFields, metro, platforms, jsx, typescript, os, ...repo } = {}) {
|
|
80
|
-
|
|
35
|
+
const name = 'suggestedEntries'
|
|
36
|
+
checkTarget(name, { os })
|
|
81
37
|
const resolution = { conditions, mainFields, metro, platforms, jsx, typescript }
|
|
82
|
-
if (vfs === undefined && repo.github === undefined) throw new Error(
|
|
83
|
-
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`)
|
|
84
40
|
if (vfs === undefined) return suggestedRepoEntries({ ...repo, packageManager }, { ...resolution, os })
|
|
85
|
-
checkVfs(
|
|
41
|
+
checkVfs(name, vfs)
|
|
86
42
|
const host = vfsHost(vfs)
|
|
87
43
|
const at = posix.resolve('/', cwd)
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
90
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'
|