updatePlugin method
CLI: Update a plugin.
Implementation
Future<PluginUpdateResult> updatePlugin(
String plugin,
PluginScope scope,
) async {
try {
writeOutput(
'Checking for updates for plugin "$plugin" at ${scope.name} scope...',
);
final result = await operations.updatePlugin(plugin, scope);
if (!result.success) {
writeError(
'Failed to update plugin "$plugin": ${result.message}',
);
_logFailure('update', plugin);
return result;
}
writeOutput(result.message);
if (!result.alreadyUpToDate) {
final id = parsePluginIdentifier(result.pluginId ?? plugin);
logEvent('tengu_plugin_updated_cli', {
...buildPluginTelemetryFields(
id.name,
id.marketplace,
getManagedPluginNames(),
).toMap(),
'old_version': result.oldVersion ?? 'unknown',
'new_version': result.newVersion ?? 'unknown',
});
}
return result;
} catch (e) {
_handleError(e, 'update', plugin);
return PluginUpdateResult(
success: false,
message: e.toString(),
);
}
}