From 704ce7896c75b73ea7609654cf9810665e2567ea Mon Sep 17 00:00:00 2001 From: divyanshujethi Date: Mon, 9 Nov 2026 19:01:57 +0530 Subject: [PATCH] feat(cli): reduce cache TTL to 4h, prioritize GitHub raw CDN, and add --refresh flag support --- bin/cli.js | 6 ++++-- bin/lib/catalog.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 965719658..3b2e3be06 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -86,8 +86,10 @@ function openUrl(url) { } // Load resources from local file or fetch remotely using shared loader -async function loadData() { - return loadCatalog(); +async function loadData(options = {}) { + const cliArgs = process.argv.slice(2); + const shouldRefresh = cliArgs.includes("--refresh") || cliArgs.includes("-r"); + return loadCatalog({ ...options, refresh: options.refresh || shouldRefresh }); } async function loadMatchmakerData() { diff --git a/bin/lib/catalog.js b/bin/lib/catalog.js index b8a5621ca..e326345fd 100644 --- a/bin/lib/catalog.js +++ b/bin/lib/catalog.js @@ -10,7 +10,7 @@ const __dirname = path.dirname(__filename); let cachedCatalog = null; -export const DEFAULT_CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours +export const DEFAULT_CACHE_TTL_MS = 4 * 60 * 60 * 1000; // 4 hours auto-refresh TTL export function getMilestone(totalCount) { const count = Number(totalCount); @@ -109,8 +109,8 @@ export function clearPersistentCache() { */ export async function fetchLiveCatalog(timeoutMs = 4000, fetchFn = fetch) { const candidateUrls = [ - "https://ritualdev.in/data.json", "https://raw.githubusercontent.com/RitualDev-Lab/DevShelf/main/site/data.json", + "https://ritualdev.in/data.json", "https://devshelf.ritualdev.in/data.json", ];