synartesis 0.3.0 → 0.3.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/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  toPayload,
25
25
  verifyAgainstServers,
26
26
  wasRefused
27
- } from "./chunk-FIIKQECN.js";
27
+ } from "./chunk-COIPI27I.js";
28
28
  import {
29
29
  DriftConflict,
30
30
  ManifestError,
@@ -1491,7 +1491,7 @@ function runList(journal, asJson, journalPath) {
1491
1491
  );
1492
1492
  }
1493
1493
  out("");
1494
- if (bytesOf(journalPath) > PRUNE_NAG_BYTES) {
1494
+ if ((bytesOf(journalPath) ?? 0) > PRUNE_NAG_BYTES) {
1495
1495
  out(` ${style.quiet(`This journal is ${sizeOf(journalPath)}; synartesis prune reclaims what is old enough to lose.`)}`);
1496
1496
  out("");
1497
1497
  }
@@ -1606,26 +1606,28 @@ function bytesOf(path) {
1606
1606
  try {
1607
1607
  return statSync(path).size;
1608
1608
  } catch {
1609
- return 0;
1609
+ return void 0;
1610
1610
  }
1611
1611
  }
1612
1612
  function sizeOf(path) {
1613
- try {
1614
- const bytes = bytesOf(path);
1615
- if (bytes < 1024 * 1024) {
1616
- return `${String(Math.max(1, Math.round(bytes / 1024)))} kB`;
1617
- }
1618
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1619
- } catch {
1613
+ const bytes = bytesOf(path);
1614
+ if (bytes === void 0) {
1620
1615
  return "unknown";
1621
1616
  }
1617
+ if (bytes < 1024 * 1024) {
1618
+ return `${String(Math.max(1, Math.round(bytes / 1024)))} kB`;
1619
+ }
1620
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1622
1621
  }
1623
1622
  var PRUNE_DEFAULT_DAYS = 30;
1623
+ var PRUNE_MAX_DAYS = 36500;
1624
1624
  function runPrune(argv, journal, journalPath) {
1625
1625
  const given = flag(argv, "--older-than");
1626
1626
  const days = given === void 0 ? PRUNE_DEFAULT_DAYS : Number(given);
1627
- if (!Number.isFinite(days) || days < 0) {
1628
- throw new UsageError(`--older-than takes a number of days, not ${given ?? ""}`);
1627
+ if (!Number.isFinite(days) || days < 0 || days > PRUNE_MAX_DAYS) {
1628
+ throw new UsageError(
1629
+ `--older-than takes a number of days from 0 to ${String(PRUNE_MAX_DAYS)}, not ${given ?? ""}`
1630
+ );
1629
1631
  }
1630
1632
  const before = new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
1631
1633
  const stale = journal.prunableRuns(before);