plugin-updater 1.0.13 → 1.0.14
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/index.js +19 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -58,8 +58,6 @@ function executeGit(command, cwd) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const updaterAPI = {
|
|
61
|
-
name: "plugin-updater",
|
|
62
|
-
|
|
63
61
|
earlyLaunch: function(configDir) {
|
|
64
62
|
EARLY_LAUNCH_CONFIG_DIR = configDir;
|
|
65
63
|
global.__PLUGIN_UPDATER_HANDLED_BY_HUB__ = true;
|
|
@@ -176,8 +174,11 @@ const updaterAPI = {
|
|
|
176
174
|
}
|
|
177
175
|
};
|
|
178
176
|
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
// OpenCode plugin server function — called by opencode with plugin input context
|
|
178
|
+
const serverPlugin = async function(input) {
|
|
179
|
+
const configDir = (input && input.directory)
|
|
180
|
+
? path.dirname(input.directory)
|
|
181
|
+
: path.dirname(getReposDir());
|
|
181
182
|
|
|
182
183
|
// 1. GUARANTEE BASE DIRECTORIES EXIST ON LAUNCH
|
|
183
184
|
const reposDir = path.join(configDir, "repos");
|
|
@@ -185,6 +186,8 @@ const pluginUpdaterEntry = async function(input) {
|
|
|
185
186
|
if (!fs.existsSync(reposDir)) fs.mkdirSync(reposDir, { recursive: true });
|
|
186
187
|
if (!fs.existsSync(pluginsDir)) fs.mkdirSync(pluginsDir, { recursive: true });
|
|
187
188
|
|
|
189
|
+
writeLog(`plugin-updater activated. configDir=${configDir}`);
|
|
190
|
+
|
|
188
191
|
if (!global.__PLUGIN_UPDATER_HANDLED_BY_HUB__) {
|
|
189
192
|
updaterAPI.earlyLaunch(configDir);
|
|
190
193
|
|
|
@@ -205,15 +208,19 @@ const pluginUpdaterEntry = async function(input) {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
}
|
|
211
|
+
|
|
212
|
+
// Return hooks object (can be empty — opencode expects this shape)
|
|
208
213
|
return {};
|
|
209
214
|
};
|
|
210
215
|
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
pluginUpdaterEntry.pluginName = updaterAPI.name;
|
|
216
|
+
// Expose updaterAPI on serverPlugin for hub access: import('plugin-updater').then(m => m.default.server.earlyLaunch(...))
|
|
217
|
+
Object.keys(updaterAPI).forEach(key => {
|
|
218
|
+
serverPlugin[key] = updaterAPI[key];
|
|
219
|
+
});
|
|
218
220
|
|
|
219
|
-
export default
|
|
221
|
+
// OpenCode V1 plugin contract: export default { id, server }
|
|
222
|
+
// opencode calls mod.default.server(input) to initialize the plugin
|
|
223
|
+
export default {
|
|
224
|
+
id: "plugin-updater",
|
|
225
|
+
server: serverPlugin
|
|
226
|
+
};
|