/** * Internal parsed representation of a package specifier. */ export type PackageConfig = { /** Package name or repository URL. */ name: string; /** Version/range for npm packages, or git ref for git sources. */ version?: string; }; export type BasicPackageOptions = { entries: FiledistExtractEntry[]; cwd: string; dryRun?: boolean; verbose?: boolean; silent?: boolean; }; /** * Controls which files are selected from a package and install behaviour. */ export type SelectorConfig = { /** * Subdirectory within the package to use as the root for file enumeration. * Glob patterns in `files` and returned relative paths are relative to this subdirectory. * When omitted, enumeration starts from the package root. * Example: `basedir: 'manual'` with `files: ['**']` selects all files under * `/manual/` and places them in the output without the `manual/` prefix. */ basedir?: string; /** * Glob patterns; files must match at least one. * Default: all files except package.json, bin/**, README.md, node_modules/** */ files?: string[]; /** * Internal: grouped file patterns that must all match during recursive selector merges. */ filePatternGroups?: string[][]; /** * Glob patterns; files matching any of these are excluded even if they match `files`. */ exclude?: string[]; /** * Regex strings; files must match at least one. Binary files always skip regex check. */ contentRegexes?: string[]; /** * Filters which of the target package's own nested `filedist.sets` are recursively * extracted. Only sets in the target package whose `presets` field includes at least * one of these tags will be processed. When omitted or empty, all nested sets are * extracted. Not applied to the files selected from the target package itself. */ presets?: string[]; /** * Force fresh package install even if a satisfying version is installed. */ upgrade?: boolean; }; /** * Controls where and how extracted files are written. */ export type OutputConfig = { /** * Output directory relative to cwd. Concatenated across recursion levels. * Defaults to '.' (current working directory) when omitted. */ path?: string; /** * Overwrite existing unmanaged files. Cannot be combined with mutable. */ force?: boolean; /** * Skip files that already exist; create missing ones. Cannot combine with force. * Files extracted with this flag set are marked mutable in the .filedist marker, * so the check command skips content verification for them. */ mutable?: boolean; /** * Create/update .gitignore alongside each .filedist marker. */ gitignore?: boolean; /** * When set to false: write without .filedist marker, no gitignore update. Existing files skipped. * Takes precedence over force. Defaults to true (managed). */ managed?: boolean; /** * When true, set extracted files to read-only (0o444) on disk. * Defaults to false (files remain writable after extraction). */ readonly?: boolean; /** * Keep stale managed files on disk instead of deleting them during extract. * Check still reports them as extra drift until they are removed or synced. */ noSync?: boolean; /** * Report what would change; no disk writes. */ dryRun?: boolean; /** * Post-extract symlink operations. Appended across recursion levels. */ symlinks?: SymlinkConfig[]; /** * Post-extract content replacements. Appended across recursion levels. */ contentReplacements?: ContentReplacementConfig[]; }; /** * Controls runtime output verbosity. */ export type ExecutionConfig = { /** Suppress per-file output; print only final summary line. */ silent?: boolean; /** Print detailed step information. */ verbose?: boolean; }; /** * Defines one post-extract symlink operation. */ export type SymlinkConfig = { /** Glob relative to outputDir. Matching files/dirs get symlinked into `target`. */ source: string; /** Directory where symlinks are created, relative to outputDir. Supports ../ paths. */ target: string; }; /** * Defines one post-extract content replacement operation. */ export type ContentReplacementConfig = { /** Glob relative to cwd selecting workspace files to modify. */ files: string; /** Regex string; all non-overlapping occurrences replaced (global flag applied). */ match: string; /** Replacement string; may contain back-references ($1, $2). */ replace: string; }; /** * One entry in the filedist.sets array. Represents a single extraction target. * * Two variants: * - Self-package entry (no `package` field): leaf of recursion; files come from the * package whose filedist.sets contains this entry. * - External-package entry (`package` field set): recurses into the named package's own * filedist.sets (or enumerates its files directly when it has no sets). */ export type FiledistExtractEntry = { /** * Flat package spec string. Supports npm specs such as "my-pkg@^1.2.3" and * git specs prefixed with "git:", such as "git:github.com/org/repo.git@main". * When omitted, the entry is a self-package entry — files are drawn from the * package that owns this sets array. */ package?: string; /** Where/how to write files. Defaults to current directory with no special flags. */ output?: OutputConfig; /** Which files to select and install options. */ selector?: SelectorConfig; /** * Preset tags for --presets CLI filtering. An entry is included when at least * one of its presets appears in the requested preset list. * Not forwarded to dependency packages. */ presets?: string[]; /** Suppress per-file output. Root-level (not nested). */ silent?: boolean; /** Print detailed step information. Root-level (not nested). */ verbose?: boolean; }; /** * Top-level structure stored under filedist key in package.json or in any cosmiconfig source. */ export type FiledistConfig = { /** All extraction entries. */ sets: FiledistExtractEntry[]; /** * Post-extract command run after successful extract (not during --dry-run). * The first item is the executable and the remaining items are its arguments. * Full argv is appended automatically. */ postExtractCmd?: string[]; }; /** * A single file operation in the diff/execute pipeline. */ export type FileOperation = { relPath: string; sourcePath: string; destPath: string; hash: string; }; /** * A file skipped during extraction with the reason. */ export type SkippedFile = { relPath: string; reason: 'conflict' | 'mutable' | 'unchanged' | 'not-managed'; }; /** * A file in outputDir that is not tracked by filedist and blocks extraction. */ export type ConflictFile = { relPath: string; /** Set when file is managed by a different package. */ existingOwner?: string; }; /** * Internal read-only structure produced by fileset/diff.ts. Not persisted. */ export type ExtractionMap = { /** Files present in package source but absent from outputDir. */ toAdd: FileOperation[]; /** Files whose hash differs between package source and outputDir. */ toModify: FileOperation[]; /** Relative paths of managed files no longer present in filtered package source. */ toDelete: string[]; /** Files skipped with reason. */ toSkip: SkippedFile[]; /** Files in outputDir not tracked by filedist that block extraction. */ conflicts: ConflictFile[]; }; /** * One row in a .filedist CSV marker file. * Format: path|packageName|packageVersion|kind|checksum|mutable * Pipe is used as separator so file paths containing commas are handled safely. */ export type ManagedFileMetadata = { /** Relative path from marker file directory. */ path: string; /** Source npm package name. */ packageName: string; /** Installed version at extraction time. */ packageVersion: string; /** Managed path type. */ kind: 'file' | 'symlink'; /** * SHA-256 hash of the file content at extraction time (after content replacements). * For symlinks, the hash is computed from the link target path string. * Used by check to detect local tampering without re-downloading the source package. */ checksum: string; /** * When true the file is allowed to change locally (e.g. extracted with mutable=true). * The check command skips content verification for mutable files. */ mutable: boolean; }; /** * Event emitted by extract/check/purge for UI progress reporting. */ export type FileProgressEvent = { type: 'file-added' | 'file-modified' | 'file-deleted' | 'file-skipped'; packageName: string; file: string; managed: boolean; gitignore: boolean; }; export type ProgressEvent = { type: 'package-start'; packageName: string; packageVersion: string; } | { type: 'package-end'; packageName: string; packageVersion: string; } | FileProgressEvent; /** * Result of a check operation for a single fileset. */ export type CheckResult = { /** Files in .filedist marker but absent from output dir. */ missing: string[]; /** Files whose content hash differs from package source. */ modified: string[]; /** Files in filtered package source but never extracted. */ extra: string[]; }; /** * Result of purging one fileset. */ export type PurgeResult = { /** Number of files deleted. */ deleted: number; /** Number of symlinks removed. */ symlinksRemoved: number; /** Number of empty dirs removed. */ dirsRemoved: number; }; /** * Result of executing an ExtractionMap. */ export type ExecuteResult = { /** Paths of newly created files (for rollback purposes). */ newlyCreated: string[]; /** Number of files added. */ added: number; /** Number of files modified. */ modified: number; /** Number of files deleted. */ deleted: number; /** Number of files skipped. */ skipped: number; }; /** * A single resolved file produced by resolveFiles(). * Carries all metadata needed to apply disk changes without further config lookups. */ export type ResolvedFile = { /** Relative path within the output directory. */ relPath: string; /** Absolute path of the source file in the installed package directory. */ sourcePath: string; /** Name of the npm package that owns this file. */ packageName: string; /** Installed version of the source package. */ packageVersion: string; /** Absolute path of the output directory where the file should be written. */ outputDir: string; /** Whether the file should be tracked in the .filedist marker. Default: true. */ managed: boolean; /** Whether the file should be added to .gitignore. Default: true. */ gitignore: boolean; /** Whether to overwrite an existing unmanaged file. Default: false. */ force: boolean; /** Whether to skip files that already exist in the output. Default: false. */ mutable: boolean; /** Whether extract should leave stale managed files in place for this output. */ noSync: boolean; /** Whether extracted files should be set to read-only (0o444) on disk. Default: false. */ readonly: boolean; /** Content replacement rules applied to this file before comparison. */ contentReplacements: ContentReplacementConfig[]; /** Symlink operations to apply in the output directory after extraction. */ symlinks: SymlinkConfig[]; }; /** Classification of a single file in the calculateDiff result. */ export type DiffStatus = 'ok' | 'missing' | 'extra' | 'conflict'; /** * One entry in a DiffResult. * - ok: desired file exists, content and state match * - missing: desired file is absent from the output directory * - extra: managed file in the marker is not present in the desired file list * - conflict: desired file exists but content, managed state, or gitignore state differs */ export type DiffEntry = { status: DiffStatus; /** Relative path within the output directory. */ relPath: string; /** Absolute path to the output directory. */ outputDir: string; /** Desired file metadata (absent for 'extra' entries). */ desired?: ResolvedFile; /** Existing marker entry (absent for 'missing' entries and unmanaged conflicts). */ existing?: ManagedFileMetadata; /** Reasons for conflict (only set for 'conflict' status). */ conflictReasons?: Array<'content' | 'managed' | 'gitignore'>; }; /** * Aggregate result of calculateDiff(). */ export type DiffResult = { /** Desired files that already match the output directory. */ ok: DiffEntry[]; /** Desired files absent from the output directory. */ missing: DiffEntry[]; /** Managed files in the marker that are not in the desired file list. */ extra: DiffEntry[]; /** Desired files with content, managed-state, or gitignore-state mismatch. */ conflict: DiffEntry[]; }; //# sourceMappingURL=types.d.ts.map