@myrialabs/clopen 0.4.44 → 0.4.45
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/backend/artifacts/project/bridge.ts +218 -0
- package/backend/artifacts/project/edit.ts +243 -0
- package/backend/artifacts/project/index.ts +38 -0
- package/backend/artifacts/project/project.test.ts +181 -0
- package/backend/artifacts/project/scan.ts +368 -0
- package/backend/artifacts/project/sources.ts +100 -0
- package/backend/artifacts/sync.ts +1 -1
- package/backend/auth/permissions.ts +15 -0
- package/backend/chat/stream-manager.ts +20 -3
- package/backend/database/migrations/083_create_project_mcp_trust.ts +32 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/index.ts +2 -0
- package/backend/database/queries/project-mcp-trust-queries.ts +43 -0
- package/backend/engine/adapters/claude/stream.ts +27 -1
- package/backend/engine/adapters/cline/mcp-tools.ts +26 -4
- package/backend/engine/adapters/cline/stream.ts +20 -6
- package/backend/engine/adapters/codex/stream.ts +21 -4
- package/backend/engine/adapters/copilot/stream.ts +6 -3
- package/backend/engine/adapters/cursor/stream.ts +19 -8
- package/backend/engine/adapters/opencode/server.ts +14 -4
- package/backend/engine/adapters/opencode/stream.ts +18 -3
- package/backend/engine/adapters/pi/mcp-tools.ts +26 -4
- package/backend/engine/adapters/pi/stream.ts +35 -3
- package/backend/engine/adapters/qwen/stream.ts +8 -0
- package/backend/engine/artifact-sync.ts +12 -5
- package/backend/files/file-watcher.test.ts +77 -0
- package/backend/files/file-watcher.ts +92 -60
- package/backend/files/watch-ignore.test.ts +182 -0
- package/backend/files/watch-ignore.ts +244 -0
- package/backend/git/git-executor.ts +14 -4
- package/backend/index.ts +11 -1
- package/backend/instructions/service.ts +5 -3
- package/backend/instructions/sync.ts +10 -27
- package/backend/mcp/external/config.ts +65 -23
- package/backend/mcp/external/project.ts +124 -0
- package/backend/mcp/external/proxy.ts +65 -11
- package/backend/mcp/index.ts +14 -9
- package/backend/mcp/internal/remote-server.ts +11 -1
- package/backend/skills/marketplace.ts +1 -1
- package/backend/snapshot/blob-store.ts +9 -5
- package/backend/snapshot/git-attribution.test.ts +42 -0
- package/backend/snapshot/git-attribution.ts +306 -0
- package/backend/snapshot/gitignore.test.ts +62 -0
- package/backend/snapshot/gitignore.ts +158 -78
- package/backend/snapshot/snapshot-service.test.ts +270 -0
- package/backend/snapshot/snapshot-service.ts +412 -136
- package/backend/snapshot/turn-activity.test.ts +52 -0
- package/backend/snapshot/turn-activity.ts +83 -0
- package/backend/snapshot/turn-changes.test.ts +58 -1
- package/backend/snapshot/turn-changes.ts +66 -0
- package/backend/worktrees/tree.ts +1 -1
- package/backend/ws/chat/composer.ts +504 -0
- package/backend/ws/chat/index.ts +3 -1
- package/backend/ws/chat/stream.ts +252 -440
- package/backend/ws/index.ts +4 -0
- package/backend/ws/project-artifacts/index.ts +236 -0
- package/backend/ws/snapshot/changes.ts +66 -31
- package/dist/assets/{index-BWyhqUi5.js → index-Am-rJRxA.js} +1 -1
- package/dist/assets/{index-DX5OwLOc.js → index-D-Ad1N96.js} +1 -1
- package/dist/assets/main--PLCDxSy.css +1 -0
- package/dist/assets/main-DelPm2Xt.js +1239 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/stores/settings.ts +5 -0
- package/shared/types/unified/message.ts +2 -0
- package/dist/assets/main-DOkwqXRU.js +0 -1215
- package/dist/assets/main-DzCY0n-j.css +0 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git's share of a turn's disk diff.
|
|
3
|
+
*
|
|
4
|
+
* A snapshot is a disk diff, so it cannot tell who changed a file. When the
|
|
5
|
+
* user pulls, merges or switches branch while a turn is running, every file
|
|
6
|
+
* git rewrote lands in that turn — one real case recorded a `git merge
|
|
7
|
+
* origin/main` as 50 files "changed by the AI". Worse than the wrong count,
|
|
8
|
+
* undoing that turn would have reverted the merge.
|
|
9
|
+
*
|
|
10
|
+
* The rule here: a change that moving HEAD explains belongs to git, not to the
|
|
11
|
+
* turn, whoever typed the command. A file whose content at capture is exactly
|
|
12
|
+
* the version git checked out is dropped from the turn. A file the turn edited
|
|
13
|
+
* on top of git's version keeps only the turn's part — its "before" becomes
|
|
14
|
+
* git's version, so undo reverts the edit and leaves the pull alone.
|
|
15
|
+
*
|
|
16
|
+
* Commits are the exception. `git commit` moves HEAD without touching the
|
|
17
|
+
* working tree: the files it records were written by whoever edited them, so
|
|
18
|
+
* reading a commit as git's own change would erase an agent's work the moment
|
|
19
|
+
* it committed it. The reflog says which kind each HEAD move was.
|
|
20
|
+
*
|
|
21
|
+
* Every answer here fails towards "not explained". When the reflog is off, git
|
|
22
|
+
* errors, or anything else is uncertain, the change stays in the turn —
|
|
23
|
+
* over-reporting is visible and harmless, silently dropping a real edit is not.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import path from 'path';
|
|
27
|
+
import fs from 'fs/promises';
|
|
28
|
+
import { execGit } from '../git/git-executor';
|
|
29
|
+
import { findNestedRepoPaths } from '../git/nested-repos';
|
|
30
|
+
import { blobStore } from './blob-store';
|
|
31
|
+
import type { SessionScopedChanges } from '$shared/types/database/schema';
|
|
32
|
+
import { debug } from '$shared/utils/logger';
|
|
33
|
+
|
|
34
|
+
/** Repository prefix ('' for the project root, `dir/` for a nested repo) → HEAD. */
|
|
35
|
+
export type RepoHeads = Map<string, string>;
|
|
36
|
+
|
|
37
|
+
export interface GitAttribution {
|
|
38
|
+
/** Paths whose whole change is git's, not the turn's. */
|
|
39
|
+
explained: Set<string>;
|
|
40
|
+
/** Paths the turn changed on top of git: the corrected "before" hash. */
|
|
41
|
+
rebased: Map<string, string>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One HEAD move that rewrote the working tree. */
|
|
45
|
+
interface Transition {
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Most paths passed to one git invocation — well under any argv limit. */
|
|
51
|
+
const PATH_BATCH = 200;
|
|
52
|
+
|
|
53
|
+
/** Reflog entries read per repository; a turn moving HEAD more is not plausible. */
|
|
54
|
+
const REFLOG_DEPTH = 200;
|
|
55
|
+
|
|
56
|
+
/** Pathspecs are literal: a file called `a[1].ts` must not act as a glob. */
|
|
57
|
+
const LITERAL = { GIT_LITERAL_PATHSPECS: '1' };
|
|
58
|
+
|
|
59
|
+
async function isRepo(dir: string): Promise<boolean> {
|
|
60
|
+
try {
|
|
61
|
+
await fs.access(path.join(dir, '.git'));
|
|
62
|
+
return true;
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function readHead(repoDir: string): Promise<string | null> {
|
|
69
|
+
try {
|
|
70
|
+
const result = await execGit(['rev-parse', '--verify', '-q', 'HEAD'], repoDir, { okExitCodes: [1] });
|
|
71
|
+
const sha = result.stdout.trim();
|
|
72
|
+
return result.exitCode === 0 && sha ? sha : null;
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* HEAD of the project and of every nested repository in it — the same set
|
|
80
|
+
* of repositories the snapshot scan reads. An unborn or unreadable HEAD is
|
|
81
|
+
* left out: there is nothing to compare it with later.
|
|
82
|
+
*/
|
|
83
|
+
export async function readRepoHeads(root: string): Promise<RepoHeads> {
|
|
84
|
+
const heads: RepoHeads = new Map();
|
|
85
|
+
|
|
86
|
+
const dirs: string[] = [];
|
|
87
|
+
if (await isRepo(root)) dirs.push(root);
|
|
88
|
+
try {
|
|
89
|
+
dirs.push(...await findNestedRepoPaths(root));
|
|
90
|
+
} catch (error) {
|
|
91
|
+
debug.warn('snapshot', 'Nested repo discovery failed while reading HEADs:', error);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await Promise.all(dirs.map(async (dir) => {
|
|
95
|
+
const head = await readHead(dir);
|
|
96
|
+
if (!head) return;
|
|
97
|
+
const relative = path.relative(root, dir).replace(/\\/g, '/');
|
|
98
|
+
heads.set(relative ? `${relative}/` : '', head);
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
return heads;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether a reflog subject is a commit authored from the working tree.
|
|
106
|
+
*
|
|
107
|
+
* `commit (merge)` is not: it concludes a merge, and the content it records
|
|
108
|
+
* came from the other branch.
|
|
109
|
+
*/
|
|
110
|
+
export function isAuthoredCommit(subject: string): boolean {
|
|
111
|
+
return /^commit( \((initial|amend)\))?:/.test(subject);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Parse `git log -g --date=unix --format=%H%x09%gd%x09%gs` output.
|
|
116
|
+
* Newest first, as git prints it.
|
|
117
|
+
*/
|
|
118
|
+
export function parseReflog(stdout: string): Array<{ sha: string; time: number; subject: string }> {
|
|
119
|
+
const entries: Array<{ sha: string; time: number; subject: string }> = [];
|
|
120
|
+
for (const line of stdout.split('\n')) {
|
|
121
|
+
const [sha, selector, ...rest] = line.split('\t');
|
|
122
|
+
if (!sha || !selector) continue;
|
|
123
|
+
const match = selector.match(/@\{(\d+)\}$/);
|
|
124
|
+
if (!match) continue;
|
|
125
|
+
entries.push({ sha, time: Number(match[1]), subject: rest.join('\t') });
|
|
126
|
+
}
|
|
127
|
+
return entries;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The HEAD moves since `sinceMs` that rewrote the working tree, oldest first.
|
|
132
|
+
*
|
|
133
|
+
* The reflog stamps seconds, so the window opens a second early; an entry that
|
|
134
|
+
* slips in from just before the turn only matters if it also touched a file
|
|
135
|
+
* this turn changed, and then its version still has to match the disk.
|
|
136
|
+
*/
|
|
137
|
+
export function workingTreeTransitions(
|
|
138
|
+
entries: Array<{ sha: string; time: number; subject: string }>,
|
|
139
|
+
startSha: string,
|
|
140
|
+
sinceMs: number
|
|
141
|
+
): Transition[] {
|
|
142
|
+
const since = Math.floor(sinceMs / 1000) - 1;
|
|
143
|
+
const window = [];
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
if (entry.time < since) break;
|
|
146
|
+
window.push(entry);
|
|
147
|
+
}
|
|
148
|
+
window.reverse();
|
|
149
|
+
|
|
150
|
+
const transitions: Transition[] = [];
|
|
151
|
+
let previous = startSha;
|
|
152
|
+
for (const entry of window) {
|
|
153
|
+
if (entry.sha !== previous && !isAuthoredCommit(entry.subject)) {
|
|
154
|
+
transitions.push({ from: previous, to: entry.sha });
|
|
155
|
+
}
|
|
156
|
+
previous = entry.sha;
|
|
157
|
+
}
|
|
158
|
+
return transitions;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function changedBetween(repoDir: string, from: string, to: string): Promise<string[]> {
|
|
162
|
+
const result = await execGit(['diff', '--name-only', '-z', '--no-renames', from, to], repoDir, 60_000);
|
|
163
|
+
if (result.exitCode !== 0) throw new Error(`git diff failed: ${result.stderr.trim()}`);
|
|
164
|
+
return result.stdout.split('\0').filter(Boolean);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Blob id of each path at `sha`; a path missing from the map is absent there. */
|
|
168
|
+
async function treeBlobs(repoDir: string, sha: string, paths: string[]): Promise<Map<string, string>> {
|
|
169
|
+
const blobs = new Map<string, string>();
|
|
170
|
+
for (let i = 0; i < paths.length; i += PATH_BATCH) {
|
|
171
|
+
const batch = paths.slice(i, i + PATH_BATCH);
|
|
172
|
+
const result = await execGit(['ls-tree', '-r', '-z', sha, '--', ...batch], repoDir, { env: LITERAL });
|
|
173
|
+
if (result.exitCode !== 0) throw new Error(`git ls-tree failed: ${result.stderr.trim()}`);
|
|
174
|
+
for (const record of result.stdout.split('\0')) {
|
|
175
|
+
const tab = record.indexOf('\t');
|
|
176
|
+
if (tab === -1) continue;
|
|
177
|
+
const [, type, object] = record.slice(0, tab).split(' ');
|
|
178
|
+
if (type === 'blob') blobs.set(record.slice(tab + 1), object);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return blobs;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Git's blob id for each file as it is on disk now, with the repository's
|
|
186
|
+
* clean filters applied — the id `git add` would give it. Comparing this with
|
|
187
|
+
* a tree entry is exact, where comparing raw bytes would call every CRLF
|
|
188
|
+
* checkout a modification.
|
|
189
|
+
*/
|
|
190
|
+
async function diskBlobs(repoDir: string, paths: string[]): Promise<Map<string, string>> {
|
|
191
|
+
const blobs = new Map<string, string>();
|
|
192
|
+
// --stdin-paths is newline-separated; a name containing one cannot be sent.
|
|
193
|
+
const sendable = paths.filter((p) => !p.includes('\n'));
|
|
194
|
+
for (let i = 0; i < sendable.length; i += PATH_BATCH) {
|
|
195
|
+
const batch = sendable.slice(i, i + PATH_BATCH);
|
|
196
|
+
const result = await execGit(['hash-object', '--stdin-paths'], repoDir, {
|
|
197
|
+
stdin: batch.join('\n') + '\n'
|
|
198
|
+
});
|
|
199
|
+
if (result.exitCode !== 0) throw new Error(`git hash-object failed: ${result.stderr.trim()}`);
|
|
200
|
+
const ids = result.stdout.split('\n').filter(Boolean);
|
|
201
|
+
if (ids.length !== batch.length) throw new Error('git hash-object returned a short list');
|
|
202
|
+
batch.forEach((p, index) => blobs.set(p, ids[index]));
|
|
203
|
+
}
|
|
204
|
+
return blobs;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Store git's checked-out version of a file and return its snapshot hash. */
|
|
208
|
+
async function storeGitVersion(repoDir: string, sha: string, repoPath: string): Promise<string> {
|
|
209
|
+
const result = await execGit(['cat-file', '--filters', `${sha}:${repoPath}`], repoDir, { raw: true });
|
|
210
|
+
if (result.exitCode !== 0 || !result.stdoutBytes) {
|
|
211
|
+
throw new Error(`git cat-file failed: ${result.stderr.trim()}`);
|
|
212
|
+
}
|
|
213
|
+
return blobStore.storeBlob(result.stdoutBytes);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Split a turn's changes into git's part and the turn's part.
|
|
218
|
+
*
|
|
219
|
+
* `startHeads` and `sinceMs` are what the turn recorded when it began.
|
|
220
|
+
*/
|
|
221
|
+
export async function attributeGitChanges(
|
|
222
|
+
root: string,
|
|
223
|
+
startHeads: RepoHeads,
|
|
224
|
+
sinceMs: number,
|
|
225
|
+
changes: SessionScopedChanges
|
|
226
|
+
): Promise<GitAttribution> {
|
|
227
|
+
const attribution: GitAttribution = { explained: new Set(), rebased: new Map() };
|
|
228
|
+
const changedPaths = Object.keys(changes);
|
|
229
|
+
if (changedPaths.length === 0 || startHeads.size === 0) return attribution;
|
|
230
|
+
|
|
231
|
+
// Longest prefix first, so a file inside a nested repo is never claimed by
|
|
232
|
+
// the outer one.
|
|
233
|
+
const prefixes = [...startHeads.keys()].sort((a, b) => b.length - a.length);
|
|
234
|
+
const byRepo = new Map<string, string[]>();
|
|
235
|
+
for (const changed of changedPaths) {
|
|
236
|
+
const prefix = prefixes.find((p) => changed.startsWith(p));
|
|
237
|
+
if (prefix === undefined) continue;
|
|
238
|
+
const list = byRepo.get(prefix) ?? [];
|
|
239
|
+
list.push(changed.slice(prefix.length));
|
|
240
|
+
byRepo.set(prefix, list);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
for (const [prefix, repoPaths] of byRepo) {
|
|
244
|
+
const repoDir = path.join(root, prefix);
|
|
245
|
+
const startSha = startHeads.get(prefix)!;
|
|
246
|
+
try {
|
|
247
|
+
const endSha = await readHead(repoDir);
|
|
248
|
+
if (!endSha || endSha === startSha) continue;
|
|
249
|
+
|
|
250
|
+
const reflog = await execGit(
|
|
251
|
+
['log', '-g', '--date=unix', '--format=%H%x09%gd%x09%gs', '-n', String(REFLOG_DEPTH), 'HEAD'],
|
|
252
|
+
repoDir,
|
|
253
|
+
30_000
|
|
254
|
+
);
|
|
255
|
+
if (reflog.exitCode !== 0) continue;
|
|
256
|
+
const transitions = workingTreeTransitions(parseReflog(reflog.stdout), startSha, sinceMs);
|
|
257
|
+
if (transitions.length === 0) continue;
|
|
258
|
+
|
|
259
|
+
// The version git last wrote for each path, and which commit holds it.
|
|
260
|
+
const lastVersion = new Map<string, string>();
|
|
261
|
+
for (const transition of transitions) {
|
|
262
|
+
for (const touched of await changedBetween(repoDir, transition.from, transition.to)) {
|
|
263
|
+
lastVersion.set(touched, transition.to);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const candidates = repoPaths.filter((p) => lastVersion.has(p));
|
|
268
|
+
if (candidates.length === 0) continue;
|
|
269
|
+
|
|
270
|
+
const bySha = new Map<string, string[]>();
|
|
271
|
+
for (const candidate of candidates) {
|
|
272
|
+
const sha = lastVersion.get(candidate)!;
|
|
273
|
+
bySha.set(sha, [...(bySha.get(sha) ?? []), candidate]);
|
|
274
|
+
}
|
|
275
|
+
const gitBlobs = new Map<string, string>();
|
|
276
|
+
for (const [sha, paths] of bySha) {
|
|
277
|
+
for (const [p, blob] of await treeBlobs(repoDir, sha, paths)) gitBlobs.set(p, blob);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const onDisk = candidates.filter((p) => changes[prefix + p].newHash !== '');
|
|
281
|
+
const current = await diskBlobs(repoDir, onDisk);
|
|
282
|
+
|
|
283
|
+
for (const candidate of candidates) {
|
|
284
|
+
const key = prefix + candidate;
|
|
285
|
+
const change = changes[key];
|
|
286
|
+
const gitBlob = gitBlobs.get(candidate);
|
|
287
|
+
const diskBlob = change.newHash ? current.get(candidate) : undefined;
|
|
288
|
+
if (change.newHash && diskBlob === undefined) continue;
|
|
289
|
+
|
|
290
|
+
if (gitBlob === diskBlob) {
|
|
291
|
+
attribution.explained.add(key);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const gitHash = gitBlob
|
|
296
|
+
? await storeGitVersion(repoDir, lastVersion.get(candidate)!, candidate)
|
|
297
|
+
: '';
|
|
298
|
+
if (gitHash !== change.oldHash) attribution.rebased.set(key, gitHash);
|
|
299
|
+
}
|
|
300
|
+
} catch (error) {
|
|
301
|
+
debug.warn('snapshot', `Git attribution skipped for ${repoDir || root}:`, error);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return attribution;
|
|
306
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The non-git scan: what it skips, and what it admits it could not read.
|
|
3
|
+
*
|
|
4
|
+
* A directory the scan could not list is not a directory whose files were
|
|
5
|
+
* deleted, and the snapshot can only tell the two apart if the scan says so.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
|
|
9
|
+
import { mkdtemp, rm, writeFile, mkdir, chmod } from 'node:fs/promises';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { scanSnapshotFiles } from './gitignore';
|
|
13
|
+
|
|
14
|
+
let root: string;
|
|
15
|
+
|
|
16
|
+
async function write(file: string, content = 'x'): Promise<void> {
|
|
17
|
+
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
|
18
|
+
await writeFile(path.join(root, file), content);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const relative = (files: string[]) => files.map((f) => path.relative(root, f).replace(/\\/g, '/')).sort();
|
|
22
|
+
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
root = await mkdtemp(path.join(tmpdir(), 'clopen-scan-'));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(async () => {
|
|
28
|
+
await chmod(path.join(root, 'locked'), 0o755).catch(() => {});
|
|
29
|
+
await rm(root, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('scanSnapshotFiles without git', () => {
|
|
33
|
+
it('prunes generated directories by name, by manifest and by signature', async () => {
|
|
34
|
+
await write('src/app.ts');
|
|
35
|
+
await write('dist/app.js');
|
|
36
|
+
await write('Cargo.toml');
|
|
37
|
+
await write('target/debug/app');
|
|
38
|
+
await write('env/pyvenv.cfg');
|
|
39
|
+
await write('env/lib/site.py');
|
|
40
|
+
|
|
41
|
+
const { files } = await scanSnapshotFiles(root, { pruneGenerated: true });
|
|
42
|
+
expect(relative(files)).toEqual(['Cargo.toml', 'src/app.ts']);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('keeps them when not asked to prune', async () => {
|
|
46
|
+
await write('src/app.ts');
|
|
47
|
+
await write('dist/app.js');
|
|
48
|
+
|
|
49
|
+
const { files } = await scanSnapshotFiles(root);
|
|
50
|
+
expect(relative(files)).toEqual(['dist/app.js', 'src/app.ts']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('reports a directory it could not read', async () => {
|
|
54
|
+
await write('src/app.ts');
|
|
55
|
+
await write('locked/secret.ts');
|
|
56
|
+
await chmod(path.join(root, 'locked'), 0o000);
|
|
57
|
+
|
|
58
|
+
const scan = await scanSnapshotFiles(root, { pruneGenerated: true });
|
|
59
|
+
expect(relative(scan.files)).toEqual(['src/app.ts']);
|
|
60
|
+
expect(scan.incomplete).toEqual(['locked/']);
|
|
61
|
+
});
|
|
62
|
+
});
|