@poli-page/cli 0.11.0 → 0.12.0

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.
Files changed (78) hide show
  1. package/README.md +91 -30
  2. package/dist/api-client.d.ts +42 -2
  3. package/dist/api-client.d.ts.map +1 -1
  4. package/dist/api-client.js +117 -4
  5. package/dist/api-client.js.map +1 -1
  6. package/dist/cloud-context.d.ts +1 -1
  7. package/dist/cloud-context.js +1 -1
  8. package/dist/commands/clone.d.ts +32 -0
  9. package/dist/commands/clone.d.ts.map +1 -0
  10. package/dist/commands/clone.js +266 -0
  11. package/dist/commands/clone.js.map +1 -0
  12. package/dist/commands/dev.d.ts +55 -3
  13. package/dist/commands/dev.d.ts.map +1 -1
  14. package/dist/commands/dev.js +307 -46
  15. package/dist/commands/dev.js.map +1 -1
  16. package/dist/commands/init.d.ts.map +1 -1
  17. package/dist/commands/init.js +8 -8
  18. package/dist/commands/init.js.map +1 -1
  19. package/dist/commands/link.d.ts +9 -0
  20. package/dist/commands/link.d.ts.map +1 -1
  21. package/dist/commands/link.js +25 -10
  22. package/dist/commands/link.js.map +1 -1
  23. package/dist/commands/new.d.ts.map +1 -1
  24. package/dist/commands/new.js +1 -7
  25. package/dist/commands/new.js.map +1 -1
  26. package/dist/commands/publish.js +1 -1
  27. package/dist/commands/publish.js.map +1 -1
  28. package/dist/commands/sync.d.ts +52 -0
  29. package/dist/commands/sync.d.ts.map +1 -0
  30. package/dist/commands/sync.js +224 -0
  31. package/dist/commands/sync.js.map +1 -0
  32. package/dist/constants.d.ts +1 -0
  33. package/dist/constants.d.ts.map +1 -1
  34. package/dist/constants.js +1 -0
  35. package/dist/constants.js.map +1 -1
  36. package/dist/credentials.d.ts +6 -1
  37. package/dist/credentials.d.ts.map +1 -1
  38. package/dist/credentials.js +28 -10
  39. package/dist/credentials.js.map +1 -1
  40. package/dist/dev-page.d.ts.map +1 -1
  41. package/dist/dev-page.js +24 -0
  42. package/dist/dev-page.js.map +1 -1
  43. package/dist/draft-bases.d.ts +54 -0
  44. package/dist/draft-bases.d.ts.map +1 -0
  45. package/dist/draft-bases.js +253 -0
  46. package/dist/draft-bases.js.map +1 -0
  47. package/dist/draft-files.d.ts +96 -0
  48. package/dist/draft-files.d.ts.map +1 -0
  49. package/dist/draft-files.js +447 -0
  50. package/dist/draft-files.js.map +1 -0
  51. package/dist/exit-codes.d.ts +3 -1
  52. package/dist/exit-codes.d.ts.map +1 -1
  53. package/dist/exit-codes.js +3 -1
  54. package/dist/exit-codes.js.map +1 -1
  55. package/dist/program.d.ts.map +1 -1
  56. package/dist/program.js +6 -3
  57. package/dist/program.js.map +1 -1
  58. package/dist/project-files.d.ts +8 -1
  59. package/dist/project-files.d.ts.map +1 -1
  60. package/dist/project-files.js +22 -1
  61. package/dist/project-files.js.map +1 -1
  62. package/dist/project-sync.d.ts +88 -16
  63. package/dist/project-sync.d.ts.map +1 -1
  64. package/dist/project-sync.js +283 -46
  65. package/dist/project-sync.js.map +1 -1
  66. package/dist/slug.d.ts +8 -0
  67. package/dist/slug.d.ts.map +1 -0
  68. package/dist/slug.js +15 -0
  69. package/dist/slug.js.map +1 -0
  70. package/dist/sync-engine.d.ts +14 -9
  71. package/dist/sync-engine.d.ts.map +1 -1
  72. package/dist/sync-engine.js +26 -29
  73. package/dist/sync-engine.js.map +1 -1
  74. package/package.json +1 -1
  75. package/dist/commands/watch.d.ts +0 -29
  76. package/dist/commands/watch.d.ts.map +0 -1
  77. package/dist/commands/watch.js +0 -108
  78. package/dist/commands/watch.js.map +0 -1
