plugin-updater 1.0.21 → 1.0.24

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/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare function getNpmPlugins(configDir: string): NpmPlugin[];
16
16
  export declare function installNpmPlugin(name: string, configDir: string): string;
17
17
  export declare function uninstallNpmPlugin(name: string, configDir: string): string;
18
18
  export declare function updateNpmPlugin(name: string, configDir: string, updateInterval?: number): string;
19
- export declare function updatePluginPublic(pluginName: string, gitUrl: string, branch?: string, commitHash?: string): void;
20
- export declare function earlyLaunch(configDir: string, plugins: Plugin[]): void;
19
+ export declare function updatePluginPublic(pluginName: string, gitUrl: string, branch?: string, commitHash?: string): Promise<void>;
20
+ export declare function earlyLaunch(configDir: string, plugins: Plugin[]): Promise<void>;
21
+ export declare function activate(): Promise<void>;
21
22
  export {};
package/dist/index.js CHANGED
@@ -247,7 +247,22 @@ function updatePlugin(pluginName, gitUrl, branch, commitHash, updateInterval = 1
247
247
  }
248
248
  return { success: true, changed: didChange };
249
249
  }
250
- function deployToExecutionDir(pluginName, executionPath, changed) {
250
+ async function callPluginCleanup(pluginExecutionFile, configDir) {
251
+ if (!fs.existsSync(pluginExecutionFile))
252
+ return;
253
+ try {
254
+ const mod = await import(pluginExecutionFile);
255
+ if (typeof mod.cleanup === "function") {
256
+ writeLog(`Calling cleanup() on ${pluginExecutionFile}`);
257
+ await mod.cleanup(configDir);
258
+ writeLog(`cleanup() complete for ${pluginExecutionFile}`);
259
+ }
260
+ }
261
+ catch (e) {
262
+ writeLog(`cleanup() call failed for ${pluginExecutionFile}: ${e.message}`, true);
263
+ }
264
+ }
265
+ async function deployToExecutionDir(pluginName, executionPath, changed, configDir) {
251
266
  const sourceDir = path.join(getReposDir(), pluginName);
252
267
  if (!fs.existsSync(sourceDir))
253
268
  return false;
@@ -298,6 +313,7 @@ function deployToExecutionDir(pluginName, executionPath, changed) {
298
313
  }
299
314
  if (!fs.existsSync(executionPath))
300
315
  fs.mkdirSync(executionPath, { recursive: true });
316
+ await callPluginCleanup(pluginExecutionFile, configDir);
301
317
  try {
302
318
  writeLog(`Running copy for ${pluginName}`);
303
319
  fs.copyFileSync(deploySource, pluginExecutionFile);
@@ -319,16 +335,17 @@ async function pluginUpdaterEntry(input) {
319
335
  EARLY_LAUNCH_CONFIG_DIR = input.configDir;
320
336
  writeLog(`Direct update request for ${input.pluginName}`);
321
337
  const updateResult = updatePlugin(input.pluginName, input.gitUrl, input.branch, input.commitHash ?? null);
322
- deployToExecutionDir(input.pluginName, pluginsDir, updateResult.changed);
338
+ await deployToExecutionDir(input.pluginName, pluginsDir, updateResult.changed, input.configDir);
323
339
  }
324
340
  }
325
- export function updatePluginPublic(pluginName, gitUrl, branch, commitHash) {
341
+ export async function updatePluginPublic(pluginName, gitUrl, branch, commitHash) {
326
342
  writeLog(`Public API update call for ${pluginName}`);
327
343
  const appName = process.argv.join(" ").includes("claude") ? "claude" : "opencode";
344
+ const configDir = getAppConfigDir(appName);
328
345
  const result = updatePlugin(pluginName, gitUrl, branch, commitHash ?? null);
329
- deployToExecutionDir(pluginName, path.join(getAppConfigDir(appName), "plugin"), result.changed);
346
+ await deployToExecutionDir(pluginName, path.join(configDir, "plugin"), result.changed, configDir);
330
347
  }
331
- export function earlyLaunch(configDir, plugins) {
348
+ export async function earlyLaunch(configDir, plugins) {
332
349
  EARLY_LAUNCH_CONFIG_DIR = configDir;
333
350
  writeLog("Starting earlyLaunch updater sequence");
334
351
  // Self-update first
@@ -362,7 +379,7 @@ export function earlyLaunch(configDir, plugins) {
362
379
  writeLog(`Processing earlyLaunch for ${plugin.name}`);
363
380
  try {
364
381
  const updateResult = updatePlugin(plugin.name, plugin.url, plugin.branch, null, plugin.updateInterval ?? 1);
365
- deployToExecutionDir(plugin.name, path.join(configDir, "plugin"), updateResult.changed);
382
+ await deployToExecutionDir(plugin.name, path.join(configDir, "plugin"), updateResult.changed, configDir);
366
383
  }
367
384
  catch (e) {
368
385
  const err = e;
@@ -370,4 +387,22 @@ export function earlyLaunch(configDir, plugins) {
370
387
  }
371
388
  }
372
389
  }
373
- pluginUpdaterEntry(null);
390
+ export async function activate() {
391
+ const isClaude = process.argv.join(" ").includes("claude");
392
+ const appName = isClaude ? "claude" : "opencode";
393
+ const configDir = getAppConfigDir(appName);
394
+ writeLog(`Plugin updater activating for ${appName}`);
395
+ const pluginsJsonPath = path.join(configDir, "config", "plugins.json");
396
+ let gitPlugins = [];
397
+ if (fs.existsSync(pluginsJsonPath)) {
398
+ try {
399
+ gitPlugins = JSON.parse(fs.readFileSync(pluginsJsonPath, "utf-8"));
400
+ writeLog(`Found ${gitPlugins.length} git plugins in plugins.json`);
401
+ }
402
+ catch (e) {
403
+ writeLog(`Failed to parse plugins.json: ${e.message}`, true);
404
+ }
405
+ }
406
+ await earlyLaunch(configDir, gitPlugins);
407
+ }
408
+ activate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",