agendex-cli 0.8.1 → 0.8.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +23 -10
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2778,10 +2778,14 @@ async function refreshToken(currentToken, convexUrl) {
2778
2778
  function requestText(urlString, options) {
2779
2779
  const url = new URL(urlString);
2780
2780
  const request = url.protocol === "https:" ? httpsRequest : httpRequest;
2781
+ const headers = { ...options.headers };
2782
+ if (options.body) {
2783
+ headers["Content-Length"] = String(Buffer.byteLength(options.body));
2784
+ }
2781
2785
  return new Promise((resolve4, reject) => {
2782
2786
  const req = request(url, {
2783
2787
  agent: false,
2784
- headers: options.headers,
2788
+ headers,
2785
2789
  method: options.method
2786
2790
  }, (res) => {
2787
2791
  let body = "";
@@ -3251,7 +3255,7 @@ import { join as join11 } from "node:path";
3251
3255
  // package.json
3252
3256
  var package_default = {
3253
3257
  name: "agendex-cli",
3254
- version: "0.8.1",
3258
+ version: "0.8.3",
3255
3259
  description: "Agendex CLI for login, sync, and daemon workflows",
3256
3260
  homepage: "https://github.com/Tyru5/Agendex#readme",
3257
3261
  repository: {
@@ -3295,16 +3299,17 @@ var package_default = {
3295
3299
 
3296
3300
  // src/version.ts
3297
3301
  var CLI_VERSION = package_default.version;
3298
- var CACHE_FILE = join11(tmpdir(), ".agendex-update-cache.json");
3302
+ var CACHE_FILE = process.env.AGENDEX_UPDATE_CACHE_FILE ?? join11(tmpdir(), ".agendex-update-cache.json");
3299
3303
  var CACHE_TTL_MS = 24 * 60 * 60 * 1000;
3300
- function readCache() {
3304
+ var UPDATE_URL = process.env.AGENDEX_UPDATE_URL ?? "https://registry.npmjs.org/agendex-cli/latest";
3305
+ function readCache(current) {
3301
3306
  try {
3302
3307
  if (!existsSync7(CACHE_FILE))
3303
3308
  return null;
3304
3309
  const { result, ts } = JSON.parse(readFileSync4(CACHE_FILE, "utf8"));
3305
3310
  if (Date.now() - ts > CACHE_TTL_MS)
3306
3311
  return null;
3307
- return result;
3312
+ return normalizeResult(result, current);
3308
3313
  } catch {
3309
3314
  return null;
3310
3315
  }
@@ -3316,16 +3321,15 @@ function writeCache(result) {
3316
3321
  }
3317
3322
  async function checkForUpdate() {
3318
3323
  const current = CLI_VERSION;
3319
- const cached = readCache();
3324
+ const cached = readCache(current);
3320
3325
  if (cached)
3321
- return { ...cached, current };
3326
+ return cached;
3322
3327
  try {
3323
3328
  const controller = new AbortController;
3324
3329
  const timeout = setTimeout(() => controller.abort(), 3000);
3325
- const res = await fetch("https://registry.npmjs.org/agendex-cli/latest", {
3330
+ const res = await fetch(UPDATE_URL, {
3326
3331
  signal: controller.signal
3327
- });
3328
- clearTimeout(timeout);
3332
+ }).finally(() => clearTimeout(timeout));
3329
3333
  if (!res.ok) {
3330
3334
  return { updateAvailable: false, current, latest: current };
3331
3335
  }
@@ -3338,6 +3342,15 @@ async function checkForUpdate() {
3338
3342
  return { updateAvailable: false, current, latest: current };
3339
3343
  }
3340
3344
  }
3345
+ function normalizeResult(result, current) {
3346
+ if (typeof result.latest !== "string")
3347
+ return null;
3348
+ return {
3349
+ updateAvailable: isNewer(result.latest, current),
3350
+ current,
3351
+ latest: result.latest
3352
+ };
3353
+ }
3341
3354
  function isNewer(latest, current) {
3342
3355
  const l = latest.split(".").map(Number);
3343
3356
  const c = current.split(".").map(Number);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agendex-cli",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Agendex CLI for login, sync, and daemon workflows",
5
5
  "homepage": "https://github.com/Tyru5/Agendex#readme",
6
6
  "repository": {