@exodus/stasis 1.0.0-beta.9 → 1.0.0-rc.1
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 +6 -2
- package/bin/stasis.js +222 -334
- package/package.json +38 -14
- 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 +1664 -1001
- package/src/cmd/diff.js +1 -4
- package/src/cmd/github-bundle.js +48 -21
- package/src/cmd/output.js +25 -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 +211 -492
- 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 +152 -249
- package/src/resolve-node.js +29 -45
- 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 +240 -282
- 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 +50 -46
- package/src/vfs-bundle/github.js +114 -94
- 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 +418 -277
- package/src/vfs-bundle/yarnclean.js +79 -0
- package/src/vfs-bundle.js +24 -55
- package/src/webpack.js +0 -4
- package/src/why.js +79 -231
- package/src/installed-commits.js +0 -182
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Types of `@exodus/stasis/validate` (validate.js).
|
|
2
|
+
import type { Client, RepoDirEntry } from '@preventive/upstream/github.js'
|
|
3
|
+
|
|
4
|
+
export { HttpError } from '@preventive/upstream/npm.js'
|
|
5
|
+
|
|
6
|
+
export const MAX_TOLD: number
|
|
7
|
+
export const FETCHED: ReadonlySet<string>
|
|
8
|
+
|
|
9
|
+
export class PatchError extends Error {
|
|
10
|
+
constructor(code: string)
|
|
11
|
+
code: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ValidateErrorCode = 'no-repository' | 'no-commit' | 'commit-not-in-history' | 'history-unread'
|
|
15
|
+
| 'no-lockfile' | 'lockfile-ambiguous' | 'lockfile-unsupported' | 'lockfile-unreadable'
|
|
16
|
+
export class ValidateError extends Error {
|
|
17
|
+
constructor(code: ValidateErrorCode, message: string)
|
|
18
|
+
code: ValidateErrorCode
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// What validation checks of a bundle, or a stasis.lock.json (validationPlan): a file's bytes, or their integrity.
|
|
22
|
+
export type PlanFile = { path: string; dir: string; rel: string; format?: string } & ({ bytes(): Uint8Array } | { integrity: string })
|
|
23
|
+
export interface PlanPackage { ecosystem: string; name: string; version: string; files: PlanFile[]; recorded: Map<string, string>; integrities: Map<string, string>; repos: Map<string, { github: string; directory?: string; commit?: string }> }
|
|
24
|
+
export interface ValidationPlan { files: number; own: PlanFile[]; packages: PlanPackage[]; patches: Map<string, string> }
|
|
25
|
+
// A parsed bundle (Bundle.parse's, or parseFileWithKind's artifact).
|
|
26
|
+
export interface PlannedBundle {
|
|
27
|
+
modules: Map<string, { name?: string; version?: string; ecosystem?: string; integrity?: string; repo?: { github: string; directory?: string; commit?: string }; patch?: { integrity: string }; files: Record<string, unknown> }>
|
|
28
|
+
formats?: Map<string, string>
|
|
29
|
+
}
|
|
30
|
+
export function validationPlan(bundle: PlannedBundle, options?: { lockfile?: boolean }): ValidationPlan
|
|
31
|
+
|
|
32
|
+
export function gitBlobId(bytes: Uint8Array): string
|
|
33
|
+
export function tarballFiles(tarball: Uint8Array): Promise<Map<string, Uint8Array | { symlink: string }>>
|
|
34
|
+
|
|
35
|
+
// A version's files by their paths; a crate's with its sha256 in hex.
|
|
36
|
+
export type PackageFiles = Map<string, Uint8Array> & { checksum?: string }
|
|
37
|
+
export type Fetch = (ecosystem: string, name: string, version: string, integrity?: string) => Promise<PackageFiles>
|
|
38
|
+
export const fetchPackage: Fetch
|
|
39
|
+
export function fetchFailure(error: unknown): 'not-published' | 'unreadable' | 'integrity-mismatch' | 'failed'
|
|
40
|
+
|
|
41
|
+
export interface PatchFile { path: string; from?: string; deleted?: true; created?: true; hunks: unknown[] }
|
|
42
|
+
export function isPatchOf(text: string, hash: string): boolean
|
|
43
|
+
export function parsePatch(patch: string): PatchFile[]
|
|
44
|
+
export function patchedFiles(files: Map<string, Uint8Array>, patch: PatchFile[]): Map<string, Uint8Array>
|
|
45
|
+
|
|
46
|
+
// A file of the repository: its bytes, git's blob id, a symlink, or in a submodule.
|
|
47
|
+
export type RepositoryEntry = { data: Uint8Array } | { sha: string } | { symlink: string } | { submodule: true }
|
|
48
|
+
export type Ref = { branch: string } | { tag: string }
|
|
49
|
+
interface Where { repository: string; movedFrom?: string; commit: string; ref?: Ref; directory: string }
|
|
50
|
+
// Own code as validateBundle takes it: read, or not and why.
|
|
51
|
+
export type OwnCode = (Where & { entries: Map<string, RepositoryEntry>; cut?: boolean })
|
|
52
|
+
| (Partial<Where> & { reason: string; entries?: Map<string, RepositoryEntry> })
|
|
53
|
+
|
|
54
|
+
export interface Lock { from: 'registry' | 'git' | 'elsewhere' | 'local'; integrity?: string; conflict?: true; directories?: string[]; at?: GitAt }
|
|
55
|
+
export interface Lockfile {
|
|
56
|
+
path: string
|
|
57
|
+
text: string
|
|
58
|
+
from?: 'repository' | 'local'
|
|
59
|
+
read?: (path: string) => string | Promise<string>
|
|
60
|
+
tree?: (dir: string) => Promise<Map<string, Uint8Array>>
|
|
61
|
+
// A git dependency's files, of the GitHub repository at the commit and path its lockfile locks.
|
|
62
|
+
git?: (at: GitAt) => Promise<Map<string, Uint8Array>>
|
|
63
|
+
patches?: string[]
|
|
64
|
+
root?: string
|
|
65
|
+
at?: string
|
|
66
|
+
}
|
|
67
|
+
export type GitAt = { github: string; commit: string; path: string }
|
|
68
|
+
// A patch pnpm's lockfile names for a version: by its path, or by its hash alone, in a file of one of
|
|
69
|
+
// `names` in a patches directory (locate).
|
|
70
|
+
export type LockedPatch = { hash: string; path: string } | { hash: string; names: string[] }
|
|
71
|
+
export interface Locked {
|
|
72
|
+
lockfiles: string[]
|
|
73
|
+
locks(ecosystem: string): boolean
|
|
74
|
+
lock(ecosystem: string, name: string, version: string): Lock | null | undefined
|
|
75
|
+
of(name: string, version: string): LockedPatch | null | undefined
|
|
76
|
+
locate(patch: { hash: string; names?: string[] }): Promise<{ path: string; text: string } | null>
|
|
77
|
+
installed(dir: string): string | null | undefined
|
|
78
|
+
aliased(as: string, named: string): boolean | undefined
|
|
79
|
+
from?: 'repository' | 'local'
|
|
80
|
+
tree?: (dir: string) => Promise<Map<string, Uint8Array>>
|
|
81
|
+
git?: (at: GitAt) => Promise<Map<string, Uint8Array>>
|
|
82
|
+
read(path: string): Promise<string>
|
|
83
|
+
split(pkg: PlanPackage): { pkg: PlanPackage; locked: Locked }[] | undefined
|
|
84
|
+
}
|
|
85
|
+
export function lockedBy(lockfiles: Lockfile[]): Locked
|
|
86
|
+
|
|
87
|
+
export interface Problem { path: string; kind: 'differs' | 'unexpected' | 'unverified'; of: string; reason?: string }
|
|
88
|
+
// A Prisma Client the repository's schemas generate, as validateBundle's `generated` gives it: its files
|
|
89
|
+
// by their paths from its output `dir`, which is by its path from the bundle's root, as `schema` is.
|
|
90
|
+
export interface PrismaClientOutput { dir: string; files: Map<string, string | Uint8Array>; schema: string; generator: string; prisma: string }
|
|
91
|
+
// A client a report tells files of the bundle generated by: their paths, from the bundle's root.
|
|
92
|
+
export interface GeneratedClient { output: string; schema: string; generator: string; prisma: string; files: string[] }
|
|
93
|
+
export interface PackageReport {
|
|
94
|
+
ecosystem: string
|
|
95
|
+
name: string
|
|
96
|
+
version: string
|
|
97
|
+
files: number
|
|
98
|
+
status: 'valid' | 'invalid' | 'unverified'
|
|
99
|
+
reason?: string
|
|
100
|
+
at?: string
|
|
101
|
+
directory?: string
|
|
102
|
+
patch?: { hash?: string; path?: string; from?: 'repository' | 'local' | 'bundle'; error?: string; verified?: boolean; applied?: boolean; recorded?: true }
|
|
103
|
+
}
|
|
104
|
+
export interface BundleValidation {
|
|
105
|
+
validatedAt: number
|
|
106
|
+
status: 'valid' | 'invalid' | 'incomplete'
|
|
107
|
+
own: (Where & { checked: true; cut?: true }) | { checked: false; reason: string; patches?: number }
|
|
108
|
+
lockfiles: string[] | null
|
|
109
|
+
counts: Record<'files' | 'own' | 'dependencies' | 'matched' | 'eol' | 'generated' | 'differs' | 'unexpected' | 'unverified' | 'skipped' | 'packages' | 'validPackages' | 'lockFailures' | 'misplaced', number>
|
|
110
|
+
problems: Problem[]
|
|
111
|
+
moreProblems: number
|
|
112
|
+
packages: PackageReport[]
|
|
113
|
+
generated: GeneratedClient[]
|
|
114
|
+
// Why no Prisma Client was generated to hold its files the repository doesn't hold to.
|
|
115
|
+
generatedError?: string
|
|
116
|
+
// validateRepository's, `strict` false: why no lockfile was held to.
|
|
117
|
+
lockfileError?: ValidateErrorCode
|
|
118
|
+
// The stasis.lock.json the repository commits beside it, which it is held to, and what it contradicts of it.
|
|
119
|
+
stasisLockfile?: { path: string; error?: string }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function validateBundle(plan: ValidationPlan, own: OwnCode | Promise<OwnCode>,
|
|
123
|
+
options?: {
|
|
124
|
+
fetch?: Fetch; locked?: Locked | null; generated?: () => Promise<PrismaClientOutput[]>; deadline?: number; now?: () => number
|
|
125
|
+
// A submodule's commit as the repository's tree pins one at a directory (null for none), and its repository's files there.
|
|
126
|
+
submodules?: { at(dir: string): Promise<string | null>; read(at: GitAt): Promise<Map<string, Uint8Array>> }
|
|
127
|
+
}): Promise<BundleValidation>
|
|
128
|
+
export function exitCodeOf(report: BundleValidation, options?: { allowUnverified?: boolean }): 0 | 1 | 2
|
|
129
|
+
|
|
130
|
+
type Read = 'getRepoTreeId' | 'getRepoTreeTarball' | 'listRepoDir' | 'getRepoFile' | 'getRepoHead' | 'listRepoTags' | 'listRepoBranches' | 'compareCommits'
|
|
131
|
+
// The reads of upstream's client followingMoves wraps, and getRepo, which it follows a move by.
|
|
132
|
+
type Reads = Pick<Client, Read | 'getRepo'>
|
|
133
|
+
// A repository's reads (followingMoves's), where it has moved too.
|
|
134
|
+
export type Repository = { name(): string } & { [M in Read]: (options: Omit<Parameters<Client[M]>[0], 'repo'>) => ReturnType<Client[M]> }
|
|
135
|
+
export function followingMoves(client: Reads, github: string): Repository
|
|
136
|
+
export function historyOf(repository: Repository, commit: string, options?: { maxCompared?: number; deadline?: number; now?: () => number }): Promise<Ref | null>
|
|
137
|
+
|
|
138
|
+
export function repositoryFiles(repository: Repository, where: { github?: string; commit: string; directory?: string }): Promise<Map<string, RepositoryEntry>>
|
|
139
|
+
export function repositoryLockfiles(options: { directory?: string; ecosystems: Set<string>; list: (dir: string) => Promise<string[]>; read: (path: string) => Promise<string> })
|
|
140
|
+
: Promise<{ path: string; text: string }[]>
|
|
141
|
+
export function configuredLockfiles(options: { directory?: string; list: (dir: string) => Promise<string[]>; read: (path: string) => Promise<string> }): Promise<string[] | undefined>
|
|
142
|
+
export function lockedNpmPackages(dir: string): Promise<{ path: string; name: string; packages: { name: string; version: string }[] }[]>
|
|
143
|
+
|
|
144
|
+
interface Options { own?: boolean; fetch?: Fetch; deadline?: number }
|
|
145
|
+
export function validateRepository(plan: ValidationPlan, where: { repository?: Repository | null; commit?: string; directory?: string }, options?: Options & {
|
|
146
|
+
lockfile?: boolean | Lockfile[]
|
|
147
|
+
// A listing of the commit's tree, as upstream's listRepoTree gives it, for these paths.
|
|
148
|
+
listTree?: (paths: string[]) => Promise<{ entries: RepoDirEntry[]; cut?: boolean }>
|
|
149
|
+
strict?: boolean
|
|
150
|
+
generated?: () => Promise<PrismaClientOutput[]>
|
|
151
|
+
// The lockfile of what is validated, held to the stasis.lock.json the repository commits.
|
|
152
|
+
attested?: () => import('@exodus/stasis-core/lockfile').Lockfile
|
|
153
|
+
// What reads a git dependency's repository (followingMoves wraps it).
|
|
154
|
+
client?: Reads
|
|
155
|
+
}): Promise<BundleValidation>
|
|
156
|
+
export function validate(file: string, options?: Options & { client?: Reads; github?: string; sha?: string; directory?: string; lockfile?: boolean | string[] }): Promise<BundleValidation>
|
|
157
|
+
|
|
158
|
+
type Stream = { write(chunk: string): unknown }
|
|
159
|
+
export function printValidationReport(report: BundleValidation, options?: { out?: Stream; err?: Stream; showValid?: boolean; colors?: boolean }): void
|