+23
-16
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
| var name = "greenly"; | ||
| var version = "1.1.4"; | ||
| var version = "1.1.5"; | ||
| //#endregion | ||
@@ -151,20 +151,27 @@ //#region src/lib/args.ts | ||
| } | ||
| async function fetchLatestVersion(pkg, timeoutMs = 3e3) { | ||
| async function fetchLatestVersion(pkg) { | ||
| const controller = new AbortController(); | ||
| const TICK_MS = 200; | ||
| let remaining = 3e3; | ||
| let previous = Date.now(); | ||
| const timer = setInterval(() => { | ||
| const now = Date.now(); | ||
| const elapsed = now - previous; | ||
| previous = now; | ||
| if (elapsed < 600) remaining -= elapsed; | ||
| if (remaining <= 0) controller.abort(); | ||
| }, TICK_MS); | ||
| try { | ||
| const controller = new AbortController(); | ||
| const timer = setTimeout(() => controller.abort(), timeoutMs); | ||
| try { | ||
| const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}/latest`, { signal: controller.signal }); | ||
| if (!res.ok) return null; | ||
| const data = await res.json(); | ||
| if (data && typeof data === "object" && "version" in data) { | ||
| const version = data.version; | ||
| return typeof version === "string" ? version : null; | ||
| } | ||
| return null; | ||
| } finally { | ||
| clearTimeout(timer); | ||
| const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}/latest`, { signal: controller.signal }); | ||
| if (!res.ok) return null; | ||
| const data = await res.json(); | ||
| if (data && typeof data === "object" && "version" in data) { | ||
| const version = data.version; | ||
| return typeof version === "string" ? version : null; | ||
| } | ||
| return null; | ||
| } catch { | ||
| return null; | ||
| } finally { | ||
| clearInterval(timer); | ||
| } | ||
@@ -706,3 +713,3 @@ } | ||
| console.log(colors.yellow(`Update available: greenly ${colors.dim(info.current)} -> ${colors.bold(info.latest)}`)); | ||
| console.log(colors.dim(`Run ${colors.bold(installCommand(pm))} to update.`) + "\n"); | ||
| console.log(colors.bold(installCommand(pm)) + "\n"); | ||
| } | ||
@@ -709,0 +716,0 @@ async function main() { |
+1
-1
| { | ||
| "name": "greenly", | ||
| "version": "1.1.4", | ||
| "version": "1.1.5", | ||
| "description": "Config-driven project check runner. Define your lint/format/typecheck/test/custom steps in greenly.config.ts and run them with one command.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
66899
0.22%792
0.89%