claude-task-worker 0.86.0 → 0.87.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.
- package/dist/index.js +36 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4523,12 +4523,43 @@ async function update() {
|
|
|
4523
4523
|
import { readFileSync as readFileSync5 } from "node:fs";
|
|
4524
4524
|
import { dirname as dirname3, join as join8 } from "node:path";
|
|
4525
4525
|
import { fileURLToPath } from "node:url";
|
|
4526
|
-
|
|
4526
|
+
import { styleText } from "node:util";
|
|
4527
|
+
var REGISTRY_URL = "https://registry.npmjs.org/claude-task-worker/latest";
|
|
4528
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
4529
|
+
function localVersion() {
|
|
4527
4530
|
const here = dirname3(fileURLToPath(import.meta.url));
|
|
4528
4531
|
const pkgPath = join8(here, "..", "package.json");
|
|
4532
|
+
const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
|
|
4533
|
+
return pkg.version ?? "unknown";
|
|
4534
|
+
}
|
|
4535
|
+
function isOutdated(current, latest) {
|
|
4536
|
+
const parse = (v) => v.split("-")[0].split(".").map(Number);
|
|
4537
|
+
const a = parse(current);
|
|
4538
|
+
const b = parse(latest);
|
|
4539
|
+
for (let i = 0; i < 3; i++) {
|
|
4540
|
+
const x = a[i] ?? 0;
|
|
4541
|
+
const y = b[i] ?? 0;
|
|
4542
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return false;
|
|
4543
|
+
if (x !== y) return y > x;
|
|
4544
|
+
}
|
|
4545
|
+
return false;
|
|
4546
|
+
}
|
|
4547
|
+
async function notifyIfOutdated() {
|
|
4548
|
+
try {
|
|
4549
|
+
const current = localVersion();
|
|
4550
|
+
const res = await fetch(REGISTRY_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
4551
|
+
if (!res.ok) return;
|
|
4552
|
+
const { version: latest } = await res.json();
|
|
4553
|
+
if (!latest || !isOutdated(current, latest)) return;
|
|
4554
|
+
console.log(
|
|
4555
|
+
styleText("yellow", "[update] A new version of claude-task-worker is available: ") + styleText("dim", current) + styleText("yellow", " -> ") + styleText(["green", "bold"], latest) + styleText("yellow", ". Run ") + styleText("cyan", '"claude-task-worker update"') + styleText("yellow", " to update.")
|
|
4556
|
+
);
|
|
4557
|
+
} catch {
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
function version() {
|
|
4529
4561
|
try {
|
|
4530
|
-
|
|
4531
|
-
console.log(pkg.version ?? "unknown");
|
|
4562
|
+
console.log(localVersion());
|
|
4532
4563
|
} catch (err) {
|
|
4533
4564
|
console.error(`[version] Failed to read version: ${err.message}`);
|
|
4534
4565
|
process.exitCode = 1;
|
|
@@ -4672,8 +4703,10 @@ Example:
|
|
|
4672
4703
|
var workerType = process.argv[2];
|
|
4673
4704
|
if (workerType === "version" || workerType === "--version" || workerType === "-v") {
|
|
4674
4705
|
version();
|
|
4706
|
+
await notifyIfOutdated();
|
|
4675
4707
|
process.exit(process.exitCode ?? 0);
|
|
4676
4708
|
}
|
|
4709
|
+
void notifyIfOutdated();
|
|
4677
4710
|
if (!workerType) {
|
|
4678
4711
|
printUsage();
|
|
4679
4712
|
process.exit(1);
|