@wspc/cli 0.1.11 → 0.1.13
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 +41 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1520,9 +1520,9 @@ function createConsistencyFetch(opts) {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
|
|
1522
1522
|
// src/version.ts
|
|
1523
|
-
var VERSION = "0.1.
|
|
1523
|
+
var VERSION = "0.1.13";
|
|
1524
1524
|
var SPEC_SHA = "bec760cd";
|
|
1525
|
-
var SPEC_FETCHED_AT = "2026-07-
|
|
1525
|
+
var SPEC_FETCHED_AT = "2026-07-08T04:52:19.152Z";
|
|
1526
1526
|
var API_BASE = "https://api.wspc.ai";
|
|
1527
1527
|
|
|
1528
1528
|
// src/index.ts
|
|
@@ -5040,17 +5040,18 @@ async function writeDriveRealtimeState(root, realtime) {
|
|
|
5040
5040
|
async function withDriveLock(root, fn) {
|
|
5041
5041
|
await mkdir(join2(root, DRIVE_DIR), { recursive: true });
|
|
5042
5042
|
const lockFile = join2(root, DRIVE_DIR, "sync.lock");
|
|
5043
|
-
const
|
|
5043
|
+
const acquire = async () => {
|
|
5044
|
+
const handle = await open(lockFile, "wx");
|
|
5045
|
+
await handle.writeFile(String(process.pid));
|
|
5046
|
+
return handle;
|
|
5047
|
+
};
|
|
5048
|
+
const fh = await acquire().catch(async (error) => {
|
|
5044
5049
|
if (error.code !== "EEXIST") throw error;
|
|
5045
|
-
|
|
5046
|
-
if (statError.code === "ENOENT") return void 0;
|
|
5047
|
-
throw statError;
|
|
5048
|
-
});
|
|
5049
|
-
if (lockStat && Date.now() - lockStat.mtimeMs <= STALE_LOCK_MS) {
|
|
5050
|
+
if (!await isLockAbandoned(lockFile)) {
|
|
5050
5051
|
throw new Error("sync lock already exists");
|
|
5051
5052
|
}
|
|
5052
5053
|
await rm(lockFile, { force: true });
|
|
5053
|
-
return
|
|
5054
|
+
return acquire().catch((retryError) => {
|
|
5054
5055
|
if (retryError.code === "EEXIST") {
|
|
5055
5056
|
throw new Error("sync lock already exists");
|
|
5056
5057
|
}
|
|
@@ -5066,6 +5067,28 @@ async function withDriveLock(root, fn) {
|
|
|
5066
5067
|
});
|
|
5067
5068
|
}
|
|
5068
5069
|
}
|
|
5070
|
+
async function isLockAbandoned(lockFile) {
|
|
5071
|
+
const pid = await readLockPid(lockFile);
|
|
5072
|
+
if (pid !== void 0 && !isProcessAlive(pid)) return true;
|
|
5073
|
+
const lockStat = await stat2(lockFile).catch((statError) => {
|
|
5074
|
+
if (statError.code === "ENOENT") return void 0;
|
|
5075
|
+
throw statError;
|
|
5076
|
+
});
|
|
5077
|
+
return lockStat === void 0 || Date.now() - lockStat.mtimeMs > STALE_LOCK_MS;
|
|
5078
|
+
}
|
|
5079
|
+
async function readLockPid(lockFile) {
|
|
5080
|
+
const text = await readFile2(lockFile, "utf8").catch(() => void 0);
|
|
5081
|
+
if (text === void 0 || !/^\d+$/.test(text.trim())) return void 0;
|
|
5082
|
+
return Number(text.trim());
|
|
5083
|
+
}
|
|
5084
|
+
function isProcessAlive(pid) {
|
|
5085
|
+
try {
|
|
5086
|
+
process.kill(pid, 0);
|
|
5087
|
+
return true;
|
|
5088
|
+
} catch (error) {
|
|
5089
|
+
return error.code !== "ESRCH";
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5069
5092
|
function isRecord2(value) {
|
|
5070
5093
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5071
5094
|
}
|
|
@@ -6604,7 +6627,14 @@ async function runDriveWatch(root, options = {}) {
|
|
|
6604
6627
|
const runSync = options.runSync ?? runDriveSyncOnce;
|
|
6605
6628
|
const debounceMs = options.debounceMs ?? 500;
|
|
6606
6629
|
const remoteDebounceMs = options.remoteDebounceMs ?? 2e3;
|
|
6607
|
-
const emit = options.onEvent ?? ((event) =>
|
|
6630
|
+
const emit = options.onEvent ?? ((event) => {
|
|
6631
|
+
if (shouldOutputJson()) {
|
|
6632
|
+
process.stdout.write(`${JSON.stringify(event)}
|
|
6633
|
+
`);
|
|
6634
|
+
return;
|
|
6635
|
+
}
|
|
6636
|
+
render({ kind: "drive_watch", display: { shape: "object" } }, event);
|
|
6637
|
+
});
|
|
6608
6638
|
let debounceTimer;
|
|
6609
6639
|
let debounceDeadlineMs;
|
|
6610
6640
|
let retryTimer;
|
|
@@ -6628,6 +6658,7 @@ async function runDriveWatch(root, options = {}) {
|
|
|
6628
6658
|
do {
|
|
6629
6659
|
rerunRequested = false;
|
|
6630
6660
|
try {
|
|
6661
|
+
emit({ kind: "drive_sync_start" });
|
|
6631
6662
|
const summary = await runSync(root);
|
|
6632
6663
|
emit({ kind: "drive_sync_once", ...summary });
|
|
6633
6664
|
backoffMs = 1e3;
|