plugin-updater 1.0.37 → 1.0.38
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 -0
- package/dist/index.js +28 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,5 +18,7 @@ export declare function uninstallNpmPlugin(name: string, configDir: string): str
|
|
|
18
18
|
export declare function updateNpmPlugin(name: string, configDir: string, updateInterval?: number): string;
|
|
19
19
|
export declare function updatePluginPublic(pluginName: string, gitUrl: string, branch?: string, commitHash?: string): Promise<void | object>;
|
|
20
20
|
export declare function earlyLaunch(configDir: string, plugins: Plugin[]): Promise<void | object>;
|
|
21
|
+
export declare function getPluginsPath(configDir: string): string;
|
|
22
|
+
export declare function getPlugins(configDir: string): Plugin[];
|
|
21
23
|
export declare function activate(opencodeHookInput?: unknown): Promise<void | object>;
|
|
22
24
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -599,6 +599,32 @@ export async function earlyLaunch(configDir, plugins) {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
+
export function getPluginsPath(configDir) {
|
|
603
|
+
if (isOpencodeHookInvocation(configDir))
|
|
604
|
+
return "";
|
|
605
|
+
const preferred = path.join(configDir, "config", "plugins.json");
|
|
606
|
+
const fallback = path.join(configDir, "plugins.json");
|
|
607
|
+
if (fs.existsSync(preferred))
|
|
608
|
+
return preferred;
|
|
609
|
+
if (fs.existsSync(fallback))
|
|
610
|
+
return fallback;
|
|
611
|
+
return preferred;
|
|
612
|
+
}
|
|
613
|
+
// single source of truth for the git-plugin list; consumers (loaders, TUI)
|
|
614
|
+
// must read through this rather than touching plugins.json directly
|
|
615
|
+
export function getPlugins(configDir) {
|
|
616
|
+
if (isOpencodeHookInvocation(configDir))
|
|
617
|
+
return [];
|
|
618
|
+
const file = getPluginsPath(configDir);
|
|
619
|
+
try {
|
|
620
|
+
if (fs.existsSync(file))
|
|
621
|
+
return JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
622
|
+
}
|
|
623
|
+
catch (e) {
|
|
624
|
+
writeLog(`Failed to parse ${file}: ${e.message}`, true);
|
|
625
|
+
}
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
602
628
|
export async function activate(opencodeHookInput) {
|
|
603
629
|
// module load below calls activate() with no argument; opencode passes a
|
|
604
630
|
// context object when re-invoking the export — return an inert plugin instance
|
|
@@ -607,17 +633,8 @@ export async function activate(opencodeHookInput) {
|
|
|
607
633
|
const appName = getAppName();
|
|
608
634
|
const configDir = getAppConfigDir(appName);
|
|
609
635
|
writeLog(`Plugin updater activating for ${appName}`);
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
if (fs.existsSync(pluginsJsonPath)) {
|
|
613
|
-
try {
|
|
614
|
-
gitPlugins = JSON.parse(fs.readFileSync(pluginsJsonPath, "utf-8"));
|
|
615
|
-
writeLog(`Found ${gitPlugins.length} git plugins in plugins.json`);
|
|
616
|
-
}
|
|
617
|
-
catch (e) {
|
|
618
|
-
writeLog(`Failed to parse plugins.json: ${e.message}`, true);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
636
|
+
const gitPlugins = getPlugins(configDir);
|
|
637
|
+
writeLog(`Found ${gitPlugins.length} git plugins in plugins.json`);
|
|
621
638
|
await earlyLaunch(configDir, gitPlugins);
|
|
622
639
|
}
|
|
623
640
|
// consumers like the loader TUI import this module for its API only — running
|