agendex-cli 0.8.1 → 0.8.2
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 +18 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3251,7 +3251,7 @@ import { join as join11 } from "node:path";
|
|
|
3251
3251
|
// package.json
|
|
3252
3252
|
var package_default = {
|
|
3253
3253
|
name: "agendex-cli",
|
|
3254
|
-
version: "0.8.
|
|
3254
|
+
version: "0.8.2",
|
|
3255
3255
|
description: "Agendex CLI for login, sync, and daemon workflows",
|
|
3256
3256
|
homepage: "https://github.com/Tyru5/Agendex#readme",
|
|
3257
3257
|
repository: {
|
|
@@ -3295,16 +3295,17 @@ var package_default = {
|
|
|
3295
3295
|
|
|
3296
3296
|
// src/version.ts
|
|
3297
3297
|
var CLI_VERSION = package_default.version;
|
|
3298
|
-
var CACHE_FILE = join11(tmpdir(), ".agendex-update-cache.json");
|
|
3298
|
+
var CACHE_FILE = process.env.AGENDEX_UPDATE_CACHE_FILE ?? join11(tmpdir(), ".agendex-update-cache.json");
|
|
3299
3299
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
3300
|
-
|
|
3300
|
+
var UPDATE_URL = process.env.AGENDEX_UPDATE_URL ?? "https://registry.npmjs.org/agendex-cli/latest";
|
|
3301
|
+
function readCache(current) {
|
|
3301
3302
|
try {
|
|
3302
3303
|
if (!existsSync7(CACHE_FILE))
|
|
3303
3304
|
return null;
|
|
3304
3305
|
const { result, ts } = JSON.parse(readFileSync4(CACHE_FILE, "utf8"));
|
|
3305
3306
|
if (Date.now() - ts > CACHE_TTL_MS)
|
|
3306
3307
|
return null;
|
|
3307
|
-
return result;
|
|
3308
|
+
return normalizeResult(result, current);
|
|
3308
3309
|
} catch {
|
|
3309
3310
|
return null;
|
|
3310
3311
|
}
|
|
@@ -3316,16 +3317,15 @@ function writeCache(result) {
|
|
|
3316
3317
|
}
|
|
3317
3318
|
async function checkForUpdate() {
|
|
3318
3319
|
const current = CLI_VERSION;
|
|
3319
|
-
const cached = readCache();
|
|
3320
|
+
const cached = readCache(current);
|
|
3320
3321
|
if (cached)
|
|
3321
|
-
return
|
|
3322
|
+
return cached;
|
|
3322
3323
|
try {
|
|
3323
3324
|
const controller = new AbortController;
|
|
3324
3325
|
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
3325
|
-
const res = await fetch(
|
|
3326
|
+
const res = await fetch(UPDATE_URL, {
|
|
3326
3327
|
signal: controller.signal
|
|
3327
|
-
});
|
|
3328
|
-
clearTimeout(timeout);
|
|
3328
|
+
}).finally(() => clearTimeout(timeout));
|
|
3329
3329
|
if (!res.ok) {
|
|
3330
3330
|
return { updateAvailable: false, current, latest: current };
|
|
3331
3331
|
}
|
|
@@ -3338,6 +3338,15 @@ async function checkForUpdate() {
|
|
|
3338
3338
|
return { updateAvailable: false, current, latest: current };
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
|
+
function normalizeResult(result, current) {
|
|
3342
|
+
if (typeof result.latest !== "string")
|
|
3343
|
+
return null;
|
|
3344
|
+
return {
|
|
3345
|
+
updateAvailable: isNewer(result.latest, current),
|
|
3346
|
+
current,
|
|
3347
|
+
latest: result.latest
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3341
3350
|
function isNewer(latest, current) {
|
|
3342
3351
|
const l = latest.split(".").map(Number);
|
|
3343
3352
|
const c = current.split(".").map(Number);
|