plugin-updater 1.0.43 → 1.0.44

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.
Files changed (2) hide show
  1. package/dist/git.js +36 -19
  2. package/package.json +1 -1
package/dist/git.js CHANGED
@@ -44,29 +44,46 @@ export function updatePlugin(pluginName, gitUrl, branch, commitHash, updateInter
44
44
  const intervalMs = updateInterval * 3_600_000;
45
45
  const elapsed = Date.now() - lastCheck;
46
46
  if (elapsed < intervalMs) {
47
- writeLog(`Fast-path: ${pluginName} skipping update check (checked ${Math.floor(elapsed / 60_000)} min ago, interval ${updateInterval}h)`);
48
- // even when skipping the network check, keep embedded submodules pinned to
49
- // this checkout a loader running against a stale core/core-auth is the
50
- // top cause of "looks broken but it's just stale". Rebuild if they moved.
51
- if (fs.existsSync(path.join(targetDir, ".gitmodules"))) {
52
- let before = "";
47
+ // The interval throttles the expensive fetch/build, NOT change detection.
48
+ // A pinned commit is intentional; otherwise do a cheap ls-remote so a new
49
+ // push is picked up on the very next launch instead of waiting out the hour.
50
+ let remoteMoved = false;
51
+ if (!commitHash) {
53
52
  try {
54
- before = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
53
+ const ref = branch || "HEAD";
54
+ const remoteHash = execSync(`git ls-remote origin ${ref}`, { cwd: targetDir }).toString().trim().split(/\s+/)[0] || "";
55
+ const localHash = execSync("git rev-parse HEAD", { cwd: targetDir }).toString().trim();
56
+ remoteMoved = !!remoteHash && !!localHash && remoteHash !== localHash;
55
57
  }
56
- catch { /* ignore */ }
57
- executeGit("git submodule sync --recursive", targetDir);
58
- executeGit("git submodule update --init --recursive", targetDir);
59
- let after = "";
60
- try {
61
- after = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
62
- }
63
- catch { /* ignore */ }
64
- if (before !== after) {
65
- writeLog(`Fast-path: ${pluginName} submodules were out of sync — resynced, forcing rebuild`);
66
- return { success: true, changed: true };
58
+ catch { /* offline / transient — fall back to skipping until the interval */ }
59
+ }
60
+ if (!remoteMoved) {
61
+ writeLog(`Fast-path: ${pluginName} skipping update check (checked ${Math.floor(elapsed / 60_000)} min ago, interval ${updateInterval}h)`);
62
+ // even when skipping the network check, keep embedded submodules pinned to
63
+ // this checkout a loader running against a stale core/core-auth is the
64
+ // top cause of "looks broken but it's just stale". Rebuild if they moved.
65
+ if (fs.existsSync(path.join(targetDir, ".gitmodules"))) {
66
+ let before = "";
67
+ try {
68
+ before = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
69
+ }
70
+ catch { /* ignore */ }
71
+ executeGit("git submodule sync --recursive", targetDir);
72
+ executeGit("git submodule update --init --recursive", targetDir);
73
+ let after = "";
74
+ try {
75
+ after = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
76
+ }
77
+ catch { /* ignore */ }
78
+ if (before !== after) {
79
+ writeLog(`Fast-path: ${pluginName} submodules were out of sync — resynced, forcing rebuild`);
80
+ return { success: true, changed: true };
81
+ }
67
82
  }
83
+ return { success: true, changed: false };
68
84
  }
69
- return { success: true, changed: false };
85
+ writeLog(`Fast-path: ${pluginName} remote moved updating despite interval`);
86
+ // fall through to the full fetch/checkout/build path below
70
87
  }
71
88
  fs.writeFileSync(lastCheckFile, Date.now().toString());
72
89
  executeGit("git fetch origin", targetDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",