Install a plugin from a local wheel file.
(
ctx: click.Context,
wheel_path_str: str,
signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
)
| 253 | |
| 254 | |
| 255 | def _install_from_local_wheel( |
| 256 | ctx: click.Context, |
| 257 | wheel_path_str: str, |
| 258 | signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT, |
| 259 | ) -> None: |
| 260 | """Install a plugin from a local wheel file.""" |
| 261 | wheel_path = Path(wheel_path_str) |
| 262 | |
| 263 | if not wheel_path.exists(): |
| 264 | ui.display_error(f"Wheel file not found: {wheel_path}") |
| 265 | ctx.exit(ExitCode.USAGE_ERROR) |
| 266 | |
| 267 | downloader = PluginDownloader() |
| 268 | enterprise_config = EnterpriseConfig.load() |
| 269 | |
| 270 | ui.display_info(f"Installing from {wheel_path.name}...") |
| 271 | |
| 272 | try: |
| 273 | plugin_name, version, installed_wheel = downloader.install_from_wheel( |
| 274 | wheel_path, signature_mode=signature_mode |
| 275 | ) |
| 276 | |
| 277 | plugin_name = enable_installed_plugin( |
| 278 | enterprise_config, plugin_name, version, installed_wheel |
| 279 | ) |
| 280 | enterprise_config.save() |
| 281 | |
| 282 | ui.display_info(f"Installed {plugin_name} v{version}") |
| 283 | |
| 284 | except SignatureVerificationError as e: |
| 285 | ui.display_error(f"Signature verification failed: {e}") |
| 286 | ui.display_info( |
| 287 | "This plugin is not signed by GitGuardian. " |
| 288 | "If you trust its origin and still want to install it, " |
| 289 | "pass --allow-unsigned." |
| 290 | ) |
| 291 | ctx.exit(ExitCode.UNEXPECTED_ERROR) |
| 292 | except Exception as e: |
| 293 | ui.display_error(f"Failed to install from wheel: {e}") |
| 294 | ctx.exit(ExitCode.UNEXPECTED_ERROR) |
| 295 | |
| 296 | |
| 297 | def _install_from_url( |
no test coverage detected