plugin-updater 1.0.32 → 1.0.34

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/index.js +47 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -243,7 +243,9 @@ function updatePlugin(pluginName, gitUrl, branch, commitHash, updateInterval = 1
243
243
  if (!fs.existsSync(reposDir))
244
244
  fs.mkdirSync(reposDir, { recursive: true });
245
245
  const branchFlag = branch ? `--branch ${branch}` : "";
246
- executeGit(`git clone --recurse-submodules ${branchFlag} ${gitUrl} ${pluginName}`, reposDir);
246
+ const cloned = executeGit(`git clone --recurse-submodules ${branchFlag} ${gitUrl} ${pluginName}`, reposDir);
247
+ if (!cloned)
248
+ return { success: false, changed: false };
247
249
  fs.writeFileSync(lastCheckFile, Date.now().toString());
248
250
  didChange = true;
249
251
  }
@@ -366,6 +368,12 @@ async function deployToExecutionDir(pluginName, executionPath, changed, configDi
366
368
  if (fs.existsSync(packageJsonPath)) {
367
369
  try {
368
370
  buildInTempDir(pluginName, sourceDir);
371
+ const runtimeDeps = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).dependencies;
372
+ if (runtimeDeps && Object.keys(runtimeDeps).length > 0) {
373
+ writeLog(`Installing runtime dependencies for ${pluginName}`);
374
+ execSync("npm install --omit=dev", { cwd: sourceDir, stdio: "pipe" });
375
+ writeLog(`Finished runtime dependencies for ${pluginName}`);
376
+ }
369
377
  }
370
378
  catch (error) {
371
379
  const err = error;
@@ -407,6 +415,7 @@ async function deployToExecutionDir(pluginName, executionPath, changed, configDi
407
415
  const err = e;
408
416
  writeLog(`Copy failed for ${pluginName}: ${err.message}`, true);
409
417
  }
418
+ applyClaudeManifest(sourceDir, configDir, pluginName);
410
419
  // Claude Code never imports deployed plugin files, so under claude the
411
420
  // updater is the runtime and invokes the plugin's activate() itself
412
421
  if (getAppName() === "claude") {
@@ -424,6 +433,37 @@ async function deployToExecutionDir(pluginName, executionPath, changed, configDi
424
433
  }
425
434
  return true;
426
435
  }
436
+ function applyClaudeManifest(sourceDir, configDir, pluginName) {
437
+ if (getAppName() !== "claude")
438
+ return;
439
+ try {
440
+ const pkg = JSON.parse(fs.readFileSync(path.join(sourceDir, "package.json"), "utf8"));
441
+ const manifest = pkg.claudeHub;
442
+ if (!manifest)
443
+ return;
444
+ if (manifest.env && typeof manifest.env === "object") {
445
+ const settingsPath = path.join(configDir, "settings.json");
446
+ let settings = {};
447
+ try {
448
+ settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
449
+ }
450
+ catch { /* fresh file */ }
451
+ const env = (settings.env ?? {});
452
+ for (const [key, value] of Object.entries(manifest.env)) {
453
+ env[key] = String(value);
454
+ writeLog(`settings.json env ${key} set by ${pluginName}`);
455
+ }
456
+ settings.env = env;
457
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), "utf8");
458
+ }
459
+ if (manifest.daemon?.script) {
460
+ writeLog(`${pluginName} defines a daemon (${manifest.daemon.script}) which the updater does not manage yet`, true);
461
+ }
462
+ }
463
+ catch (e) {
464
+ writeLog(`claudeHub manifest handling failed for ${pluginName}: ${e.message}`, true);
465
+ }
466
+ }
427
467
  async function pluginUpdaterEntry(input) {
428
468
  const appName = getAppName();
429
469
  const configDir = getAppConfigDir(appName);
@@ -443,6 +483,8 @@ export async function updatePluginPublic(pluginName, gitUrl, branch, commitHash)
443
483
  const configDir = getAppConfigDir(getAppName());
444
484
  // interval 0: an explicit update request must never fast-path-skip
445
485
  const result = updatePlugin(pluginName, gitUrl, branch, commitHash ?? null, 0);
486
+ if (!result.success)
487
+ throw new Error(`could not set up ${pluginName} - see the updater log`);
446
488
  await deployToExecutionDir(pluginName, path.join(configDir, "plugin"), result.changed, configDir);
447
489
  }
448
490
  export async function earlyLaunch(configDir, plugins) {
@@ -488,6 +530,10 @@ export async function earlyLaunch(configDir, plugins) {
488
530
  writeLog(`Processing earlyLaunch for ${plugin.name}`);
489
531
  try {
490
532
  const updateResult = updatePlugin(plugin.name, plugin.url, plugin.branch, null, plugin.updateInterval ?? 1);
533
+ if (!updateResult.success) {
534
+ writeLog(`Skipping deploy for ${plugin.name}: update failed`, true);
535
+ continue;
536
+ }
491
537
  await deployToExecutionDir(plugin.name, path.join(configDir, "plugin"), updateResult.changed, configDir);
492
538
  }
493
539
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",