@@ -0,0 +1,96 @@
1
+ import type { ApiClient, DraftConflict, DraftFile } from './api-client.js';
2
+ import type { CloudContext } from './cloud-context.js';
3
+ import { type SyncableFiles } from './project-sync.js';
4
+ /** A draft file that could not be downloaded as listed. Names the path, never the URL. */
5
+ export declare class DownloadError extends Error {
6
+ readonly exitCode: 3;
7
+ }
8
+ /** A draft listing the CLI refuses to write: an unsafe path, or over the clone caps. */
9
+ export declare class DraftListingError extends Error {
10
+ readonly exitCode: 3;
11
+ }
12
+ /** The API's cap on the files of one project. */
13
+ export declare const MAX_CLONE_FILES = 1000;
14
+ /** What one clone holds in memory before it writes anything. */
15
+ export declare const MAX_CLONE_BYTES: number;
16
+ export declare function sha256Hex(bytes: Uint8Array | string): string;
17
+ /**
18
+ * Downloads one listed file and checks its size and SHA-256 against the
19
+ * listing, reading at most `file.size` bytes. A `403` (the presigned URL
20
+ * expired) lists the draft again once and retries with the new URL; the
21
+ * bytes must still match the original listing, so a file changed in the
22
+ * meantime fails rather than mixing two states of the draft.
23
+ */
24
+ export declare function downloadDraftFile(file: DraftFile, relist: () => Promise<DraftFile[]>, fetchFn?: typeof fetch): Promise<Buffer>;
25
+ /**
26
+ * Throws unless every listed path is one the CLI may write on any OS, and
27
+ * the listing fits the clone caps. Checked as a whole before any download:
28
+ * the paths come from the server and are untrusted.
29
+ */
30
+ export declare function checkDraftListing(files: DraftFile[]): void;
31
+ /**
32
+ * Downloads every listed file into memory, `DOWNLOAD_CONCURRENCY` at a
33
+ * time; the first failure fails the whole. `list` is called at most once
34
+ * more, shared by every file that meets a `403`.
35
+ */
36
+ export declare function downloadDraft(files: DraftFile[], list: () => Promise<DraftFile[]>, fetchFn?: typeof fetch): Promise<Map<string, Buffer>>;
37
+ /**
38
+ * A file the draft and the folder disagree on: `remoteSha256` is the
39
+ * draft's hash, `null` when the draft has no such file. A conflict the
40
+ * sync reports also says, in `localSha256`, whether this folder has the
41
+ * file (`null`: it does not, so keeping "mine" deletes it from the draft),
42
+ * and `reconciled` when the reconciliation of a folder with no bases found
43
+ * it (nobody knows which side changed it).
44
+ */
45
+ export interface Conflict extends DraftConflict {
46
+ localSha256?: string | null;
47
+ reconciled?: true;
48
+ }
49
+ /**
50
+ * The hash the sync will see for `bytes` once they are on disk at `path`:
51
+ * a text file is read as UTF-8, so bytes that are not valid UTF-8 hash
52
+ * differently from the draft's.
53
+ */
54
+ export declare function localHashOf(path: string, bytes: Buffer): string;
55
+ /**
56
+ * First agreement of a folder that has no bases with the cloud draft
57
+ * (a folder linked by an older CLI, `poli link --existing`, `poli init
58
+ * --starter`). A local file with the draft's hash, or a manifest that
59
+ * stores the same, gets that base; a file only the folder has stays
60
+ * unbased (sent later with base `null`); a file that differs, or one only
61
+ * the draft has, is a conflict. Records the bases and the conflicts (as
62
+ * pending, so a later process still finds them), sends nothing, and
63
+ * returns the conflicts sorted by path.
64
+ */
65
+ export declare function reconcileDraft(ctx: CloudContext, cwd: string, client: ApiClient, homeDir?: string): Promise<Conflict[]>;
66
+ /**
67
+ * Settles, without asking, the conflicts of a refused sync that are not
68
+ * one (decision: same bytes are the same file): the draft already holds the
69
+ * local bytes (a sync whose answer was lost), the manifest stores the same,
70
+ * or the file is gone on both sides. Records their bases and returns the
71
+ * others.
72
+ */
73
+ export declare function settleConflicts(ctx: CloudContext, cwd: string, client: ApiClient, conflicts: Conflict[], local: Pick<SyncableFiles, 'contents' | 'hashes'>, homeDir?: string): Promise<Conflict[]>;
74
+ /**
75
+ * Applies the user's choice to each conflict and records both hashes:
76
+ *
77
+ * - `mine`: the draft's current hash becomes the base, so the next sync
78
+ * sends the local file over it (or, `null`, sends it as new).
79
+ * - `theirs`: the draft is listed afresh; a file whose hash moved again
80
+ * since the conflict, or whose local file changed since then, is not
81
+ * written and comes back as still in conflict. Otherwise the verified
82
+ * download replaces the local file (the manifest keeps `cloud` and its
83
+ * client-only keys), or, `null`, the local file is deleted.
84
+ *
85
+ * Resolved paths leave the folder's pending conflicts. A folder with no
86
+ * entry in the store (never reconciled, or forgotten) is left untouched:
87
+ * every resolution comes back as still open, and the next sync reconciles.
88
+ *
89
+ * Returns the conflicts still open, with the draft's current hash.
90
+ */
91
+ export declare function resolveConflicts(ctx: CloudContext, cwd: string, client: ApiClient, resolutions: Array<{
92
+ path: string;
93
+ choice: 'mine' | 'theirs';
94
+ remoteSha256: string | null;
95
+ }>, homeDir?: string): Promise<Conflict[]>;
96
+ //# sourceMappingURL=draft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,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,IAAI,CAAC;CAClB;AAWD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAM/D;AAgBD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CACnC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC,CA2BrB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,QAAQ,CAAC,EACjD,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoCrB;AA0ED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,EAC5F,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC,CAiErB"}
@@ -0,0 +1,447 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstat, readFile, unlink } from 'node:fs/promises';
3
+ import { MANIFEST_FILENAME } from './constants.js';
4
+ import { manifestsEquivalent, readPending, updateBases, writeBases, } from './draft-bases.js';
5
+ import { ExitCode } from './exit-codes.js';
6
+ import { oneLine } from './output.js';
7
+ import { isAcceptedProjectPath, isPortableProjectPath, projectFileEncoding, } from './project-files.js';
8
+ import { readSyncableFiles } from './project-sync.js';
9
+ import { assertSafeRelativePath, resolveInside, resolveWritable, safeWriteFile, } from './security/paths.js';
10
+ import { hashContent } from './sync-engine.js';
11
+ /** A draft file that could not be downloaded as listed. Names the path, never the URL. */
12
+ export class DownloadError extends Error {
13
+ exitCode = ExitCode.NETWORK_OR_API_ERROR;
14
+ }
15
+ /** A draft listing the CLI refuses to write: an unsafe path, or over the clone caps. */
16
+ export class DraftListingError extends Error {
17
+ exitCode = ExitCode.NETWORK_OR_API_ERROR;
18
+ }
19
+ /** The API's cap on the files of one project. */
20
+ export const MAX_CLONE_FILES = 1000;
21
+ /** What one clone holds in memory before it writes anything. */
22
+ export const MAX_CLONE_BYTES = 20 * 1024 * 1024;
23
+ /**
24
+ * Per file, request and body together. A file is at most 5 MiB: 60 s lets
25
+ * it through at about 700 kbit/s, and still ends a stalled transfer well
26
+ * before the listing's URLs (valid at least 15 minutes) expire.
27
+ */
28
+ const DOWNLOAD_TIMEOUT_MS = 60_000;
29
+ export function sha256Hex(bytes) {
30
+ return createHash('sha256').update(bytes).digest('hex');
31
+ }
32
+ function quote(path) {
33
+ return JSON.stringify(oneLine(path));
34
+ }
35
+ function downloadError(path, reason) {
36
+ return new DownloadError(`Could not download ${quote(path)}: ${reason}.`);
37
+ }
38
+ async function fetchVerified(file, url, fetchFn) {
39
+ let response;
40
+ try {
41
+ // Presigned: the URL is the credential, so no Authorization header,
42
+ // and no redirect that could take the request elsewhere.
43
+ response = await fetchFn(url, {
44
+ redirect: 'error',
45
+ signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),
46
+ });
47
+ }
48
+ catch {
49
+ // The error may quote the URL: never pass it on.
50
+ throw downloadError(file.path, 'the request failed');
51
+ }
52
+ if (response.status === 403) {
53
+ await response.body?.cancel().catch(() => { });
54
+ return { forbidden: true };
55
+ }
56
+ if (!response.ok) {
57
+ await response.body?.cancel().catch(() => { });
58
+ throw downloadError(file.path, `the storage answered HTTP ${response.status}`);
59
+ }
60
+ const chunks = [];
61
+ let total = 0;
62
+ if (response.body) {
63
+ const reader = response.body.getReader();
64
+ try {
65
+ for (;;) {
66
+ const { done, value } = await reader.read();
67
+ if (done)
68
+ break;
69
+ total += value.byteLength;
70
+ if (total > file.size) {
71
+ await reader.cancel().catch(() => { });
72
+ throw downloadError(file.path, 'it is larger than listed');
73
+ }
74
+ chunks.push(value);
75
+ }
76
+ }
77
+ catch (err) {
78
+ if (err instanceof DownloadError)
79
+ throw err;
80
+ throw downloadError(file.path, 'the transfer failed');
81
+ }
82
+ }
83
+ const bytes = Buffer.concat(chunks, total);
84
+ if (bytes.length !== file.size)
85
+ throw downloadError(file.path, 'it is smaller than listed');
86
+ if (sha256Hex(bytes) !== file.sha256) {
87
+ throw downloadError(file.path, 'its content does not match the listed hash');
88
+ }
89
+ return { bytes };
90
+ }
91
+ /**
92
+ * Downloads one listed file and checks its size and SHA-256 against the
93
+ * listing, reading at most `file.size` bytes. A `403` (the presigned URL
94
+ * expired) lists the draft again once and retries with the new URL; the
95
+ * bytes must still match the original listing, so a file changed in the
96
+ * meantime fails rather than mixing two states of the draft.
97
+ */
98
+ export async function downloadDraftFile(file, relist, fetchFn = fetch) {
99
+ const first = await fetchVerified(file, file.url, fetchFn);
100
+ if ('bytes' in first)
101
+ return first.bytes;
102
+ let fresh;
103
+ try {
104
+ fresh = (await relist()).find((f) => f.path === file.path);
105
+ }
106
+ catch {
107
+ throw downloadError(file.path, 'access was refused and the draft could not be listed again');
108
+ }
109
+ if (!fresh)
110
+ throw downloadError(file.path, 'it is no longer in the draft');
111
+ if (fresh.sha256 !== file.sha256 || fresh.size !== file.size) {
112
+ throw downloadError(file.path, 'it changed in the cloud during the download; try again');
113
+ }
114
+ const second = await fetchVerified(file, fresh.url, fetchFn);
115
+ if ('bytes' in second)
116
+ return second.bytes;
117
+ throw downloadError(file.path, 'access was refused');
118
+ }
119
+ /**
120
+ * Throws unless every listed path is one the CLI may write on any OS, and
121
+ * the listing fits the clone caps. Checked as a whole before any download:
122
+ * the paths come from the server and are untrusted.
123
+ */
124
+ export function checkDraftListing(files) {
125
+ if (files.length > MAX_CLONE_FILES) {
126
+ throw new DraftListingError(`The draft lists ${files.length} files, over the limit of ${MAX_CLONE_FILES}.`);
127
+ }
128
+ const total = files.reduce((sum, f) => sum + f.size, 0);
129
+ if (total > MAX_CLONE_BYTES) {
130
+ throw new DraftListingError('The draft is larger than 20 MiB, the most a clone downloads.');
131
+ }
132
+ const seen = new Set();
133
+ const folders = new Set();
134
+ for (const { path } of files) {
135
+ let safe = isAcceptedProjectPath(path) && isPortableProjectPath(path);
136
+ if (safe) {
137
+ try {
138
+ assertSafeRelativePath(path);
139
+ }
140
+ catch {
141
+ safe = false;
142
+ }
143
+ }
144
+ if (!safe) {
145
+ throw new DraftListingError(`The draft has a file this CLI will not write: ${quote(path)}. Rename it in the editor, then clone again.`);
146
+ }
147
+ // Two paths one file system may treat as one (case, Unicode form).
148
+ const key = path.normalize('NFC').toLowerCase();
149
+ if (seen.has(key)) {
150
+ throw new DraftListingError(`The draft lists ${quote(path)} more than once, or with another letter case.`);
151
+ }
152
+ seen.add(key);
153
+ const segments = key.split('/');
154
+ for (let i = 1; i < segments.length; i++)
155
+ folders.add(segments.slice(0, i).join('/'));
156
+ }
157
+ for (const { path } of files) {
158
+ if (folders.has(path.normalize('NFC').toLowerCase())) {
159
+ throw new DraftListingError(`The draft lists ${quote(path)} both as a file and as a folder.`);
160
+ }
161
+ }
162
+ }
163
+ /** How many downloads run at once. */
164
+ const DOWNLOAD_CONCURRENCY = 6;
165
+ /**
166
+ * Downloads every listed file into memory, `DOWNLOAD_CONCURRENCY` at a
167
+ * time; the first failure fails the whole. `list` is called at most once
168
+ * more, shared by every file that meets a `403`.
169
+ */
170
+ export async function downloadDraft(files, list, fetchFn = fetch) {
171
+ let relisted;
172
+ const relist = () => (relisted ??= list());
173
+ const out = new Map();
174
+ let next = 0;
175
+ let failed = false;
176
+ const worker = async () => {
177
+ while (!failed && next < files.length) {
178
+ const file = files[next++];
179
+ try {
180
+ out.set(file.path, await downloadDraftFile(file, relist, fetchFn));
181
+ }
182
+ catch (err) {
183
+ failed = true;
184
+ throw err;
185
+ }
186
+ }
187
+ };
188
+ await Promise.all(Array.from({ length: Math.min(DOWNLOAD_CONCURRENCY, files.length) }, worker));
189
+ return out;
190
+ }
191
+ /**
192
+ * A path from the server the sync may compare, write or delete: in the
193
+ * file set and portable, as the sync's own files are. Every write or
194
+ * delete still goes through `resolveInside` / `resolveWritable`.
195
+ */
196
+ function isSyncablePath(path) {
197
+ return isAcceptedProjectPath(path) && isPortableProjectPath(path);
198
+ }
199
+ /**
200
+ * The hash the sync will see for `bytes` once they are on disk at `path`:
201
+ * a text file is read as UTF-8, so bytes that are not valid UTF-8 hash
202
+ * differently from the draft's.
203
+ */
204
+ export function localHashOf(path, bytes) {
205
+ const encoding = projectFileEncoding(path);
206
+ return hashContent({
207
+ encoding,
208
+ content: bytes.toString(encoding === 'base64' ? 'base64' : 'utf-8'),
209
+ });
210
+ }
211
+ function byPath(a, b) {
212
+ return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
213
+ }
214
+ /** `true` when the draft's manifest `file` stores the same as the local `content`. */
215
+ async function sameManifest(file, content, relist) {
216
+ const bytes = await downloadDraftFile(file, relist);
217
+ return manifestsEquivalent(content, bytes.toString('utf-8'));
218
+ }
219
+ /**
220
+ * First agreement of a folder that has no bases with the cloud draft
221
+ * (a folder linked by an older CLI, `poli link --existing`, `poli init
222
+ * --starter`). A local file with the draft's hash, or a manifest that
223
+ * stores the same, gets that base; a file only the folder has stays
224
+ * unbased (sent later with base `null`); a file that differs, or one only
225
+ * the draft has, is a conflict. Records the bases and the conflicts (as
226
+ * pending, so a later process still finds them), sends nothing, and
227
+ * returns the conflicts sorted by path.
228
+ */
229
+ export async function reconcileDraft(ctx, cwd, client, homeDir) {
230
+ // Local first: a file set over the limits fails before any request.
231
+ const local = await readSyncableFiles(cwd);
232
+ const list = () => client.listDraftFiles(ctx.session, ctx.orgId, ctx.projectId);
233
+ const listing = await list();
234
+ const bases = {};
235
+ const conflicts = [];
236
+ for (const file of listing) {
237
+ // A path this CLI would never write is not this folder's to settle.
238
+ if (!isSyncablePath(file.path))
239
+ continue;
240
+ const hash = local.hashes.get(file.path);
241
+ const same = hash !== undefined &&
242
+ (hash === file.sha256 ||
243
+ (file.path === MANIFEST_FILENAME &&
244
+ (await sameManifest(file, local.contents.get(file.path), list))));
245
+ if (same)
246
+ bases[file.path] = { server: file.sha256, local: hash };
247
+ else
248
+ conflicts.push({ path: file.path, remoteSha256: file.sha256 });
249
+ }
250
+ conflicts.sort(byPath);
251
+ const pending = conflicts.map((c) => ({
252
+ ...c,
253
+ localSha256: local.hashes.get(c.path) ?? null,
254
+ reconciled: true,
255
+ }));
256
+ await writeBases(cwd, ctx.projectId, bases, homeDir, pending);
257
+ return conflicts;
258
+ }
259
+ /**
260
+ * Settles, without asking, the conflicts of a refused sync that are not
261
+ * one (decision: same bytes are the same file): the draft already holds the
262
+ * local bytes (a sync whose answer was lost), the manifest stores the same,
263
+ * or the file is gone on both sides. Records their bases and returns the
264
+ * others.
265
+ */
266
+ export async function settleConflicts(ctx, cwd, client, conflicts, local, homeDir) {
267
+ const list = () => client.listDraftFiles(ctx.session, ctx.orgId, ctx.projectId);
268
+ let listing;
269
+ const set = {};
270
+ const remove = [];
271
+ const left = [];
272
+ for (const conflict of conflicts) {
273
+ const hash = local.hashes.get(conflict.path);
274
+ if (conflict.remoteSha256 === null && hash === undefined) {
275
+ remove.push(conflict.path);
276
+ continue;
277
+ }
278
+ if (hash !== undefined && conflict.remoteSha256 === hash) {
279
+ set[conflict.path] = { server: hash, local: hash };
280
+ continue;
281
+ }
282
+ if (conflict.path === MANIFEST_FILENAME && hash !== undefined) {
283
+ const file = (await (listing ??= list())).find((f) => f.path === conflict.path && f.sha256 === conflict.remoteSha256);
284
+ if (file && (await sameManifest(file, local.contents.get(file.path), list))) {
285
+ set[file.path] = { server: file.sha256, local: hash };
286
+ continue;
287
+ }
288
+ }
289
+ left.push(conflict);
290
+ }
291
+ if (Object.keys(set).length > 0 || remove.length > 0) {
292
+ await updateBases(cwd, ctx.projectId, { set, remove, removePending: [...Object.keys(set), ...remove] }, homeDir);
293
+ }
294
+ return left;
295
+ }
296
+ function isRecord(value) {
297
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
298
+ }
299
+ const PAGINATION_KEYS = ['orphanThreshold', 'cssRenderingPrecision'];
300
+ /**
301
+ * The local manifest with the fields the API stores (`manifestProjection`)
302
+ * taken from the cloud's: `cloud` and every other key stay as they are.
303
+ */
304
+ function mergeCloudManifest(localText, serverText) {
305
+ let server;
306
+ try {
307
+ server = JSON.parse(serverText);
308
+ }
309
+ catch {
310
+ server = undefined;
311
+ }
312
+ if (!isRecord(server)) {
313
+ throw new DownloadError(`The cloud's ${MANIFEST_FILENAME} is not a JSON object.`);
314
+ }
315
+ let local;
316
+ try {
317
+ local = localText === null ? undefined : JSON.parse(localText);
318
+ }
319
+ catch {
320
+ local = undefined;
321
+ }
322
+ const out = isRecord(local) ? { ...local } : {};
323
+ const project = isRecord(out.project) ? { ...out.project } : {};
324
+ const name = isRecord(server.project) ? server.project.name : undefined;
325
+ if (name === undefined)
326
+ delete project.name;
327
+ else
328
+ project.name = name;
329
+ out.project = project;
330
+ const engine = isRecord(out.engine) ? { ...out.engine } : {};
331
+ const pagination = isRecord(engine.paginationOptions) ? { ...engine.paginationOptions } : {};
332
+ const serverEngine = isRecord(server.engine) ? server.engine : {};
333
+ const serverPagination = isRecord(serverEngine.paginationOptions)
334
+ ? serverEngine.paginationOptions
335
+ : {};
336
+ for (const key of PAGINATION_KEYS) {
337
+ if (serverPagination[key] === undefined)
338
+ delete pagination[key];
339
+ else
340
+ pagination[key] = serverPagination[key];
341
+ }
342
+ if (Object.keys(pagination).length > 0)
343
+ engine.paginationOptions = pagination;
344
+ else
345
+ delete engine.paginationOptions;
346
+ if (Object.keys(engine).length > 0)
347
+ out.engine = engine;
348
+ else
349
+ delete out.engine;
350
+ for (const key of ['fonts', 'templates']) {
351
+ if (Array.isArray(server[key]))
352
+ out[key] = server[key];
353
+ else
354
+ delete out[key];
355
+ }
356
+ return JSON.stringify(out, null, '\t') + '\n';
357
+ }
358
+ async function readLocalText(cwd, path) {
359
+ try {
360
+ return await readFile(await resolveWritable(cwd, path), 'utf-8');
361
+ }
362
+ catch (err) {
363
+ if (err.code === 'ENOENT')
364
+ return null;
365
+ throw err;
366
+ }
367
+ }
368
+ /** Deletes a regular file of the project; a symlink or anything else at `path` is left alone. */
369
+ async function removeLocalFile(cwd, path) {
370
+ const target = await resolveInside(cwd, path);
371
+ const stats = await lstat(target).catch(() => null);
372
+ if (stats?.isFile())
373
+ await unlink(target);
374
+ }
375
+ /**
376
+ * Applies the user's choice to each conflict and records both hashes:
377
+ *
378
+ * - `mine`: the draft's current hash becomes the base, so the next sync
379
+ * sends the local file over it (or, `null`, sends it as new).
380
+ * - `theirs`: the draft is listed afresh; a file whose hash moved again
381
+ * since the conflict, or whose local file changed since then, is not
382
+ * written and comes back as still in conflict. Otherwise the verified
383
+ * download replaces the local file (the manifest keeps `cloud` and its
384
+ * client-only keys), or, `null`, the local file is deleted.
385
+ *
386
+ * Resolved paths leave the folder's pending conflicts. A folder with no
387
+ * entry in the store (never reconciled, or forgotten) is left untouched:
388
+ * every resolution comes back as still open, and the next sync reconciles.
389
+ *
390
+ * Returns the conflicts still open, with the draft's current hash.
391
+ */
392
+ export async function resolveConflicts(ctx, cwd, client, resolutions, homeDir) {
393
+ for (const { path } of resolutions) {
394
+ if (!isSyncablePath(path)) {
395
+ throw new DraftListingError(`This CLI will not write ${quote(path)}.`);
396
+ }
397
+ }
398
+ const pending = await readPending(cwd, ctx.projectId, homeDir);
399
+ if (!pending)
400
+ return resolutions.map(({ path, remoteSha256 }) => ({ path, remoteSha256 }));
401
+ const atConflict = new Map(pending.map((p) => [p.path, p]));
402
+ const list = () => client.listDraftFiles(ctx.session, ctx.orgId, ctx.projectId);
403
+ let fresh;
404
+ let local;
405
+ const set = {};
406
+ const remove = [];
407
+ const left = [];
408
+ for (const { path, choice, remoteSha256 } of resolutions) {
409
+ if (choice === 'mine') {
410
+ if (remoteSha256 === null)
411
+ remove.push(path);
412
+ // `local` is set to the draft's hash too: unless the local bytes
413
+ // are the draft's, it differs from them, so the next sync sends
414
+ // the file, with the draft's hash as its base.
415
+ else
416
+ set[path] = { server: remoteSha256, local: remoteSha256 };
417
+ continue;
418
+ }
419
+ fresh ??= new Map((await list()).map((f) => [f.path, f]));
420
+ local ??= await readSyncableFiles(cwd);
421
+ const now = fresh.get(path);
422
+ const localNow = local.hashes.get(path) ?? null;
423
+ const localThen = atConflict.get(path)?.localSha256;
424
+ // Either side moved since the user saw the conflict: taking the
425
+ // draft's now would drop a change they never saw.
426
+ if ((now?.sha256 ?? null) !== remoteSha256 ||
427
+ (localThen !== undefined && localThen !== localNow)) {
428
+ left.push({ path, remoteSha256: now?.sha256 ?? null, localSha256: localNow });
429
+ continue;
430
+ }
431
+ if (!now) {
432
+ await removeLocalFile(cwd, path);
433
+ remove.push(path);
434
+ continue;
435
+ }
436
+ const bytes = await downloadDraftFile(now, list);
437
+ const written = path === MANIFEST_FILENAME
438
+ ? Buffer.from(mergeCloudManifest(await readLocalText(cwd, path), bytes.toString('utf-8')))
439
+ : bytes;
440
+ await safeWriteFile(cwd, path, written);
441
+ set[path] = { server: now.sha256, local: localHashOf(path, written) };
442
+ }
443
+ const resolved = resolutions.map((r) => r.path).filter((p) => !left.some((l) => l.path === p));
444
+ await updateBases(cwd, ctx.projectId, { set, remove, removePending: resolved, addPending: left }, homeDir);
445
+ return left.map(({ path, remoteSha256 }) => ({ path, remoteSha256 }));
446
+ }
447
+ //# sourceMappingURL=draft-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-files.js","sourceRoot":"","sources":["../src/draft-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AO,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;IACvE,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/F,MAAM,WAAW,CAChB,GAAG,EACH,GAAG,CAAC,SAAS,EACb,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,EAC1D,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -19,6 +19,8 @@ export declare const ExitCode: {
19
19
  readonly NOT_AUTHENTICATED: 4;
