@mhalle/vost 0.8.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/LICENSE +191 -0
- package/README.md +24 -0
- package/dist/batch.d.ts +82 -0
- package/dist/batch.js +152 -0
- package/dist/batch.js.map +1 -0
- package/dist/copy.d.ts +242 -0
- package/dist/copy.js +1229 -0
- package/dist/copy.js.map +1 -0
- package/dist/exclude.d.ts +68 -0
- package/dist/exclude.js +157 -0
- package/dist/exclude.js.map +1 -0
- package/dist/fileobj.d.ts +82 -0
- package/dist/fileobj.js +127 -0
- package/dist/fileobj.js.map +1 -0
- package/dist/fs.d.ts +581 -0
- package/dist/fs.js +1318 -0
- package/dist/fs.js.map +1 -0
- package/dist/gitstore.d.ts +74 -0
- package/dist/gitstore.js +131 -0
- package/dist/gitstore.js.map +1 -0
- package/dist/glob.d.ts +14 -0
- package/dist/glob.js +68 -0
- package/dist/glob.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/lock.d.ts +15 -0
- package/dist/lock.js +71 -0
- package/dist/lock.js.map +1 -0
- package/dist/mirror.d.ts +53 -0
- package/dist/mirror.js +270 -0
- package/dist/mirror.js.map +1 -0
- package/dist/notes.d.ts +148 -0
- package/dist/notes.js +508 -0
- package/dist/notes.js.map +1 -0
- package/dist/paths.d.ts +16 -0
- package/dist/paths.js +44 -0
- package/dist/paths.js.map +1 -0
- package/dist/refdict.d.ts +117 -0
- package/dist/refdict.js +267 -0
- package/dist/refdict.js.map +1 -0
- package/dist/reflog.d.ts +33 -0
- package/dist/reflog.js +83 -0
- package/dist/reflog.js.map +1 -0
- package/dist/tree.d.ts +79 -0
- package/dist/tree.js +283 -0
- package/dist/tree.js.map +1 -0
- package/dist/types.d.ts +354 -0
- package/dist/types.js +302 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FS: immutable snapshot of a committed tree state.
|
|
3
|
+
*
|
|
4
|
+
* Read-only when writable is false (tag/detached snapshot).
|
|
5
|
+
* Writable when writable is true — writes auto-commit and return a new FS.
|
|
6
|
+
*/
|
|
7
|
+
import { type FsModule, type FileType, type WalkEntry, type WriteEntry, type ChangeReport, type CommitInfo, type StatResult } from './types.js';
|
|
8
|
+
import { type TreeWrite } from './tree.js';
|
|
9
|
+
import { Batch } from './batch.js';
|
|
10
|
+
import { FsWriter } from './fileobj.js';
|
|
11
|
+
import type { GitStore } from './gitstore.js';
|
|
12
|
+
/**
|
|
13
|
+
* An immutable snapshot of a committed tree.
|
|
14
|
+
*
|
|
15
|
+
* Read-only when `writable` is false (tag snapshot).
|
|
16
|
+
* Writable when `writable` is true -- writes auto-commit and return a new FS.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FS {
|
|
19
|
+
/** @internal */
|
|
20
|
+
_store: GitStore;
|
|
21
|
+
/** @internal */
|
|
22
|
+
_commitOid: string;
|
|
23
|
+
/** @internal */
|
|
24
|
+
_refName: string | null;
|
|
25
|
+
/** @internal */
|
|
26
|
+
_writable: boolean;
|
|
27
|
+
/** @internal */
|
|
28
|
+
_treeOid: string;
|
|
29
|
+
/** @internal */
|
|
30
|
+
_changes: ChangeReport | null;
|
|
31
|
+
/** @internal */
|
|
32
|
+
_commitTime: number | null;
|
|
33
|
+
/** @internal */
|
|
34
|
+
get _fsModule(): FsModule;
|
|
35
|
+
/** @internal */
|
|
36
|
+
get _gitdir(): string;
|
|
37
|
+
constructor(store: GitStore, commitOid: string, treeOid: string, refName: string | null, writable?: boolean);
|
|
38
|
+
/**
|
|
39
|
+
* @internal Create an FS from a commit OID (reads the commit to get tree OID).
|
|
40
|
+
*/
|
|
41
|
+
static _fromCommit(store: GitStore, commitOid: string, refName: string | null, writable?: boolean): Promise<FS>;
|
|
42
|
+
toString(): string;
|
|
43
|
+
/** @internal */
|
|
44
|
+
private _readonlyError;
|
|
45
|
+
/** The 40-character hex SHA of this snapshot's commit. */
|
|
46
|
+
get commitHash(): string;
|
|
47
|
+
/** The branch or tag name, or `null` for detached snapshots. */
|
|
48
|
+
get refName(): string | null;
|
|
49
|
+
/** Whether this snapshot can be written to. */
|
|
50
|
+
get writable(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch commit metadata (message, time, author name/email) in a single read.
|
|
53
|
+
*
|
|
54
|
+
* @returns Commit info object with message, time, authorName, and authorEmail.
|
|
55
|
+
*/
|
|
56
|
+
getCommitInfo(): Promise<CommitInfo>;
|
|
57
|
+
/** The commit message (trailing newline stripped). */
|
|
58
|
+
getMessage(): Promise<string>;
|
|
59
|
+
/** Timezone-aware commit timestamp. */
|
|
60
|
+
getTime(): Promise<Date>;
|
|
61
|
+
/** The commit author's name. */
|
|
62
|
+
getAuthorName(): Promise<string>;
|
|
63
|
+
/** The commit author's email address. */
|
|
64
|
+
getAuthorEmail(): Promise<string>;
|
|
65
|
+
/** Report of the operation that created this snapshot, or `null`. */
|
|
66
|
+
get changes(): ChangeReport | null;
|
|
67
|
+
/** The 40-char hex SHA of the root tree. */
|
|
68
|
+
get treeHash(): string;
|
|
69
|
+
/** @internal */
|
|
70
|
+
_getCommitTime(): Promise<number>;
|
|
71
|
+
/**
|
|
72
|
+
* Read file contents as bytes.
|
|
73
|
+
*
|
|
74
|
+
* @param path - File path in the repo.
|
|
75
|
+
* @param opts - Optional read options.
|
|
76
|
+
* @param opts.offset - Byte offset to start reading from.
|
|
77
|
+
* @param opts.size - Maximum bytes to return (undefined for all).
|
|
78
|
+
* @returns Raw file contents as Uint8Array.
|
|
79
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
80
|
+
* @throws {IsADirectoryError} If path is a directory.
|
|
81
|
+
*/
|
|
82
|
+
read(path: string, opts?: {
|
|
83
|
+
offset?: number;
|
|
84
|
+
size?: number;
|
|
85
|
+
}): Promise<Uint8Array>;
|
|
86
|
+
/**
|
|
87
|
+
* Read file contents as a string.
|
|
88
|
+
*
|
|
89
|
+
* @param path - File path in the repo.
|
|
90
|
+
* @param encoding - Text encoding (default `"utf-8"`).
|
|
91
|
+
* @returns Decoded text content.
|
|
92
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
93
|
+
* @throws {IsADirectoryError} If path is a directory.
|
|
94
|
+
*/
|
|
95
|
+
readText(path: string, encoding?: string): Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* List entry names at path (or root if null/undefined).
|
|
98
|
+
*
|
|
99
|
+
* @param path - Directory path, or null/undefined for the repo root.
|
|
100
|
+
* @returns Array of entry names (files and subdirectories).
|
|
101
|
+
* @throws {NotADirectoryError} If path is a file.
|
|
102
|
+
*/
|
|
103
|
+
ls(path?: string | null): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Walk the repo tree recursively, like `os.walk`.
|
|
106
|
+
*
|
|
107
|
+
* Yields `[dirpath, dirnames, fileEntries]` tuples. Each file entry is a
|
|
108
|
+
* WalkEntry with `name`, `oid`, and `mode`.
|
|
109
|
+
*
|
|
110
|
+
* @param path - Subtree to walk, or null/undefined for root.
|
|
111
|
+
* @throws {NotADirectoryError} If path is a file.
|
|
112
|
+
*/
|
|
113
|
+
walk(path?: string | null): AsyncGenerator<[string, string[], WalkEntry[]]>;
|
|
114
|
+
/**
|
|
115
|
+
* Return true if path exists (file or directory).
|
|
116
|
+
*
|
|
117
|
+
* @param path - Path to check.
|
|
118
|
+
*/
|
|
119
|
+
exists(path: string): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Return true if path is a directory (tree) in the repo.
|
|
122
|
+
*
|
|
123
|
+
* @param path - Path to check.
|
|
124
|
+
*/
|
|
125
|
+
isDir(path: string): Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Return the FileType of path.
|
|
128
|
+
*
|
|
129
|
+
* Returns `'blob'`, `'executable'`, `'link'`, or `'tree'`.
|
|
130
|
+
*
|
|
131
|
+
* @param path - Path to check.
|
|
132
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
133
|
+
*/
|
|
134
|
+
fileType(path: string): Promise<FileType>;
|
|
135
|
+
/**
|
|
136
|
+
* Return the size in bytes of the object at path.
|
|
137
|
+
*
|
|
138
|
+
* @param path - Path to check.
|
|
139
|
+
* @returns Size in bytes.
|
|
140
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
141
|
+
*/
|
|
142
|
+
size(path: string): Promise<number>;
|
|
143
|
+
/**
|
|
144
|
+
* Return the 40-character hex SHA of the object at path.
|
|
145
|
+
*
|
|
146
|
+
* For files this is the blob SHA; for directories the tree SHA.
|
|
147
|
+
*
|
|
148
|
+
* @param path - Path to check.
|
|
149
|
+
* @returns 40-char hex SHA string.
|
|
150
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
151
|
+
*/
|
|
152
|
+
objectHash(path: string): Promise<string>;
|
|
153
|
+
/**
|
|
154
|
+
* Read the target of a symlink.
|
|
155
|
+
*
|
|
156
|
+
* @param path - Symlink path in the repo.
|
|
157
|
+
* @returns The symlink target string.
|
|
158
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
159
|
+
* @throws {Error} If path is not a symlink.
|
|
160
|
+
*/
|
|
161
|
+
readlink(path: string): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Read raw blob data by hash, bypassing tree lookup.
|
|
164
|
+
*
|
|
165
|
+
* FUSE pattern: `stat()` -> cache hash -> `readByHash(hash)`.
|
|
166
|
+
*
|
|
167
|
+
* @param hash - 40-char hex SHA of the blob.
|
|
168
|
+
* @param opts - Optional read options.
|
|
169
|
+
* @param opts.offset - Byte offset to start reading from.
|
|
170
|
+
* @param opts.size - Maximum bytes to return (undefined for all).
|
|
171
|
+
* @returns Raw blob contents as Uint8Array.
|
|
172
|
+
*/
|
|
173
|
+
readByHash(hash: string, opts?: {
|
|
174
|
+
offset?: number;
|
|
175
|
+
size?: number;
|
|
176
|
+
}): Promise<Uint8Array>;
|
|
177
|
+
/**
|
|
178
|
+
* Return a StatResult for path (or root if null/undefined).
|
|
179
|
+
*
|
|
180
|
+
* Combines fileType, size, oid, nlink, and mtime in a single call --
|
|
181
|
+
* the hot path for FUSE `getattr`.
|
|
182
|
+
*
|
|
183
|
+
* @param path - Path to stat, or null/undefined for root.
|
|
184
|
+
* @returns StatResult with mode, fileType, size, hash, nlink, and mtime.
|
|
185
|
+
* @throws {FileNotFoundError} If path does not exist.
|
|
186
|
+
*/
|
|
187
|
+
stat(path?: string | null): Promise<StatResult>;
|
|
188
|
+
/**
|
|
189
|
+
* List directory entries with name, oid, and mode.
|
|
190
|
+
*
|
|
191
|
+
* Like `ls()` but returns WalkEntry objects so callers get entry types
|
|
192
|
+
* (useful for FUSE `readdir` d_type).
|
|
193
|
+
*
|
|
194
|
+
* @param path - Directory path, or null/undefined for root.
|
|
195
|
+
* @returns Array of WalkEntry objects.
|
|
196
|
+
*/
|
|
197
|
+
listdir(path?: string | null): Promise<WalkEntry[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Expand a glob pattern against the repo tree.
|
|
200
|
+
*
|
|
201
|
+
* Supports `*`, `?`, and `**`. `*` and `?` do not match a leading `.`
|
|
202
|
+
* unless the pattern segment itself starts with `.`. `**` matches zero or
|
|
203
|
+
* more directory levels, skipping directories whose names start with `.`.
|
|
204
|
+
*
|
|
205
|
+
* @param pattern - Glob pattern to match.
|
|
206
|
+
* @returns Sorted, deduplicated list of matching paths (files and directories).
|
|
207
|
+
*/
|
|
208
|
+
glob(pattern: string): Promise<string[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Expand a glob pattern against the repo tree, yielding unique matches.
|
|
211
|
+
*
|
|
212
|
+
* Like `glob()` but returns an unordered async iterator instead of a
|
|
213
|
+
* sorted list. Useful when you only need to iterate once and don't
|
|
214
|
+
* need sorted output.
|
|
215
|
+
*
|
|
216
|
+
* A `/./` pivot marker (rsync `-R` style) is preserved in the output
|
|
217
|
+
* so that callers can reconstruct partial source paths.
|
|
218
|
+
*
|
|
219
|
+
* @param pattern - Glob pattern to match.
|
|
220
|
+
*/
|
|
221
|
+
iglob(pattern: string): AsyncGenerator<string>;
|
|
222
|
+
/** @internal */
|
|
223
|
+
private _iglobEntries;
|
|
224
|
+
/** @internal */
|
|
225
|
+
private _iglobWalk;
|
|
226
|
+
/** @internal */
|
|
227
|
+
private _iglobMatchEntries;
|
|
228
|
+
/**
|
|
229
|
+
* @internal Build ChangeReport from writes and removes with type detection.
|
|
230
|
+
*/
|
|
231
|
+
_buildChanges(writes: Map<string, TreeWrite>, removes: Set<string>): Promise<ChangeReport>;
|
|
232
|
+
/**
|
|
233
|
+
* @internal Commit changes: rebuild tree, create commit, update ref atomically.
|
|
234
|
+
*/
|
|
235
|
+
_commitChanges(writes: Map<string, TreeWrite>, removes: Set<string>, message?: string | null, operation?: string | null): Promise<FS>;
|
|
236
|
+
/**
|
|
237
|
+
* Write data to path and commit, returning a new FS.
|
|
238
|
+
*
|
|
239
|
+
* @param path - Destination path in the repo.
|
|
240
|
+
* @param data - Raw bytes to write.
|
|
241
|
+
* @param opts - Optional write options.
|
|
242
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
243
|
+
* @param opts.mode - File mode override (e.g. `'executable'`).
|
|
244
|
+
* @returns New FS snapshot with the write committed.
|
|
245
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
246
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
247
|
+
*/
|
|
248
|
+
write(path: string, data: Uint8Array, opts?: {
|
|
249
|
+
message?: string;
|
|
250
|
+
mode?: FileType | string;
|
|
251
|
+
}): Promise<FS>;
|
|
252
|
+
/**
|
|
253
|
+
* Write text to path and commit, returning a new FS.
|
|
254
|
+
*
|
|
255
|
+
* @param path - Destination path in the repo.
|
|
256
|
+
* @param text - String content (encoded as UTF-8).
|
|
257
|
+
* @param opts - Optional write options.
|
|
258
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
259
|
+
* @param opts.mode - File mode override (e.g. `'executable'`).
|
|
260
|
+
* @returns New FS snapshot with the write committed.
|
|
261
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
262
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
263
|
+
*/
|
|
264
|
+
writeText(path: string, text: string, opts?: {
|
|
265
|
+
message?: string;
|
|
266
|
+
mode?: FileType | string;
|
|
267
|
+
}): Promise<FS>;
|
|
268
|
+
/**
|
|
269
|
+
* Write a local file into the repo and commit, returning a new FS.
|
|
270
|
+
*
|
|
271
|
+
* Executable permission is auto-detected from disk unless `mode` is set.
|
|
272
|
+
*
|
|
273
|
+
* @param path - Destination path in the repo.
|
|
274
|
+
* @param localPath - Path to the local file.
|
|
275
|
+
* @param opts - Optional write options.
|
|
276
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
277
|
+
* @param opts.mode - File mode override (e.g. `'executable'`).
|
|
278
|
+
* @returns New FS snapshot with the write committed.
|
|
279
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
280
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
281
|
+
*/
|
|
282
|
+
writeFromFile(path: string, localPath: string, opts?: {
|
|
283
|
+
message?: string;
|
|
284
|
+
mode?: FileType | string;
|
|
285
|
+
}): Promise<FS>;
|
|
286
|
+
/**
|
|
287
|
+
* Create a symbolic link entry and commit, returning a new FS.
|
|
288
|
+
*
|
|
289
|
+
* @param path - Symlink path in the repo.
|
|
290
|
+
* @param target - The symlink target string.
|
|
291
|
+
* @param opts - Optional write options.
|
|
292
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
293
|
+
* @returns New FS snapshot with the symlink committed.
|
|
294
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
295
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
296
|
+
*/
|
|
297
|
+
writeSymlink(path: string, target: string, opts?: {
|
|
298
|
+
message?: string;
|
|
299
|
+
}): Promise<FS>;
|
|
300
|
+
/**
|
|
301
|
+
* Apply multiple writes and removes in a single atomic commit.
|
|
302
|
+
*
|
|
303
|
+
* `writes` maps repo paths to content. Values may be:
|
|
304
|
+
* - `Uint8Array` -- raw blob data
|
|
305
|
+
* - `string` -- UTF-8 text (encoded automatically)
|
|
306
|
+
* - `WriteEntry` -- full control over source, mode, and symlinks
|
|
307
|
+
*
|
|
308
|
+
* `removes` lists repo paths to delete (string, array, or Set).
|
|
309
|
+
*
|
|
310
|
+
* @param writes - Map of repo paths to content.
|
|
311
|
+
* @param removes - Path(s) to delete.
|
|
312
|
+
* @param opts - Optional apply options.
|
|
313
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
314
|
+
* @param opts.operation - Operation name for auto-generated messages.
|
|
315
|
+
* @returns New FS snapshot with the changes committed.
|
|
316
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
317
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
318
|
+
*/
|
|
319
|
+
apply(writes?: Record<string, WriteEntry | Uint8Array | string> | null, removes?: string | string[] | Set<string> | null, opts?: {
|
|
320
|
+
message?: string;
|
|
321
|
+
operation?: string;
|
|
322
|
+
}): Promise<FS>;
|
|
323
|
+
/**
|
|
324
|
+
* Return a Batch for accumulating multiple writes in one commit.
|
|
325
|
+
*
|
|
326
|
+
* @param opts - Optional batch options.
|
|
327
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
328
|
+
* @param opts.operation - Operation name for auto-generated messages.
|
|
329
|
+
* @returns A Batch instance. Call `batch.commit()` to finalize.
|
|
330
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
331
|
+
*/
|
|
332
|
+
batch(opts?: {
|
|
333
|
+
message?: string;
|
|
334
|
+
operation?: string;
|
|
335
|
+
}): Batch;
|
|
336
|
+
/**
|
|
337
|
+
* Return a buffered writer that commits on close.
|
|
338
|
+
*
|
|
339
|
+
* Accepts `Uint8Array` or `string` via `write()`. Strings are UTF-8 encoded.
|
|
340
|
+
*
|
|
341
|
+
* @param path - Destination path in the repo.
|
|
342
|
+
* @returns An FsWriter instance. Call `close()` to flush and commit.
|
|
343
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
344
|
+
*/
|
|
345
|
+
writer(path: string): FsWriter;
|
|
346
|
+
/**
|
|
347
|
+
* Copy local files into the repo.
|
|
348
|
+
*
|
|
349
|
+
* Sources must be literal paths; use `diskGlob()` to expand patterns
|
|
350
|
+
* before calling.
|
|
351
|
+
*
|
|
352
|
+
* @param sources - Local path(s). Trailing `/` copies contents; `/./` is a pivot marker.
|
|
353
|
+
* @param dest - Destination path in the repo.
|
|
354
|
+
* @param opts - Copy-in options.
|
|
355
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
356
|
+
* @param opts.followSymlinks - Dereference symlinks on disk.
|
|
357
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
358
|
+
* @param opts.mode - Override file mode for all files.
|
|
359
|
+
* @param opts.ignoreExisting - Skip files that already exist at dest.
|
|
360
|
+
* @param opts.delete - Remove repo files under dest not in source.
|
|
361
|
+
* @param opts.ignoreErrors - Collect errors instead of aborting.
|
|
362
|
+
* @param opts.checksum - Compare by content hash (default true).
|
|
363
|
+
* @returns New FS with `.changes` set.
|
|
364
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
365
|
+
*/
|
|
366
|
+
copyIn(sources: string | string[], dest: string, opts?: {
|
|
367
|
+
dryRun?: boolean;
|
|
368
|
+
followSymlinks?: boolean;
|
|
369
|
+
message?: string;
|
|
370
|
+
mode?: string;
|
|
371
|
+
ignoreExisting?: boolean;
|
|
372
|
+
delete?: boolean;
|
|
373
|
+
ignoreErrors?: boolean;
|
|
374
|
+
checksum?: boolean;
|
|
375
|
+
exclude?: import('./exclude.js').ExcludeFilter;
|
|
376
|
+
}): Promise<FS>;
|
|
377
|
+
/**
|
|
378
|
+
* Copy repo files to local disk.
|
|
379
|
+
*
|
|
380
|
+
* Sources must be literal repo paths; use `glob()` to expand patterns
|
|
381
|
+
* before calling.
|
|
382
|
+
*
|
|
383
|
+
* @param sources - Repo path(s). Trailing `/` copies contents; `/./` is a pivot marker.
|
|
384
|
+
* @param dest - Local destination directory.
|
|
385
|
+
* @param opts - Copy-out options.
|
|
386
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
387
|
+
* @param opts.ignoreExisting - Skip files that already exist at dest.
|
|
388
|
+
* @param opts.delete - Remove local files under dest not in source.
|
|
389
|
+
* @param opts.ignoreErrors - Collect errors instead of aborting.
|
|
390
|
+
* @param opts.checksum - Compare by content hash (default true).
|
|
391
|
+
* @returns This FS with `.changes` set.
|
|
392
|
+
*/
|
|
393
|
+
copyOut(sources: string | string[], dest: string, opts?: {
|
|
394
|
+
dryRun?: boolean;
|
|
395
|
+
ignoreExisting?: boolean;
|
|
396
|
+
delete?: boolean;
|
|
397
|
+
ignoreErrors?: boolean;
|
|
398
|
+
checksum?: boolean;
|
|
399
|
+
}): Promise<FS>;
|
|
400
|
+
/**
|
|
401
|
+
* Make repoPath identical to localPath (including deletes).
|
|
402
|
+
*
|
|
403
|
+
* @param localPath - Local directory to sync from.
|
|
404
|
+
* @param repoPath - Repo directory to sync to.
|
|
405
|
+
* @param opts - Sync-in options.
|
|
406
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
407
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
408
|
+
* @param opts.ignoreErrors - Collect errors instead of aborting.
|
|
409
|
+
* @param opts.checksum - Compare by content hash (default true).
|
|
410
|
+
* @returns New FS with `.changes` set.
|
|
411
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
412
|
+
*/
|
|
413
|
+
syncIn(localPath: string, repoPath: string, opts?: {
|
|
414
|
+
dryRun?: boolean;
|
|
415
|
+
message?: string;
|
|
416
|
+
ignoreErrors?: boolean;
|
|
417
|
+
checksum?: boolean;
|
|
418
|
+
exclude?: import('./exclude.js').ExcludeFilter;
|
|
419
|
+
}): Promise<FS>;
|
|
420
|
+
/**
|
|
421
|
+
* Make localPath identical to repoPath (including deletes).
|
|
422
|
+
*
|
|
423
|
+
* @param repoPath - Repo directory to sync from.
|
|
424
|
+
* @param localPath - Local directory to sync to.
|
|
425
|
+
* @param opts - Sync-out options.
|
|
426
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
427
|
+
* @param opts.ignoreErrors - Collect errors instead of aborting.
|
|
428
|
+
* @param opts.checksum - Compare by content hash (default true).
|
|
429
|
+
* @returns This FS with `.changes` set.
|
|
430
|
+
*/
|
|
431
|
+
syncOut(repoPath: string, localPath: string, opts?: {
|
|
432
|
+
dryRun?: boolean;
|
|
433
|
+
ignoreErrors?: boolean;
|
|
434
|
+
checksum?: boolean;
|
|
435
|
+
}): Promise<FS>;
|
|
436
|
+
/**
|
|
437
|
+
* Remove files from the repo.
|
|
438
|
+
*
|
|
439
|
+
* Sources must be literal paths; use `glob()` to expand patterns before calling.
|
|
440
|
+
*
|
|
441
|
+
* @param sources - Repo path(s) to remove.
|
|
442
|
+
* @param opts - Remove options.
|
|
443
|
+
* @param opts.recursive - Allow removing directories.
|
|
444
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
445
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
446
|
+
* @returns New FS with `.changes` set.
|
|
447
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
448
|
+
* @throws {FileNotFoundError} If no source paths match.
|
|
449
|
+
*/
|
|
450
|
+
remove(sources: string | string[], opts?: {
|
|
451
|
+
recursive?: boolean;
|
|
452
|
+
dryRun?: boolean;
|
|
453
|
+
message?: string;
|
|
454
|
+
}): Promise<FS>;
|
|
455
|
+
/**
|
|
456
|
+
* Move or rename files within the repo.
|
|
457
|
+
*
|
|
458
|
+
* Sources must be literal paths; use `glob()` to expand patterns before calling.
|
|
459
|
+
*
|
|
460
|
+
* @param sources - Repo path(s) to move.
|
|
461
|
+
* @param dest - Destination path in the repo.
|
|
462
|
+
* @param opts - Move options.
|
|
463
|
+
* @param opts.recursive - Allow moving directories.
|
|
464
|
+
* @param opts.dryRun - Preview only; returned FS has `.changes` set.
|
|
465
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
466
|
+
* @returns New FS with `.changes` set.
|
|
467
|
+
* @throws {PermissionError} If this snapshot is read-only.
|
|
468
|
+
*/
|
|
469
|
+
move(sources: string | string[], dest: string, opts?: {
|
|
470
|
+
recursive?: boolean;
|
|
471
|
+
dryRun?: boolean;
|
|
472
|
+
message?: string;
|
|
473
|
+
}): Promise<FS>;
|
|
474
|
+
/**
|
|
475
|
+
* Copy files from source FS into this branch in a single atomic commit.
|
|
476
|
+
*
|
|
477
|
+
* Follows the same rsync trailing-slash conventions as `copyIn`/`copyOut`:
|
|
478
|
+
*
|
|
479
|
+
* - `"config"` → directory mode — copies `config/` *as* `config/` under dest.
|
|
480
|
+
* - `"config/"` → contents mode — pours the *contents* of `config/` into dest.
|
|
481
|
+
* - `"file.txt"` → file mode — copies the single file into dest.
|
|
482
|
+
* - `""` or `"/"` → root contents mode — copies everything.
|
|
483
|
+
*
|
|
484
|
+
* Since both snapshots share the same object store, blobs are referenced
|
|
485
|
+
* by OID — no data is read into memory regardless of file size.
|
|
486
|
+
*
|
|
487
|
+
* @param source - Any FS (branch, tag, detached commit). Read-only; not modified.
|
|
488
|
+
* @param sources - Source path(s) in source. Accepts a single string or array. Defaults to `""` (root).
|
|
489
|
+
* @param dest - Destination path in this branch. Defaults to `""` (root).
|
|
490
|
+
* @param opts - Copy-ref options.
|
|
491
|
+
* @param opts.delete - Remove dest files under the target that aren't in source.
|
|
492
|
+
* @param opts.dryRun - Compute changes but don't commit. Returned FS has `.changes` set.
|
|
493
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
494
|
+
* @returns New FS for the dest branch with the commit applied.
|
|
495
|
+
* @throws {Error} If source belongs to a different repo.
|
|
496
|
+
* @throws {PermissionError} If this FS is read-only.
|
|
497
|
+
*/
|
|
498
|
+
copyFromRef(source: FS, sources?: string | string[], dest?: string, opts?: {
|
|
499
|
+
delete?: boolean;
|
|
500
|
+
dryRun?: boolean;
|
|
501
|
+
message?: string;
|
|
502
|
+
}): Promise<FS>;
|
|
503
|
+
/**
|
|
504
|
+
* The parent snapshot, or `null` for the initial commit.
|
|
505
|
+
*
|
|
506
|
+
* @returns The parent FS, or `null` if this is the initial commit.
|
|
507
|
+
*/
|
|
508
|
+
getParent(): Promise<FS | null>;
|
|
509
|
+
/**
|
|
510
|
+
* Return the FS at the n-th ancestor commit.
|
|
511
|
+
*
|
|
512
|
+
* @param n - Number of commits to go back (default 1).
|
|
513
|
+
* @returns FS at the ancestor commit.
|
|
514
|
+
* @throws {Error} If n < 0 or history is too short.
|
|
515
|
+
*/
|
|
516
|
+
back(n?: number): Promise<FS>;
|
|
517
|
+
/**
|
|
518
|
+
* Move branch back N commits.
|
|
519
|
+
*
|
|
520
|
+
* Walks back through parent commits and updates the branch pointer.
|
|
521
|
+
* Automatically writes a reflog entry.
|
|
522
|
+
*
|
|
523
|
+
* @param steps - Number of commits to undo (default 1).
|
|
524
|
+
* @returns New FS snapshot at the ancestor commit.
|
|
525
|
+
* @throws {PermissionError} If called on a read-only snapshot (tag).
|
|
526
|
+
* @throws {Error} If not enough history exists.
|
|
527
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
528
|
+
*/
|
|
529
|
+
undo(steps?: number): Promise<FS>;
|
|
530
|
+
/**
|
|
531
|
+
* Move branch forward N steps using reflog.
|
|
532
|
+
*
|
|
533
|
+
* Reads the reflog to find where the branch was before the last N movements.
|
|
534
|
+
* This can resurrect "orphaned" commits after undo.
|
|
535
|
+
*
|
|
536
|
+
* @param steps - Number of reflog entries to go back (default 1).
|
|
537
|
+
* @returns New FS snapshot at the target position.
|
|
538
|
+
* @throws {PermissionError} If called on a read-only snapshot (tag).
|
|
539
|
+
* @throws {Error} If not enough redo history exists.
|
|
540
|
+
* @throws {StaleSnapshotError} If the branch has advanced since this snapshot.
|
|
541
|
+
*/
|
|
542
|
+
redo(steps?: number): Promise<FS>;
|
|
543
|
+
/**
|
|
544
|
+
* Walk the commit history, yielding ancestor FS snapshots.
|
|
545
|
+
*
|
|
546
|
+
* All filters are optional and combine with AND.
|
|
547
|
+
*
|
|
548
|
+
* @param opts - Log filter options.
|
|
549
|
+
* @param opts.path - Only yield commits that changed this file.
|
|
550
|
+
* @param opts.match - Message pattern (`*`/`?` wildcards).
|
|
551
|
+
* @param opts.before - Only yield commits on or before this time.
|
|
552
|
+
*/
|
|
553
|
+
log(opts?: {
|
|
554
|
+
path?: string;
|
|
555
|
+
match?: string;
|
|
556
|
+
before?: Date;
|
|
557
|
+
}): AsyncGenerator<FS>;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Write data to a branch with automatic retry on concurrent modification.
|
|
561
|
+
*
|
|
562
|
+
* Re-fetches the branch FS on each attempt. Uses exponential backoff
|
|
563
|
+
* with jitter (base 10ms, factor 2x, cap 200ms) to avoid thundering-herd.
|
|
564
|
+
*
|
|
565
|
+
* @param store - The GitStore instance.
|
|
566
|
+
* @param branch - Branch name to write to.
|
|
567
|
+
* @param path - Destination path in the repo.
|
|
568
|
+
* @param data - Raw bytes to write.
|
|
569
|
+
* @param opts - Optional retry-write options.
|
|
570
|
+
* @param opts.message - Commit message (auto-generated if omitted).
|
|
571
|
+
* @param opts.mode - File mode override (e.g. `'executable'`).
|
|
572
|
+
* @param opts.retries - Maximum number of attempts (default 5).
|
|
573
|
+
* @returns New FS snapshot with the write committed.
|
|
574
|
+
* @throws {StaleSnapshotError} If all attempts are exhausted.
|
|
575
|
+
* @throws {Error} If the branch does not exist.
|
|
576
|
+
*/
|
|
577
|
+
export declare function retryWrite(store: GitStore, branch: string, path: string, data: Uint8Array, opts?: {
|
|
578
|
+
message?: string;
|
|
579
|
+
mode?: FileType | string;
|
|
580
|
+
retries?: number;
|
|
581
|
+
}): Promise<FS>;
|