@rigxyz/tapd 0.6.7 → 0.6.9

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/dist/bin.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  importStateDbPath,
18
18
  init,
19
19
  isSyncPaused,
20
+ isVersionPrunedError,
20
21
  join,
21
22
  list,
22
23
  loadIgnore,
@@ -25,12 +26,13 @@ import {
25
26
  openStateDb,
26
27
  quarantineFiles,
27
28
  readBindingConfig,
29
+ readMerges,
28
30
  readNotSynced,
29
31
  removeImport,
30
32
  revoke,
31
33
  safeResolveRigPath,
32
34
  start
33
- } from "./chunk-32K6ANXS.js";
35
+ } from "./chunk-57Z2Y3S2.js";
34
36
 
35
37
  // src/bin.ts
36
38
  import { join as pathJoin, resolve } from "path";
@@ -214,6 +216,18 @@ var PathCurrentlyDeletedError = class extends Error {
214
216
  path;
215
217
  lastCursor;
216
218
  };
219
+ var VersionPrunedError = class extends Error {
220
+ constructor(path, cursor) {
221
+ super(
222
+ "That version is no longer kept. Rig keeps every version from the last week, one an hour for 90 days, then one a day."
223
+ );
224
+ this.path = path;
225
+ this.cursor = cursor;
226
+ this.name = "VersionPrunedError";
227
+ }
228
+ path;
229
+ cursor;
230
+ };
217
231
  var HashMismatchError = class extends Error {
218
232
  constructor(path, expected, actual) {
219
233
  super(`Hash mismatch restoring "${path}": expected ${expected}, got ${actual}`);
@@ -258,7 +272,13 @@ async function restore(opts) {
258
272
  throw new PathNeverExistedError(opts.path);
259
273
  }
260
274
  const client = clientFor3(opts.rootDir, opts.fetch);
261
- const dl = await client.downloadUrl(writeEvent.hash);
275
+ let dl;
276
+ try {
277
+ dl = await client.downloadUrl(writeEvent.hash);
278
+ } catch (err) {
279
+ if (isVersionPrunedError(err)) throw new VersionPrunedError(opts.path, writeEvent.id);
280
+ throw err;
281
+ }
262
282
  const bytes = await client.getObjectBytes(dl.downloadUrl);
263
283
  const actualHash = `sha256:${sha256Hex(bytes)}`;
264
284
  if (actualHash !== writeEvent.hash) {
@@ -284,7 +304,7 @@ import { existsSync as existsSync4 } from "fs";
284
304
  import { join as join4 } from "path";
285
305
 
286
306
  // src/version.ts
287
- var TAPD_VERSION = "0.6.7";
307
+ var TAPD_VERSION = "0.6.9";
288
308
 
289
309
  // src/status.ts
290
310
  var STATE_KEY_LAST_APPLY_ERROR = "last_apply_error";
@@ -307,6 +327,7 @@ function statusToJson(report) {
307
327
  pendingUploads: report.pendingUploads,
308
328
  notSynced: report.notSynced,
309
329
  conflicts: report.conflicts,
330
+ merged: report.merged,
310
331
  lastApplyError: report.lastApplyError,
311
332
  offline: report.offline,
312
333
  mounts: report.mounts
@@ -363,6 +384,7 @@ async function status(opts) {
363
384
  notSynced: [],
364
385
  conflicts: [],
365
386
  conflictCount: 0,
387
+ merged: [],
366
388
  lastApplyError: null,
367
389
  daemon,
368
390
  offline: false,
@@ -424,6 +446,7 @@ async function status(opts) {
424
446
  notSynced: readNotSynced(db),
425
447
  conflicts,
426
448
  conflictCount,
449
+ merged: readMerges(db),
427
450
  lastApplyError,
428
451
  daemon,
429
452
  offline,
@@ -1138,6 +1161,12 @@ async function runStatus(flags2) {
1138
1161
  } else {
1139
1162
  console.log(` conflicts: ${C.dim("none")}`);
1140
1163
  }
1164
+ if (report.merged.length > 0) {
1165
+ console.log(` merged: ${report.merged.length} ${C.dim("(local + remote edits merged automatically, recent)")}`);
1166
+ for (const m of report.merged.slice(-5)) {
1167
+ console.log(C.dim(` ${m.path} with ${m.theirsChangeId}${m.changeId ? ` \u2192 ${m.changeId}` : " (upload pending)"} ${m.at}`));
1168
+ }
1169
+ }
1141
1170
  if (report.lastApplyError) {
1142
1171
  const e = report.lastApplyError;
1143
1172
  console.log(
@@ -1389,6 +1418,11 @@ async function runRestore(flags2) {
1389
1418
  else console.error(kleur.red("error:"), err.message);
1390
1419
  process.exit(1);
1391
1420
  }
1421
+ if (err instanceof VersionPrunedError) {
1422
+ if (json) printJsonError("version_pruned", err.message);
1423
+ else console.error(kleur.red("error:"), err.message);
1424
+ process.exit(1);
1425
+ }
1392
1426
  if (err instanceof HashMismatchError) {
1393
1427
  if (json) printJsonError("hash_mismatch", err.message);
1394
1428
  else console.error(kleur.red("error:"), err.message);