20
20
  readonly NOT_AUTHORIZED: 5;
21
21
  readonly INVALID_LOCAL_STATE: 6;
22
+ /** A sync refused for files someone else changed, still unresolved. */
23
+ readonly CONFLICT: 7;
22
24
  };
23
25
  export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];
24
26
  /** Bad arguments or flags: exits with INVALID_USAGE through `errorToExitCode`. */
@@ -30,7 +32,7 @@ export declare class UsageError extends Error {
30
32
  * catch blocks instead of hardcoding `process.exitCode = 1`.
31
33
  *
32
34
  * Honours an explicit `exitCode` property on the error if present (used
33
- * by sentinels like TtyRequiredError).
35
+ * by sentinels like UsageError).
34
36
  */
35
37
  export declare function errorToExitCode(err: unknown): ExitCodeValue;
36
38
  //# sourceMappingURL=exit-codes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit-codes.d.ts","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ;;;;;;;;CAQX,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAErE,kFAAkF;AAClF,qBAAa,UAAW,SAAQ,KAAK;IACpC,QAAQ,CAAC,QAAQ,IAA0B;CAC3C;AAwBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAmE3D"}
1
+ {"version":3,"file":"exit-codes.d.ts","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ;;;;;;;;IAQpB,uEAAuE;;CAE9D,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAErE,kFAAkF;AAClF,qBAAa,UAAW,SAAQ,KAAK;IACpC,QAAQ,CAAC,QAAQ,IAA0B;CAC3C;AAwBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAmE3D"}
@@ -19,6 +19,8 @@ export const ExitCode = {
19
19
  NOT_AUTHENTICATED: 4,
20
20
  NOT_AUTHORIZED: 5,
21
21
  INVALID_LOCAL_STATE: 6,
22
+ /** A sync refused for files someone else changed, still unresolved. */
23
+ CONFLICT: 7,
22
24
  };
