@exodus/stasis 1.0.0-beta.13 → 1.0.0-beta.15
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 +5 -1
- package/bin/stasis.js +191 -149
- package/package.json +31 -7
- package/src/audit.js +224 -90
- package/src/babel.js +44 -37
- package/src/bundle-reader.js +24 -4
- package/src/cmd/build.js +218 -8
- package/src/cmd/bundle-options.js +31 -25
- package/src/cmd/bundle.js +1147 -311
- package/src/cmd/github-bundle.js +17 -9
- package/src/cmd/output.js +10 -3
- package/src/cmd/tokens.js +73 -0
- package/src/define.js +5 -0
- package/src/diff.js +2 -2
- package/src/flow.js +42 -0
- package/src/installed-commits.js +4 -2
- package/src/loaders/bash.js +2 -27
- package/src/loaders/cargo.js +6 -6
- package/src/loaders/foundry.js +4 -6
- package/src/loaders/paths.js +4 -15
- package/src/loaders/php.js +3 -5
- package/src/loaders/rust.js +19 -39
- package/src/loaders/solidity-ownership.js +4 -15
- package/src/loaders/solidity.js +4 -67
- package/src/metro-assets.js +65 -0
- package/src/metro-resolver.js +76 -123
- package/src/parse.js +7 -3
- package/src/resolve-fields.js +133 -366
- package/src/resolve-node.js +9 -7
- package/src/resolve-typescript.js +102 -30
- package/src/scan.js +154 -54
- package/src/sixel.js +333 -0
- package/src/table.js +116 -0
- package/src/validate-notes.d.ts +18 -0
- package/src/validate-notes.js +66 -0
- package/src/validate.d.ts +132 -0
- package/src/validate.js +1349 -0
- package/src/vfs-bundle/entries.js +5 -2
- package/src/vfs-bundle/github.js +68 -19
- package/src/vfs-bundle/glob.js +420 -0
- package/src/vfs-bundle/lazy.js +128 -0
- package/src/vfs-bundle/prisma.js +102 -29
- package/src/vfs-bundle/tree.js +238 -75
- package/src/vfs-bundle/yarnclean.js +100 -0
- package/src/vfs-bundle.js +16 -7
- package/src/why.js +9 -7
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Types of `@exodus/stasis/validate` (validate.js), whose comments tell what each does.
|
|
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 = 'not-a-bundle' | '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 (validationPlan).
|
|
22
|
+
export interface PlanFile { path: string; dir: string; rel: string; format?: string; bytes(): Uint8Array }
|
|
23
|
+
export interface PlanPackage { ecosystem: string; name: string; version: string; files: PlanFile[] }
|
|
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; files: Record<string, unknown> }>
|
|
28
|
+
formats?: Map<string, string>
|
|
29
|
+
}
|
|
30
|
+
export function validationPlan(bundle: PlannedBundle): 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[] }
|
|
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
|
+
patches?: string[]
|
|
62
|
+
root?: string
|
|
63
|
+
}
|
|
64
|
+
// A patch pnpm's lockfile names for a version: by its path, or by its hash alone, in a file of one of
|
|
65
|
+
// `names` in a patches directory (locate).
|
|
66
|
+
export type LockedPatch = { hash: string; path: string } | { hash: string; names: string[] }
|
|
67
|
+
export interface Locked {
|
|
68
|
+
lockfiles: string[]
|
|
69
|
+
locks(ecosystem: string): boolean
|
|
70
|
+
lock(ecosystem: string, name: string, version: string): Lock | null | undefined
|
|
71
|
+
of(name: string, version: string): LockedPatch | null | undefined
|
|
72
|
+
locate(patch: { hash: string; names?: string[] }): Promise<{ path: string; text: string } | null>
|
|
73
|
+
installed(dir: string): string | null | undefined
|
|
74
|
+
aliased(as: string, named: string): boolean | undefined
|
|
75
|
+
from?: 'repository' | 'local'
|
|
76
|
+
tree?: (dir: string) => Promise<Map<string, Uint8Array>>
|
|
77
|
+
read(path: string): Promise<string>
|
|
78
|
+
}
|
|
79
|
+
export function lockedBy(lockfiles: Lockfile[]): Locked
|
|
80
|
+
|
|
81
|
+
export interface Problem { path: string; kind: 'differs' | 'unexpected' | 'unverified'; of: string; reason?: string }
|
|
82
|
+
export interface PackageReport {
|
|
83
|
+
ecosystem: string
|
|
84
|
+
name: string
|
|
85
|
+
version: string
|
|
86
|
+
files: number
|
|
87
|
+
status: 'valid' | 'invalid' | 'unverified'
|
|
88
|
+
reason?: string
|
|
89
|
+
at?: string
|
|
90
|
+
directory?: string
|
|
91
|
+
patch?: { hash?: string; path?: string; from?: 'repository' | 'local' | 'bundle'; error?: string; applied?: boolean }
|
|
92
|
+
}
|
|
93
|
+
export interface BundleValidation {
|
|
94
|
+
validatedAt: number
|
|
95
|
+
status: 'valid' | 'invalid' | 'incomplete'
|
|
96
|
+
own: (Where & { checked: true; cut?: true }) | { checked: false; reason: string; patches?: number }
|
|
97
|
+
lockfiles: string[] | null
|
|
98
|
+
counts: Record<'files' | 'own' | 'dependencies' | 'matched' | 'eol' | 'differs' | 'unexpected' | 'unverified' | 'skipped' | 'packages' | 'validPackages' | 'lockFailures' | 'misplaced', number>
|
|
99
|
+
problems: Problem[]
|
|
100
|
+
moreProblems: number
|
|
101
|
+
packages: PackageReport[]
|
|
102
|
+
// validateRepository's, `strict` false: why no lockfile was held to.
|
|
103
|
+
lockfileError?: ValidateErrorCode
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function validateBundle(plan: ValidationPlan, own: OwnCode | Promise<OwnCode>,
|
|
107
|
+
options?: { fetch?: Fetch; locked?: Locked | null; deadline?: number; now?: () => number }): Promise<BundleValidation>
|
|
108
|
+
export function exitCodeOf(report: BundleValidation, options?: { allowUnverified?: boolean }): 0 | 1 | 2
|
|
109
|
+
|
|
110
|
+
type Read = 'getRepoTreeId' | 'getRepoTreeTarball' | 'listRepoDir' | 'getRepoFile' | 'getRepoHead' | 'listRepoTags' | 'listRepoBranches' | 'compareCommits'
|
|
111
|
+
// The reads of upstream's client followingMoves wraps, and getRepo, which it follows a move by.
|
|
112
|
+
type Reads = Pick<Client, Read | 'getRepo'>
|
|
113
|
+
// A repository's reads (followingMoves's), where it has moved too.
|
|
114
|
+
export type Repository = { name(): string } & { [M in Read]: (options: Omit<Parameters<Client[M]>[0], 'repo'>) => ReturnType<Client[M]> }
|
|
115
|
+
export function followingMoves(client: Reads, github: string): Repository
|
|
116
|
+
export function historyOf(repository: Repository, commit: string, options?: { maxCompared?: number; deadline?: number; now?: () => number }): Promise<Ref | null>
|
|
117
|
+
|
|
118
|
+
export function repositoryFiles(repository: Repository, where: { github?: string; commit: string; directory?: string }): Promise<Map<string, RepositoryEntry>>
|
|
119
|
+
export function repositoryLockfiles(options: { directory?: string; ecosystems: Set<string>; list: (dir: string) => Promise<string[]>; read: (path: string) => Promise<string> })
|
|
120
|
+
: Promise<{ path: string; text: string }[]>
|
|
121
|
+
|
|
122
|
+
interface Options { own?: boolean; fetch?: Fetch; deadline?: number }
|
|
123
|
+
export function validateRepository(plan: ValidationPlan, where: { repository?: Repository | null; commit?: string; directory?: string }, options?: Options & {
|
|
124
|
+
lockfile?: boolean | Lockfile[]
|
|
125
|
+
// A listing of the commit's tree, as upstream's listRepoTree gives it, for these paths.
|
|
126
|
+
listTree?: (paths: string[]) => Promise<{ entries: RepoDirEntry[]; cut?: boolean }>
|
|
127
|
+
strict?: boolean
|
|
128
|
+
}): Promise<BundleValidation>
|
|
129
|
+
export function validate(file: string, options?: Options & { client?: Reads; github?: string; sha?: string; directory?: string; lockfile?: boolean | string[] }): Promise<BundleValidation>
|
|
130
|
+
|
|
131
|
+
type Stream = { write(chunk: string): unknown }
|
|
132
|
+
export function printValidationReport(report: BundleValidation, options?: { out?: Stream; err?: Stream; showValid?: boolean; colors?: boolean }): void
|