( plugin: string, scope: InstallableScope = 'user', )
| 100 | * @param scope Installation scope: user, project, or local (defaults to 'user') |
| 101 | */ |
| 102 | export async function installPlugin( |
| 103 | plugin: string, |
| 104 | scope: InstallableScope = 'user', |
| 105 | ): Promise<void> { |
| 106 | try { |
| 107 | console.log(`Installing plugin "${plugin}"...`) |
| 108 | |
| 109 | const result = await installPluginOp(plugin, scope) |
| 110 | |
| 111 | if (!result.success) { |
| 112 | throw new Error(result.message) |
| 113 | } |
| 114 | |
| 115 | console.log(`${figures.tick} ${result.message}`) |
| 116 | |
| 117 | // _PROTO_* routes to PII-tagged plugin_name/marketplace_name BQ columns. |
| 118 | // Unredacted plugin_id was previously logged to general-access |
| 119 | // additional_metadata for all users — dropped in favor of the privileged |
| 120 | // column route. |
| 121 | const { name, marketplace } = parsePluginIdentifier( |
| 122 | result.pluginId || plugin, |
| 123 | ) |
| 124 | logEvent('tengu_plugin_installed_cli', { |
| 125 | _PROTO_plugin_name: |
| 126 | name as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED, |
| 127 | ...(marketplace && { |
| 128 | _PROTO_marketplace_name: |
| 129 | marketplace as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED, |
| 130 | }), |
| 131 | scope: (result.scope || |
| 132 | scope) as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, |
| 133 | install_source: |
| 134 | 'cli-explicit' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, |
| 135 | ...buildPluginTelemetryFields(name, marketplace, getManagedPluginNames()), |
| 136 | }) |
| 137 | |
| 138 | // eslint-disable-next-line custom-rules/no-process-exit |
| 139 | process.exit(0) |
| 140 | } catch (error) { |
| 141 | handlePluginCommandError(error, 'install', plugin) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * CLI command: Uninstall a plugin non-interactively |
no test coverage detected