@co0ontty/wand 1.1.0 → 1.1.1
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/server.js +7 -3
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -19,11 +19,15 @@ const PKG_NODE_REQ = PKG_JSON.engines?.node ?? ">=22.5.0";
|
|
|
19
19
|
const PKG_REPO_URL = "https://github.com/co0ontty/wand";
|
|
20
20
|
// ── Update check cache ──
|
|
21
21
|
let cachedLatestVersion = null;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let cacheTimestamp = 0;
|
|
23
|
+
const CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
24
|
+
async function checkNpmLatestVersion(forceRefresh = false) {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
if (forceRefresh || !cachedLatestVersion || (now - cacheTimestamp > CACHE_TTL_MS)) {
|
|
24
27
|
try {
|
|
25
28
|
const { stdout } = await execAsync(`npm view ${PKG_NAME} version`, { timeout: 15000 });
|
|
26
29
|
cachedLatestVersion = stdout.trim();
|
|
30
|
+
cacheTimestamp = now;
|
|
27
31
|
}
|
|
28
32
|
catch {
|
|
29
33
|
cachedLatestVersion = null;
|
|
@@ -460,7 +464,7 @@ export async function startServer(config, configPath) {
|
|
|
460
464
|
});
|
|
461
465
|
app.get("/api/check-update", async (_req, res) => {
|
|
462
466
|
try {
|
|
463
|
-
const result = await checkNpmLatestVersion();
|
|
467
|
+
const result = await checkNpmLatestVersion(true);
|
|
464
468
|
res.json(result);
|
|
465
469
|
}
|
|
466
470
|
catch (error) {
|