forge-remote 2.1.4 → 2.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-remote",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Desktop relay for Forge Remote — mobile command center for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -36,12 +36,18 @@ function isNewer(local, remote) {
36
36
  }
37
37
 
38
38
  /**
39
- * Check npm for a newer version. Logs a warning if one is found.
39
+ * Check npm for a newer version. If one is found, re-launches the CLI
40
+ * with `npx forge-remote@latest` and exits the current process.
40
41
  * Never throws — silently returns on any failure.
42
+ *
43
+ * @returns {Promise<boolean>} true if an update was found and re-launch initiated
41
44
  */
42
45
  export async function checkForUpdate() {
43
46
  const localVersion = getLocalVersion();
44
- if (!localVersion) return;
47
+ if (!localVersion) return false;
48
+
49
+ // Skip if we're already running via @latest (avoid infinite loop)
50
+ if (process.env.FORGE_REMOTE_UPDATED === "1") return false;
45
51
 
46
52
  try {
47
53
  const controller = new AbortController();
@@ -52,21 +58,29 @@ export async function checkForUpdate() {
52
58
  });
53
59
  clearTimeout(timeout);
54
60
 
55
- if (!res.ok) return;
61
+ if (!res.ok) return false;
56
62
 
57
63
  const data = await res.json();
58
64
  const remoteVersion = data.version;
59
65
 
60
66
  if (remoteVersion && isNewer(localVersion, remoteVersion)) {
61
- console.log();
62
- log.warn(
63
- `A new version of forge-remote is available: ${localVersion} → ${remoteVersion}`,
64
- );
65
- log.warn(" Run: npm update -g forge-remote");
66
- log.warn(" Then: forge-remote init (to update Firestore rules)");
67
- console.log();
67
+ log.info(`Updating forge-remote: ${localVersion} → ${remoteVersion}`);
68
+
69
+ // Re-launch with @latest, passing through all original args
70
+ const args = process.argv.slice(2);
71
+ const { execSync } = await import("child_process");
72
+ try {
73
+ execSync(`npx forge-remote@latest ${args.join(" ")}`, {
74
+ stdio: "inherit",
75
+ env: { ...process.env, FORGE_REMOTE_UPDATED: "1" },
76
+ });
77
+ } catch {
78
+ // Child process exited — that's expected when user Ctrl+C
79
+ }
80
+ process.exit(0);
68
81
  }
69
82
  } catch {
70
83
  // Network error, timeout, etc. — don't bother the user.
71
84
  }
85
+ return false;
72
86
  }