diff --git a/extensions/eclipse-che-theia-plugin-ext/src/browser/plugin/che-plugin-manager.ts b/extensions/eclipse-che-theia-plugin-ext/src/browser/plugin/che-plugin-manager.ts index 4f8aac7f7..81634b264 100644 --- a/extensions/eclipse-che-theia-plugin-ext/src/browser/plugin/che-plugin-manager.ts +++ b/extensions/eclipse-che-theia-plugin-ext/src/browser/plugin/che-plugin-manager.ts @@ -23,6 +23,7 @@ import { inject, injectable, postConstruct } from 'inversify'; import { ChePluginFrontentService } from './che-plugin-frontend-service'; import { ChePluginPreferences } from './che-plugin-preferences'; import { ChePluginServiceClientImpl } from './che-plugin-service-client'; +import { DevfileService } from '@eclipse-che/theia-remote-api/lib/common/devfile-service'; import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; import { PluginFilter } from '../../common/plugin/plugin-filter'; import { PluginServer } from '@theia/plugin-ext/lib/common/plugin-protocol'; @@ -79,6 +80,9 @@ export class ChePluginManager { @inject(OpenerService) protected readonly openerService: OpenerService; + @inject(DevfileService) + protected readonly devfileService: DevfileService; + @postConstruct() async onStart() { await this.initDefaults(); @@ -222,6 +226,20 @@ export class ChePluginManager { registries[registry.name] = registry; } + /** + * Scan devfile plugins for custom registry, add the registry to cache if detected. + */ + const devfile = await this.devfileService.get(); + if (devfile.components) { + devfile.components + .filter(component => component.plugin && component.plugin.id && component.plugin.registryUrl) + .forEach(component => { + const registryUrl = component.plugin?.registryUrl!; + const name = component.plugin?.id!; + registries[name] = { name, uri: registryUrl, publicUri: registryUrl }; + }); + } + await this.chePluginService.updateCache(registries); } @@ -450,10 +468,9 @@ export class ChePluginManager { try { // remove the plugin from workspace configuration - await this.chePluginService.removePlugin(metadata.key); - this.messageService.info( - `Plugin '${metadata.publisher}/${metadata.name}/${metadata.version}' has been successfully removed` - ); + const key = `${metadata.publisher}/${metadata.name}/${metadata.version}`; + await this.chePluginService.removePlugin(key); + this.messageService.info(`Plugin '${key}' has been successfully removed`); // remove the plugin from the list of workspace plugins this.installedPlugins = this.installedPlugins.filter(p => p !== metadata.key); diff --git a/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts b/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts index e10d55b04..09150f1f5 100644 --- a/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts +++ b/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts @@ -277,7 +277,7 @@ export class ChePluginServiceImpl implements ChePluginService { for (let pIndex = 0; pIndex < registryPlugins.length; pIndex++) { const metadataInternal: ChePluginMetadataInternal = registryPlugins[pIndex]; - const pluginYamlURI = this.getPluginYampURI(registry, metadataInternal); + const pluginYamlURI = this.getPluginYamlURI(registry, metadataInternal); try { const pluginMetadata = await this.loadPluginMetadata(pluginYamlURI, longKeyFormat, registry.publicUri); @@ -335,7 +335,7 @@ export class ChePluginServiceImpl implements ChePluginService { * @param plugin plugin metadata * @return uri to plugin yaml file */ - private getPluginYampURI(registry: ChePluginRegistry, plugin: ChePluginMetadataInternal): string { + private getPluginYamlURI(registry: ChePluginRegistry, plugin: ChePluginMetadataInternal): string { if (plugin.links && plugin.links.self) { const self: string = plugin.links.self; if (self.startsWith('/')) {