23
25
  /** Bad arguments or flags: exits with INVALID_USAGE through `errorToExitCode`. */
24
26
  export class UsageError extends Error {
@@ -31,7 +33,7 @@ import { ManifestValidationError } from './manifest.schema.js';
31
33
  * catch blocks instead of hardcoding `process.exitCode = 1`.
32
34
  *
33
35
  * Honours an explicit `exitCode` property on the error if present (used
34
- * by sentinels like TtyRequiredError).
36
+ * by sentinels like UsageError).
35
37
  */
36
38
  export function errorToExitCode(err) {
37
39
  if (err && typeof err === 'object' && 'exitCode' in err) {
@@ -1 +1 @@
1
- {"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,OAAO,EAAE,CAAC;IACV,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,CAAC;IAChB,oBAAoB,EAAE,CAAC;IACvB,iBAAiB,EAAE,CAAC;IACpB,cAAc,EAAE,CAAC;IACjB,mBAAmB,EAAE,CAAC;CACb,CAAC;AAIX,kFAAkF;AAClF,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC3B,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC;CAC3C;AAED,OAAO,EACN,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC3C,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACzD,MAAM,CAAC,GAAI,GAA8B,CAAC,QAAQ,CAAC;QACnD,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAkB,CAAC;IACtD,CAAC;IAED,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;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OAAO,QAAQ,CAAC,YAAY,CAAC;AAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,aAAa,YAqD5B"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC,wBAAgB,aAAa,YAuD5B"}