threadnote 0.7.3 → 0.7.4
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/threadnote.cjs +73 -15
- package/package.json +1 -1
package/dist/threadnote.cjs
CHANGED
|
@@ -10124,11 +10124,7 @@ async function runPostUpdate(config, options) {
|
|
|
10124
10124
|
throw new Error("Provide --from-version and --to-version for post-update.");
|
|
10125
10125
|
}
|
|
10126
10126
|
const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
10127
|
-
await ensurePinnedOpenVikingInstalled(config, {
|
|
10128
|
-
dryRun: options.dryRun === true,
|
|
10129
|
-
interactive,
|
|
10130
|
-
yes: options.yes === true
|
|
10131
|
-
});
|
|
10127
|
+
await ensurePinnedOpenVikingInstalled(config, { dryRun: options.dryRun === true });
|
|
10132
10128
|
await runApplicablePostUpdateMigrations(config, {
|
|
10133
10129
|
dryRun: options.dryRun === true,
|
|
10134
10130
|
fromVersion: options.fromVersion,
|
|
@@ -10141,7 +10137,7 @@ async function runPostUpdate(config, options) {
|
|
|
10141
10137
|
async function maybeRunPostUpdateAfterRepair(config, options) {
|
|
10142
10138
|
const toVersion = await currentPackageVersion();
|
|
10143
10139
|
const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
10144
|
-
await ensurePinnedOpenVikingInstalled(config, { dryRun: options.dryRun
|
|
10140
|
+
await ensurePinnedOpenVikingInstalled(config, { dryRun: options.dryRun });
|
|
10145
10141
|
const state = await readPostUpdateState(config);
|
|
10146
10142
|
const migrations = await applicablePostUpdateMigrations(config, {
|
|
10147
10143
|
fromVersion: "0.0.0",
|
|
@@ -10184,18 +10180,80 @@ async function ensurePinnedOpenVikingInstalled(config, options) {
|
|
|
10184
10180
|
return;
|
|
10185
10181
|
}
|
|
10186
10182
|
console.log("");
|
|
10187
|
-
console.log(`OpenViking ${installedVersion}
|
|
10188
|
-
console.log(
|
|
10189
|
-
|
|
10190
|
-
);
|
|
10183
|
+
console.log(`Upgrading OpenViking ${installedVersion} -> ${pinned} (pinned by Threadnote).`);
|
|
10184
|
+
console.log("Picks up upstream fixes for share-sync reliability (reindex lock acquisition, ov wait timeout).");
|
|
10185
|
+
const wasRunning = await isOpenVikingHealthy(config);
|
|
10186
|
+
const usingLaunchd = await isLaunchAgentInstalled();
|
|
10191
10187
|
const threadnoteCommand = currentThreadnoteCommand() ?? await findExecutable([NPM_PACKAGE_NAME]) ?? NPM_PACKAGE_NAME;
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10188
|
+
await maybeRun(options.dryRun, threadnoteCommand, ["install", "--force", "--no-start"]);
|
|
10189
|
+
if (options.dryRun) {
|
|
10190
|
+
if (wasRunning || usingLaunchd) {
|
|
10191
|
+
console.log("Would restart OpenViking server so the new binary takes effect.");
|
|
10192
|
+
}
|
|
10193
|
+
return;
|
|
10194
|
+
}
|
|
10195
|
+
if (!wasRunning && !usingLaunchd) {
|
|
10196
10196
|
return;
|
|
10197
10197
|
}
|
|
10198
|
-
|
|
10198
|
+
console.log("Restarting OpenViking server so the new binary takes effect.");
|
|
10199
|
+
if (usingLaunchd) {
|
|
10200
|
+
const launchAgentPath = launchAgentPlistPath();
|
|
10201
|
+
await runCommand("launchctl", ["unload", launchAgentPath], { allowFailure: true });
|
|
10202
|
+
await runCommand("launchctl", ["load", launchAgentPath], { allowFailure: true });
|
|
10203
|
+
} else {
|
|
10204
|
+
await maybeRun(false, threadnoteCommand, ["stop"]);
|
|
10205
|
+
await maybeRun(false, threadnoteCommand, ["start"]);
|
|
10206
|
+
}
|
|
10207
|
+
const healthyAfter = await waitForOpenVikingHealthy(config, 1e4);
|
|
10208
|
+
if (!healthyAfter) {
|
|
10209
|
+
console.log(
|
|
10210
|
+
`Warning: OpenViking did not return to healthy at ${openVikingHealthEndpoint(config)} within 10s after the restart.`
|
|
10211
|
+
);
|
|
10212
|
+
console.log("Check the server log or run: threadnote start");
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
function openVikingHealthEndpoint(config) {
|
|
10216
|
+
return `http://${config.host}:${config.port}/health`;
|
|
10217
|
+
}
|
|
10218
|
+
async function isOpenVikingHealthy(config) {
|
|
10219
|
+
const controller = new AbortController();
|
|
10220
|
+
const timer = setTimeout(() => {
|
|
10221
|
+
controller.abort();
|
|
10222
|
+
}, 800);
|
|
10223
|
+
try {
|
|
10224
|
+
const response = await fetch(openVikingHealthEndpoint(config), { signal: controller.signal });
|
|
10225
|
+
return response.ok;
|
|
10226
|
+
} catch (_err) {
|
|
10227
|
+
return false;
|
|
10228
|
+
} finally {
|
|
10229
|
+
clearTimeout(timer);
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
async function waitForOpenVikingHealthy(config, timeoutMs) {
|
|
10233
|
+
const deadline = Date.now() + timeoutMs;
|
|
10234
|
+
while (Date.now() < deadline) {
|
|
10235
|
+
if (await isOpenVikingHealthy(config)) {
|
|
10236
|
+
return true;
|
|
10237
|
+
}
|
|
10238
|
+
await new Promise((resolvePromise) => {
|
|
10239
|
+
setTimeout(resolvePromise, 500);
|
|
10240
|
+
});
|
|
10241
|
+
}
|
|
10242
|
+
return isOpenVikingHealthy(config);
|
|
10243
|
+
}
|
|
10244
|
+
function launchAgentPlistPath() {
|
|
10245
|
+
return (0, import_node_path10.join)((0, import_node_os5.homedir)(), "Library", "LaunchAgents", "io.threadnote.openviking.plist");
|
|
10246
|
+
}
|
|
10247
|
+
async function isLaunchAgentInstalled() {
|
|
10248
|
+
if (process.platform !== "darwin") {
|
|
10249
|
+
return false;
|
|
10250
|
+
}
|
|
10251
|
+
try {
|
|
10252
|
+
await (0, import_promises9.access)(launchAgentPlistPath(), import_node_fs5.constants.F_OK);
|
|
10253
|
+
return true;
|
|
10254
|
+
} catch (_err) {
|
|
10255
|
+
return false;
|
|
10256
|
+
}
|
|
10199
10257
|
}
|
|
10200
10258
|
async function readOpenVikingCliVersion(ov) {
|
|
10201
10259
|
const result = await runCommand(ov, ["version"], { allowFailure: true });
|