offgrid-ai 0.7.1 → 0.7.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/package.json +1 -1
- package/src/cli.mjs +2 -2
- package/src/updates.mjs +9 -2
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { uninstallCommand } from "./commands/uninstall.mjs";
|
|
|
10
10
|
|
|
11
11
|
async function offerUpdate(argv) {
|
|
12
12
|
const invocation = detectInvocation();
|
|
13
|
-
const update = await checkForUpdate({ force:
|
|
13
|
+
const update = await checkForUpdate({ force: false });
|
|
14
14
|
if (!update) return false;
|
|
15
15
|
|
|
16
16
|
const plan = updateCommand(invocation, argv);
|
|
@@ -56,7 +56,7 @@ async function printVersion() {
|
|
|
56
56
|
const version = currentPackageVersion();
|
|
57
57
|
console.log(`offgrid-ai v${version}`);
|
|
58
58
|
const invocation = detectInvocation();
|
|
59
|
-
const update = await checkForUpdate({ force:
|
|
59
|
+
const update = await checkForUpdate({ force: false });
|
|
60
60
|
if (update) {
|
|
61
61
|
const plan = updateCommand(invocation, ["version"]);
|
|
62
62
|
console.log(pc.yellow(`Update available: v${update.latest}. Run: ${plan.display}`));
|
package/src/updates.mjs
CHANGED
|
@@ -15,8 +15,15 @@ export async function checkForUpdate({ now = Date.now(), fetchImpl = globalThis.
|
|
|
15
15
|
const cacheFile = join(DATA_DIR, "update-cache.json");
|
|
16
16
|
const cached = await readUpdateCache(cacheFile);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Use cache if fresh (within 24h) and still applies to current version
|
|
19
|
+
if (!force && cached?.lastChecked && now - cached.lastChecked < UPDATE_CHECK_INTERVAL) {
|
|
20
|
+
if (cached.currentVersion === currentVersion) {
|
|
21
|
+
return updateResult(currentVersion, cached.latestVersion);
|
|
22
|
+
}
|
|
23
|
+
// Cache is from a different version — if latest isn't newer than current, no update
|
|
24
|
+
if (cached.latestVersion && !isNewerVersion(cached.latestVersion, currentVersion)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
try {
|