plugin-updater 1.0.21 → 1.0.22
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 +2 -2
- package/dist/index.js +23 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ 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
21
|
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
|
|
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(
|
|
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;
|