@geonosis/ratchet 0.2.1 → 0.4.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.
@@ -468,7 +468,8 @@ var counterById = (id) => {
468
468
  };
469
469
 
470
470
  // src/lock.ts
471
- import { closeSync, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync4, rmSync as rmSync2, writeSync } from "fs";
471
+ import { randomUUID } from "crypto";
472
+ import { linkSync, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
472
473
  import { homedir } from "os";
473
474
  import { dirname as dirname2, join as join3 } from "path";
474
475
  var heavyLockPath = () => process.env.GEONOSIS_HEAVY_LOCK ?? join3(homedir(), ".cache", "geonosis", "heavy.lock");
@@ -500,19 +501,21 @@ var heldFor = (holder) => {
500
501
  };
501
502
  var write = (path) => {
502
503
  mkdirSync2(dirname2(path), { recursive: true });
504
+ const mine = {
505
+ cwd: process.cwd(),
506
+ pid: process.pid,
507
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
508
+ };
509
+ const staging = `${path}.${process.pid}.${randomUUID()}`;
503
510
  try {
504
- const handle = openSync(path, "wx");
505
- const mine = {
506
- cwd: process.cwd(),
507
- pid: process.pid,
508
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
509
- };
510
- writeSync(handle, JSON.stringify(mine));
511
- closeSync(handle);
511
+ writeFileSync3(staging, JSON.stringify(mine));
512
+ linkSync(staging, path);
512
513
  return true;
513
514
  } catch (error) {
514
515
  if (error.code === "EEXIST") return false;
515
516
  throw error;
517
+ } finally {
518
+ rmSync2(staging, { force: true });
516
519
  }
517
520
  };
518
521
  var acquireExclusive = async ({
@@ -710,7 +713,7 @@ var formatProve = ({ proofs, proven }) => {
710
713
  };
711
714
 
712
715
  // src/ratchet.ts
713
- import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
716
+ import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
714
717
  import { resolve as resolve7 } from "path";
715
718
  var EVIDENCE_LINES = 10;
716
719
  var recorded = (run) => {
@@ -779,7 +782,7 @@ var runRatchet = async ({
779
782
  for (const one of measurements) {
780
783
  if (one.verdict !== "skipped") next[one.key] = one.now;
781
784
  }
782
- writeFileSync3(baselinePath, `${JSON.stringify(next, null, 2)}
785
+ writeFileSync4(baselinePath, `${JSON.stringify(next, null, 2)}
783
786
  `);
784
787
  return { measurements, rewritten: true };
785
788
  }
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  formatReport,
6
6
  runProve,
7
7
  runRatchet
8
- } from "./chunk-XYTUTPQI.js";
8
+ } from "./chunk-QVORWCUD.js";
9
9
 
10
10
  // src/cli.ts
11
11
  var cwdFlag = process.argv.indexOf("--cwd");
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  runCommand,
13
13
  runProve,
14
14
  runRatchet
15
- } from "./chunk-XYTUTPQI.js";
15
+ } from "./chunk-QVORWCUD.js";
16
16
  export {
17
17
  CONFIG_FILE,
18
18
  COUNTERS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geonosis/ratchet",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Debt as a number that may only shrink — one ratchet, pluggable counters.",
5
5
  "keywords": [
6
6
  "ratchet",