@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/copy.d.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy/sync/remove/move operations between local disk and git repo.
|
|
3
|
+
*
|
|
4
|
+
* Ports the Python vost copy/ subpackage into a single module.
|
|
5
|
+
*/
|
|
6
|
+
import { type FsModule } from './types.js';
|
|
7
|
+
import type { FS } from './fs.js';
|
|
8
|
+
import type { ExcludeFilter } from './exclude.js';
|
|
9
|
+
/**
|
|
10
|
+
* Walk a git tree and return file entries as a map.
|
|
11
|
+
*
|
|
12
|
+
* Builds a `{relativePath: {oid, mode}}` map for all files under
|
|
13
|
+
* `repoPath`. OID values are hex strings suitable for comparison
|
|
14
|
+
* against local file hashes. Returns an empty map when `repoPath`
|
|
15
|
+
* does not exist or is not a directory.
|
|
16
|
+
*
|
|
17
|
+
* @param fs - Filesystem snapshot to walk.
|
|
18
|
+
* @param repoPath - Root path in the repo tree (empty string for root).
|
|
19
|
+
* @returns Map of relative paths to `{oid, mode}` objects.
|
|
20
|
+
*/
|
|
21
|
+
export declare function walkRepo(fs: FS, repoPath: string): Promise<Map<string, {
|
|
22
|
+
oid: string;
|
|
23
|
+
mode: string;
|
|
24
|
+
}>>;
|
|
25
|
+
/**
|
|
26
|
+
* Expand a glob pattern against the local filesystem.
|
|
27
|
+
*
|
|
28
|
+
* Uses the same dotfile-aware rules as the repo-side `fs.glob()`:
|
|
29
|
+
* `*` and `?` do not match a leading `.` unless the pattern segment
|
|
30
|
+
* itself starts with `.`.
|
|
31
|
+
*
|
|
32
|
+
* @param fsModule - Node.js-compatible filesystem module.
|
|
33
|
+
* @param pattern - Glob pattern (e.g. `"src/**\/*.ts"`). Supports `*`, `?`, and `**`.
|
|
34
|
+
* @returns Sorted list of matching paths.
|
|
35
|
+
*/
|
|
36
|
+
export declare function diskGlob(fsModule: FsModule, pattern: string): Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* A resolved repo source path with its copy mode.
|
|
39
|
+
* - `repoPath` — normalized path in the repo.
|
|
40
|
+
* - `mode` — 'file' for a single file, 'dir' for a directory, 'contents' for trailing-slash contents mode.
|
|
41
|
+
* - `prefix` — prefix for pivot marker support.
|
|
42
|
+
*/
|
|
43
|
+
export type ResolvedRepoSource = {
|
|
44
|
+
repoPath: string;
|
|
45
|
+
mode: 'file' | 'dir' | 'contents';
|
|
46
|
+
prefix: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Resolve repo source paths into their copy mode (file/dir/contents).
|
|
50
|
+
*
|
|
51
|
+
* Trailing `/` means contents mode; bare directory names mean directory mode;
|
|
52
|
+
* files mean file mode. Empty string or `/` means root contents.
|
|
53
|
+
*
|
|
54
|
+
* @param fs - The FS snapshot to resolve paths against.
|
|
55
|
+
* @param sources - Array of repo paths to resolve.
|
|
56
|
+
* @returns Array of resolved sources with mode and prefix.
|
|
57
|
+
* @throws {FileNotFoundError} If a source path does not exist.
|
|
58
|
+
* @throws {NotADirectoryError} If a trailing-`/` source is not a directory.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveRepoSources(fs: FS, sources: string[]): Promise<ResolvedRepoSource[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Copy local files, directories, or globs into the repo.
|
|
63
|
+
*
|
|
64
|
+
* Sources may use a trailing `/` for "contents" mode (pour directory
|
|
65
|
+
* contents into `dest` without creating a subdirectory).
|
|
66
|
+
*
|
|
67
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
68
|
+
* returned with `.changes` populated.
|
|
69
|
+
*
|
|
70
|
+
* With `delete: true`, files under `dest` that are not covered by
|
|
71
|
+
* `sources` are removed (rsync `--delete` semantics).
|
|
72
|
+
*
|
|
73
|
+
* @param fs - Filesystem snapshot (must be writable, i.e. a branch).
|
|
74
|
+
* @param sources - One or more local paths to copy. A trailing `/` means "contents of directory".
|
|
75
|
+
* @param dest - Destination path in the repo tree.
|
|
76
|
+
* @param opts - Copy options.
|
|
77
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
78
|
+
* @param opts.followSymlinks - Dereference symlinks instead of storing them. Default `false`.
|
|
79
|
+
* @param opts.message - Custom commit message.
|
|
80
|
+
* @param opts.mode - Override file mode for all written files.
|
|
81
|
+
* @param opts.ignoreExisting - Skip files that already exist at the destination. Default `false`.
|
|
82
|
+
* @param opts.delete - Remove destination files not present in sources. Default `false`.
|
|
83
|
+
* @param opts.ignoreErrors - Continue on per-file errors, collecting them in `changes.errors`. Default `false`.
|
|
84
|
+
* @param opts.checksum - Use content hashing to detect changes. When `false`, uses mtime comparison. Default `true`.
|
|
85
|
+
* @param opts.operation - Operation name for the commit message. Default `"cp"`.
|
|
86
|
+
* @returns FS snapshot after the copy, with `.changes` set.
|
|
87
|
+
* @throws {FileNotFoundError} If a source path does not exist (unless `ignoreErrors` is set).
|
|
88
|
+
* @throws {NotADirectoryError} If a trailing-`/` source is not a directory.
|
|
89
|
+
*/
|
|
90
|
+
export declare function copyIn(fs: FS, sources: string | string[], dest: string, opts?: {
|
|
91
|
+
dryRun?: boolean;
|
|
92
|
+
followSymlinks?: boolean;
|
|
93
|
+
message?: string;
|
|
94
|
+
mode?: string;
|
|
95
|
+
ignoreExisting?: boolean;
|
|
96
|
+
delete?: boolean;
|
|
97
|
+
ignoreErrors?: boolean;
|
|
98
|
+
checksum?: boolean;
|
|
99
|
+
operation?: string;
|
|
100
|
+
exclude?: ExcludeFilter;
|
|
101
|
+
}): Promise<FS>;
|
|
102
|
+
/**
|
|
103
|
+
* Copy repo files, directories, or globs to local disk.
|
|
104
|
+
*
|
|
105
|
+
* Sources may use a trailing `/` for "contents" mode (pour directory
|
|
106
|
+
* contents into `dest` without creating a subdirectory).
|
|
107
|
+
*
|
|
108
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
109
|
+
* returned with `.changes` populated.
|
|
110
|
+
*
|
|
111
|
+
* With `delete: true`, local files under `dest` that are not covered
|
|
112
|
+
* by `sources` are removed (rsync `--delete` semantics).
|
|
113
|
+
*
|
|
114
|
+
* @param fs - Filesystem snapshot to copy from.
|
|
115
|
+
* @param sources - One or more repo paths to copy. A trailing `/` means "contents of directory".
|
|
116
|
+
* @param dest - Destination directory on local disk.
|
|
117
|
+
* @param opts - Copy options.
|
|
118
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
119
|
+
* @param opts.ignoreExisting - Skip files that already exist at the destination. Default `false`.
|
|
120
|
+
* @param opts.delete - Remove local files not present in sources. Default `false`.
|
|
121
|
+
* @param opts.ignoreErrors - Continue on per-file errors, collecting them in `changes.errors`. Default `false`.
|
|
122
|
+
* @param opts.checksum - Use content hashing to detect changes. When `false`, uses mtime comparison. Default `true`.
|
|
123
|
+
* @param opts.operation - Operation name for the commit message.
|
|
124
|
+
* @returns FS snapshot with `.changes` set describing what was copied.
|
|
125
|
+
* @throws {FileNotFoundError} If a source path does not exist in the repo (unless `ignoreErrors` is set).
|
|
126
|
+
* @throws {NotADirectoryError} If a trailing-`/` source is not a directory.
|
|
127
|
+
*/
|
|
128
|
+
export declare function copyOut(fs: FS, sources: string | string[], dest: string, opts?: {
|
|
129
|
+
dryRun?: boolean;
|
|
130
|
+
ignoreExisting?: boolean;
|
|
131
|
+
delete?: boolean;
|
|
132
|
+
ignoreErrors?: boolean;
|
|
133
|
+
checksum?: boolean;
|
|
134
|
+
operation?: string;
|
|
135
|
+
}): Promise<FS>;
|
|
136
|
+
/**
|
|
137
|
+
* Remove files or directories from the repo.
|
|
138
|
+
*
|
|
139
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
140
|
+
* returned with `.changes` populated.
|
|
141
|
+
*
|
|
142
|
+
* @param fs - Filesystem snapshot (must be writable, i.e. a branch).
|
|
143
|
+
* @param sources - One or more repo paths to remove.
|
|
144
|
+
* @param opts - Remove options.
|
|
145
|
+
* @param opts.recursive - Allow removal of directories. Default `false`.
|
|
146
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
147
|
+
* @param opts.message - Custom commit message.
|
|
148
|
+
* @returns FS snapshot after the removal, with `.changes` set.
|
|
149
|
+
* @throws {FileNotFoundError} If no source matches any file.
|
|
150
|
+
* @throws {IsADirectoryError} If a source is a directory and `recursive` is `false`.
|
|
151
|
+
*/
|
|
152
|
+
export declare function remove(fs: FS, sources: string | string[], opts?: {
|
|
153
|
+
recursive?: boolean;
|
|
154
|
+
dryRun?: boolean;
|
|
155
|
+
message?: string;
|
|
156
|
+
}): Promise<FS>;
|
|
157
|
+
/**
|
|
158
|
+
* Make `repoPath` identical to `localPath` (disk to repo sync).
|
|
159
|
+
*
|
|
160
|
+
* Copies new and changed files from `localPath` into `repoPath` and
|
|
161
|
+
* deletes repo files that do not exist on disk. Equivalent to
|
|
162
|
+
* `copyIn` with `delete: true`.
|
|
163
|
+
*
|
|
164
|
+
* If `localPath` does not exist, all files under `repoPath` are
|
|
165
|
+
* deleted (treating the source as empty).
|
|
166
|
+
*
|
|
167
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
168
|
+
* returned with `.changes` populated.
|
|
169
|
+
*
|
|
170
|
+
* @param fs - Filesystem snapshot (must be writable, i.e. a branch).
|
|
171
|
+
* @param localPath - Source directory on local disk.
|
|
172
|
+
* @param repoPath - Destination path in the repo tree.
|
|
173
|
+
* @param opts - Sync options.
|
|
174
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
175
|
+
* @param opts.message - Custom commit message.
|
|
176
|
+
* @param opts.ignoreErrors - Continue on per-file errors. Default `false`.
|
|
177
|
+
* @param opts.checksum - Use content hashing. When `false`, uses mtime. Default `true`.
|
|
178
|
+
* @returns FS snapshot after sync, with `.changes` set.
|
|
179
|
+
* @throws {PermissionError} If the FS is read-only.
|
|
180
|
+
*/
|
|
181
|
+
export declare function syncIn(fs: FS, localPath: string, repoPath: string, opts?: {
|
|
182
|
+
dryRun?: boolean;
|
|
183
|
+
message?: string;
|
|
184
|
+
ignoreErrors?: boolean;
|
|
185
|
+
checksum?: boolean;
|
|
186
|
+
exclude?: ExcludeFilter;
|
|
187
|
+
}): Promise<FS>;
|
|
188
|
+
/**
|
|
189
|
+
* Make `localPath` identical to `repoPath` (repo to disk sync).
|
|
190
|
+
*
|
|
191
|
+
* Copies new and changed files from the repo to `localPath` and
|
|
192
|
+
* deletes local files that do not exist in the repo. Equivalent to
|
|
193
|
+
* `copyOut` with `delete: true`.
|
|
194
|
+
*
|
|
195
|
+
* If `repoPath` does not exist in the repo, all files under
|
|
196
|
+
* `localPath` are deleted (treating the source as empty).
|
|
197
|
+
*
|
|
198
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
199
|
+
* returned with `.changes` populated.
|
|
200
|
+
*
|
|
201
|
+
* @param fs - Filesystem snapshot to sync from.
|
|
202
|
+
* @param repoPath - Source path in the repo tree.
|
|
203
|
+
* @param localPath - Destination directory on local disk.
|
|
204
|
+
* @param opts - Sync options.
|
|
205
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
206
|
+
* @param opts.ignoreErrors - Continue on per-file errors. Default `false`.
|
|
207
|
+
* @param opts.checksum - Use content hashing. When `false`, uses mtime. Default `true`.
|
|
208
|
+
* @returns FS snapshot with `.changes` set describing what was synced.
|
|
209
|
+
*/
|
|
210
|
+
export declare function syncOut(fs: FS, repoPath: string, localPath: string, opts?: {
|
|
211
|
+
dryRun?: boolean;
|
|
212
|
+
ignoreErrors?: boolean;
|
|
213
|
+
checksum?: boolean;
|
|
214
|
+
}): Promise<FS>;
|
|
215
|
+
/**
|
|
216
|
+
* Move or rename files within the repo.
|
|
217
|
+
*
|
|
218
|
+
* Implements POSIX `mv` semantics: when there is a single source file
|
|
219
|
+
* and `dest` is not an existing directory and does not end with `/`,
|
|
220
|
+
* the destination is the exact target path (rename). Otherwise files
|
|
221
|
+
* are placed inside `dest`.
|
|
222
|
+
*
|
|
223
|
+
* With `dryRun: true`, no changes are written; the input FS is
|
|
224
|
+
* returned with `.changes` populated.
|
|
225
|
+
*
|
|
226
|
+
* @param fs - Filesystem snapshot (must be writable, i.e. a branch).
|
|
227
|
+
* @param sources - One or more repo paths to move.
|
|
228
|
+
* @param dest - Destination path in the repo tree.
|
|
229
|
+
* @param opts - Move options.
|
|
230
|
+
* @param opts.recursive - Allow moving directories. Default `false`.
|
|
231
|
+
* @param opts.dryRun - Preview changes without writing. Default `false`.
|
|
232
|
+
* @param opts.message - Custom commit message.
|
|
233
|
+
* @returns FS snapshot after the move, with `.changes` set.
|
|
234
|
+
* @throws {FileNotFoundError} If no source matches any file.
|
|
235
|
+
* @throws {IsADirectoryError} If a source is a directory and `recursive` is `false`.
|
|
236
|
+
* @throws {Error} If source and destination are the same path.
|
|
237
|
+
*/
|
|
238
|
+
export declare function move(fs: FS, sources: string | string[], dest: string, opts?: {
|
|
239
|
+
recursive?: boolean;
|
|
240
|
+
dryRun?: boolean;
|
|
241
|
+
message?: string;
|
|
242
|
+
}): Promise<FS>;
|